texts
sequence | tags
sequence |
---|---|
[
"How to bind a angular ng-click event on after lnserted HTML",
"I am developing rails application where angularjs use in it.\n\nI am facing one problem which i can't understand. Angularjs works fine in all events but i have one module where new html load after page scroll and one another where push new html into existing html on page.\n\nOn new html inserted in page, one button in new html where i would like to ng-click event bind with it so when user click on that button i want to procedure.\n\nI tried it but not getting how to bind with button because on loaded html bind easily but in new html not bind.\n\nHow to bind on that new HTML button?\n\nAny one have a idea?\n\nThanks"
] | [
"html",
"angularjs",
"angularjs-ng-click"
] |
[
"handling file not found exception?",
"I made this code to empty some files that I regularly delete, such as temp files in Windows. Several friends may wish to use the same application and I am working on the best way to handle the file not found exception.\n\nHow can this best be handled for use by multiple users?\n\npublic void Deletefiles()\n {\n try\n { \n string[] DirectoryList = Directory.GetDirectories(\"C:\\\\Users\\\\user\\\\Desktop\\\\1\");\n string[] FileList = Directory.GetFiles(\"C:\\\\Users\\\\user\\\\Desktop\\\\1\");\n\n foreach (string x in DirectoryList)\n {\n Directory.Delete(x, true);\n FoldersCounter++;\n }\n\n foreach (string y in FileList)\n {\n File.Delete(y);\n FilesCounter++;\n }\n\n MessageBox.Show(\"Done...\\nFiles deleted - \" + FileList.Length + \"\\nDirectories deleted - \" + DirectoryList.Length + \"\\n\" + FilesCounter + \"\\n\", \"message\", MessageBoxButtons.OK, MessageBoxIcon.Information);\n }\n\n catch (Exception z)\n {\n if (z.Message.Contains(\"NotFound\"))\n {\n MessageBox.Show(\"File Not Found\");\n }\n else\n {\n throw (z);\n }\n //throw new FileNotFoundException();\n }\n }"
] | [
"c#-4.0"
] |
[
"How to change fontawsome class name with ajax?",
"I want to change the icon after deleting row. Should I only use font awesome icon once in blade, then remove the class name, then add the class name with ajax?\nblade:\n<div id="status-{{ $country->id }}">\n <div id="icon-{{$country->id}}">\n @if( getStatus($country->status) == 'Active' || getStatus($country->status) == 'Aktif' )\n <i class="fa fa-check-circle text-success"></i>\n @elseif( getStatus($country->status) == 'Inactive' || getStatus($country->status) == 'Pasif' )\n <i class="fas fa-minus-circle text-info"></i>\n @else\n <i class="fas fa-times-circle text-danger"></i>\n @endif\n <strong>{{ getStatus($country->status) }}</strong>\n </div>\n</div>\n\najax:\n$.ajax({\n url: url,\n type: "DELETE",\n header: {\n _token: "{{ csrf_token() }}",\n },\n success() {\n toastr['error']("{{ __('home.delete.message') }}");\n swal("{{ __('home.delete.message') }}", {\n icon: "success",\n });\n $('#status-' + id).text('Deleted')\n $('#icon-' + id).attr('i').addClass('fas fa-times-circle text-danger')\n },\n error(error) {\n toastr['warning']("{{ __('home.error.message') }}");\n }\n});"
] | [
"javascript",
"html",
"ajax",
"laravel"
] |
[
"Override ASP.NET Authorization annotations",
"Is there a way to override Authorize annotation in ASP.Net?\n\nI'm using MVC and my controller is annotated with: \n\n[Authorize(Roles=\"Admin\")]\n\n\nThe majority of actions in this controller are restricted to Admin users.\n\nI would like to override one action method so that it becomes available to all users:\n\n[HttpPost]\n[Authorize(Users=\"*\")] \npublic Boolean Submit(FormCollection collection)\n\n\nThis is not working and users are being re-directed to login page. What am I doing wrong?\n\nThank you."
] | [
"c#",
".net",
"asp.net",
"asp.net-mvc",
"security"
] |
[
"Function specialization to access struct members with getter using enum",
"I have an enum and a struct\nenum STORE_ENUM { A_DATA, B_DATA, C_DATA, D_DATA };\nstruct Store {\n int a;\n char b;\n long c;\n bool d;\n\n}\n\nand I want to access its members with a specialized get function that basically looks like this\nT get(STORE_ENUM,store s);\n\nand it returns the appropriate type and hopefully statically type checks.\nis this possible in C++?"
] | [
"c++",
"c++11",
"templates"
] |
[
"snapshot of overlay image from array of images",
"I have multiple images under scrollview. When i click one image it will displays overlay image of camera overlay view. But when i click button it won't take snapshot of camera overlay image. I take reference from http://www.musicalgeometry.com/?p=1681#comment-37185\n\ncode:\n\n- (void)ButtonPressed {\n\n[self captureStillImageWithOverlay:[NSArray arrayWithObjects:[UIImage imageNamed:@\"img1.png\"],[UIImage imageNamed:@\"img2.png\"],[UIImage imageNamed:@\"img3.png\"],[UIImage imageNamed:@\"img4.png\"],[UIImage imageNamed:@\"img5.png\"], nil]];\n\n}"
] | [
"iphone",
"objective-c",
"camera",
"overlay",
"augmented-reality"
] |
[
"Why would you want to trigger the unique option in add_index in migration",
"What is the difference between\n\nadd_index :users, :email\n\n\nand\n\nadd_index :users, :email, unique: true\n\n\nWhy would you want your index to be unique and why does it matter?\nI thought add_index is simply just a way for database query to be faster. More of something for the database rather than for us to use."
] | [
"mysql",
"ruby-on-rails",
"activerecord",
"migration"
] |
[
"SQLite where integer not returning",
"There are numerous other questions with similar problems and after going through them I've been unsuccessful in getting/understanding why when I try to query on an integer column it is not doing any filtering.\n\nThe query is:\n\nString selectRoadsSQL = \"SELECT ID, Lat, Lng, Active, DateCreated, DateLastUsed FROM roads WHERE Active = ?\"\n\n\nThis is executed by this piece of code\n\nCursor cursor = db.rawQuery(selectRoadsSQL, new String[] { Integer.toString(status)});\nwhile (cursor.moveToNext()) {\nString active = cursor.getString(cursor.getColumnIndex(DataTables.Roads.Active));\nLog.e(\"Test\", active);\n}\n\n\nstatus is an integer that is passed and it is either 0 or 1. In this scenario I am passing a 1.\n\nRegardless if I pass a 0 or 1 I always get back all rows. The actual DB itself shows some rows with a 0 and others with a 1.\n\nEven if I change the ? to a 1 so the query contains the actual integer value it still returns all rows.\n\n\n\nI would expect to only get back the results with a \"1\" in the Active column.\n\nI'm totally stumped. Thank you."
] | [
"android"
] |
[
"Ruby - refactoring to handle different types of errors",
"I have an object that serves as a parent object to several others. It has a method similar to this:\n\nclass Parent\n def commit\n begin\n ...\n rescue => e\n ...\n end\n end\nend\n\nclass ChildA < Parent\nend\n\nclass ChildB < Parent\nend\n\n\nHowever, ChildA has to behave in a unique way when commit throws a specific type of error, UniqueError. I could overwrite the whole commit file for that function, but that feels awkward. It sets me up for problems if I need to change the body in the begin section, since I now would need to change it in two places.\n\nWhat's the cleanest way to refactor this?"
] | [
"ruby",
"refactoring"
] |
[
"How to group my List into categories",
"I have this following class:\n\npublic class TV\n{\n public string GroupId { get; set; }\n public string Title { get; set; }\n public string Genre { get; set; }\n}\n\n\nThen I have this following list (which is dynamic created and will never be same):\n\nList<TV> myList = new List<TV>();\nmyList.Add(new TV { GroupId = \"1\", Title = \"Title 1\", Genre = \"Genre A\" });\nmyList.Add(new TV { GroupId = \"1\", Title = \"Title 2\", Genre = \"Genre A\" });\nmyList.Add(new TV { GroupId = \"1\", Title = \"Title 3\", Genre = \"Genre A\" });\nmyList.Add(new TV { GroupId = \"3\", Title = \"Title 4\", Genre = \"Genre 18\" });\nmyList.Add(new TV { GroupId = \"A\", Title = \"Title 5\", Genre = \"Genre 18\" });\nmyList.Add(new TV { GroupId = \"A\", Title = \"Title 6\", Genre = \"Genre A\" });\nmyList.Add(new TV { GroupId = \"B\", Title = \"Title 7\", Genre = \"Genre A\" });\nmyList.Add(new TV { GroupId = \"C\", Title = \"Title 8\", Genre = \"Genre A\" });\nmyList.Add(new TV { GroupId = \"D\", Title = \"Title 9\", Genre = \"Genre 18\" });\nmyList.Add(new TV { GroupId = \"D\", Title = \"Title 10\", Genre = \"Genre A\" });\nmyList.Add(new TV { GroupId = \"D\", Title = \"Title 11\", Genre = \"Genre A\" });\nmyList.Add(new TV { GroupId = \"E\", Title = \"Title 12\", Genre = \"Genre A\" });\n\n\nI have the following (hardcoded) navigation categories that are links: \n\n\n [0-9] [ABC] [DEF] [GHI] [JKL] [MNO] [PQR] [STU] [VWXYZ]\n\n\nI’m trying to loop myList and by looking at the GroupId property, I want to place it in the appropriate div so I end up having divs like this:\n\n<div id=\"group-09\">\n<div>\n 1, Title 1, Genre A\n 1, Title 2, Genre A\n 1, Title 3, Genre A\n 3, Title 4, Genre 18\n</div>\n</div>\n\n<div id=\"group-ABC\">\n<div>\n A, Title 5, Genre 18\n A, Title 6, Genre A\n B, Title 7, Genre A\n C, Title 8, Genre A\n</div>\n</div>\n\n<div id=\"group-DEF\">\n<div>\n D, Title 9, Genre 18\n D, Title 10, Genre A\n D, Title 11, Genre A\n E, Title 12, Genre A\n</div>\n</div>\n\n\nI can’t seem to figure out the logic to properly do this!\nDoes anyone have a suggestion?\nThanks"
] | [
"c#",
"asp.net"
] |
[
"How to get device token for push notification purpose in Xamarin.Forms?",
"I want to get device token which I can use as Token for push notification.\n\nI have ready many blogs but didn't find device token. I also need to pass this in Token input to send notification in UrbanAirship.\n\nExample: 555D111CC00D77FA2956E85648D3B4187B42AF737BBB1670FE6EF8595784DR654\n\nPlease suggest"
] | [
"xamarin.forms",
"xamarin.ios"
] |
[
"Sinch - Instant Message - Push Notification received while app is closed",
"I have the following scenario:\n\n\niPhoneA & iPhoneB: sinch client initialized with message support and Push Support enabled\niPhoneA's app is closed\niPhoneB sends a message to iPhoneA.\niPhoneA receives a notification correctly (the banner appears). So iPhoneA open app by icon.\n\n\nHow can I detect and catch received notification?\n\nThanks"
] | [
"ios",
"background",
"push-notification",
"sinch",
"instant-message"
] |
[
"ViewScoped CDI bean recreated after some AJAX requests",
"I have a CDI ViewScoped bean and a JSF page. After a couple of AJAX requests the bean somehow recreated.\nHere is the full code of the application:\n\nindex.xhtml\n\n<html xmlns=\"http://www.w3.org/1999/xhtml\"\n xmlns:h=\"http://xmlns.jcp.org/jsf/html\"\n xmlns:f=\"http://java.sun.com/jsf/core\"\n xmlns:ui=\"http://xmlns.jcp.org/jsf/facelets\">\n <h:head>\n <title>Facelet Title</title>\n </h:head>\n <h:body>\n Hello from Facelets\n <h:form>\n <h:inputText value=\"#{questionBean.newTag}\"></h:inputText>\n <h:commandButton value=\"Add Tag\">\n <f:ajax listener=\"#{questionBean.addTag()}\" execute=\"@form\" render=\"@form\"></f:ajax>\n </h:commandButton>\n <ui:repeat value=\"#{questionBean.tagsOfQuestion}\" var=\"tag\">\n <h:outputLabel value=\"#{tag}\"></h:outputLabel>\n <h:commandButton value=\"X\">\n <f:ajax event=\"click\" listener=\"#{questionBean.removeTag(tag)}\" render=\"@form\" execute=\"@form\"/>\n </h:commandButton>\n </ui:repeat>\n </h:form>\n </h:body>\n</html>\n\n\nHere is the backing CDI bean\nQuestionBean.java\n\n import java.util.ArrayList;\n import java.util.Date;\n import java.util.List;\n import javax.faces.view.ViewScoped;\n import javax.inject.Named;\n\n @Named\n @ViewScoped \n public class QuestionBean {\n private String newTag;\n private List<String> tagsOfQuestion = new ArrayList<String>();\n private Date dateCreated = new Date();\n\n public QuestionBean(){\n System.out.println(\"Date Created : \"+dateCreated);\n }\n\n public void addTag(){\n if(!newTag.isEmpty()){\n getTagsOfQuestion().add(newTag);\n }\n newTag = \"\";\n }\n\n public void removeTag(String tagToRemove){\n getTagsOfQuestion().remove(tagToRemove);\n }\n\n public String getNewTag() {\n return newTag;\n }\n\n public void setNewTag(String newTag) {\n this.newTag = newTag;\n }\n\n public List<String> getTagsOfQuestion() {\n return tagsOfQuestion;\n }\n\n public void setTagsOfQuestion(List<String> tagsOfQuestion) {\n this.tagsOfQuestion = tagsOfQuestion;\n }\n\n}"
] | [
"ajax",
"jsf",
"jsf-2.2",
"view-scope",
"uirepeat"
] |
[
"Trouble understanding NSOperation & NSOperationQueue (swift)",
"I'm having trouble understanding how to create a synchronous NSOperationQueue.\nI've created a prototype that basically says: \n\n\nCreate 4 operations that very long or very short to complete\nRegardless of time to complete, they should finish in the order they are created in the queue.\n\n\nMy NSOperation class is very simple:\n\nclass LGOperation : NSOperation\n{\n private var operation: () -> ()\n init(operation: () -> ())\n {\n self.operation = operation\n }\n\n override func main()\n {\n if self.cancelled {\n return\n }\n operation()\n }\n}\n\n\nAnd my test class is also quite simple:\n\nclass LGOperationTest\n{\n\n class func downloadImage(url: String)\n {\n // This is a simple AFHTTPRequestOperation for the image\n LGImageHelper.downloadImageWithUrl(url, complete: { (image: AnyObject?) in\n println(\"downloaded \\(url)\")\n })\n }\n\n class func test()\n {\n var queue = NSOperationQueue.mainQueue()\n queue.maxConcurrentOperationCount = 1\n var op1 = LGOperation(operation: { self.downloadImage(\"http://www.toysrus.com/graphics/tru_prod_images/Animal-Planet-T-Rex---Grey--pTRU1-2909995dt.jpg\") })\n\n var op2 = LGOperation(operation: { println(\"OPERATION 2\") })\n\n var op3 = LGOperation(operation: { self.downloadImage(\"http://www.badassoftheweek.com/trex.jpg\") })\n\n var op4 = LGOperation(operation: { println(\"OPERATION 3\") })\n var ops: [NSOperation] = [op1, op2, op3, op4]\n op2.addDependency(op1)\n op3.addDependency(op2)\n op4.addDependency(op3)\n op4.completionBlock = {\n println(\"finished op 4\")\n }\n\n queue.addOperation(op1)\n queue.addOperation(op2)\n queue.addOperation(op3)\n queue.addOperation(op4) \n println(\"DONE\") \n }\n}\n\n\nSo I would expect here is for the operations to finish in order, instead the output is:\n\n\nDONE \nOPERATION 2 \nOPERATION 4 \nfinished op 4\ndownloaded\nhttp://www.toysrus.com/graphics/tru_prod_images/Animal-Planet-T-Rex---Grey--pTRU1-2909995dt.jpg\ndownloaded http://www.badassoftheweek.com/trex.jpg\n\n\nWHY can't I make web requests fire synchronously with other code? (I know I can use completion blocks and chain them but I'd like to figure out how to do it with NSOperation)"
] | [
"multithreading",
"swift"
] |
[
"How to escape from visualMap control in echarts",
"I am using heatmap in echarts to show temperature change.\nI want to show unique color like grey when the value of the item is zero or undefined.\n\nBut it is showing the colored grid.\nI found a solution to give same zero value for both zero and undefined and set the same color.\n\nbut their color is being controlled by visual map.\nECHARTS doc says \"Mark as visual map: false, then this item does not control by visual map any more\". but this is very unclear.\nWhere can I set this property \"visual map\"?\nin data of series?\n\nPlease help me if you have experience with this.\nThank you in advance."
] | [
"heatmap",
"echarts"
] |
[
"What would happen if I try use drawImage() for an image which not yet fully loaded?",
"If I pass the reference to an image to drawImage API of HTML canvas, but the image is still loading, then what would happen? Will get an exception, or the API will go ahead with the partial data, or the API will block till the image is loaded?"
] | [
"javascript",
"image",
"canvas",
"html5-canvas"
] |
[
"Limit TextView boundaries to ImageView upon user touch",
"I have an imageview which only takes up a portion of the screen. And I have a textview on top of the imageview. When the user touches the textview, they can drag it to where ever they want on the screen. However, I want to limit the user to only be able to move the textview on the imageview. \n\nWhen the textview is moved to the top or right side of the screen it automatically blocks it from going any further (similar to if you move your computer mouse to the top or left side of the screen). I want to try to mimic this effect just in the bounds of the imageview.\n\nI have tried numerous techniques like getting the size of the imageview and comparing it to the y and x values and if the textview would go past this point it would equal this point. However, no success so far. \n\nThis is my current code (within the OnTouchListener()):\n\n if (touchY >= imageHeight){\n params.leftMargin = leftSideText;//sets the margin so the textview is displayed on the screen according to them because its aligned to top and left\n params.topMargin = (tvOne.getHeight()) - imageHeight;\n params.addRule(RelativeLayout.ALIGN_PARENT_TOP);\n params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);\n tvOne.setLayoutParams(params);\n }\n\n\nwhere some of the variables are:\n\n touchX = (int) eventTwo.getRawX();\n touchY = (int) eventTwo.getRawY();\n //helps make the edit text start where the user touches the screen rather than that just being the top corner\n int editTextWidth = tvOne.getWidth() / 2;\n int editTextHeight = tvOne.getHeight() / 2;\n\n topText = touchY - editTextHeight;\n leftSideText = touchX - editTextWidth;\n\n\nThis code just makes the textview disappear once it goes past this point.\n\nSo, to clear up what I'm asking, how do you limit textview boundaries to the range of an imageview? If you could provide any help or suggestions it would be greatly appreciated, thanks!\n\nEDIT: I found the reason to my problem, yet, I have not found the solution. First, it seems the textview is not disappearing its just not visible on the black background below the image. Second, the reason why the textview is going past the imageview is because the full image is not being displayed, or so it seems. So, when I get the height its referring to the whole image height, yet, the whole image is not being displayed.\n\nTake a look at my question here"
] | [
"java",
"android",
"android-layout",
"textview",
"ontouchlistener"
] |
[
"The mechanism how the database concurrency works",
"Could some body explain me how the database concurrency works? I am using HSQLDB.\n\nFor example, if there are two different users to insert a record at the same time from two different entry points, how does the database handle this? Are these two insert commands executed one by one? or at the same time?\n\nFeel free to provide any other information if you know.\n\nMany thanks!\n\nIke"
] | [
"database",
"database-concurrency"
] |
[
"How to: Android Quiz App, extracting da",
"I'm looking to create a 'quiz' application that will have multiple categories, in those categories will be questions that the user will be able to answer in order and their progress will be saved. I want the progress to be saved locally so it can be used without the internet but I would also like to access some of the information that is being saved if possible, such as what users have completed what category? \n\nI have Java and SQL knowledge but I'm pretty confused about the whole thing when it comes to adding them together.\n\nDo I need to implement an SQLite database in the app to store progress for the users, as well as a regular SQL server that will store the required data online? I was hoping it would be possible just to use the SQLite database to do both of these but I've looked and I can't figure out if it is possible.\n\nThanks."
] | [
"java",
"android",
"sql",
"sqlite"
] |
[
"Setting up Authlogic I keep hitting: \"undefined method `login' for #\"",
"I am trying (unsuccessfully) to setup Authlogic for my Rails3 project. In the user_sessions#new view, I keep getting the following error:\n\nundefined method `login' for #<UserSession: no credentials provided>\nExtracted source (around line #7):\n\n5: <%= form_for(:user_session, :url => user_session_path) do |f| %>\n6: <%= f.label :login %><br>\n7: <%= f.text_field :login %><br>\n8: <%= f.password_field(:password) %> \n9: <%= f.submit %>\n10: <% end %>\n\n\nI believe that the error is coming because Authlogic is failing to detect which database column should be used for the login field.\n\nI was under the understanding that Authlogic is supposed to fall back on the :email column if no login column is present. For belt and braces I tried adding a config option to the User class but it still did not solve the problem\n\nHere is my code:\n\nUser model\n\nclass User < ActiveRecord::Base\n\n attr_accessible :password, :password_confirmation\n acts_as_authentic do |c|\n c.login_field = :email\n end\nend\n\n\nUserSessions controller\n\nclass UserSessionsController < ApplicationController \n def new\n @user_session = UserSession.new\n end\n\n # ...\nend\n\n\nUserSessions#new view\n\n<%= form_for(:user_session, :url => user_session_path) do |f| %>\n <%= f.label :login %><br>\n <%= f.text_field :login %><br>\n <%= f.password_field(:password) %> \n <%= f.submit %>\n<% end %>\n\n\nUserSession model\n\nclass UserSession < Authlogic::Session::Base\n # configuration here, see documentation for sub modules of Authlogic::Session\nend\n\n\nDB Schema (for authlogic tables)\n\ncreate_table \"sessions\", :force => true do |t|\n t.string \"session_id\", :null => false\n t.text \"data\"\n t.datetime \"created_at\"\n t.datetime \"updated_at\"\nend\n\nadd_index \"sessions\", [\"session_id\"], :name => \"index_sessions_on_session_id\"\nadd_index \"sessions\", [\"updated_at\"], :name => \"index_sessions_on_updated_at\"\n\ncreate_table \"users\", :force => true do |t|\n t.string \"email\"\n t.datetime \"created_at\"\n t.datetime \"updated_at\"\n t.string \"first_name\"\n t.string \"last_name\"\n t.string \"crypted_password\"\n t.string \"password_salt\"\n t.string \"persistence_token\"\nend\n\n\nWhy won't Authlogic use the login column I tell it to (or is this even the problem)?"
] | [
"ruby-on-rails-3",
"authlogic"
] |
[
"Invoking a BPMN REST Endpoint in WSO2BPS and get payloads in to format xml",
"I want to use BPMN Service Task and invoke a REST API.\nI need to receive requests from the service ESB in format XML.\n\nExample of request:\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<reqSendEvent extrSystem=\"rout\" typeEvent=\"newRout\" xmlns=\"http://magnit.ru/tanderCoreMassageData.xsd\">\n <originTime>2017.08.25 15:12:00</originTime>\n <content>\n <rout>\n <name>xxxxx</name> \n </rout>\n </content>\n</reqSendEvent>\n\n\nservicetask:\n\n<serviceTask id=\"servicetask1\" name=\"Service Task\" activiti:class=\"org.wso2.developerstudio.bpmn.extensions.restTask.RESTTask\">\n <extensionElements>\n <activiti:field name=\"serviceURL\">\n <activiti:expression><![CDATA[http://localhost:9773/tanderBPMN/services/servicetask1]]></activiti:expression>\n </activiti:field>\n <activiti:field name=\"method\">\n <activiti:string><![CDATA[POST]]></activiti:string>\n </activiti:field>\n <activiti:field name=\"headers\">\n <activiti:expression><![CDATA[Content-Type:text/xml]]></activiti:expression>\n </activiti:field>\n <activiti:field name=\"outputMappings\">\n <activiti:string><![CDATA[xxxxxx]]></activiti:string>\n </activiti:field>\n </extensionElements>\n</serviceTask>\n\n\nIn all the examples, using JSON payloads. What do i write expression in to the outputMappings to get value from tag *//rout/name?"
] | [
"wso2",
"activiti",
"bpmn",
"wso2bps"
] |
[
"Open a Blob file from Mysql to PC using SaveFileDialog",
"I'm trying to open a Blob(winword document) from MySql using SaveFileDialog using this code:\n\nmyConn.Open();\nMySqlDataReader myReader;\nmyReader = view.ExecuteReader();\nlong CurrentIndex = 0;\nlong BytesReturned;\n\n\nwhile (myReader.Read())\n{\n if (saveFileDialog1.ShowDialog() == DialogResult.OK)\n {\n string strFilename = saveFileDialog1.FileName;\n FileStream fs = new FileStream(strFilename, FileMode.CreateNew, FileAccess.Write);\n BinaryWriter bw = new BinaryWriter(fs);\n CurrentIndex = 0;\n long len = myReader.GetBytes(1, 0, null, 0, 0);\n byte[] blob = new byte[len];\n BytesReturned = myReader.GetBytes(1, CurrentIndex, blob, 0, (int)len);\n\n while (BytesReturned == (int)len)\n {\n bw.Write(blob);\n bw.Flush();\n CurrentIndex += (int)len;\n BytesReturned = myReader.GetBytes(1, CurrentIndex, blob, 0, (int)len);\n\n\n }\n bw.Write(blob,0 , (int)len - 1);\n bw.Flush();\n bw.Close();\n\n }\n myReader.Close();\n}\n\n\nThe exception I am getting is:\n\n\n Index out bounds of the array.\n\n\nAny suggestions on different approach other than FileStream?"
] | [
"c#",
"mysql"
] |
[
"Save dataframe as AVRO Spark 2.4.0",
"Since Spark 2.4.0 it's possible to save as AVRO without external jars. However I can't get it working at all. My code looks like this:\n\nkey = 'filename.avro'\ndf.write.mode('overwrite').format(\"avro\").save(key)\n\n\nI get the following error:\n\npyspark.sql.utils.AnalysisException: 'Failed to find data source: avro. Avro is built-in but external data source module since Spark 2.4. Please deploy the application as per the deployment section of \"Apache Avro Data Source Guide\".;'\n\n\nSo I look at the Apache Avro Data Source Guide (https://spark.apache.org/docs/latest/sql-data-sources-avro.html) and it gives the following example:\n\ndf=spark.read.format(\"avro\").load(\"examples/src/main/resources/users.avro\")\n\ndf.select(\"name\",\"favorite_color\").write.format(\"avro\").save(\"namesAndFavColors.avro\")\n\n\nIt is the same, so I'm lost.. Anyone have an idea what goes wrong?"
] | [
"python",
"apache-spark",
"pyspark",
"avro"
] |
[
"Can't enable codeception tests for Yii2",
"I have problems configuring Codeception acceptance tests for my Yii2 website.\n\nTests are running okay, but I'd like to change the configuration so testing contact form won't send any emails. It should be pretty simple task, but I can't force it to use alternative config.\n\nFollowing this tutorial: http://codeception.com/for/yii\n\n/codeception.yml:\n\nactor: Tester\npaths:\n tests: tests\n log: tests/_output\n data: tests/_data\n helpers: tests/_support\nsettings:\n bootstrap: _bootstrap.php\n memory_limit: 1024M\n colors: true\nmodules:\n config:\n Yii2:\n configFile: 'config/test.php'\n\n\n/tests/acceptance.suite.yml\n\nclass_name: AcceptanceTester\nmodules:\n enabled:\n - WebDriver:\n url: http://localhost/mypage\n browser: firefox\n - Yii2:\n part: orm\n entryScript: index.php\n cleanup: false\n configFile: test.php\n\n\nAnd again I have no idea which directory this file points to. I tried with /config/test.php, /tests/config/test.php, nothing.\n\n/config/test.php\n\n<?php\n$params = require(__DIR__ . '/params.php');\n$dbParams = require(__DIR__ . '/test_db.php');\n\n/**\n * Application configuration shared by all test types\n */\nreturn [\n 'id' => 'basic-tests',\n 'basePath' => dirname(__DIR__), \n 'language' => 'en-US',\n 'components' => [\n 'db' => $dbParams,\n 'mailer' => [\n 'useFileTransport' => true, // <--- I'm interested in this setting \n ],\n 'urlManager' => [\n 'showScriptName' => true,\n ],\n 'user' => [\n 'identityClass' => 'app\\models\\User',\n ], \n 'request' => [\n 'cookieValidationKey' => 'test',\n 'enableCsrfValidation' => false,\n // but if you absolutely need it set cookie domain to localhost\n /*\n 'csrfCookie' => [\n 'domain' => 'localhost',\n ],\n */\n ], \n ],\n 'params' => $params,\n];\n\n\nI even thought that this path might be relative to /tests directory, so I created file there as well:\n\n/tests/config/test.php\n\n<?php\n// config/test.php\n$config = yii\\helpers\\ArrayHelper::merge(\n require(__DIR__ . '/main.php'),\n require(__DIR__ . '/main-local.php'),\n [\n 'id' => 'app-tests',\n 'components' => [\n 'db' => [\n 'dsn' => 'mysql:host=localhost;dbname=yii_app_test',\n ],\n 'mailer' => [\n 'useFileTransport' => true\n ]\n ]\n ]\n);\nreturn $config;\n\n\n/tests/_bootstrap.php\n\n<?php\ndefine('YII_ENV', 'test');\ndefined('YII_DEBUG') or define('YII_DEBUG', true);\n\nrequire_once(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');\nrequire __DIR__ .'/../vendor/autoload.php';\n\n\npart of /config/web.php to check if environment values are passed, but they aren't\n\nif (YII_ENV_TEST || YII_ENV === 'test'){\n die('Testing settings loaded');\n}\n\n\nLaunching my tests with ./vendor/bin/codecept run tests/acceptance/ContactCest.php\n\nI'm not publishing tests because they are irrelevant, as they just use clicks on elements to send contact form.\nAt the moment I've wasted 4 hours trying to override that config file. Probably it's some stupid rookie mistake, but I'm about to give up now. \n\nHelp me, StackOverflow, you are my only hope! ;)"
] | [
"selenium",
"testing",
"yii2",
"codeception"
] |
[
"python, command line and windows path",
"I have added both python 2.7 and 3.4 to my system path. Personally I use python 3.4, however I use Vim as my editor and one of the plugins I use requires python 2.7 to be first in the path. This is annoying because now when I use the python command in the windows command line it loads python 2.7 rather than 3.4\n\nIs there any way that I can add python 2.7 to the windows path just for vim? And make the command line load python 3.4?\n\nEDIT: the plugin that requires python 2.7 is YouCompleteMe (https://github.com/Valloric/YouCompleteMe)"
] | [
"windows",
"vim",
"python-3.x",
"path",
"python-2.x"
] |
[
"Resolving many to many relationship MYSQL database",
"I have 3 tables,\n\nusers(id) , userproduct (user_id,product_id) and product (id).\n\nWhen a user adds a product their user_id and the product_id is saved in USERPRODUCT table.\n\nNow at the same time another user can save a product (kind of like \"set as favorite\") for this I need to save the user_id of the user who saved it and the product_id of the product. This will create another table (call it favorites) however this table is also a resolve to the many to many relationship between \"users\" table and \"product\" table.\n\nthe question: is it possible for this, to have 2 tables resolving a many to many relationship or is there any other way to solve my issue.\n\nif it is possible how will one be draw this in the ER diagram"
] | [
"php",
"mysql",
"database",
"many-to-many"
] |
[
"How to change font-awesome icon color when it is active",
"How to change font-awesome icon color when it is active, I have a menu with font-awesome links and I would like change the icons colors when is active, some can help on this?\n\nI did read about states: https://smacss.com/book/state but still not working in my code, its a way to make this work? thank you. \n\njsfiddle: https://jsfiddle.net/oosa8yzk/\n\nmy html\n\n <ul>\n <li>\n <a class=\"menu\" data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"home\">\n <i class=\"fa fa-bars fa-2x\" aria-hidden=\"true\"></i>\n </a>\n </li>\n <li>\n <a class=\"search\"><i class=\"fa fa-search fa-2x\" aria-hidden=\"true\"></i></a>\n </li>\n </ul>\n\n\nmy sass:\n\n ul {\n list-style-type: none;\n li {\n padding: 10px;\n border-top: 1px solid blue;\n &:first-child {\n border: none;\n }\n i {\n color: black;\n &:hover {\n color: white;\n background-color: blue;\n }\n }\n &:hover {\n background-color: blue;\n color: white;\n }\n &:active {\n background-color: yellow;\n color: black;\n }\n &:focus {\n background-color: red;\n color: white;\n }\n }\n }\n\n\nmy css:\n\nul {\n list-style-type: none;\n}\nul li {\n padding: 10px;\n border-top: 1px solid blue;\n}\nul li:first-child {\n border: none;\n}\nul li i {\n color: black;\n}\nul li i:hover {\n color: white;\n background-color: blue;\n}\nul li:hover {\n background-color: blue;\n color: white;\n}\nul li:active {\n background-color: yellow;\n color: black;\n}\nul li:focus {\n background-color: red;\n color: white;\n}"
] | [
"html",
"css",
"sass"
] |
[
"Ajax Form Post and Validation Not Working",
"I am try to post data using Ajax and jquery form validation but its not works at first time of submit function with validation. Any Solutions?\n\n$(document).ready(function() {\n$(\"#myForm\").validate();\n});\n\n(function($){\n function processForm( e ){\n $.ajax({\n url: 'post.php',\n dataType: 'text',\n type: 'post',\n contentType: 'application/x-www-form-urlencoded',\n data: $(this).serialize(),\n success: function( data, textStatus, jQxhr ){\n //$('#response pre').html( data );\n alert('scuss');\n },\n error: function( jqXhr, textStatus, errorThrown ){\n //console.log( errorThrown );\n alert('error');\n }\n });\n\n e.preventDefault();\n }\n\n$('#myForm').submit(function(e){\ne.preventDefault();\nif(!$(\"#myForm\").valid()) return; \n$('#myForm').submit( processForm ); \n}); \n})(jQuery);"
] | [
"jquery",
"ajax",
"forms",
"validation"
] |
[
"Drawing on a JButton[][] grid in a Java GUI",
"I have a 2D array of JButtons that I would like for the user to be able to draw lines on when the mouse is clicked. Grid of Buttons Image\n\nCurrently, when a user clicks on a specific JButton in the grid, it turns red. I want to be able to hold left-click down and hover over the JButtons I want to turn red. Here is what I have so far \n\n for (int i = 0; i < 40; i++) {\n for (int j = 0; j < 40; j++) {\n if (grid[i][j] != grid[0][0] && grid[i][j] != grid[39][39]) {\n\n grid[i][j].addMouseListener(new java.awt.event.MouseAdapter(){\n\n @Override\n public void mousePressed(java.awt.event.MouseEvent evt) {\n JButton button = (JButton) evt.getSource();\n button.setBackground(Color.red);\n\n paintedButtons.add(button);\n button.transferFocus();\n paintedButtons.add(button);\n }\n\n// public void mouseEntered(MouseEvent evt) {\n// JButton button = (JButton) evt.getSource();\n// button.setBackground(Color.red);\n//\n// paintedButtons.add(button);\n// \n// }\n });\n }\n grid[0][0].setBackground(Color.GRAY);\n grid[39][39].setBackground(Color.GREEN);\n }\n }\n\n\n\nThe mouseEntered method almost does what I want. The problem is I only want it to happen when I hold down left-click. Thanks."
] | [
"java",
"swing",
"user-interface",
"mouseevent",
"jbutton"
] |
[
"IntelliJ/AndroidStudio requiring device/VM for unit tests",
"I started a new project in IntelliJ and out of the box it doesn't quite work. Currently the problem is that when I try to run a unit test it prompts me to pick a device/VM for the code to run on. Except that these are jUnit classes and shouldn't need a device. It really doesn't need anything:\n\npublic class ExampleUnitTest {\n @Test\n public void addition_isCorrect() throws Exception {\n assertEquals(4, 2 + 2);\n }\n}\n\n\nAny thoughts? The project can be viewed here, but it's pretty much a stock project."
] | [
"android-studio",
"intellij-idea",
"junit"
] |
[
"Does the size of a pointer to an array matter when passed as a parameter to a function",
"Does the size of the parameter arr[] (which is a pointer to an array) matter? I know arr[] is treated as a pointer, does it matter if you put a value in between those brackets? If so why? If not why? \n\nWhy is arr[] treated as a pointer? Can it be re-written as int *arr (with no brackets)?\n\nI know the parameter size can take any value, but what about the pointer (int arr[]) pointing to an array?\n\n#include <iostream>\nusing namespace std;\n\n// function declaration:\ndouble getAverage(int arr[], int size);\n\nint main () {\n // an int array with 5 elements.\n int balance[5] = {1000, 2, 3, 17, 50};\n double avg;\n\n // pass pointer to the array as an argument.\n avg = getAverage( balance, 5 ) ;\n\n // output the returned value \n cout << \"Average value is: \" << avg << endl; \n\n return 0;\n}"
] | [
"c++",
"arrays",
"pointers",
"parameters"
] |
[
"PHP Readdir not reading alphabetically",
"Possible Duplicate:\n PHP readdir() not returning files in alphabetical order \n\n\n\n\nWhen uploaded to the hosting server, Readdir does not seem to read files alphabetically. I kinda named my files in a particular order so I really need the feature.\n\nHere is my code:\n\nif (is_dir($dir)) {\n\n if ($dh = opendir($dir)) { \n\n while (($file = readdir($dh)) !== false) {\n\n $ext = pathinfo($dir.$file,PATHINFO_EXTENSION);\n\n if ($ext == 'jpg' || $ext == 'png') {\n\n $dataArr = split('\\.',$file);\n\n $file = $dataArr[0];\n\n\n\n ?>\n <li>\n <a href=\"/test/img/picture gallery/<?php echo $folder.'/'; ?><?php echo $file; ?>.jpg\">\n <img src=\"/test/img/picture gallery/<?php echo $folder.'/thumbs/t'; ?><?php echo $fileFirst; ?>.jpg\" title=\"\" class=\"image0\">\n </a>\n </li>\n <?php\n }\n\n } \n\n closedir($dh); \n\n } \n\n }\n\n\nAny ideas on how to make this possible? Thanks!\n\nEDIT:\n\nFixed.\n\nI tried saving them into an array and using the sort() function of PHP to well, sort it alphabetically. It appears that the file system does not read files alphabetically."
] | [
"php",
"arrays",
"html",
"dir"
] |
[
"Populate Multiple combobox's makes VBA userform slow",
"At the moment I'm working with making a userform with 40 combobox's all which have the same list. My problem is filling all those combobox's is making the userform.show slow. The list that gets populated in those combobox's is a very long list (46542 rows and list length can vary) the list is with 3 columns.\n\nI have been fooling around with CONCATENATE the whole list but that doesn't make much of a change. Also because I need to have the value when selected in the combobox to be CONCATENATE with all 3 columns in the combobox etc. when selecting row no. 1 in the combobox instead of writing only column 1 in the comboxbox textfield it will return all 3 columns so that means I'm actually having 4 columns where the first is CONCATENATE and hidden in the dropdown.\n\nSo my question is, is there a way to do the process more light?\n\nSo here is the code:\n\nPrivate Sub UserForm_Initialize()\nSet tsheet = ThisWorkbook.Sheets(\"Players\")\nDim v As Variant, i As Long\nv = tsheet.Range(\"A2:l\" & Worksheets(\"Players\").Cells(Rows.Count, \n1).End(xlUp).Row).Value\nWith Me.ComboBox1\n.RowSource = \"\"\n.ColumnCount = 4\n.BoundColumn = 2\n.ColumnWidths = \"1;50;50;50\" 'Hide first column in dropdown\nFor i = LBound(v) To UBound(v)\n.AddItem v(i, 1) & \" \" & v(i, 2) & \" \" & v(i, 3)\n.List(.ListCount - 1, 1) = v(i, 1)\n.List(.ListCount - 1, 2) = v(i, 2)\n.List(.ListCount - 1, 3) = v(i, 3)\nNext i\nEnd With\nWith Me.ComboBox2\n.RowSource = \"\"\n.ColumnCount = 4\n.BoundColumn = 2\n.ColumnWidths = \"1;50;50;50\" 'Hide first column in dropdown\nFor i = LBound(v) To UBound(v)\n.AddItem v(i, 1) & \" \" & v(i, 2) & \" \" & v(i, 3)\n.List(.ListCount - 1, 1) = v(i, 1)\n.List(.ListCount - 1, 2) = v(i, 2)\n.List(.ListCount - 1, 3) = v(i, 3)\nNext i\nEnd With\n\n\nThis code goes on until it hit combox40\n\nMy old code was working pretty fast but it didn't have the column that was concatenated\n\nComboBox3.ColumnWidths = \"50;50;50\" 'COLUMN WITH OF LISTBOX\nComboBox3.ColumnCount = 3 \n'COLUMN NUMBER OF LISTBOX\nComboBox3.List = tsheet.Range(\"A2:l\" & \nWorksheets(\"Players\").Cells(Rows.Count, 1).End(xlUp).Row).Value"
] | [
"excel",
"vba",
"combobox",
"multiple-columns"
] |
[
"flex PopUpWindow resize with percentages",
"I have the following:\n\nvar win:Window = new Window();\nPopUpManager.addPopUp(win,this,true);\nPopUpManager.centerPopUp(win);\n\n\nWhat about if I want the popup window to be stretched and be 80% width and height from the parent? How do I achieve that?"
] | [
"apache-flex",
"resize",
"popupwindow"
] |
[
"Error: No default engine was specified and no extension was provided. at new View -- node-push server",
"I'm using node-push server from here\n\nI'm able to start the server successfully. Below is my config file\n\n{\n\"webPort\": 8000,\n\n\"mongodbUrl\": \"mongo URL\",\n\n\"gcm\": {\n \"apiKey\": \"API KEY\"\n},\n\n\"apn\": {\n \"connection\": {\n \"gateway\": \"gateway.sandbox.push.apple.com\",\n \"cert\": \"/path/to/cert.pem\",\n \"key\": \"/path/to/key.pem\"\n },\n \"feedback\": {\n \"address\": \"feedback.sandbox.push.apple.com\",\n \"cert\": \"/path/to/cert.pem\",\n \"key\": \"/path/to/key.pem\",\n \"interval\": 43200,\n \"batchFeedback\": true\n }\n}\n\n\n}\n\nBelow is my service\n\nvar express = require('express');\nvar bodyParser = require('body-parser');\nvar app = express();\n\napp.set('views', __dirname + '/views');\napp.set('view engine', 'jade');\napp.get('/sendTestGCM',function(request,response){\nvar querystring = require('querystring');\nvar http = require('http');//importing http\n\nvar registrationIds = [];\nregistrationIds.push('key here');\nvar gcm_android = querystring.stringify({//message to be sent\n \"users\": registrationIds,\n \"android\": {\n \"data\": {\n \"message\": \"Test Message with Node-push server package\"\n }\n },\n \"type\":\"android\"\n});\nvar options = { //URL information \n host: 'localhost',\n path: '/send',\n port: '8000',\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Content-Length': gcm_android.length\n }\n};\n\nvar post_request = http.request(options,function(res){//Post Request\n res.setEncoding('utf8');\n res.on('data', function (chunk) {\n console.log('Response: ' + chunk);\n console.log(\"status code\"+res.statusCode);\n response.end(\"\"+chunk);\n });\n});\npost_request.write(gcm_android);\npost_request.end();\n});\napp.listen(\"port\");\n\n\nWhen I test this service it is throwing exception as \"Error: No default engine was specified and no extension was provided.\".\n\nAnyone please suggest me reason for this.\n\nThanks In Advance."
] | [
"node.js",
"express",
"push"
] |
[
"Reporting Services 2005 - Page Breaks While Exporting To PDF",
"I have a report .rdlc\nthe report contains 4 lists all contained within each other (so there are 4 levels):\n\n----------------------------Page 1---------------------------------------\n\nList1: Fields! items1 \n List 2: Fields! items2\n List 3: Fields! items3\n List 4: Fields! items4\n Contents for List 4\nList1: Fields! items1 \n List 2: Fields! items2\n List 3: Fields! items3\n List 4: Fields! items4\n Contents for List 4\nempty space\nempty space\nempty space\nempty space\n----------------------------Page 2---------------------------------------\n\nList1: Fields! items1 \n List 2: Fields! items2\n List 3: Fields! items3\n List 4: Fields! items4\n Contents for List 4\nList1: Fields! items1 \n List 2: Fields! items2\n List 3: Fields! items3\n List 4: Fields! items4\n Contents for List 4\n\n\nIn report i haven’t specified any page break(PageBreakAtEnd or PageBreakAtStart) in any of the Lists. the problem is when exporting to PDF it puts a page break and moves the List1 Section in to next page.\n\nbut i don’t want the list to be moved to next page. it has to continue the third set of list1 items in the page 1 and when it reaches to the end of the page then it has to move the List item to Next page below is the example what I am looking for.\n\n----------------------------Page 1---------------------------------------\nList1: Fields! items1 \n List 2: Fields! items2\n List 3: Fields! items3\n List 4: Fields! items4\n Contents for List 4\nList1: Fields! items1 \n List 2: Fields! items2\n List 3: Fields! items3\n List 4: Fields! items4\n Contents for List 4\nList1: Fields! items1 \n List 2: Fields! items2\n List 3: Fields! items3\n----------------------------Page 2---------------------------------------\n List 4: Fields! items4\n Contents for List 4\nList1: Fields! items1 \n List 2: Fields! items2\n List 3: Fields! items3\n List 4: Fields! items4\n Contents for List 4"
] | [
"pdf",
"reporting-services"
] |
[
"Design of NO SQL Database",
"As a training project I am trying to build a Family tree application on Azure.\n\nThe first step is the database, I plan to use table storage.\n\nWhat would a table storage design look like for a Family tree application?\n\nI have though of a couple of solutions.\n\n\none entry per person, with xml with all relationships for that person. But that would mean updating several rows for a given change and a lot of duplicate data.\none table for each type of information, one for persons, one for relationships... But this just feels like a relational database"
] | [
"database-design",
"azure",
"nosql",
"azure-table-storage"
] |
[
"Ajax Call Sending Null (JSP/AJAX/HTTPS)",
"I am trying to make a XmlHttpRequest to a JSP file to send a XML over. But somehow when I try to fetch the parameter using String xml = request.getParameter("xml"), the value of xml shows up as NULL.\nHere is the place where I make the call using JavaScript:\ngc3table.xml.cell_attrs.push("id");\ngc3table.setSerializationLevel(true, true, false, false, false, true);\n\nxml = gc3table.serialize();\n\ngc3table.xml.cell_attrs.pop(); \n\ntry {\n\n // Firefox, Opera 8.0+, Safari\n gc3xmlHttp = new XMLHttpRequest();\n \n} catch (e) {\n \n // Internet Explorer\n try {\n \n gc3xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");\n \n } catch (e) {\n \n try {\n gc3xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");\n } catch (e) {\n alert("Your browser does not support AJAX!");\n return "";\n }\n }\n}\n\nvar returnArray = Serialize.encodeForAjax(xml);\n\ngc3xmlHttp.open("POST", "/gtc/supportFiles/common/jsp/upload.jsp?controllerName=" + GMMGlobal.getControllerName(), true);\ngc3xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");\ngc3xmlHttp.send("xml=" + returnArray[0]);\n\nThe encodeForAjax function just modifies the plain string into an encoded form.\nAnd this is the JSP file:\n<%@ page language="java" contentType="text/xml; charset=UTF-8" %>\n\n<%@ page errorPage="exception.jsp" %>\n<%@ page session="true" %>\n\n\n<%@page import="java.net.URLDecoder"%>\n\n<%@ page import="com.gtc.provisioning.gmm.GuiController" %>\n\n<%\n\n String controllerName = request.getParameter("controllerName");\n GuiController controller = (GuiController) session.getAttribute(controllerName);\n\n String xml = request.getParameter("xml");\n .\n .\n .\n .\n%>\n\nThe front end is made up of DHTMLX, JSP and JavaScript, and runs on Tomcat. The same code works every time on my local but not on the test servers. Which is baffling!\nThe only difference between the two is that my local runs on HTTP and my test servers run on HTTPS. Could this be the problem? I intend to think that is the case, because there is no other change I can think of.\nForgot to mention that, I do see this error on the Tomcat console on the servers:\n23-Jun-2020 20:34:55.362 INFO [https-jsse-nio-9443-exec-8] org.apache.coyote.http11.Http11Processor.service Error parsing HTTP request header\nNote: further occurrences of HTTP request parsing errors will be logged at DEBUG level.\njava.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens\n at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:416)\n at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:260)\n at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)\n at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)\n at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639)\n at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)\n at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n at java.lang.Thread.run(Thread.java:748)\n\nAny pointers would be appreciated! Thanks!"
] | [
"javascript",
"ajax",
"jsp",
"tomcat",
"dhtmlx"
] |
[
"how to incrementally update nested objects in elasticsearch?",
"I have 2 document types (in normal form in relational db):\n\n1: post (with title, text and author fields)\n\n2: comment (with text, author, post_id fields)\n\nI have only one type in elastic (post) that aggregate each post with all comments on them in nested form.\n\nI want to index posts with comments on it as nested objects for decreasing response time of queries but it will increase cost of indexing significantly if I reindex whole \"post\" document every time a new \"comment\" added, how can I handle it efficiently? It is acceptable for me to have data of comments with 1h delay.\n\nIn fact it is three question:\n\n1- how can I update a post document with only added comment data. (without need to reconstruct whole post document and send it to elastic) \n\n2- how can I aggregate index commands that was related to a document and send it as a one single command to elastic?\n\n3- Is river plugin a solution for these? is it index comments without need to reconstruct whole post document? is it aggregate all updates related to one document and apply it with one index request?"
] | [
"indexing",
"elasticsearch",
"elasticsearch-jdbc-river"
] |
[
"How to call javascript function and get return value from android?",
"In this code I return a string. I want to store this string in android activity. How can I call JavaScript function and get return value from android activity?\n\n <script type=\"text/javascript\">\n function gettext(){\n return 'http://192.168.1.11/bmahtml5/images/specs_larg_2.png';\n };\n function button_clicked(){\n window.location='ios:nativecall';\n };\n </script>"
] | [
"java",
"javascript",
"android"
] |
[
"How to secure WCF web service using ADFS in .NET 4.5?",
"Using the Identity And Access tool ( part of VS 2012 ) i am able to configure a WCF to use our corporate ADFS server. \n\nRelevant web.config\n\n <system.serviceModel>\n <behaviors>\n <serviceBehaviors>\n <behavior>\n <!-- To avoid disclosing metadata information, set the values below to false before deployment -->\n <serviceMetadata httpGetEnabled=\"true\" httpsGetEnabled=\"true\" />\n <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->\n <serviceDebug includeExceptionDetailInFaults=\"false\" />\n <serviceCredentials useIdentityConfiguration=\"true\">\n <!--Certificate added by Identity and Access Tool for Visual Studio.-->\n <!-- <serviceCertificate findValue=\"CN=localhost\" storeLocation=\"LocalMachine\" storeName=\"My\" x509FindType=\"FindBySubjectDistinguishedName\" />-->\n <serviceCertificate findValue=\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\" storeLocation=\"LocalMachine\" storeName=\"My\" x509FindType=\"FindByThumbprint\" />\n </serviceCredentials>\n <serviceAuthorization principalPermissionMode=\"Always\"/>\n </behavior>\n </serviceBehaviors>\n </behaviors>\n <protocolMapping>\n <add scheme=\"http\" binding=\"ws2007FederationHttpBinding\" />\n <add binding=\"basicHttpsBinding\" scheme=\"https\" />\n </protocolMapping>\n <serviceHostingEnvironment aspNetCompatibilityEnabled=\"true\" multipleSiteBindingsEnabled=\"true\" />\n <bindings>\n <ws2007FederationHttpBinding>\n <binding name=\"\">\n <security mode=\"TransportWithMessageCredential\">\n <message establishSecurityContext=\"false\">\n <issuerMetadata address=\"https://auth1.domain.com/adfs/services/trust/mex\" />\n </message>\n </security>\n </binding>\n </ws2007FederationHttpBinding>\n </bindings>\n </system.serviceModel>\n <system.webServer>\n <modules runAllManagedModulesForAllRequests=\"true\" />\n <!--\n To browse web app root directory during debugging, set the value below to true.\n Set to false before deployment to avoid disclosing web app folder information.\n -->\n <directoryBrowse enabled=\"true\" />\n </system.webServer>\n <system.identityModel>\n <identityConfiguration>\n <audienceUris>\n <add value=\"https://wcfurl.domain.com/\" />\n </audienceUris>\n <issuerNameRegistry type=\"System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry\">\n <authority name=\"http://auth1.domain.com/adfs/services/trust\">\n <keys>\n <add thumbprint=\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\" />\n </keys>\n <validIssuers>\n <add name=\"http://auth1.domain.com/adfs/services/trust\" />\n </validIssuers>\n </authority>\n </issuerNameRegistry>\n <!--certificationValidationMode set to \"None\" by the the Identity and Access Tool for Visual Studio. For development purposes.-->\n <certificateValidation certificateValidationMode=\"None\" />\n </identityConfiguration>\n </system.identityModel>\n\n\nHowever when i reference this WCF service from a console application ( Add Service Reference ) the call is made directly to the WCF service, it is not redirected to ADFS to be authenticated as it would be with a standard ASP.NET application. \n\nDo i really have to implement the call to adfs by code ? If so any clue on how to do it ?"
] | [
"wcf",
"wif",
"adfs",
"ws-trust"
] |
[
"How to call a bash script with positional parameters?",
"I have a script which will be executed using the below command,\n\nbin/nutch crawl urls -dir /data/test/\n\n\nbin/nutch - Script file\ncrawl, urls, /data/test/ - Parameters\n-dir - Option\n\nThe above script should executed from a shell script named test.sh. I have the below code to execute it, but it fails to pass the positional parameters,\n\npath=\"/home/vel/vel-home/scripting/apache-nutch-1.6/bin\"\n. $path/nutch \"crawl\" -dir \"$path/urls\" \"$path/data/test/\"\n\n\nPlease help me to resolve this issue."
] | [
"bash",
"parameters"
] |
[
"Apply function with arguments to a dataFrame",
"I'm trying to apply a function to a dataframe, where the arguments come from the dataframe itself. Is there a way to do this succinctly?\n\ndf: \n | a | b | c | d |\nA | 20 | 15 | 33 | 5 |\nB | 5 | 6 | 10 | 8 |\nC | 10 | 15 | 5 | 10|\n\n\nFunction to apply to each cell\n\n# c = sum of the current column\n# r = sum of the current row \n# t = sum of all values\ndef calcIndex(x, c, r, t):\n return (x/c)*(t/r)*100\n\n\nResult\n\n | a | b | c | d |\nA | 111 | 81 | 134 | 42 |\nB | 70 | 82 | 102 | 170 |\nC | 101 | 148 | 37 | 154 |\n\n\nI've tried df.apply but not sure how to access the specific row/column total depending on which x is being calculated"
] | [
"python",
"pandas",
"dataframe"
] |
[
"Prepend CDN url to mvc 4 bundler output",
"Using the built in MVC4 bundler, how do I prepend my CDN url to the link tags it produces? I've setup Amazon Cloudfront so that it pulls assets from my webserver when first requested. So when I define a bundle like so:\n\n bundles.Add(new StyleBundle(\"~/Content/css\").Include(\n \"~/Content/reset.css\",\n \"~/Content/960_24_col.css\",\n \"~/Content/Site.css\"\n ));\n\n\nWhen deployed, I can reference it thus:\n\nhttp://[cloundfrontid].cloudfront.net/Content/css?v=muhFMZ4thy_XV3dMI2kPt-8Rljm5PNW0tHeDkvenT0g1\n\n\nNow I just need to change the links produced by the bundler from being relative to absolute links pointing to my CDN.\n\n <link href=\"[INSERT_CDN_URL_HERE]/Content/css?v=muhFMZ4thy_XV3dMI2kPt-8Rljm5PNW0tHeDkvenT0g1\" rel=\"stylesheet\"/>\n\n\nI think it may be possible to rewrite the path using IBundleTransform but I can't find any examples of this.\n\nNOTE:\nJust to be clear, I know you can specify a CDN link for a bundle, but that only works if the bundle can be replaced by a static link."
] | [
"c#",
"asp.net-mvc-4",
"cdn",
"bundling-and-minification"
] |
[
"Creating 8 byte IV in Java",
"Im new to cryptography in Java and I am trying to write a program to encrypt and decrypt a phrase using DES symmetric cipher, based on CBC mode of operation.\n\nCan anyone tell me how to go about creating an 8-byte initialization vector and how to cast the new IV into AlgorithmParameterSpec class?\n\nAlso, which packages should I import?\n\nEdit: Right now I have these lines:SecureRandom sr = new SecureRandom(); //create new secure random\nbyte [] iv = new byte[8]; //create an array of 8 bytes \nsr.nextBytes(iv); //create random bytes to be used for the IV (?) Not too sure.\nIvParameterSpec IV = new IvParameterSpec(iv); //creating the IV \n\nIs my above approach correct?\n\nThanks."
] | [
"java",
"des",
"cbc-mode"
] |
[
"How to place the cursor in a custom postion when completion happens?",
"I am trying to create a completion for JavaScript. I have the following exampe for the completion.\n\nvar jsonob = {\n label: String(counter.label),\n kind: counter.kind, \n insertText: counter.insertText, \n};\ncompletionList.push(jsonob);\n\n\n\nand counter.insertText has the \"function ${1:functionName} (){\\n\\t\\n}\" String\n\nwhen the completion happens what it shows is \n\nfunction ${1:functionName} (){\n\n}\n\n\nbut it should highlight the word functionName. How to fix this issue?"
] | [
"visual-studio-code",
"vscode-extensions"
] |
[
"How to grab element by index when elements have different parents",
"I am trying to grab the elements of index 3 and 4 in the following xml:\n\n<Automated>\n <Group>\n <Test><id>testId</id>...</Test>\n <Test>...</Test>\n <Test>...</Test> <!-- 3? -->\n </Group>\n <Test>...</Test> <!-- 4? -->\n</Automated>\n\n\nAs far as I was aware, the expression //x was used to grab all elements with type x. The expression I was attempting to use to grab the 3rd and 4th elements is:\n\n//Test[3] , //Test[4]\n\n\nHowever, element //Test[4] does not return anything. Upon further investigating, I've realized that //Test[1] will actually return both elements 1 and 4. Which is actually the first child of the first element, and the second (first test?) child. \n\nIs there any way to achieve what I want to do? \n\nThe only other thing that I can think of to do (since I'm using this in c# and have access to scripting this) is using a counter to iterate through all possible selections of //Test[x] and then index it myself. However, that seems like more work than is necessary."
] | [
"xml",
"xpath"
] |
[
"(OpenGL 3.1 - 4.2) Dynamic Uniform Arrays?",
"Lets say I have 2 species such as humans and ponies. They have different skeletal systems so the uniform bone array will have to be different for each species. Do I have to implement two separate shader programs able to render each bone array properly or is there a way to dynamically declare uniform arrays and iterate through that dynamic array instead?\n\nKeeping in mind performance (There's all of the shaders suck at decision branching going around)."
] | [
"opengl",
"glsl",
"opengl-3",
"opengl-4"
] |
[
"Sage CRM - How to open a screen in a popup window a in custom ASP page?",
"Kind of the same way when you click in a Search menu of a Avanced Search field\n\n\n\nIn the imagen above, the \"Buscar\" button opens the ´AddressSearchBox´ screen in a popup, i want the same behaivoir but applied to the ´CustomCommunicationDetailBox´ screen when clicking a button in my custom ASP page\n\nI see in the button that it is a lot a Javascript, but do i have to make the onlick button all by hand?"
] | [
"sage-crm"
] |
[
"Powershell execute an action on compliance search",
"I created a new compliance search, and started the compliance search, now i want to execute an action with that compliance search to purge the results. However, i keep getting that the flag -Purge is not available.\n\n PS C:\\WINDOWS\\system32> New-ComplianceSearchAction -Purge -PurgeType SoftDelete -SearchName \"TEST delete a meeting\"\nA parameter cannot be found that matches parameter name 'Purge'.\n + CategoryInfo : InvalidArgument: (:) [New-ComplianceSearchAction], ParameterBindingException\n + FullyQualifiedErrorId : NamedParameterNotFound,New-ComplianceSearchAction\n + PSComputerName : nam05b.ps.compliance.protection.outlook.com\n\n\nI have also tried re-ordering the flags as checked below, still the same error:\n\nPS C:\\WINDOWS\\system32> New-ComplianceSearchAction -SearchName \"TEST delete a meeting\" -Purge -PurgeType \"SoftDelete\"\nA parameter cannot be found that matches parameter name 'Purge'.\n + CategoryInfo : InvalidArgument: (:) [New-ComplianceSearchAction], ParameterBindingException\n + FullyQualifiedErrorId : NamedParameterNotFound,New-ComplianceSearchAction\n + PSComputerName : nam05b.ps.compliance.protection.outlook.com\n enter code here"
] | [
"powershell"
] |
[
"How to convert a Date from typescript into c# and back with the correct time zone?",
"I'm using angularx-flatpickr for selecting a date with time.\nMy local timezone is +2. \n\nI'm selecting this date: '10.07.2019 12:00'\nIn JS console i'm getting: Wed Jul 10 2019 12:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)\nIn the api post i see JSON object with time=2019-07-10T10:00:00.000Z\nIn c# i'm using System.DateTime and i get a DateTime object with: {10.07.2019 10:00:00}\nIn datebase stored: 10.07.2019 10:00:00\nBack in JS when requesting the data i use a view model with Date type. But the object from the view model is a string \"2019-07-10T10:00:00\".\nSo now i can use new Date(\"2019-07-10T10:00:00\") to convert into JS Date. But the time is now wrong because of the time zone: Wed Jul 10 2019 10:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)\n\nI think it makes sense to store the UTC DateTime in the datebase.\nSo this means i need to convert the time in JS to the correct time zone from the user. What is the best best practice to do this?"
] | [
"c#",
"typescript",
"timezone"
] |
[
"Nested blocks and ERB",
"For the life of me, I can't figure out why this doesn't work as expected.\n\nCode:\n\nrequire 'erb'\n\ndef say_hello(name)\n \"Nice to see you, #{ name }!\"\nend\n\ndef greetings\n template = <<-TEMPLATE\nHello!\n<%= yield %>\nGoodbye!\n TEMPLATE\n ERB.new(template).result(binding)\nend\n\npeople = ['Aaron', 'Bob', 'Tim', 'Juan']\nt = greetings do\n people.each do |p|\n say_hello(p)\n end\nend\n\nputs t\n\n\n(a bit contrived, I know, but it'll serve the point.)\n\nWhat I Expect:\n\nHello!\nNice to see you, Aaron!\nNice to see you, Bob!\nNice to see you, Tim!\nNice to see you, Juan!\nGoodbye!\n\n\nWhat I Get:\n\nHello!\n['Aaron', 'Bob', 'Tim', 'Juan']\nGoodbye!\n\n\nThoughts:\n\nI'm guessing this is happening because the interior block (beginning with people.each) gets coerced into a string before the block executes. Perhaps ERB doesn't like how I'm trying to inject a new block of constructed text into its template.\n\nWhat's going on here?"
] | [
"ruby",
"block",
"erb",
"yield"
] |
[
"Visual Studio F5 debugging is slower than Attach to Process",
"If i start my application with F5 (debugging) it takes for a certain operation about 2000ms. If i start the application with F5 + CTRL (without debugging) and attach Visual Studio with \"Attach to Process\" it takes only ~100ms. \n\nHas someone a idea what component can cause this performance 'problem'?\n\nC# application / VS 2012. \n\nEdit\n\nCode-Snipped: \n\nStopwatch stopwatch = new Stopwatch();\nstopwatch.Start();\nchanged.Validate(context);\nstopwatch.Stop();\nConsole.WriteLine(stopwatch.ElapsedMilliseconds);"
] | [
"c#",
"performance",
"visual-studio",
"debugging",
"visual-studio-2012"
] |
[
"VB.NET OpenXML to Read Excel File",
"I have been searching for a way to effectively read an Excel file and have found the following code for parsing and reading a large spreadsheet:\n\nPublic Sub ExcelProcessing()\n\n Dim strDoc As String = \"C:\\Documents and Settings\\Practice.xlsx\"\n Dim txt As String\n\n Dim spreadsheetDocument As SpreadsheetDocument = spreadsheetDocument.Open(strDoc, False)\n\n Dim workbookPart As WorkbookPart = spreadsheetDocument.WorkbookPart\n Dim worksheetPart As WorksheetPart = workbookPart.WorksheetParts.First()\n\n Dim reader As OpenXmlReader = OpenXmlReader.Create(worksheetPart)\n Dim text As String\n While reader.Read()\n\n If reader.ElementType = GetType(CellValue) Then\n\n\n text = reader.GetText()\n MessageBox.Show(text)\n\n End If\n\n\n End While\n\n\nThe issue is where I assign reader.GetText() to my string. The value passed is a small integer while the actual cell value is a string. The messagebox fires once for each populated cell, so this tells me the code is finding cells that contain values; however, I can not extract the actual \"inner text\" of the cell.\n\nThoughts? Suggestions?"
] | [
"vb.net",
"openxml",
"vb.net-2010",
"openxml-sdk",
"xmlreader"
] |
[
"can't install Zend optimizer",
"I downloaded template which requires Zend optimizer installed.\n\n1) I installed WAMP \n2) copied template content in to /localhost directory\n3) Installed Zend Optimizer (in installation process setter path to apache, php.ini)\n4) Started WAMP\n\nAnd got message \n\n\n CMS Server Tester\n Your server was tested to meet all CMS requirements. Following errors were encountered an need to be fixed to run the software:\n\n\nPHP extension \"curl\" is not loaded.\nPlease verify your server configuration. Make sure that extension \"curl\" is enabled.\nPHP extension \"Zend Optimizer|Zend Guard Loader\" is not loaded.\nPlease verify your server configuration. Make sure that extension \"Zend Optimizer|Zend Guard Loader\" is enabled.\n\n\nWhat is the problem? I made anything according to instructions"
] | [
"php",
"apache",
"zend-optimizer"
] |
[
"variable accessiblity in different event listeners",
"i have three javascript events - mouseup, mousedown and mousemove. On each event a different function is called. I want these three functions to share a same variable which is assigned an initial value out side of these functions. \nCan that be done?\nsarfraz asked for the code and here it is:\n\nif(window.addEventListener) {\nwindow.addEventListener('load', function () {\n var canvas, context;\n\n // Initialization sequence.\n var z=false;\n function init () {\n // Find the canvas element.\n canvas = document.getElementById('imageView');\n if (!canvas) {\n alert('Error: I cannot find the canvas element!');\n return;\n }\n\n if (!canvas.getContext) {\n alert('Error: no canvas.getContext!');\n return;\n }\n\n // Get the 2D canvas context.\n context = canvas.getContext('2d');\n if (!context) {\n alert('Error: failed to getContext!');\n return;\n }\n\n // Attach the mousemove event handler.\n canvas.addEventListener('mousedown',ev_mousedown,false);\n canvas.addEventListener('mouseup',ev_mouseup,false);\n canvas.addEventListener('mousemove', ev_mousemove, false);\n\n }\n //The mouseup\n\n function ev_mouseup(ev)\n {\n z=false;\n }\n //The mousedown\n function ev_mousedown(ev)\n {\n z=true;\n }\n // The mousemove event handler.\n var started = false;\n function ev_mousemove (ev) {\n var x, y;\n\n // Get the mouse position relative to the canvas element.\n if (ev.layerX || ev.layerX == 0) { // Firefox\n x = ev.layerX;\n y = ev.layerY;\n } else if (ev.offsetX || ev.offsetX == 0) { // Opera\n x = ev.offsetX;\n y = ev.offsetY;\n }\n\n // The event handler works like a drawing pencil which tracks the mouse \n // movements. We start drawing a path made up of lines.\n if (!started) {\n if(z){\n context.beginPath();\n context.moveTo(x, y);\n started = true;\n }\n } else {\n context.lineTo(x, y);\n context.stroke();\n }\n }\n\n init();\n}, false); }"
] | [
"javascript",
"javascript-events"
] |
[
"Oracle 10g Create a View passing in a parameter",
"I am have been searching but I have not been able to find a satisfactory solution where I can pass a parameter to a view. \n\nWhat I am trying to do is to call a view saved in Oracle 10g passing in a date via NHibernate, which sounds simple enough, but I am reading that passing parameters to view is not so. So, I am unless I am being misled, can someone please advise me whether this is possible and how; or should I do this as a Stored Procedure?\n\nCREATE OR REPLACE aView AS VIEW\n SELECT col1,\n col2,\n col3,\n FROM someTable\n WHERE col4 <= TO_DATE('somePassInDate', 'dd/mm/yyyy');\n\n\nThe above is the sort of query I want to run. I don't hibernate to create this query.\n\nThanks"
] | [
"oracle",
"oracle10g"
] |
[
"How to send multiple objects using nodejs and georedis?",
"I have 4 sets in redis DB , I want to get near by locations from all 4 sets and send back as an api result, below codes are working fine when I am using for only 1 set, but my requirement is to get from all 4 sets, please help me.\n\nrouter.route('/get_near_by').post(function(req, res) {\n\nvar geo = georedis.initialize(client, {\n zset: 'LocationsSet',\n nativeGeo: false\n});\nvar luxuryXL = geo.addSet('luxuryXL');\nvar luxurySedan = geo.addSet('luxurySedan');\nvar sedanFour = geo.addSet('sedanFour');\nvar sedanSix = geo.addSet('sedanSix');\nvar lat = req.body.lat;\nvar lng = req.body.lng;\nvar result = [];\n\nvar options = {\n withCoordinates: true, // Will provide coordinates with locations, default false\n withHashes: true, // Will provide a 52bit Geohash Integer, default false\n withDistances: true, // Will provide distance from query, default false\n order: 'ASC', // or 'DESC' or true (same as 'ASC'), default false\n units: 'km', // or 'km', 'mi', 'ft', default 'm'\n count: 10, // Number of results to return, default undefined\n accurate: true // Useful if in emulated mode and accuracy is important, default false\n};\n\nluxuryXL.nearby({latitude: lat, longitude: lng}, 5000, options, function(err, luxuryXL){\n if(err) {\n console.error(err)\n } else {\n return res.send(luxuryXL);\n }\n });\n});\n\n\nBelow are the codes I tried but they are not working -\n\nluxuryXL.nearby({latitude: lat, longitude: lng}, 5000, options, function(err, luxuryXL){\n if(err) {\n console.error(err)\n } else {\n result['a'] = res.send(luxuryXL);\n }\n});"
] | [
"node.js",
"redis"
] |
[
"asp net web core on IIS : site is inacessible",
"I want to deploy my project ASP net web core on my LAN.\n\nHowever, from visual studio I have published the project. I want to deploy on IIS (windows classic (not windows server)). But when I go to site the browser tell : site is inaccessible\n\nSomeone has an idea ?\n\nI have tried to follow the Microsoft tutorial and some youtube tutorials but nothing works for me.\n\nThank you."
] | [
"asp.net-mvc",
"iis"
] |
[
"cant assign datatable value to list of class",
"This is my Model:\n\npublic class Category\n {\n public Category()\n {\n SubCategory = new List<SubCategory>();\n TicketsInfo = new List<TicketInfo>();\n UserDetails = new List<UserDetails>();\n }\n\n [Key]\n public int CategoryId { get; set; }\n public string Name { get; set; }\n\n\n public List<SubCategory> SubCategory { get; set; } //subcategory is my another class\n public List<TicketInfo> TicketsInfo { get; set; }//ticketinfo is my another class\n public List<UserDetails> UserDetails { get; set; }//userdetails is my another class\n }\n\n\nThis is my controller:\n\nDataTable categoryDetailsforTickets = categoriesBal.FetchTicketDetailsforSubcategory(categoryId);\n List<Category> categoryModelforTickets = new List<Category>();\n\n if (categoryDetailsforTickets.Rows.Count != 0)\n {\n for (int i = 0; i < categoryDetailsforTickets.Rows.Count; i++)\n {\n Category categoryModel = new Category();\n categoryModel.TicketsInfo[i].TicketId =(int) categoryDetailsforTickets.Rows[i].ItemArray[i];\n categoryModel.UserDetails[i].FName = categoryDetailsforTickets.Rows[i].ItemArray[i].ToString();\n categoryModel.TicketsInfo[i].Subject = categoryDetailsforTickets.Rows[i].ItemArray[i].ToString();\n categoryModelforTickets.Add(categoryModel);\n }\n }\n\n\nbut it is throwing me error on this line:\n\ncategoryModel.TicketsInfo[i].TicketId =(int) categoryDetailsforTickets.Rows[i].ItemArray[i];\n\n\nIndex was out of range. Must be non-negative and less than the size of the collection.\nParameter name: index\n\nthere are two records coming in my datatable.\n\ncan anybody figure out what is the problem???"
] | [
"asp.net-mvc-4"
] |
[
"How does Apple compresses video using JPEG, JSON, and ?",
"I found a very nice mechanism to compress videos using JPEG, JSON and canvas.\n\nApple developed this on his website. The mechanism is explained here.\n\nDoes anybody know if there is a plugin, programm or something else to create such a thing?"
] | [
"json",
"video",
"html5-canvas",
"jpeg"
] |
[
"cannot find mx:DateChooser in Flash Builder 4.6",
"http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7d9b.html#WS2db454920e96a9e51e63e3d11c0bf63b33-7fd3\n\nShows that mx:DateChooser control can be used in Flash Builder 4.6\n\nI cannot find it in the codehint.\n\nPlease advise on how do I have a DateChooser control for use in Flash Builder 4.6\n\nUpdate:\n\nI really cannot find datechooser as seen in this screenshot.\nhttp://cl.ly/EJKp\n\ndefinitely I am using sdk4.6 for flex also shown here.\nhttp://cl.ly/EJT0"
] | [
"apache-flex",
"flash-builder",
"flex4.6",
"datechooser"
] |
[
"Stored procedure returns int value when the TSQL have full text search property",
"I have to use CONTAINS (full text search) in my stored procedure's query. So when I bind this stored procedure into my application through Entity Framework it returns an int value instead of a list of object.\n\nEX:\n\nStored procedure:\n\nALTER PROCEDURE [dbo].[GetTableData]\n (@UserId UNIQUEIDENTIFIER)\nAS\nBEGIN\n SET NOCOUNT ON;\n\n SELECT Column1, Column2 \n FROM TABLE1\n WHERE Id = @UserId AND CONTAINS(Column1,'test')\nEND\n\n\nActual result:\n\npublic virtual int GetTableData(Nullable<System.Guid> userId)\n{\n var userIdParameter = userId.HasValue ?\n new ObjectParameter(\"UserId\", userId) :\n new ObjectParameter(\"UserId\", typeof(System.Guid));\n\n return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GetTableData_Result>(\"GetTableData\", userIdParameter );\n }\n\n\nExpected result:\n\npublic virtual ObjectResult<GetTableData_Result> GetTableData(Nullable<System.Guid> userId)\n{\n var userIdParameter = userId.HasValue ?\n new ObjectParameter(\"UserId\", userId) :\n new ObjectParameter(\"UserId\", typeof(System.Guid));\n\n return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GetTableData_Result>(\"GetTableData\", userIdParameter );\n}\n\n\nIf I remove AND CONTAINS(Column1,'test') condition, it's working perfectly and gives the expected result.\n\nI also tried with SET FMTONLY OFF options. That also not working.\n\nHow can I solve this problem? \n\nNeed to add any property or any other things in stored procedure?\n\nCan anyone help me to solve this problem?"
] | [
"sql-server",
"stored-procedures",
"linq-to-entities",
"entity-framework-6",
"c#-2.0"
] |
[
"Order a django queryset by ManyToManyField = Value",
"If have some models like:\n\nclass Tag(models.Model):\n name = models.CharField()\n\nclass Thing(models.Model):\n title = models.CharField()\n tags = models.ManyToManyField(Tag)\n\n\nI can do a filter:\n\nThing.objects.filter(tags__name='foo')\nThing.objects.filter(tags__name__in=['foo', 'bar'])\n\n\nBut is it possible to order a queryset on the tags value?\n\nThing.objects.order_by(tags__name='foo')\nThing.objects.order_by(tags__name__in=['foo','bar'])\n\n\nWhat I would expect (or like) back in this example, would be ALL Thing models, but ordered where they have a Tag/Tags that I know. I don't want to filter them out, but bring them to the top.\n\nI gather this is possible using the FIELD operator, but seemingly I can only make it work on columns in that models table, e.g. title, but not on linked tables.\n\nThanks!\n\nEDIT: After having accepted the below solution, I realised a bug/limitation with it.\n\nIf a particular Thing has multiple Tags, then (due to the left join done behind the scenes in the SQL) it will produce one entry for that Thing, for each Tag that it has. With a True or False for each Tag that matches or not.\n\nAdding .distinct() to the queryset helps only slightly, limiting to a max of 2 rows per Thing (i.e. one tagged=True, and one tagged=False).\n\nI know what I need to do in the SQL, which is to MAX() the CASE(), and then GROUP BY Thing's primary key, which means I will get one row per Thing, and if there has been any tag matches, tagged will be True (and False otherwise).\n\nI see the way that people typically achieve this kind of thing is to use .values() like this:\n\nThing.objects.values('pk').annotate(tagged=Max(Case(...)))\n\n\nBut the result is only pk and tagged, I need the whole Thing model as the result. So I've managed to achieve what I want, thusly:\n\nfrom django.db.models import Case, When, Max, BooleanField\n\ntags = ['music'] # for example\n\nqueryset = Thing.objects.all().annotate(tagged=Max(Case(\n When(tags__name__in=tags, then=True),\n default=False,\n output_field=BooleanField()\n)))\nqueryset.query.group_by = ['pk']\nqueryset.order_by('-tagged')\n\n\nThis seems to work, but the group by mechanism feels weird/hacky. Is it acceptable/reliable to group in this way? \n\nSorry for the epic updated :("
] | [
"python",
"django",
"django-models"
] |
[
"Dimple Filter for X Value",
"I've been using a little d3 and am now exploring dimple. I am trying to create some pie charts. However, I want the x-axis value to be a subset of the actual values.\n\nHere's what I have:\n\n var svg = dimple.newSvg(\"body\", 800, 600);\n\n//data\n var data = [{\"Inst\":\"Two\", \"Finaid\":\"Grant\", \"Value\":50},\n {\"Inst\":\"Two\",\"Finaid\":\"None\", \"Value\":10},\n {\"Inst\":\"Two\",\"Finaid\":\"No\", \"Value\": 30},\n {\"Inst\":\"One\", \"Finaid\":\"Grant\", \"Value\":20},\n {\"Inst\":\"One\",\"Finaid\":\"None\", \"Value\":10},\n {\"Inst\":\"One\",\"Finaid\":\"No\", \"Value\": 30}];\n\n//basic chart\n var chart = new dimple.chart(svg, data);\n console.log(data);\n chart.setBounds(50,20,460,360)\n chart.addCategoryAxis(\"y\", \"Inst\")\n chart.addMeasureAxis(\"x\", \"Value\");\n chart.addMeasureAxis(\"p\", \"Value\");\n chart.addMeasureAxis(\"z\", \"Value\");\n chart.addSeries(\"Finaid\", dimple.plot.pie);\n chart.addLegend(600,20,90,300, \"left\");\n chart.draw();\n\n\nSo this works, but I want the x-axis value to only be the value of \"Finaid\":\"Grant\" something like chart.addMeasureAxis(\"x\", {\"Finaid\":\"Grant\"}.Value);... although I realize that actual code does nothing.\n\nAny suggestions? Thanks"
] | [
"d3.js",
"dimple.js"
] |
[
"Standard .Net TDD Memory Test",
"Is it useful to write a standardised TDD [Test] method that would expose common memory issues ?\n\nThe set of tests could be easily, quickly applied to a method and would red-fail 'classic' .NET memory issues but would green-pass the classic solutions. \n\nFor example common memory issues could be : too much relocation by the garbage collector\n; allocating too much ; too many garbage collections ( classic example prefer StringBuilder over string reallocs ); holding on to memory for too long (classic example call dispose and do not reling on finalizers ); objects inappropriately reaching g1, g2, LOH ; little leaks that add up to something significant over time, … and others.\n\nPerhaps the code could look something like this …\n\n[Test]\npublic void Verify_MyMethodUnderTest_Is_Unlikely_To_Have_Common_Memory_Problem()\n{\n\n//-Setup\nvar ExpectationToleranceA = ...\nvar ExpectationToleranceB = ...\n...\n\n//-Execute\nvar MeasurementA = MyClassUnderTest.MyMethodUnderTest( dependancyA ) ; \nvar MeasurementB = MyClassUnderTest.MyMethodUnderTest( dependancyB ) ; \n…\n\n//-Verfiy\nAssert.That( MeasurementA , Is.WithinTolerance( ExpectationToleranceA ) ) ;\nAssert.That( MeasurementB , Is.WithinTolerance( ExpectationToleranceB ) ) ;\n\n}\n\n\nThere are other posts on memory pressure issues, but the idea here is to be able to quickly point a standard test at a method and the test would red-fail at common/classic memory pressure issues but green-pass the common solutions. A developer may then be pointed to review failing code and possibly fix the leak, change the tolerances or even remove the TDD memory pressure test.\n\ndoes this idea have legs?\n\nThere is a related question here for C++ app, Memory leak detection while running unit tests, which is a similar question but not quite the same thing. Twk's question is pointing to looking at memory after all the test have run ...\n\nMy idea here is for .NET to \n1) unit test each method for common memory issues \n2) fail the classic memory issues \n3) pass the classic fixes to classic common memory issues \n4) be able to quickly throw a quick standard test at a function to see whether it exhibits classic symptoms \n5) be able to upgrade the Standard TDD .Net Memory Pressure Test applied in the unit test. This implies a refactor of the above code so that upgrades to the standard test will change upgrade the memory tests applied throughout the Nunit test suite for a project.\n\n(p.s. I know there is no Is.WithinTolerance call but I was just demonstrating an idea. )\ncheers ..."
] | [
".net",
"unit-testing",
"memory-management",
"memory-leaks"
] |
[
"Is it possible to get system.localtime in particular format in zabbix?",
"I have an item which prints the local time of the system and want to design a trigger that works when the local time on the system is < 6AM\n\nThis is the item.\n\nzabbix_get -s 192.168.201.101 -k system.localtime[local]\n\nAnd this is the output\n\n2017-07-25,04:39:14.682,-05:00\n\nI am using Zabbix 3.0.\n\nHow do I format this item to show the time like hhmmss (043914).\nI want to have it in this format so that i can use it in a trigger expression like so - \n\nIf localtime > 060000 and <some_other_condition> then raise alert\n\nCurrently i see that zabbix raises alerts based on the server time, so i cannot use the inbuilt item.key.time(0) function as the server time is different from the host time."
] | [
"zabbix"
] |
[
"Error 404 api azure translator basic program python",
"I started a translator project on azure.\nI copy the simple test code.\nimport os, requests, uuid, json\n\nsubscription_key = 'KEY_IN_PORTAL_AZURE'\nendpoint = 'URL_IN_PORTAL_AZURE'\n\npath = '/translate?api-version=3.0'\nparams = '&from=fr&to=en'\nconstructed_url = endpoint + path + params\n\nheaders = {\n 'Ocp-Apim-Subscription-Key': subscription_key,\n 'Content-type': 'application/json',\n 'X-ClientTraceId': str(uuid.uuid4())\n}\n\nbody = [{\n 'text' : 'Bonjour'\n}]\nrequest = requests.post(constructed_url, headers=headers, json=body)\nresponse = request.json()\n\nprint(json.dumps(response, sort_keys=True, indent=4,\n ensure_ascii=False, separators=(',', ': ')))\n\nI change the key and the endpoint but the program return\n{\n "error": {\n "code": "404",\n "message": "Resource not found"\n }\n}\n\nI delete the service and i retry same thing"
] | [
"python",
"azure",
"portal",
"azureportal"
] |
[
"Strtotime doesn't work and gives back 1970 and 2019 to 2024",
"I am making a select box which will have the options of the past 18 years and this select will be appended every time the user clicks a button. \n\nI created a select box which does this using php and this code which is inside the select:\n\n<?php\n for($x=1; $x<=18; $x++){\n $year = date('Y', strtotime(date('Y').'-'.$x.'year'));\n echo '<option value='.$year.'>'.$year.'</option>';\n }\n?>\n\n\nHowever it gives me this: http://puu.sh/nciOj/6fbcd52435.png.\n\nI have tried looking on other posts but none of them seem to help and I have tried looking elsewhere on the internet as well. I have tried taking out year and that didn't work. I also tried moving the $x++; to inside the the for loop. \n\nWhat I want to happen is when you click on the select box it will show you the past 18 years. I am sorry if this is a really easy or really stupid question!"
] | [
"php",
"jquery"
] |
[
"How to concatenate two boost::asio::streambuf's?",
"I use boost::asio as a network framework. As a read/write medium it uses boost::asio::streambuf. I want to:\n\n\nread some message in one buffer\nappend second buffer at the beginning of the first one\nsend new composite message\n\n\nWhat are the possible efficient (zero-copy) options to do this?"
] | [
"c++",
"boost-asio"
] |
[
"Android - Round to 2 decimal places",
"Possible Duplicate:\n Round a double to 2 significant figures after decimal point \n\n\n\n\nI know that there are plenty of examples on how to round this kind numbers.\nBut could someone show me how to round double, to get value that I can display as a \nString and ALWAYS have 2 decimal places?"
] | [
"android",
"double",
"decimal",
"rounding"
] |
[
"Why is Jquery not in the footer?",
"I am trying to fix my javascript blocking issue, since i found the jquery.js in the header i have been trying to find a solution to move it.\n\ni found a laborator_actions.php which contains\n\n// Scripts\nwp_enqueue_script( array( 'jquery', 'bootstrap', 'tweenmax', 'modernizr', 'joinable', 'isotope', 'packery' ) );\n\n\nAll of the above except for 'jquery' ARE in the FOOTER. Jquery is NOT in the footer but in the header right now. How can i move it?\n\nrefer to http://satisphy.com\n\nThanks"
] | [
"wordpress"
] |
[
"JavaScript - DataForm.set : undefined is not a function",
"Hello Stackoverflower,\n\na quick question:\n\nI would like to create a DataForm in JavaScript, push the DataForm into an array, send the array to another function, modify in the new function the DataForm and then post the DataForm.\n\nI implemented this like the following abstract, where function1() populates the array with many FormData(), and function2() retrieves each FormData within the array and .set() a new value to the key:\n\nvar arrayTempIds = [];\n\nfunction function1() {\n var formData = new FormData();\n formData.append(\"id\", value);\n arrayTempIds.push(formData);\n};\n\nfunction function2() {\n for(var i = 0; i < arrayTempIds.length; i++) {\n newId = arrayTempIds[i];\n newId.set(\"id\", returndata.id);\n }\n};\n\n\nEverything works except the fact that it seems that I cannot write arrayTempIds[i].set(), as the error that comes is:\n\nUncaught TypeError: undefined is not a function\n\n\nDoes anyone know why?\n\nLuca"
] | [
"javascript"
] |
[
"Why some of Numpy is written in C++?",
"In https://github.com/numpy/numpy it is found that 2.8% of numpy code is C++. Is it just for interfacing with users' C++ codes (like 0.1% of code which is written in fortran) or is some functionality of numpy built on this code?\nAnd if some functionality of numpy is built on this C++ code, why didn't they use C for those purposes?"
] | [
"numpy"
] |
[
"Python - Efficiently building a dictionary",
"I am trying to build a dict(dict(dict())) out of multiple files, which are stored in different numbered directories, i.e. \n\n/data/server01/datafile01.dat\n/data/server01/datafile02.dat\n...\n/data/server02/datafile01.dat\n/data/server02/datafile02.dat\n...\n/data/server86/datafile01.dat\n...\n/data/server86/datafile99.dat\n\n\nI have a couple problems at the moment:\n\n\nSwitching between directories \n\n\nI know that I have 86 servers, but the number of files per server may vary. I am using:\n\nfor i in range(1,86):\n basedir='/data/server%02d' % i\n for file in glob.glob(basedir+'*.dat'):\n Do reading and sorting here\n\n\nbut I cant seem to switch between the directories properly. It just sits in the first one and gets stuck it seems when there are no files in the directory\n\n\nChecking if key already exists\n\n\nI would like to have a function that somehow checks if a key is already present or not, and in case it isnt creates that key and certain subkeys, since one cant define dict[Key1][Subkey1][Subsubkey1]=value\n\nBTW i am using Python 2.6.6"
] | [
"python"
] |
[
"how can i fix \"file not found error \" in my code",
"i trying to make a program which converts normal audio into 8d audio i grabbed this code from github https://github.com/TheJoin95/ambisonics-3d-audio/blob/master/init.py \n\nfrom glob import glob\nfrom pydub import AudioSegment\nfrom pydub.generators import WhiteNoise\nfrom math import *\nfrom random import *\nimport sys\n\nif len(sys.argv) > 2:\n AudioSegment.converter = sys.argv[1] #ffmpeg installation exe dir path\n AudioSegment.ffmpeg = sys.argv[1] #ffmpeg installation exe dir path\n AudioSegment.ffprobe = sys.argv[2] #ffprobe installation exe dir path\n\ndef calc_pan(index):\n return cos(radians(index))\n\n#playlist_songs = [AudioSegment.from_mp3(mp3_file) for mp3_file in glob(\"mp3/*.mp3\")]\n\n#first_song = playlist_songs.pop(0)\ninterval = 0.2 * 1000 # sec\nsong = AudioSegment.from_mp3('mp3/hellomp.mp3')\nsong_inverted = song.invert_phase()\nsong.overlay(song_inverted)\n\nsplitted_song = splitted_song_inverted = []\nsong_start_point = 0\n\nprint(\"split song in part\")\nwhile song_start_point+interval < len(song):\n splitted_song.append(song[song_start_point:song_start_point+interval])\n song_start_point += interval\n\nif song_start_point < len(song):\n splitted_song.append(song[song_start_point:])\n\nprint(\"end splitting\")\nprint(\"total pieces: \" + str(len(splitted_song)))\n\nambisonics_song = splitted_song.pop(0)\npan_index = 0\nfor piece in splitted_song:\n pan_index += 5\n piece = piece.pan(calc_pan(pan_index))\n ambisonics_song = ambisonics_song.append(piece, crossfade=interval/50)\n\n\n# lets save it!\nout_f = open(\"compiled/everlong.mp3\", 'wb')\n\nambisonics_song.export(out_f, format='mp3')\n\n\n\n\ni expected to be an 8D audio but i got some errors how can i fix it and make my code work\n\n\n Warning (from warnings module): File\n \"C:\\Users\\lenovo\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\pydub\\utils.py\",\n line 165\n warn(\"Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work\", RuntimeWarning) RuntimeWarning: Couldn't find ffmpeg or\n avconv - defaulting to ffmpeg, but may not work Traceback (most recent\n call last): File\n \"C:/Users/lenovo/AppData/Local/Programs/Python/Python37-32/8dmusic.py\",\n line 20, in \n song = AudioSegment.from_mp3('mp3/hellomp.mp3') File \"C:\\Users\\lenovo\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\pydub\\audio_segment.py\",\n line 716, in from_mp3\n return cls.from_file(file, 'mp3', parameters=parameters) File \"C:\\Users\\lenovo\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\pydub\\audio_segment.py\",\n line 610, in from_file\n file = _fd_or_path_or_tempfile(file, 'rb', tempfile=False) File \"C:\\Users\\lenovo\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\pydub\\utils.py\",\n line 57, in _fd_or_path_or_tempfile\n fd = open(fd, mode=mode) FileNotFoundError: [Errno 2] No such file or directory: 'mp3/hellomp.mp3'"
] | [
"python",
"audio",
"mp3"
] |
[
"Add Xib file as CameraOverlay to create a Custom Camera UI (XAMARIN.iOS)",
"I m trying to create a camera Custom UI (somewhat like Instagram camera view )\n\nCan Some one help me with adding .xib (layout for my cameraOverlayView) as cameraOverlayView .\n\ninside -> ViewDidLoad()\n\n base.ViewDidLoad();\n var imagePickerControl = new UIImagePickerController();\n imagePickerControl.SourceType = UIImagePickerControllerSourceType.Camera;\n imagePickerControl.ShowsCameraControls = true;\n //Code lines needed to add the xib \"CameraOverlayView.xib\" as uiview to pass next line \n imagePickerControl.CameraOverlayView = ;\n\n var imagePickerDelegate = new CameraImagePicker(this);\n imagePickerControl.Delegate = imagePickerDelegate;\n NavigationController.PresentModalViewController(imagePickerControl, true);\n\n\nI was refering to \nhttps://developer.xamarin.com/recipes/ios/general/templates/using_the_ios_view_xib_template/\n\nBut I was unable to add the xib as my CameraOverlay\n\nAsk for related code if needed ..\nthanks in advance"
] | [
"c#",
"ios",
"xamarin",
"xamarin.ios",
"camera-overlay"
] |
[
"C# Directive to indicate 32-bit or 64-bit build",
"Is there some sort of C# directive to use when using a development machine (32-bit or 64-bit) that says something to the effect of:\n\n\nif (32-bit Vista)\n // set a property to true\nelse if (64-bit Vista)\n // set a property to false\n\n\nbut I want to do this in Visual Studio as I have an application I'm working on that needs to be tested in 32/64 bit versions of Vista.\n\nIs something like this possible?"
] | [
"c#",
"visual-studio-2008"
] |
[
"Load h5 keras model file in R",
"I'm building a R package for binary classification and I'm using opencpu to host it. Currently I've saved the h5 file as .RData file(serialized), which is then loaded in the environment using the .onLoad() function in R. This enables the R script to use the environment variable to load keras model using keras::unserialized_model().\n\nI've tried directly using keras::load_model_hdf5() in the code, but after building and deploying on opencpu, when I try to hit the prediction API, I get error\n\nioerror: unable to open file (unable to open file: name = '/home/modelfile_26feb.h5', errno = 13, error message = 'permission denied', flags = 0, o_flags = 0)\n\nI have changed permission for the file(777) and even the groups but still getting the error.\n\nI even tried putting the file in inst/extdata folder so that it gets in the package but still same error.\n\nCan anyone help on this, or suggest some alternative to load the h5 model directly?"
] | [
"r",
"keras",
"opencpu"
] |
[
"How can I wrap divs?",
"Basically, I want the inner divs outside the outer div to wrap according to the width of the outer div, which in turn expands and contracts according to the width of the browser window, like so:\n\n.---------------------.\n| | <-- Browser Window\n| .-----------------. |\n| | ,-, ,-, ,-, | |\n| | |X| |X| |X| | |\n| | `-` `-` `-` | |\n| | | |\n| | ,-, ,-, ,-, | |\n| | |X| |X| |X| | |\n| | `-` `-` `-` | |\n| `-----------------` |\n| |\n`---------------------`\n\n.-------------------------------.\n| | <-- Browser Window enlarged\n| .---------------------------. |\n| | ,-, ,-, ,-, ,-, ,-, | |\n| | |X| |X| |X| |X| |X| <----- Inner divs wrap around accordingly, as if\n| | `-` `-` `-` `-` `-` | | they are text\n| | | |\n| | ,-, | |\n| | |X| | |\n| | `-` | |\n| `---------------------------` |\n| |\n`-------------------------------`\n\n\nWhat would be the best (as in simplest in terms of developer time) way to make this happen?"
] | [
"javascript",
"html",
"css",
"layout"
] |
[
"Return the names from columns in sqlite database",
"I am trying to perform an sqlite query in java code which will return the columns names from an sqlite table. How can I do so? I am only managed to get the values from the table and not the names of the columns."
] | [
"java",
"sqlite"
] |
[
"Module library Jar not shown in External Libraries in Android Studio",
"I am having trouble getting a jar library to show up under External Libraries in Android Studio. I am trying to add javadoc for this library, and the only method I've found online is to right click on the library in External Libraries and select Library Properties.... \n\nThe project structure is a tree of many modules:\n\nrootsdk / \n main.jar\n main-javadoc.jar\n plugins /\n plugin1 / \n build.gradle\n ...\n plugin2 /\n build.gradle\n ...\n ...\n\n\nThe dependency is declared in the build.gradle files like:\n\ncompileOnly files('../../main.jar')\n\n\nIf I open up the individual directories plugin1, then the dependency shows up in External Libraries correctly. But if I open up the rootsdk project, it does not appear. All of the modules are listed and compilable from the root project, and I can use classes defined in the library just fine, but it does not appear under External Libraries, so I cannot add the javadoc for it.\n\nThe strange thing is some of the plugins use other libraries, but defined differently:\n\nrepositories {\n flatDir {\n dirs 'libs'\n }\n}\n\n...\n\nimplementation(name: 'core-debug', ext: 'aar')\n\n\nAnd these libraries show up under External Libraries as expected. \n\nIs there something missing to force main.jar to show up under External Libraries, or is this a bug in AS?"
] | [
"android",
"android-studio",
"intellij-idea"
] |
[
"How to fix/set column width in a django modeladmin change list table when a list_filter is added?",
"I'm working on improving the admin.py in a django project, and while I'm not totally jazzed about how the table was coming out with three fields in the list_diplay, at least it's better than just getting a default object list with one column spanning the whole page... \n\nAnyway, what I'm asking is why if this:\n\nclass FieldAdmin(admin.ModelAdmin):\n list_display = ('name', 'label', 'standard', )\n\n\nlooks like this:\n\n\n\nWhen I add a list_filter, like this:\n\nclass FieldAdmin(admin.ModelAdmin):\n list_display = ('name', 'label', 'standard', )\n list_filter = ['standard',]\n\n\nWhy does it look like this?\n\n\n\nIs there a way to get the columns to re-grow to fill the width like it was prior to adding the filter? I've been reading the docs and googling, but it doesn't seem built in? The project I'm working on is currently using django 1,2,3,final.\n\nFWIW, the css that causes this is here:\n\n.change-list .filtered table, .change-list .filtered .paginator, \n.filtered #toolbar, .filtered div.xfull {\n margin-right: 160px !important;\n width: auto !important;\n}\n\n\ndisabling the width style specification fixes it, but I'd rather do things the django way if there is one - I was hoping maybe there's a way to customize the filter view from the FieldAdmin class?"
] | [
"python",
"django",
"django-admin",
"django-admin-filters"
] |
[
"Oracle control file equivalent in sql server",
"I have oracle generated control file .ctl file and text file containing the data I need to import.\n\nI need to import this data in text file into SQL Server table and using this .ctl file.\n\nOracle has built in command like SQLLDR which does this stuff, but is there any equivalent for this for SQL Server?\n\nAny help would be greatly appreciated. Thanks in advance."
] | [
"sql-server",
"oracle",
"oracle11g",
"sql-server-2012",
"data-import"
] |
[
"batch if statment return same result in any case",
"in C:\\Easy_ERROR there is only 3 files. when only in 1 file you can find the string 'alexm'\n\n@echo off\n@break off\n@color 0a\n@cls\n\nFOR %%a IN (C:\\Easy_ERROR\\EIM*.txt) DO (\nfind /c /i \"ALEXM\" C:\\Easy_ERROR\\%%~nxa \n IF %errorlevel% EQU 0 ECHO FOUND\n )\n)\n\npause\nexit\n\n\nwhen you run it, the statement:\n\nIF %errorlevel% EQU 0 ECHO FOUND\n\n\nalways writing me \"FOUND\" for all 3 files!\n\nits only an exemple for something else that im trying to do. but the same case!"
] | [
"batch-file"
] |
[
"Creating a JSON output from a multidimensional array",
"I populate an array with the results of three SQL queries. Then I create a temporary table, insert all this data into it then query the table to be able to pass the result as a json array to my Java app (Android).\n\nSo.\n\n$i=0;\ntry {\n $stmt = $conn->prepare(\"SELECT APPID FROM COMMENTROOM WHERE BADGEID=? GROUP BY APPID\");\n $stmt->execute(array($badgeID));\n while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {\n $row2[$i][0] = $row['APPID'];\n $i++;\n }\n } catch(PDOException $e) {\n echo 'ERROR: ' . $e->getMessage();\n $server_dir = $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\\\');\n header('Location: http://' . $server_dir);\n exit();\n}\n\nfor ($i=0; $i<count($row2); $i++)\n{\n try {\n $stmt = $conn->prepare(\"SELECT APPNAME, MARKETLINK, FILENAME, USERID FROM TABLE_ADS WHERE ID=?\");\n $stmt->execute(array($row2[$i][0]));\n while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {\n $row2[$i][1] = $row['APPNAME'];\n $row2[$i][2] = $row['MARKETLINK'];\n $row2[$i][3] = $row['FILENAME'];\n $row2[$i][4] = $row['USERID'];\n }\n } catch(PDOException $e) {\n echo 'ERROR: ' . $e->getMessage();\n $server_dir = $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\\\');\n header('Location: http://' . $server_dir);\n exit();\n }\n}\n\nfor ($i=0; $i<count($row2); $i++)\n{\n try {\n $stmt = $conn->prepare(\"SELECT BADGEID FROM REG_USERS WHERE ID=?\");\n $stmt->execute(array($row2[$i][4]));\n while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {\n $row2[$i][5] = $row['BADGEID'];\n }\n } catch(PDOException $e) {\n echo 'ERROR: ' . $e->getMessage();\n $server_dir = $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\\\');\n header('Location: http://' . $server_dir);\n exit();\n }\n}\n\n\nThen finally after I inserted the data from the $row2 array into the temporary table I do\n\ntry {\n $stmt = $conn->prepare(\"SELECT * FROM TEMP_COMMENTLIST\");\n $stmt->execute();\n while ($row = $stmt->fetchAll(PDO::FETCH_ASSOC)) {\n $output[] = $row;\n }\n } catch(PDOException $e) {\n echo 'ERROR: ' . $e->getMessage();\n $server_dir = $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\\\');\n header('Location: http://' . $server_dir);\n exit();\n }\nprint(json_encode($output));\n\n\nThe output looks like\n\n[[{\"APPID\":\"0000000021\",\"APPNAME\":\"Enhanced Email\",\"MARKETLINK\":\"https:\\/\\/play.google.com\\/store\\/apps\\/details?id=com.qs.enhancedemail\",\"FILENAME\":\"00000000089_2013-10-23 13:26:38_Enhanced Email.png\",\"USERID\":\"00000000089\",\"BADGEID\":\"2626511\"},{\"APPID\":\"0000000037\",\"APPNAME\":\"Mobile....\n\n\nHowever I think there must be a better solution than messing with this temporary table thing. Is a there a way to create the SAME output from the $row2 array without any more sql queries?\n\nSOLUTION:\nI mixed hotzu's and SoaperGEM's solution:\n\n $result = array();\ntry{\n $stmt = $conn->prepare(\"SELECT c.APPID, t.APPNAME, t.MARKETLINK, t.FILENAME, t.USERID, c.BADGEID FROM COMMENTROOM c\n INNER JOIN TABLE_ADS t ON t.ID = c.APPID \n INNER JOIN REG_USERS r ON r.ID = t.USERID \n WHERE c.BADGEID = ? \n GROUP BY c.APPID\");\n $stmt->execute(array($badgeID));\n while ($row = $stmt->fetch(PDO::FETCH_OBJ)) {\n $result[] = $row;\n }\n} catch(PDOException $e) {\n echo 'ERROR: ' . $e->getMessage();\n $server_dir = $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\\\');\n header('Location: http://' . $server_dir);\n exit();\n}\n\n\necho \"[\".json_encode($result).\"]\";\nexit();"
] | [
"php",
"json"
] |
[
"flextable background colour issues",
"I am making a flextable using the iris dataset and have noticed an odd issue with the background colour function. I am trying to conditionally colour cells if they are over a certain value:\n\n regulartable(iris) %>%\n bg(i=1, j=which(iris[1,1:4] > 5), \"green\")\n\n\n\n\nIt works fine if at least one of the cells satisfies the condition for j, but if non of them do it colours the whole line rather than colouring nothing:\n\n regulartable(iris) %>%\n bg(i=1, j=which(iris[1,1:4] > 6), \"green\")\n\n\n\n\nIs there a way to make it only colour if the condition is met? Also is this a feature or a bug in the flextable package?\n\nEdit:\n\nThis has been resolved by version 0.5.1 of the flextable package."
] | [
"r",
"flextable"
] |
[
"Is it possible to mark code to be compiled only in debug mode?",
"I've got a try catch (or with in F#) structures all over the code but I don't really need them in debug mode, it's easer for me to debug errors via VS debugger.\n\nSo I want to mark try catch codelines to be compiled only in release mode - is it possible or not ?"
] | [
"c#",
".net",
"visual-studio",
"debugging",
"f#"
] |
[
"Mixing Threaded Timer and PLINQ",
"I'm having a problem when calling PLINQ's ForAll Extension in a Threaded Timer Callback. That will create threads indefinitely. The code example is a simple down stripped version of the actual problem.\n\nclass Program\n{\n static List<int> x = new List<int>();\n\n static void Main(string[] args)\n { \n x = Enumerable.Range(0, 9).ToList();\n System.Threading.Timer[] timers = new System.Threading.Timer[10];\n for (int i = 0; i < 10; i++)\n timers[i] = new System.Threading.Timer(ElapsedCallback, null, 1000, 1000);\n Console.ReadLine();\n }\n\n static void ElapsedCallback(object state)\n {\n int id = Thread.CurrentThread.ManagedThreadId;\n x.AsParallel().ForAll(y => Console.WriteLine(y + \" - \" + Thread.CurrentThread.ManagedThreadId + \" - \" + id));\n }\n}\n\n\nIf monitored in the taskmanager one can see that the thread count will raise until the process hangs. If i limit the ThreadPool Size the process will create threads until that size and then gets stuck also.\n\nIf seen that pattern in other code also. For example the ConnectionPool in the Firebird ADO.Net Provider does it this way also to clean up unused Connections. If i'm doing something dumb here i'm not the only one ;) Any insights?\n\nEdit : Jim asked for some context so ...\n\nThis pattern is used in a Transaction Pool for ReadOnly Transactions. The App might have multiple readonly transactions open in a dozen different Databases. Each database has its own Pool of Transaction and its own Timer that regularly commits and disposes old transactions for that database in the pool. Each transaction commit is then parallelized via PLINQ's ForAll."
] | [
"c#",
"multithreading",
"timer",
"plinq"
] |
[
"facebook connect api",
"Is it possible to use the facebook connect api to just grab some information and use it with a customized form?\nBecause facebook register api shows a pre-filled form, how to get these data and use them with another form\nThanks"
] | [
"facebook"
] |
[
"Lateinit property in fragment has not been initialized",
"Why is my fragment not entering onCreateView when the variable is declared only in onCreate?\n\nIt only tells me \"lateinit property beatBox has not been initialized\" But it is!\n\nbeatBox is delared as a lateinit at the class level and defined in onCreate but the program does not enter the onCreateView method. I can put a Log.d in it and check the object type that is created! It crashes unless I redefine var beatBox, making a reference to a new object.\n\nWhy will my fragment not enter onCreateView?\n\nclass BeatBoxFragment : Fragment() {\n\n private lateinit var beatBox: BeatBox\n\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n var beatBox = BeatBox(requireContext())\n Log.d(\"Crashing\", beatBox.toString() + \" has been created, yer program does not go into onCreateView\")\n }\n override fun onCreateView(\n inflater: LayoutInflater,\n container: ViewGroup?,\n savedInstanceState: Bundle?\n ): View? {\n //var beatBox = BeatBox(requireContext())\n Log.d(\"Crashing\", \"The program does not enter onCreateView unless I uncomment the beatBox definition!)\n\n }\n\n}"
] | [
"android",
"android-fragments",
"kotlin"
] |
[
"Referencing columns in a ROWTYPE table",
"In PostgreSQL I would like to dynamically access columns in a ROWTYPE by referencing a column number.\n\nI would for example like to access column number 59, by for example r.column(59), instead of r.columnname. Is this possible?\n\nThe purpose is that i want loop through a number of columns and dont want to hard code all columns.\n\nFor example:\n\nr data.stageing_table%rowtype;\n\nFOR r IN SELECT * FROM data.stage_table LOOP\n INSERT INTO TABLE XXX\n .....\n VALUES(r.column(8))\n\nEND LOOP\n\n\nIs it possible to access columns in my rowtype result set?"
] | [
"postgresql",
"rowtype"
] |
[
"Pass string from UserForm to website field using VBA",
"I am new to the use of VBA for web interactions.\n\nI have a UserForm (\"FrmResults\") with a textbox (\"TxtSql\"). I am trying to use VBA to open a website and paste the text from the textbox to a textarea on this website. \n\nSo far I have the following code but this always starts the Debugger at the last piece, i.e. where I am trying to set the value of the textarea - even if I just use \"test\" for testing. I also tried using .InnerHtml instead of .Value but this fails as well.\n\nIt always stops after it has opened the website so it fails to paste the copied text from the clipboard there. \n\nCan someone tell me what I am doing wrong or missing here ? \n\nMy code: \n\n Dim IE As Object\n Dim MyURL As String\n Dim varResults As New DataObject\n\n varResults.SetText TxtSql.Text\n varResults.PutInClipboard\n\n Set IE = CreateObject(\"InternetExplorer.Application\")\n MyURL = \"myURL\"\n\n IE.Navigate MyURL\n IE.Visible = True\n\n While IE.busy\n DoEvents\n\n Wend\n\n With IE.Document\n .getElementById(\"Oracle_profile_sql\").Value = varResults\n' .all(\"mapnow_button\").Click\n End With"
] | [
"vba",
"excel",
"internet-explorer"
] |
[
"React useEffect() only run on first render with dependencies",
"There are several other SO questions on this where the answer is either to eliminate the dependencies complaints via ESLint (I'm using typescript) or to do something else to still allow the second parameter of useEffect to be []. However per the React docs this is not recommended. Also under the react useEffect docs it says\n\n\n If you pass an empty array ([]), the props and state inside the effect\n will always have their initial values. While passing [] as the second\n argument is closer to the familiar componentDidMount and\n componentWillUnmount mental model, there are usually better solutions\n to avoid re-running effects too often. Also, don’t forget that React\n defers running useEffect until after the browser has painted, so doing\n extra work is less of a problem.\n\n\nI have the following code:\n\n useEffect(() => {\n container.current = new VisTimeline(container.current, items, groups, options);\n }, [groups, items, options]);\n\n\nI want it to run only one time.\n\nIs the only way around this to let it run each time and useState to track it has ran before like this:\n\n const [didLoad, setDidLoad] = useState<boolean>(false);\n\n useEffect(() => {\n if (!didLoad) {\n container.current = new VisTimeline(container.current, items, groups, options);\n setDidLoad(true);\n }\n }, [didLoad, groups, items, options]);"
] | [
"reactjs",
"typescript",
"react-hooks"
] |
[
"ApplicationUserManager GeneratePasswordResetTokenAsync Invalid column UserId",
"When using GeneratePasswordResetTokenAsync I get three invalid column warnings, two for UserId and one for RoleId. I believe this has something to do with AspNetUsers relationships, which I have not edited in my database. I am running the code below. I've edited the code below to show where dbUser is derived from, which gets its context from the web.config's DefaultConnection.\nusing (var appContext = ApplicationDbContext.Create())\n{\n var dbUser = appContext.Users.FirstOrDefault(x => x.UserName == Username); \n if (dbUser.EmailConfirmed)\n {\n var provider = Startup.DataProtectionProvider;\n var userManager = new ApplicationUserManager(new UserStore<ApplicationUser>(appContext));\n userManager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(provider.Create("PasswordReset"));\n token = await userManager.GeneratePasswordResetTokenAsync(dbUser.Id);\n\n ...\n }\n}\n\nI tried adding an extended context with this:\nprotected override void OnModelCreating(DbModelBuilder modelBuilder)\n {\n modelBuilder.Entity<AspNetUser>()\n .HasMany(n => n.AspNetUserClaims)\n .WithRequired() \n .Map(a => a.MapKey("UserId"));\n\n modelBuilder.Entity<AspNetUser>()\n .HasMany(n => n.AspNetUserLogins)\n .WithRequired() \n .Map(a => a.MapKey("UserId"));\n\n modelBuilder.Entity<AspNetUser>()\n .HasMany(n => n.AspNetRoles)\n .WithRequired()\n .Map(a => a.MapKey("RoleId"));\n }\n\nBut this had no effect. What I don't understand is why the call to GeneratePasswordResetTokenAsync would not understand the relationship to it's connected tables, they are all AspNet_X tables. In other words they are AspNetRoles (through AspNetUserRoles), AspNetUserClaims, and AspNetUserLogins.\nAm I just looking at this issue wrong?"
] | [
".net",
"database",
"dbcontext",
"change-password",
"asp.net-roles"
] |
[
"TSQL odd duplicate row",
"I am getting some odd duplicate rows in a TSQL query. Right now it is possible for an employee to have two credentials so those duplicates are ok, I will take care of that when I add credential priority, but what I am failing to understand is why this query is generating near duplicate rows when the data in the mro column is both 0 and 1 which should not be possible with the data.\n\nQuery\n\n Select \n DISTINCT v.clientvisit_id,\n (case when v.non_billable=0 then v.duration else 0 end) / 60 as billable_hours,\n (case when (v.non_billable=0 AND Z_ServiceLedger.payer_id=63) then v.duration else 0 end) / 60 as billable_mro_hours,\n Credentials.credentials\nFrom Z_ServiceLedger\n Inner Join ClientVisit v On Z_ServiceLedger.clientvisit_id =\n v.clientvisit_id\n Left Join Employees On v.emp_id = Employees.emp_id\n Left Join EmployeeCredential On Employees.emp_id = EmployeeCredential.emp_id\n Left Join Credentials On Credentials.credential_id =\n EmployeeCredential.credential_id\nWHERE v.rev_timein >= @param1 And v.rev_timein < DateAdd(d, 1, @param2) And\n Z_ServiceLedger.amount > 0 AND\n v.splitprimary_clientvisit_id is null and\n v.gcode_primary_clientvisit_id is null and\n v.rev_timein <= \n CASE WHEN EmployeeCredential.end_date is not null\n THEN EmployeeCredential.end_date\n ELSE GETDATE()\n END AND\n v.non_billable = 0 and\n v.duration / 60 > 0 and\n (EmployeeCredential.is_primary is null or EmployeeCredential.is_primary != 'False') and\n v.client_id != '331771 ' and\n v.non_billable = 'FALSE'\nGROUP BY Credentials.credentials, v.non_billable, v.duration, Z_ServiceLedger.payer_id, v.clientvisit_id HAVING COUNT(*) > 1\nORDER BY v.clientvisit_id \n\n\nSample output \n\nclientvisit_id billable_hours billable_mro_hours credentials \n921094 1 0 AS\n\n921094 1 0 Res Tech\n\n921094 1 1 AS"
] | [
"sql",
"sql-server",
"tsql"
] |
[
"Accessing Java method in xpage repeat control",
"I've created a Java Script Library which has a java class that contains some jdbc code.\n\nIt has a method to get values from a database (mysql). \n\nNow i need to access it in the repeat control like <xp:repeat value = ?? >\n\nBut i don't find a way to access it there.\n\nIf it is a javascript library, the method is accessed as <xp:repeat value=\"#{javascript:getSQLData()}\"\n\nHow to achieve it? And is it the right approach to use java in script libraries when we also have a separate application named Java inside the Code Section (below script library in the application view).\n\nMy java code is:\n\npackage com.db;\n\n\nimport java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\nimport java.sql.Statement;\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class Db { \n\nConnection con;\nStatement st;\nResultSet rs;\n\npublic Db(){\n\n this.connect(\"localhost\", \"3306\", \"vijay\", \"root\", \"\");\n try {\n this.query(\"select * from prodet;\");\n } catch (SQLException e) {\n // TODO Auto-generated catch block\n System.out.println(\"///////////////query///////////////////////////////////////////\");\n e.printStackTrace();\n }\n}\n\npublic void connect(String server, String port, String db, String user, String pwd){\n try {\n Class.forName(\"com.mysql.jdbc.Driver\");\n con=DriverManager\n .getConnection(\"jdbc:mysql://localhost:3306/vijay\",\"root\", \"\");\n //con=DriverManager.getConnection(\"\\\"jdbc:mysql://\"+server+\":\"+port+\"/\"+db+\"\\\"\"+\",\"+\"\\\"\"+user+\"\\\"\"+\",\"+\"\\\"\"+pwd+\"\\\"\");\n st=con.createStatement();\n } catch (ClassNotFoundException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n } catch (SQLException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n}\n\nList arr = new ArrayList();\n\n\n@SuppressWarnings(\"unchecked\")\npublic void query(String q) throws SQLException{\n rs=st.executeQuery(q); \n while(rs.next()){\n arr.add(rs.getString(2));\n arr.add(rs.getInt(3));\n\n }\n}\n\npublic String getData(){\n\n String arra = arr.toString();\n return arra;\n}\n\npublic String doAllDb(){\n\n return this.getData();\n}\n\npublic static void main(String a[]){\n Db d = new Db();\n\n System.out.println(d.getData());\n}\n\n\n}\n\nAnd the ssjs to access the method is:\n\nimportPackage(com.db);\n\n\nvar v = new com.db.Db();\n v.doAllDb();\n\nThis ssjs is written under Bind data using ssjs.\n\n<xp:repeat id=\"repeat1\" rows=\"30\">\n <xp:this.value><![CDATA[#{javascript:importPackage(com.db);\n\n\nvar v = new com.db.Db();\n v.doAllDb();}]]>\n .\n\nWhen the xpage is previewed, it is blank. Doesn't show any value. But i tested the java code. It is working fine."
] | [
"xpages"
] |
[
"How to get active namenode hostname from Cloudera Manager REST API?",
"I'm able to access the Cloudera manager rest API.\n\ncurl -u username:password http://cmhost:port/api/v10/clusters/clusterName\n\n\nHow to find the active namenode and resource mangarer hostname?\n\nI couldn't find anything relevant from API docs.\n\nhttp://cloudera.github.io/cm_api/apidocs/v10/index.html\n\nNote: Cluster is configured with high availability"
] | [
"hadoop",
"cloudera-manager"
] |
[
"How do you read from a node.js website in c#?",
"I am having a problem in c#. I have a program that will read data from my node.js website to get data. But when I run the program it reads nothing. I tried the program on google.com(static website) and it worked. What will I have to do?\n\nwebData = wc.DownloadString(\"https://log.markratcliffe.repl.co/users/\" + textBox1.Text + \"password.txt\");"
] | [
"c#",
"node.js",
"network-programming"
] |
[
"write function not reading timer",
"I'm trying to write a timer function. In its first state, the timer worked, but the code it executed had to be placed within the timer, inside the goActive/goInactive functions respectively. Now I'm trying to separate the timer from the function calls by having goActive/goInactive return little signal variables, which other code blocks can interpret. \n\nRight now I've just got a simple mock-up. I want goActive and goInactive to return 1 or -1, and then another function, checktimer, ought to write them to the screen as they update. But I've not figured out the logic. I'm very new to JS; I appreciate all help:\n\n\r\n\r\nvar TimeoutID;\r\nvar timerstatus = 0;\r\n\r\nfunction inputdetect() {\r\n // attaches event handler to specified event\r\n // takes event as string, function to run, and optional boolean\r\n // to indicate when the event propogates\r\n // these are false, so events \"bubble up\"\r\n this.addEventListener(\"mousemove\", resetTimer, false);\r\n this.addEventListener(\"mousedown\", resetTimer, false);\r\n this.addEventListener(\"mousewheel\", resetTimer, false);\r\n this.addEventListener(\"keypress\", resetTimer, false);\r\n this.addEventListener(\"touchmove\", resetTimer, false);\r\n this.addEventListener(\"DOMmousescroll\", resetTimer, false);\r\n this.addEventListener(\"MSpointermove\", resetTimer, false);\r\n\r\n startTimer();\r\n}\r\n\r\ninputdetect();\r\n\r\nfunction startTimer() {\r\n //waits two seconds before calling inactive\r\n TimeoutID = window.setTimeout(goInactive, 2000); // does it need to take the window variable??\r\n}\r\n\r\nfunction resetTimer(e) {\r\n window.clearTimeout(TimeoutID);\r\n goActive();\r\n}\r\n\r\nfunction goActive() {\r\n //what happens when the UI is not idle\r\n\r\n $('#hi').text(\"The UI is not idle.\");\r\n timerstatus = 1;\r\n $('#var').text(timerstatus);\r\n\r\n startTimer();\r\n return timerstatus;\r\n}\r\n\r\nfunction goInactive() {\r\n $('#hi').text(\"The UI is idle.\");\r\n timerstatus = -1;\r\n $('#var').text(timerstatus);\r\n return timerstatus;\r\n // REPLACING CURSOR WHEN UI IS IDLE\r\n //this part won't work\r\n}\r\n\r\nfunction checktimer(timerstatus) {\r\n $('#ct').text(timerstatus);\r\n}\r\n\r\n$(document).ready(function() {\r\n window.setInterval(checktimer(timerstatus), 2000);\r\n});\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js\"></script>\r\n<div>check timer update goes: <span id=\"ct\"></p></div>\r\n\r\n<!--this is where the HTML will go*/-->\r\n<p id = \"hi\">hello</p>\r\n<p id = \"ts\">Timer status is: <span id = \"var\"></span> \r\n </p>"
] | [
"javascript",
"timer"
] |
Subsets and Splits