texts
sequence
tags
sequence
[ "general setup for searchify in rails, how to access variable from initializer file", "how do i access a variable from an initializer file?\n\ni have a file called search.rb in my initializer folder\n\napi_client = IndexTank::Client.new 'http://:[email protected]'\nindex = api_client.indexes 'idx'\n\n\nhowever, in my controller whenever im trying to index a newly created lesson, rails gives me an error of\n\nundefined method `document' for nil:NilClass\n\n\nmy controller is...\n\ndef create\n index.document(@lesson.id).add({:text => @lesson.content })\nend\n\n\nalso is this a bad way of indexing my documents? whenever they're being created? thanks" ]
[ "ruby-on-rails", "full-text-search", "initializer", "indextank", "searchify" ]
[ "Querying a value over pyOSC", "I'm working on a python script to send OSC messages to MOTU's Cuemix software. After much hackery, I was finally able to set a high value, and a low value with two different scripts. \n\nThese scripts are SND_UP and SND_DOWN : https://github.com/derjur/KnobOSC\n\nThis is great and all, but the point of this project was to get a rotary knob to turn up and down with a configurable granularity. But I need to know the current value of the Cuemix knob in order to change it by a relative amount in my scripts. \n\ntl;dr - I need to query the state of a device through OSC to get its current value... \n\nAdditionally, when I run pyosc in server mode, I receive this error for all sorts of OSC addresses... (posting the one line of several thousand that's relevant to the control I want to modify). \n\nOSCServer: NoCallbackError on request from NYNAEVE:50106: No callback registered to handle OSC-address '/dev/0/0/mon'" ]
[ "python", "midi", "osc" ]
[ "htaccess redicect to www exclude subdomain", "i have the following rule to redirect non www to www\n\nRewriteCond %{HTTP_HOST} !^www\\.\nRewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]\n\n\nbut now i want a subdomain assets.company.com το be excluded but nothing seems to work for me\n\ni have try\n\nRewriteCond %{HTTP_HOST} !^assets\\. [NC] [AND]\nRewriteCond %{HTTP_HOST} !^www\\. [NC]\nRewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]\n\n\nand its not working\n\nPleas help" ]
[ ".htaccess" ]
[ "\"No Instance of type variable R exist so that Observable conforms to Observable\" Error when updating to RxJava2", "I am trying to make a call to API using retrofit and rxJava. The code below seems to work well when using RxJava 1, but once I updated to RxJava 2 I am getting this error: \n\nError : \n\n\n No Instance of type variable R exist so that Observable conforms to\n Observable\n\n\nApi \n\nObservable<HttpResult<List<Article>>> getList(@Query(\"key\")String key);\n\n\nApi request done here, and this is where I get this error inside .map operator \n\nObservable cache=providers.getList().map(new HttpRsltFunc<List<Article>>());\n\n\nResult class model :\n\nprivate class HttpRsltFunc<T> implements Func1<HttpResult<T>, T> {\n @Override\n public T call(HttpResult<T> httpResult) { \n return httpResult.getData();\n }\n }\n\n\nEdit : \n\nWhen importing rx.Observable instead of io.reactivex.Observable the code works just fine.\n\nThank you" ]
[ "java", "android", "rx-java", "retrofit2", "rx-java2" ]
[ "newline in RegEx search in Chrome developer tools", "How do I search for a newline character in the Chrome developer tools so that I can search for a text that spans multiple lines?\n\nI've tried [\\r\\n]+ but that doesn't seem to work." ]
[ "google-chrome", "google-chrome-devtools" ]
[ "Entity Framework 6 raw sql query returns 0 in place of int value", "I have a small problem where one of my queries return proper integer values in SQL Server 2008 yet when I run the query through ctx.Database.SqlQuery<> it makes all integer column values as 0.\n\nOther columns such as DateTime or varchar return proper data.\n\nSample query result in SQL Server 2008:\n\n2015-03-08 F4U4 H012 Line 01 0 15916 147 190 15390 0 0 0\n\n\nSame query result in EF using the following code:\n\nusing (MEYNDBEntities ctx = new MEYNDBEntities())\n{\n var obj = ctx.Database.SqlQuery<DBResultDPRDataUpload>(query).ToList();\n return obj;\n}\n\n2015-03-08 F4U4 H012 Line 01 0 0 0 0 0 0 0 0\n\n\nI am able to query the same database context with other queries using the same procedure and it returns integer values without any issue.\n\nWhat can be the issue here? Please let me know if more information is required.\n\nSample select statement:\n\nSELECT \n convert(DATE, getdate()) AS DPRDate\n ,substring(label, 0, charindex('-', label)) AS Farm\n ,substring(label, charindex('-', label) + 1, len(label)) AS House\n ,'Line 01' AS [LineNo]\n ,0 AS [Live BC]\n ,d.TBC AS [Net BC]\n ,b.noDoas AS [Number of DOAs]\n ,c.ROA AS [Number of ROAs]\n ,d.TBW AS [DBW]\n ,0 AS [LBW]\n ,0 AS [DOA Weight]\n ,0 AS [ROA Weight]\nFROM \n <multiple tables>\n\n\nThank you in advance!" ]
[ "c#", "asp.net-mvc", "entity-framework", "sql-server-2008" ]
[ "How to setup security rules for a Flutter app that uses Cloud Firestore?", "I am creating a Flutter mobile app and want to use Cloud Firestore to store some data that the clients should access. So far, there is no user-specific data, so I don't want my users to have to login in the app. What security rules do I need to specify to allow clients to read data, but deny public access (from \"outside\" of the app)?\n\nThese are the security rules I have setup so far.\n\nservice cloud.firestore {\n match /databases/{database}/documents {\n match /{document=**} {\n allow write: if false;\n allow read: if request.auth.uid != null;\n }\n }\n}\n\n\nUnder Authentication --> Sign-in method, I have enabled anonymous authentication. But I'm not sure if the security rules are correct and what Dart code I need in the client to get the desired behavior (no need for client to specify credentials, but protection of my data from access outside of the app)." ]
[ "firebase", "flutter", "google-cloud-firestore", "firebase-security" ]
[ "how to catch event from a custom component", "I can catch event in a custom component using processKeyEvent method like this way. \n\nclass CustomComp extends JPanel\n{\n @Override\n public void processKeyEvent(final KeyEvent event)\n {\n if (event.getKeyCode() == KeyEvent.VK_DOWN)\n {\n //do somthing here\n }\n }\n}\n\n\nis there any alternative ways to do that?" ]
[ "java", "swing", "events", "custom-component" ]
[ "Batch command job works in master but not in slave Jenkins", "I have created free style project in jenkins to install msi installer. Free style project has\n\n\nParameterized job with string as parameter.\nRestrict where this project can be run is enabled and selected the Label\nSelected 'Executed windows batch command' in build step\n\n\nBatch command\n\n@ECHO OFF\n\nIF NOT EXIST \"C:\\Build\\Sample_%buidVersion%.msi\" (\necho \"The specified build does not exist in path\"\nEXIT /B 1\n) ELSE (\necho \"Installation of build\" %buidVersion% \"is started\"\nSTART \"\" /WAIT msiexec.exe /i \"C:\\\\Build\\\\Sample_%buidVersion%.msi\" /L*V \"C:\\package.log\" ADDSOURCE=ALL /qn\n)\n\nIF %errorlevel% NEQ 0 (\necho \"Error in installation, Please check C:\\package.log for more details\"\n) ELSE (\necho \"The build\" %buidVersion% \"installation is successful\"\n)\nEXIT\n\n\nWhen i execute this in master without applying 'Restrict where this project can be run is enabled and selected the Label' this option the job is successful by running in master but on enabling this and executing it in the slave says error as, \n\n\n \"The specified build does not exist in path.\" \n Build step 'Execute Windows batch command' marked build as failure" ]
[ "jenkins" ]
[ "Five square elements inside a variable-size container", "I have a variable-sized container (the dimensions are a percentage of the viewport size)\nInside it, I want to place five perfectly-square elements without resizing the container. As the aspect ratio of the container almost never will be 5:1, there will be some space around the elements.\nFor the case where the aspect ratio is greater than 5:1, the extra space will be at the sides of the elements:\n\n(The elements are the blue squares, the container is in cyan. I have two of the containers in this page.)\nFor this, the container is a Flexbox, with the elements containing a single 1x1 transparent image with a height of 100%, and the rest of the content as an absolute element in order to not resize the elements.\n\nFor the case where the aspect ratio is less than 5:1, the extra space will be on top and on the bottom of the elements:\n\n(Same as before)\nFor this, the container is still a flexbox, but the image has display: none, the width of each element is set to 100% and each element as a ::before with padding-bottom: 100%\n\nThis works for the two separate cases, but not to swap between them. Currently I have a media query that swaps between the two solutions at some precalculated screen aspect ratio, but this does not work after adding some paddings to the page.\nIs there a better way of having five square elements, that will just occupy whatever space is available without deforming the container?" ]
[ "css", "sass" ]
[ "How to find out if some file is available in root directory?", "Could anybody post here some code how can I find out if some file is available for example in this directory: /sys/class\n\nI solved it with this code:\n\nFile file = new File(\"/path/myfile\");\nif(file.exists()){\n//your code here\n}\nelse{\n//your code here\n}" ]
[ "android", "file", "directory", "find", "root" ]
[ "How can I use EF to add multiple child entities to an object when the child has an identity key?", "We are using EF5 and SQL Server 2012 the following two classes:\n\npublic class Question\n{\n public Question()\n {\n this.Answers = new List<Answer>();\n }\n public int QuestionId { get; set; }\n public string Title { get; set; }\n public virtual ICollection<Answer> Answers { get; set; }\n\n}\npublic class Answer\n{\n public int AnswerId { get; set; }\n public string Text { get; set; }\n public int QuestionId { get; set; }\n public virtual Question Question { get; set; }\n}\n\n\nMapping is as follows:\n\npublic class AnswerMap : EntityTypeConfiguration<Answer>\n{\n public AnswerMap()\n {\n // Primary Key\n this.HasKey(t => t.AnswerId);\n\n // Identity\n this.Property(t => t.AnswerId)\n .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);\n\n\nDatabase DDL\n\nCREATE TABLE Answer (\n [AnswerId] INT IDENTITY (1, 1) NOT NULL,\n [QuestionId] INT NOT NULL,\n [Text] NVARCHAR(1000),\n CONSTRAINT [PK_Answer] PRIMARY KEY CLUSTERED ([AnswerId] ASC)\n)\";\n\n\nHere are the results of what I have tried:\n\nThis works for one child:\n\nvar a = new Answer{\n Text = \"AA\",\n QuestionId = 14\n};\nquestion.Answers.Add(a);\n_uow.Questions.Update(question);\n_uow.Commit();\n\n\nThis does not work for more than one child:\n\nError: An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key.\n\nvar a = new Answer{\n AnswerId = 0,\n Text = \"AAA\",\n QuestionId = 14\n};\nvar b = new Answer {\n AnswerId = 0,\n Text = \"BBB\",\n QuestionId = 14\n};\nquestion.Answers.Add(a);\nquestion.Answers.Add(b);\n_uow.Questions.Update(question);\n_uow.Commit();\n\n\nThis does not work for more than one child:\n\nIt creates AnswerID's 1000 and 1001 but I want new Id's to be created by the database.\n\nvar a = new Answer{\n AnswerId = 1000,\n Text = \"AAA\",\n QuestionId = 14\n};\nvar b = new Answer {\n AnswerId = 1001,\n Text = \"BBB\",\n QuestionId = 14\n};\nquestion.Answers.Add(a);\nquestion.Answers.Add(b);\n_uow.Questions.Update(question);\n_uow.Commit();\n\n\nDoes not work: \n\nCompiler error. Can't convert null to int\n\nvar a = new Answer{\n AnswerId = null,\n Text = \"AAA\",\n QuestionId = 14 \n};\nvar b = new Answer\n{\n AnswerId = null,\n Text = \"BBB\",\n QuestionId = 14\n};\nquestion.Answers.Add(a);\nquestion.Answers.Add(b);\n_uow.Questions.Update(question);\n_uow.Commit();\n\n\nDoesn't work: \n\nObjectStateManager cannot track multiple objects with the same key.\n\nvar a = new Answer{\n Text = \"AAA\",\n QuestionId = 14\n};\nvar b = new Answer\n{\n Text = \"BBB\",\n QuestionId = 14\n};\nquestion.Answers.Add(a);\nquestion.Answers.Add(b);\n_uow.Questions.Update(question);\n_uow.Commit();\n\n\nIn my application I have one or more new Answer objects generated on the client and then these are sent to the server. Above I am simulating what will happen without adding the client into the question. Note that the adding of all Answers to the Question object is done on the client and then comes over in a JSON string to the server. It is then deserialized to a Question Object like this:\n\npublic HttpResponseMessage PutQuestion(int id, Question question) {\n _uow.Questions.Update(question);\n _uow.Commit();\n\n\nI want each Answer objects to be created with a new identity ID, for these to be added to the Question object and for the Question object to be returned back in the normal way.\n\nI don't know how this can be done. All my simple tests so far don't work. Please note this is a variation on an earlier question by our group member which was less clear and which I am trying to close. This question is I hope more clear.\n\nNotes:\n\nHere is the way update is coded:\n\npublic virtual void Update(T entity)\n{\n DbEntityEntry dbEntityEntry = DbContext.Entry(entity);\n if (dbEntityEntry.State == EntityState.Detached)\n {\n DbSet.Attach(entity);\n } \n dbEntityEntry.State = EntityState.Modified;\n}" ]
[ "c#", "sql-server", "asp.net-mvc", "entity-framework", "entity-framework-5" ]
[ "Bad practice to read SharedPreferences in a while loop?", "Is it considered bad practice to read from SharedPreferences in a while loop? Is the data always read from internal/external storage, or is it cached in memory?\n\nI'm doing this because one of the threads in my applications needs to know if a change has been made since the last iteration." ]
[ "android", "performance", "while-loop", "sharedpreferences" ]
[ "receive multiple responses in javascript with one request", "How can I receive multiple responses from a server using javascript.\n\nI have a requirement where a request is posted one time with the data and number of iterations and at server side the request is processed for the number of iterations. On completion of each iteration the server sends back the response. So for one request and 10 iterations my java script need to receive the 10 responses and show it on the web page. Is there any way that I can handle this using javascript. I cannot use any other technology.\n\nRight now I am using the following way\n\n function showResponse(){\n xmlHttp = GetXmlHttpObject();\n var dataString = document.getElementById(\"request-parameters\").value;\n var iterations = document.getElementById(\"iterations\").value;\n if(xmlHttp==null){\n alert(\"your browser does not support AJAX!\");\n }\n var url = \"http://localhost:8080/servlet/requestServlet\";\n\n xmlHttp.onreadystatechange=stateChanged;\n xmlHttp.open(\"POST\",url,true);\n xmlHttp.send(dataString);\n}\n\nfunction GetXmlHttpObject(){\n var xmlHttp=null;\n try{\n //Firefox, Opera, Safari\n xmlHttp=new XMLHttpRequest();\n }catch(e){\n //IE\n try{\n xmlHttp=new ActiveXObject(\"Msxml2.XMLHTTP\");\n }catch(e){\n xmlHttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n }\n }\n return xmlHttp;\n}\n\nfunction stateChanged(){\n if(xmlHttp.readyState==4){\n\n if(xmlHttp.status == 200){\n var resp = xmlHttp.responseText;\n var responseDiv = document.getElementById(\"response\");\n responseDiv.innerHTML=responseDiv.innerHTML+resp1[1];\n\n }\n }\n}\n\n\nI cannot modify this approach. Is it possible to get it done with XmlHttp object." ]
[ "javascript", "java", "websocket" ]
[ "random stack level too deep (SystemStackError)", "I have been running into a strange gremlin of sorts in my code as of late. Randomly it will dump a \"stack level too deep (SystemStackError)\" error on a piece of code that has previous, sometimes moments before, been working. I have read through the similar threads here at SO involving stack level, but cannot seem to find my problem. There is a recursion happening somewhere but it doesn't seem to be consistent.\n\nThe the two most common error points:\n\nstack level too deep (SystemStackError)\n ./features/step_definitions/login.rb:40:in `/^I enter username \"([^\"]*)\"$/'\n features/01_login.feature:30:in `When I enter username \"John\"'\n\n\n\nstack level too deep (SystemStackError)\n ./features/step_definitions/login.rb:23:in `/^I press select env$/'\n features/01_login.feature:26:in `Then I press select env'\n\n\nRunning my test the first error would pop up with the username, having only moments before completed this test successfully. Running my test again after a reset would bring up the second error which is even more bizarre since the test needs to run THROUGH this point to even get to the username which we reached in the first run. This order is not consistent. Sometimes it will just error out over one or another piece making it difficult to track down.\n\nThe code for the the two errors in question.\n\nWhen (/^I enter username \"([^\"]*)\"$/) do | username |\n enter_text \"UITextFieldLabel text:'Username'\", \"John\"\n end\n\nThen (/^I press select env$/) do\n touch \"label text:'Select Env'\"\n end" ]
[ "ios", "cucumber", "calabash", "stack-level" ]
[ "Ruby on Rails Update field of all users", "I'm having a bit of trouble and I'm not sure if it's even possible to do what I want.\n\nI have a user model with a field called points. I also have a matches model.\n\nI've been trying to use my matches_controller to update the points field of every user when a match gets updated (by a site admin). The goal is to add points if the user selected the correct score. \n\nI'm not sure if I'm able to do this. I'm wondering am I incorrect trying to access the user model from the matches_controller? Because I want to update all fields when a match score is updated, I need to do it from the matches_controller\n\nI've been going around in circles trying to solve this. Am I approaching it incorrectly? \n\nThanks for reading and hopefully helping.\n\nHere's the relevant code\n\n\n matches_controller.rb\n\n\n def update \n respond_to do |format|\n if @match.update(match_params)\n format.html { redirect_to @match, notice: 'Match was successfully updated.' }\n format.json { render :show, status: :ok, location: @match }\n else\n format.html { render :edit }\n format.json { render json: @match.errors, status: :unprocessable_entity }\n end\n end\n\n MatchPick.where(:matchID => params[:id]).update_all(result: match_params[:result], closed: match_params[:played], points: 0)\n MatchPick.where(:matchID => params[:id], :userPick => match_params[:result]).update_all(points: 3)\n update_user_points\n end\n\n def update_user_points\n @users = User.all\n @users.each do |user| \n user.points = 4\n puts params\n end\n end" ]
[ "ruby-on-rails", "ruby" ]
[ "One page item renderer magento", "I am trying to change template for item renderer on checkout onepage. Here is part from checkout.xml where this renderer is set.\n\n <block type=\"checkout/onepage_review_info\" name=\"root\" output=\"toHtml\" template=\"checkout/onepage/review/info.phtml\">\n <action method=\"addItemRender\"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>\n <action method=\"addItemRender\"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>\n <action method=\"addItemRender\"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>\n <block type=\"checkout/cart_totals\" name=\"checkout.onepage.review.info.totals\" as=\"totals\" template=\"checkout/onepage/review/totals.phtml\"/>\n <block type=\"core/text_list\" name=\"checkout.onepage.review.info.items.before\" as=\"items_before\" translate=\"label\">\n <label>Items Before</label>\n </block>\n <block type=\"core/text_list\" name=\"checkout.onepage.review.info.items.after\" as=\"items_after\" translate=\"label\">\n <label>Items After</label>\n </block>\n <block type=\"checkout/agreements\" name=\"checkout.onepage.agreements\" as=\"agreements\" template=\"checkout/onepage/agreements.phtml\"/>\n <block type=\"core/template\" name=\"checkout.onepage.review.button\" as=\"button\" template=\"checkout/onepage/review/button.phtml\"/>\n </block>\n\n\nI want to change it for configurable products. I am not sure which solution is the best." ]
[ "php", "magento" ]
[ "neural net model for finding feature relationship to output", "I was trying to create a simple neural net model for finding the relationship for features to output. For example, I have feature sets {x1,x2... ,xn} => y. I am expecting from neural-net is to adjust the weight and relationship across features to form output y.\n\nFor my tests, I used a simple feature set as {x1, x2, y} => y. Here I expected my model should be able to easily find weight for x1 and x2 as 0 with minimal training and find 100% accuracy easily. In reality my feature relationship would be more complicated. \n\nHowever, my model is failing to get any reasonable accuracy. I tried with about 1000 samples and 300 epoch. \n\nI tried multiple simple models built with Keras including 4-Dense layers with 100 hidden layers and LSTM models. \n\nIs my expectation reasonable here. What is the best model for achieving this? Any help is appreciated. Let me know if any more details required. \n\nhere is one simple model I was testing with:\n\n # Init Keras\n self.regressor = Sequential()\n\n self.regressor.add(Dense(units = 100, init='uniform', activation='relu', input_shape = X_shape))\n# self.regressor.add(Dropout(0.2))\n\n self.regressor.add(Dense(units = 100, activation='relu'))\n# self.regressor.add(Dropout(0.2))\n\n self.regressor.add(Dense(units = 100, activation='relu'))\n# self.regressor.add(Dropout(0.2))\n\n self.regressor.add(Dense(units = 100, activation='relu'))\n self.regressor.add(Dropout(0.2))\n\n self.regressor.add(Flatten())\n\n self.regressor.add(Dense(units = 1, activation='sigmoid'))\n# self.regressor.add(Dense(units = 1, activation=\"tanh\"))\n# self.regressor.add(Dense(units = 1, activation=\"softmax\"))\n\n\n self.regressor.compile(optimizer = 'adam', loss = 'mean_squared_error', metrics=['accuracy'])" ]
[ "python", "tensorflow", "keras", "neural-network", "lstm" ]
[ "What CLR do when compare T with null, and T is a struct?", "private static void SaveOrRemove<T>(string key, T value)\n{\n if (value == null)\n {\n Console.WriteLine(\"Remove: \" + key);\n }\n\n //...\n}\n\n\nIf I call passing 0 to value: SaveOrRemove(\"MyKey\", 0), the condition value == null is false, then CLR dont make a value == default(T). What really happens?" ]
[ "c#", "generics", "clr" ]
[ "How to emulate iOS style dropdown menus with html, css, javascript/jquery?", "The lower portion of that image contains the element I'm seeking to emulate. My job is to recreate a native iOS app as a multiplatform mobile webapp with PhoneGap, and the supervisor wants it to look EXACTLY like the old version. So I need to make an ordinary html dropdown menu appear as that lottery-machine style rolling cylinder of options. Anyone know a trick to do this?" ]
[ "jquery", "css", "web-applications" ]
[ "How to apply ifelse function across multiple columns and create new columns in R", "I would like to apply an ifelse function across multiple columns of my dataset and create new "rescored" columns. Here is a sample dataset:\ndata = data.frame(year = "2021",\n month = sample(x = c(1:12), size = 10, replace = TRUE),\n C1 = sample(x = c('Off', 'Yes'), size = 10, replace = TRUE),\n C2 = sample(x = c('Off', 'Yes'), size = 10, replace = TRUE),\n C3 = sample(x = c('Off', 'Yes'), size = 10, replace = TRUE),\n C4 = sample(x = c('Off', 'Yes'), size = 10, replace = TRUE),\n C5 = sample(x = c('Off', 'Yes'), size = 10, replace = TRUE),\n C6 = sample(x = c('Off', 'Yes'), size = 10, replace = TRUE),\n C7 = sample(x = c('Off', 'Yes'), size = 10, replace = TRUE),\n C8 = sample(x = c('Off', 'Yes'), size = 10, replace = TRUE),\n C9 = sample(x = c('Off', 'Yes'), size = 10, replace = TRUE),\n C10 = sample(x = c('Off', 'Yes'), size = 10, replace = TRUE))\n\nI would like to apply a function like this across all rows that begin with C:\nrescored = data %>%\n mutate(T1 = ifelse(C1 == "Off", 1,\n ifelse(C1 == "Yes", 0, NA)))\n\nMy real dataset has 50 or more rows that need this function applied. Is there a simple way to do this? I've tried using variations on "across" in dplyr like below but haven't been successful. I'm sure there is also an "apply" option.\nrescored = data %>%\n mutate(across(C1:C50, ifelse(~ .x == "Off", 1,\n ifelse(~.x == "Yes", 0, NA))))" ]
[ "r", "function", "if-statement", "dplyr", "across" ]
[ "How to load AngularJS files with appended scripts? (CSP strict-dynamic requirement)", "I'm hosting AngularJS locally. If I load the JS files this way before the closing body tag, it works:\n\n<script src=\"javascript/angular.min.js\"></script>\n<script src=\"javascript/angular.min.js.map\" type=\"application/json\"></script>\n<script src=\"javascript/angular-route.min.js\"></script>\n<script src=\"javascript/angular-route.min.js.map\" type=\"application/json\"></script>\n\n\nIn order to allow for the new 'strict-dynamic' CSP, I need to load all of my scripts within a single sourceless script (i.e., no 'src' is allowed for script elements on a page; the script itself must be contained within the script tags). For all scripts except for AngularJS, my script loading routine works without issue. If I try to load it this way, it fails with error message in the console (\"Cannot read property 'module' of undefined,\" etc.):\n\n<script>\nwindow.onload = function () {\n var loadScript = function (url, type) {\n var script = document.createElement('script');\n script.src = url;\n if (type === 'application/json') {\n script.type = type;\n }\n document.body.appendChild(script);\n };\n\n loadScript('javascript/angular.min.js', '');\n loadScript('javascript/angular.min.js.map', 'application/json');\n loadScript('javascript/angular-route.min.js', '');\n loadScript('javascript/angular-route.min.js.map', 'application/json');\n};\n</script>\n\n\nThis also fails if the routine is not restricted to the window.onload event:\n\n<script>\nvar loadScript = function (url, type) {\n var script = document.createElement('script');\n script.src = url;\n if (type === 'application/json') {\n script.type = type;\n }\n document.body.appendChild(script);\n};\n\nloadScript('javascript/angular.min.js', '');\nloadScript('javascript/angular.min.js.map', 'application/json');\nloadScript('javascript/angular-route.min.js', '');\nloadScript('javascript/angular-route.min.js.map', 'application/json');\n</script>\n\n\n...and it makes no difference if I grab the files from local hosting or from Google's Ajax CDN.\n\nAny clue how to solve this? With the 'strict-dynamic' CSP, I have no choice but to load the AngularJS framework files using a technique like the ones above." ]
[ "javascript", "angularjs", "loading", "content-security-policy" ]
[ "I am having conflict issues between Google Plus and Youtube Data API?", "So I have a site I'm working on which includes searching for videos using Google's YouTube Data API v3 (I am using the javascript library). Everything works fine prior to including new code on the same page importing Google+'s code to use it's share functionality. Now whenever I load the page, neither the YouTube video searches nor sharing via Google Plus seems to work. Below is the code for YouTube's Data API client load and search:\n\nfunction initializeGapi() {\n gapi.client.setApiKey(API_KEY); // client API_KEY variable for client\n gapi.client.load('youtube', 'v3', \n function() { \n console.log('Youtube API loaded.');\n searchYoutube(''); // searches youtube\n }\n );\n}\n\n\nThis HTML tag is included in the header of the page:\n\n<script src=\"https://apis.google.com/js/client.js?onload=OnLoadCallback\"></script>\n\n\nSo everything was working well. Now the problem is when I introduce the code below for Google Plus for it's share button feature:\n\n<div id=\"googlepluscta\"> // share button\n <button\n class=\"g-interactivepost\"\n data-contenturl=\"https://plus.google.com/pages/\"\n data-contentdeeplinkid=\"/pages\"\n data-clientid=\"142489821045.apps.googleusercontent.com\"\n data-cookiepolicy=\"single_host_origin\"\n data-prefilltext=\"Engage your users today, create a Google+ page for your business.\"\n data-calltoactionlabel=\"CREATE\"\n data-calltoactionurl=\"http://plus.google.com/pages/create\"\n data-calltoactiondeeplinkid=\"/pages/create\">\n Tell your friends\n </button>\n</div>\n\n\nAlso, right before the tag the following is included to load the Google Plus client:\n\n<script type=\"text/javascript\">\n (function() {\n var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;\n po.src = 'https://apis.google.com/js/client:plusone.js';\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);\n })();\n</script>\n\n\nI've include screenshot links as well in case they may be helpful:" ]
[ "javascript", "youtube", "google-plus" ]
[ "How to get authorization to UCWA and Skype Web SDK?", "I have a Skype for Business account call [email protected] and I'm trying to get authorization. \n\n\nMy first request to lyncdiscover service\n\n\nGET https://lyncdiscover.shockw4ves.onmicrosoft.com/\n\n\nAnswer:\n\n{\n \"_links\": {\n \"self\": {\n \"href\": \"https://webdir1e.online.lync.com/Autodiscover/AutodiscoverService.svc/root?originalDomain=shockw4ves.onmicrosoft.com\"\n },\n \"user\": {\n \"href\": \"https://webdir1e.online.lync.com/Autodiscover/AutodiscoverService.svc/root/oauth/user?originalDomain=shockw4ves.onmicrosoft.com\"\n },\n \"xframe\": {\n \"href\": \"https://webdir1e.online.lync.com/Autodiscover/XFrame/XFrame.html\"\n }\n }\n}\n\n\n\n\n\nThen i take a user link and do next request\n\n\nGET https://webdir1e.online.lync.com/Autodiscover/AutodiscoverService.svc/root/oauth/user?originalDomain=shockw4ves.onmicrosoft.com\n\n\nAnswer:\n401 Unauthorized\n\nCache-Control → no-cache\nContent-Length → 1293\nContent-Type → text/html\nDate → Wed, 30 Sep 2015 11:16:37 GMT\nWWW-Authenticate → \n Bearer trusted_issuers=\"00000001-0000-0000-c000-000000000000@*\", \n client_id=\"00000004-0000-0ff1-ce00-000000000000\", \n authorization_uri=\"https://login.windows.net/common/oauth2/authorize\", \n MsRtcOAuth \n href=\"https://webdir1e.online.lync.com/WebTicket/oauthtoken\",\n grant_type=\"urn:microsoft.rtc:passive,urn:microsoft.rtc:anonmeeting\"\nX-Content-Type-Options → nosniff\nX-MS-Correlation-Id → 2147499790\nX-MS-Server-Fqdn → AMS1E01EDG08.infra.lync.com\nclient-request-id → ea4f5098-732f-4feb-ae34-cf6ff7fc1a73\n\n\n\n\n\nThis response contains my credentials data. I take authorization uri and do my next request\n\n\nPOST https://login.windows.net/common/oauth2/authorize\n\nbody of x-www-form-urlencoded:\n\ngrant_type=password\[email protected]\npassword=xxxxxxxxxx\nclient_id=00000004-0000-0ff1-ce00-000000000000\n\nAnswer:\n\n<html>\n <head>\n <title>Continue</title>\n </head>\n <body>\n <form method=\"POST\" name=\"hiddenform\" action=\"https://login.microsoftonline.com/common/oauth2/authorize\">\n <input type=\"hidden\" name=\"grant_type\" value=\"password\" />\n <input type=\"hidden\" name=\"username\" value=\"[email protected]\" />\n <input type=\"hidden\" name=\"password\" value=\"xxxxxxxxx\" />\n <input type=\"hidden\" name=\"client_id\" value=\"00000004-0000-0ff1-ce00-000000000000\" />\n <noscript>\n <p>Script is disabled. Click Submit to continue</p>\n <input type=\"submit\" value=\"Submit\" />\n </noscript>\n </form>\n <script language=\"javascript\">window.setTimeout('document.forms[0].submit()', 0);</script>\n </body>\n</html>\n\n\n\n\n\nCopy this html form and run in browser. Its redirect to https://login.microsoftonline.com/common/oauth2/authorize and open page with error text:\n\n\nSign In\nSorry, but we’re having trouble signing you in.\nWe received a bad request.\n\nAdditional technical information:\nCorrelation ID: 0669eee8-0dc5-4aa1-a94d-41e5bbc2f25d\nTimestamp: 2015-09-30 14:06:30Z\nAADSTS50011: No reply address is registered for the application.\n\n\n\n\nWhat i do wrong? Also i test with: \n\ngrant_type=password \ngrant_type=\"urn:microsoft.rtc:passive,urn:microsoft.rtc:anonmeeting\" \ngrant_type=\"urn:microsoft.rtc:windows,urn:microsoft.rtc:anonmeeting,password\"\n\n\nWhat is error No reply address is registered for the application ?" ]
[ "javascript", "http", "skype-for-business", "skypedeveloper", "ucwa" ]
[ "Keeping a variable alive across multiple function calls in rust", "I am trying to memoize a recursive collatz sequence function in rust, however I need the hashmap of memoized values to keep its contents across separate function calls. Is there an elegant way to do this in rust, or do I have to declare the hashmap in main and pass it to the function each time? I believe the hashmap is being redeclared as an empty map each time I call the function. Here is my code:\n\nfn collatz(n: int) -> int {\n let mut map = HashMap::<int, int>::new();\n if map.contains_key(&n) {return *map.get(&n);}\n if n == 1 { return 0; }\n map.insert(n, \n match n % 2 {\n 0 => { 1 + collatz(n/2) }\n _ => { 1 + collatz(n*3+1) }\n }\n );\n return *map.get(&n);\n}\n\n\nOn a side note, why do I need to add all of the &'s and *'s when I am inserting and pulling items out of the HashMap? I just did it because the compiler was complaining and adding them fixed it but I'm not sure why. Can't I just pass by value? Thanks." ]
[ "memoization", "rust", "collatz" ]
[ "Saving linked list internal iterator", "I have some ADT which is based on a linked list.\nMany of my functions use the following algorithm to find some particular list element:\n\ncurrentElement = listGetFirst(list)\nwhile (currentElement != neededElement)\n{\ncurrentElement = listGetNext(list);\n}\n\n\nNow i want to write 2 functions for saving internal iterator and restoring it back, like this:\n\nvoid listSaveIterator(List list, ListElement *iterator)\n{\n *iterator = listGetCurrent(list);\n}\n\nvoid listRestore(List list, ListElement iterator)\n{\n ListElement element = listGetFirst(list);\n while (element != NULL)\n {\n if (element == iterator)\n {\n return;\n }\n element = listGetNext(list);\n }\n}\n\n\nWill this work?\nIs there a better approach?" ]
[ "c", "linked-list" ]
[ "Run pgrouting 1.x and 2.x on same machine", "We want to run pgrouting 2.x on our test server. Additionally, we want existing applications still run on pgrouting 1.x.\nDoes anyone know, if it's possible installing and running them in parallel?\n\nCurrently, we run on Postgres 9.1.9 and PostGIS 2.0.1." ]
[ "postgis", "postgresql-9.1", "pgrouting" ]
[ "WinServer 2012 r2 + PHP(wamp64) PHPMailer error “Could not instantiate mail function”", "I tried all the steps which are prompted in win server 2012 r2 relates answer including its related answers and particular PHPMailer too.\n\nBut still, I'm running with the same issue. Additionally, have checked about port 25 is running no firewall issue here.\n\nIf anyone can help me, it's really appreciated.\n\nNOTE:\nWin server 2012 r2 relates answer\nPHPMailer answer\n\nserver fault answer\nThanks\n\nUPDATE\n\n//To test is via basic mail function\n/*\nmail(\"[email protected]\", \"Test Subject\", \"Test Message\");\n*/\n\n//To Test via PHPMailer \n\nuse PHPMailer\\PHPMailer\\PHPMailer;\nuse PHPMailer\\PHPMailer\\Exception;\n\nrequire 'vendor/phpmailer/phpmailer/src/Exception.php';\nrequire 'vendor/phpmailer/phpmailer/src/PHPMailer.php';\nrequire 'vendor/phpmailer/phpmailer/src/SMTP.php';\n\n//PHPMailer Object\n$mail = new PHPMailer;\n\n//From email address and name\n$mail->From = \"[email protected]\";\n$mail->FromName = \"Full Name\";\n\n//To address and name\n$mail->addAddress(\"[email protected]\"); //Tried $mail->addAddress(\"[email protected]\", \"test name\"); and third param too. \n\n//Send HTML or Plain Text email\n$mail->isHTML(true); //Tried with false too.\n\n$mail->Host = \"smtp.gmail.com\";\n$mail->Port = 587;\n$mail->SMTPDebug = 3;\n$mail->SMTPSecure = 'ssl';\n\n// optional\n// used only when SMTP requires authentication \n$mail->SMTPAuth = true;\n$mail->Username = SMTP_EMAIL_HERE;\n$mail->Password = SMTP_PASS_HERE;\n\n$mail->Subject = \"Subject Text\";\n$mail->Body = \"<i>Mail body in HTML</i>\";\n$mail->AltBody = \"This is the plain text version of the email content\";\nif(!$mail->send()) \n{\n echo \"Mailer Error: \" . $mail->ErrorInfo;\n} \nelse \n{\n echo \"Message has been sent successfully\";\n}\n\n\nEven, I tried my SMTP credential via online SMTP Tool and it's working fine but above code isn't.\n\nNOTE: I verified about PHP/Apache modules availability and it's there so no issue about the module." ]
[ "phpmailer", "windows-server-2012-r2", "php-7.2", "wamp64" ]
[ "How to view local files in web browser by displaying and creating a link to local files stored in your computer in your webApp?", "I have created a webapp using JSP,Html and Javascript which currently runs on my localhost using apache webserver. I want to display the files and folders and of a directory in local computer. I also want to create a download link or view link of those so that when anyone click on it it will be viewed in new tab or become downloadable as it happens in any ftp server. I know similar type of question has\nbeen asked but none of them worked for me.\nTo create the download link I used\n\n<a href=\"D:/mylocaldrive/a.png\" download=\"a.png\">Download</a>\n\n\nthis does not work as it is not in my webapp path and download attribute also does not work in internet explorer." ]
[ "javascript", "html", "jsp" ]
[ "Populate a class from a Dictionary", "I have a dictionary collection of more than 100 fields and values. Is there a way to populate a gigantic class with a 100 fields using this collection?\n\nThe key in this dictionary corresponds to the property name of my class and the value would be the Value of the Property for the class.\n\nDictionary<string, object> myDictionary = new Dictionary<string, object>();\nmyDictionary.Add(\"MyProperty1\", \"Hello World\");\nmyDictionary.Add(\"MyProperty2\", DateTime.Now);\nmyDictionary.Add(\"MyProperty3\", true);\n\n\nPopulates the properties of the following class.\n\npublic class MyClass\n{\n public string MyProperty1 {get;set;}\n public DateTime MyProperty2 {get;set;}\n public bool MyProperty3 {get;set;}\n}" ]
[ "c#", ".net", "performance", "reflection" ]
[ "C# how to reduce garbage collection", "I am writing a simulation which has an update loop that's called every frame. In the update function, I have millions of objects to update, so it looks like this.\n\npublic void Update(float deltaTime)\n{\n Time += deltaTime;\n foreach (SimulationObject obj in objects.ToArray())\n obj.Update(deltaTime);\n}\n\nwhere objects is\nList<SimulationObject> objects = new List<SimulationObject>();\nand is populated at program initialization time.\n\n\nYou can probably see objects.ToArray() makes a copy of this huge list every frame then the copy gets garbage-collected. This causes huge performance issue for me. For a run of about 2 minutes, the garbage collected reaches about 2G. Since the list of this objects is being asynchronously modified in the background by some third-party library, it seems I can't remove ToArray().\n\nI am wondering if there's a good way to reduce garbage collection, either avoid copying or reuse the allocated space?\n\nI am new to C# and tried searching for answers, but was not able to. If this is a duplicated post, I apologize." ]
[ "c#", "performance", "garbage-collection" ]
[ "modal window pop up leaving the page", "Hey guys I'm using bootstrap modal class for popping up window when a user leaves the page. \n\nAnd what I need is to pop up the window using javascript not the button.\n\nSo it does not work and I'm stuck with it, any help is appreciated \n\nModal Window\n\n<div class=\"modal fade\" data-toggle=\"draftModal\" data-target=\"#draftModal\">\n <div class=\"modal-dialog\">\n <div class=\"modal-content\">\n <div class=\"modal-body\">\n <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n <div>\n <p>You are about to leave the deal. Would you like to save as a draft?</p>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>\n <button type=\"button\" class=\"btn btn-primary\">Save changes</button>\n </div>\n </div>\n </div>\n </div>\n</div>\n\n\nJS\n\n<script type=\"text/javascript\">\n$(document).ready(function(){\n window.onbeforeunload(function(event){\n event.preventDefault();\n $('.modal').modal('show');\n });\n});" ]
[ "javascript", "jquery", "twitter-bootstrap" ]
[ "Multiple ErrorDocuments in .HTAccess", "I have a custom error Document \"/error.php?e=ERRORCODE\" and in my .htaccess I know I need to do:\n\nErrorDocument 400 /error.php?e=400\n\n\nBut so all error codes redirect to my custom error page, I have done this:\n\nErrorDocument 400 /error.php?e=400\nErrorDocument 401 /error.php?e=401\nErrorDocument 402 /error.php?e=402\nErrorDocument 403 /error.php?e=403\nErrorDocument 404 /error.php?e=404\nErrorDocument 405 /error.php?e=405\nErrorDocument 406 /error.php?e=406\nErrorDocument 407 /error.php?e=407\nErrorDocument 408 /error.php?e=408\nErrorDocument 409 /error.php?e=409\nErrorDocument 410 /error.php?e=410\nErrorDocument 411 /error.php?e=411\nErrorDocument 412 /error.php?e=412\nErrorDocument 413 /error.php?e=413\nErrorDocument 414 /error.php?e=414\nErrorDocument 415 /error.php?e=415\nErrorDocument 416 /error.php?e=416\nErrorDocument 417 /error.php?e=417\n\nErrorDocument 422 /error.php?e=422\nErrorDocument 423 /error.php?e=423\nErrorDocument 424 /error.php?e=424\n\nErrorDocument 500 /error.php?e=500\nErrorDocument 501 /error.php?e=501\nErrorDocument 502 /error.php?e=502\nErrorDocument 503 /error.php?e=503\nErrorDocument 504 /error.php?e=504\nErrorDocument 505 /error.php?e=505\nErrorDocument 506 /error.php?e=506\nErrorDocument 507 /error.php?e=507\nErrorDocument 508 /error.php?e=508\nErrorDocument 509 /error.php?e=509\nErrorDocument 510 /error.php?e=510\n\n\nAnd I wanted to know if there was a way to compress all of the above into one line.\n\nThanks." ]
[ "apache", ".htaccess", "errordocument" ]
[ "Credential for Release Signing SHA-1 on Google Sheets API not working", "I'm having problem with the credential made on Google API console for Sheets API using release signing SHA-1 from Play Store. I made 3 different credential for SHA-1 debug, release and release (that signed by Playstore). The debug and release credential works fine, but the credential using SHA-1 provided by Google Playstore return error 404 (it does not have access to the spreadsheet, I presume).\n\nNote that all the SHA-1 and package name are correct.\n\nI believe this has nothing to do with the code, but approval credential from Google.\n\n\nDoes Google have limitation on creating a credential (especially for OAuth 2.0)? I only made around 8 credentials/ client ID.\nDoes it took times for the credential to work? Because I just release the app on Playstore 3 days ago, the app is already live on Playstore tho.\n\n\nWhat should I do? I try to directly contact Google API support but couldn't find any link/ reference to contact them.\n\nThank you in advance for those whom willing to help." ]
[ "android", "google-sheets-api" ]
[ "Plotting count data in r", "I have counted crashes at intersections and am wondering how to plot this data in time series. The data was counted through the years of 2008 to 2018. the data is found at this link. Please, i am interested in the code and proper technique for plotting the data. \n\nhttps://www.kaggle.com/christiandoe/intersection-crash-data-between-years-20082018/download\n\nIn order to get the data into table format the melt command from shape2 is required: \n\nusing melt from reshape2:\n\n > attidtudeM=melt(df)\n\n > head(attidtudeM)\n\n variable value\n 1 F2008 0\n 2 F2008 1\n 3 F2008 1\n 4 F2008 2\n 5 F2008 0\n 6 F2008 1\n\n > table(attidtudeM)\n\nvariable 0 1 2 3 4 5 6 7\n F2008 235 38 11 3 0 0 0 0\n F2009 244 27 8 6 2 0 0 0\n F2010 237 9 31 3 2 2 3 0\n F2011 241 33 11 0 1 0 1 0\n F2012 246 31 8 1 1 0 0 0\n F2013 251 28 7 1 0 0 0 0\n F2014 265 16 5 0 0 1 0 0\n F2015 261 6 17 0 2 0 1 0\n F2016 263 17 5 0 1 0 0 1\n F2017 275 7 4 0 0 0 0 1\n\n\n\r\n\r\nF2008 F2009 F2010 F2011 F2012 F2013 F2014 F2015 F2016 F2017\r\n 1 1 1 \r\n1 2 1 1 2 1 \r\n1 1 2 \r\n2 1 2 \r\n \r\n1 1 \r\n 3 1 \r\n \r\n1 1 2 3 2 2 1 \r\n 3 1 \r\n 2 \r\n 1 \r\n \r\n \r\n1 1 4 1 1 2 2 2\r\n \r\n \r\n2 1 \r\n 2 1 1 1 1 2\r\n1 3 2 2 1 5 4 1 7\r\n \r\n \r\n 1 \r\n2 2 \r\n1 6 2 1 2 1 1 2\r\n1 2 1 \r\n 5 2 1 2 \r\n \r\n 2 1 1 \r\n \r\n 1 2 2 1 \r\n \r\n \r\n 2 2 \r\n1 \r\n 1 \r\n 1 \r\n1 0 \r\n \r\n \r\n 1\r\n 4" ]
[ "plot", "count" ]
[ "In Ember, why does action bubble to route from controller and not first to the parent controllers?", "In Ember, why does action bubble to route from controller? Should not it first bubble to the parent controller hierarchy and then to route?" ]
[ "ember.js" ]
[ "How to filter with a nested document based on multiple terms?", "I am trying to replicate this DSL query in NEST. Basically a structured filter that will return all of the products that have the color red.\n\n{\n \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"nested\": {\n \"path\": \"keywordFacets\",\n \"query\": {\n \"bool\": {\n \"filter\": [\n { \"term\": { \"keywordFacets.name\": \"color\" } },\n { \"term\": { \"keywordFacets.value\": \"Red\" } }\n ]\n }\n }\n }\n }\n ]\n }\n }\n}\n\n\nHere is the POCO with attribute mapping.\n\n[ElasticsearchType]\npublic class Product\n{\n [Keyword]\n public long ProductId { get; set; }\n\n [Nested]\n public List<KeywordFacet> KeywordFacets { get; set; }\n\n // other properties...\n}\n\n[ElasticsearchType]\npublic class KeywordFacet\n{\n [Keyword]\n public string Name { get; set; }\n [Keyword]\n public string Value { get; set; }\n}\n\n\nI can't figure out how to get the two terms inside the nested filter array. This is my failed attempt so far:\n\nvar searchRequest = new SearchDescriptor<Product>()\n .Query(q => q\n .Bool(b => b\n .Filter(bf => bf\n .Nested(nq => nq\n .Path(nqp => nqp.KeywordFacets)\n .Query(qq => qq\n .Bool(bb => bb\n .Filter(ff => ff\n .Term(t => t\n .Field(p => p.KeywordFacets.First().Name)\n .Value(\"color\")\n .Field(p2 => p2.KeywordFacets.First().Value).Value(\"Red\")))))))));\n\n\nHere is some sample data that is returned when I run the DSL query in Postman:\n\n{\n \"productId\": 183150,\n \"keywordFacets\": [\n {\n \"name\": \"color\",\n \"value\": \"Red\"\n },\n {\n \"name\": \"color\",\n \"value\": \"Blue\"\n },\n {\n \"name\": \"color\",\n \"value\": \"Grey\"\n }\n ]\n}" ]
[ "nest" ]
[ "Name error in python with nested function", "I m getting error in running nested function in my python interpreter\n\nimport MySQLdb\nimport serial\nimport time\nimport smtplib\n\n\nser=serial.Serial('/dev/ttyACM1',9600)\ndb=MySQLdb.connect(\"localhost\",\"root\",\"pass\",\"db\")\n\ncursor=db.cursor()\n\nwhile 1:\n print(\"Waiting ;;...\")\n print(\"\")\n print(\"collecting\")\n print(\"\")\n\n time.sleep(3)\n\n x=ser.readline()\n time.sleep(3)\n if x>700:\n send()\n print\"send mail\"\n\n print(\"inserting into Database\")\n sql=\"INSERT INTO vidit2(temp) VALUES(%s);\" %(x)\n cursor.execute(sql)\n db.commit()\n time.sleep(3)\n\n\n\ndef send():\n\n content=\"send\"\n\n mail=smtplib.SMTP(\"smtp.gmail.com\",587)\n\n mail.ehlo()\n\n mail.starttls()\n\n mail.login(\"emailid\",\"pass\")\n\n mail.sendmail(\"sender\",\"reciever\",content)\n\n mail.close()\n\n\nError:\npython temp.py \nWaiting ;;...\n\ncollecting\n\nTraceback (most recent call last):\n File \"temp.py\", line 24, in \n send()\nNameError: name 'send' is not defined\n\nPlease help.\nThanks in Advance" ]
[ "function", "python-3.x", "smtpclient" ]
[ "Communication between Python and VBA", "I try to design a programm in VBA (used within a simulation software) which is able to call Python for some calculations and receive the result to proceed. The VBA-Python call will happen many times.\nMy first idea is based on a text file communication, e.g. something like this:\nin VBA:\ndo something\n\nwrite text file 'calc_todo.txt' in specific directory\n\nwhile not exists 'calc_finished.txt':\n wait 1 second\n\nread 'calc_finished.txt'\n\ndelete'calc_finished.txt'\n\ndelete'calc_todo.txt'\n\ndo something\n\nwrite text file 'calc_todo.txt' in specific directory\n\n... repeat\n\n\n\nin Python:\ndo something\n\nwhile not exists 'calc_todo.txt':\n wait 1 second\n\nread 'calc_todo.txt'\n\ndo calculations based on 'calc_todo.txt'\n\nwrite 'calc_finished.txt'\n\ndelete'calc_todo.txt'\n\ndo something\n\nwhile not exists 'calc_todo.txt':\n wait 1 second\n\n... repeat\n\nI have done something similar in past and unfortunately there are a lot of things I do not like:\n\nfixed waiting time of e.g. 1 second might slow down performance\nif something breaks VBA and/or Python will get stuck in a while loop or run in an error\nto fix the second issue, error handling with initialisation can be implemented but last time it was a mess\n\nWhat would be a more professional way on how to handle such communication?" ]
[ "python", "vba", "communication" ]
[ "How to deploy a standalone CherryPy process?", "I'm currently preparing to deploy a stand-alone CherryPy app. While I could just hack together a boot script and shoehorn it into the system's startup sequence, I'd rather find a more elegant solution.\n\nWhat I need to do is:\n\n\nStart the app as a daemon during boot\nRestart it if it crashes\nMonitor CPU/memory usage\n\n\nI'm sure there must be an existing solution for this. Any suggestions?" ]
[ "python", "web-applications", "cherrypy" ]
[ "When will Install4J support JRE 12?", "Packaging my own JRE 12 causes the installer size to increase by 120 MB. Clearly this is not ideal." ]
[ "compression", "install4j" ]
[ "configure mvc.net application on facebook", "I have integrated facebook in my application mvc.net application. \nI have configured my apllication on face book\nwith the url : http://localhost:portnumber/Home/Test?Return=\"ok\"\n\nwhen i run the application then it opened pop up of facebook having two text boexs for user name and password with warning message:\n\"Given URL is not allowed by the Application configuration\" \n\nIn my application Test is the name of Action method of controller\n\nPlease suggest me how to handle this.\n\nThanks \n\nMunish" ]
[ "asp.net-mvc" ]
[ "SDL: draw a half-transparent rectangle", "I cannot figure out how to draw a half-transparent red rectangle onto the screen surface.\nHere's the code I have so far:\n\n#!/usr/bin/perl\n\nuse SDL;\nuse SDL::Video;\nuse SDL::Surface;\nuse SDL::Rect;\n\n# the size of the window box or the screen resolution if fullscreen\nmy $screen_width = 800;\nmy $screen_height = 600;\n\nSDL::init(SDL_INIT_VIDEO);\n\n# setting video mode\nmy $screen_surface = SDL::Video::set_video_mode($screen_width, $screen_height, 32, SDL_ANYFORMAT|SDL_SRCALPHA);\n\n# drawing something somewhere\nmy $mapped_color = SDL::Video::map_RGBA($screen_surface->format(), 255, 0, 0, 128); #should be half-transparent, I suppose?\n\nSDL::Video::fill_rect($screen_surface, \nSDL::Rect->new($screen_width / 4, $screen_height / 4, \n $screen_width / 2, $screen_height / 2), $mapped_color);\n\n# update an area on the screen so its visible\nSDL::Video::update_rect($screen_surface, 0, 0, $screen_width, $screen_height);\n\nsleep(5); # just to have time to see it\n\n\nIt results in the red opaque rectangle on the black background, which is not what I am trying to achieve." ]
[ "perl", "sdl", "alpha" ]
[ "Get the five closest addresses from String Array", "I have a String array in Android (Java) with 175 elements which contains addresses. Now I need to sort the five closest addresses and make it to a list, I have got it to work with one element and a Spinner. \n\nThis is my code: \n\nfor(String sa: stringarray) {\n addresses = geocoder.getFromLocationName(sa, maxInput);\n\n } \n\n\nwhat this does is that it run through the loop and replace every element. So if I then run \n\nAddress address = addresses.get(0);\n\n\nI will get the last element in the string array. \n\nIs there any way to store an element in like a Hashmap and compare that value to my position which I get from Googles API - getLastLocation in onConnected? \n\nBest regards \nAntiderive" ]
[ "java", "android", "geolocation", "arrays" ]
[ "Mongoose JS findOne always returns null", "I've been fighting with trying to get Mongoose to return data from my local MongoDB instance; I can run the same command in the MongoDB shell and I get results back. I have found a post on stackoverflow that talks about the exact problem I'm having here; I've followed the answers on this post but I still can't seem to get it working. I created a simple project to try and get something simple working and here's the code.\n\nvar mongoose = require('mongoose');\nvar Schema = mongoose.Schema;\n\nvar userSchema = new Schema({\n userId: Number,\n email: String,\n password: String,\n firstName: String,\n lastName: String,\n addresses: [\n {\n addressTypeId: Number,\n address: String,\n address2: String,\n city: String,\n state: String,\n zipCode: String\n }\n ],\n website: String,\n isEmailConfirmed: { type: Boolean, default: false },\n isActive: { type: Boolean, default: true },\n isLocked: { type: Boolean, default: false },\n roles: [{ roleName: String }],\n claims: [{ claimName: String, claimValue: String }]\n});\n\nvar db = mongoose.connect('mongodb://127.0.0.1:27017/personalweb');\nvar userModel = mongoose.model('user', userSchema);\n\nuserModel.findOne({ email: '[email protected]' }, function (error, user) {\n console.log(\"Error: \" + error);\n console.log(\"User: \" + user);\n});\n\n\nAnd here is the response of the 2 console.log statements:\n\nError: null\n\nUser: null\n\nWhen the connect method is called I see the connection being made to my Mongo instance but when the findOne command is issued nothing appears to happen. If I run the same command through the MongoDB shell I get the user record returned to me. Is there anything I'm doing wrong?\n\nThanks in advance." ]
[ "javascript", "node.js", "mongodb", "mongoose" ]
[ "Upload whole folder structure in Amazon s3 bucket using powershell", "I am in process to automate upload my static files to Amazon s3 bucket. My folder structure is bit complex as it contain lods of folders with sub folders and files. \n\nIs there any easy way to upload the parent folder to s3 bucket instead looping through all folder, create them of S3 bucket and then upload the files in folders? \n\nI want to do this though powershell." ]
[ "powershell", "amazon-s3" ]
[ "Try in to verify println or Log in kotlin and android using mockk", "Im trying to verify whether my code is printing in Kotlin or logging out the right Log in Android. With other function it is ok for me but for these kind of function can anyone show me how to do it.\n @Test\n fun mockTest() {\n println("hello")\n verify(exactly = 1){\n println("hello")\n }\n }\n\nThis is the error I have encountered.\nio.mockk.MockKException: Missing calls inside verify { ... } block.\n\n at io.mockk.impl.recording.states.VerifyingState.checkMissingCalls(VerifyingState.kt:52)\n at io.mockk.impl.recording.states.VerifyingState.recordingDone(VerifyingState.kt:21)\n at io.mockk.impl.recording.CommonCallRecorder.done(CommonCallRecorder.kt:48)\n at io.mockk.impl.eval.RecordedBlockEvaluator.record(RecordedBlockEvaluator.kt:60)\n at io.mockk.impl.eval.VerifyBlockEvaluator.verify(VerifyBlockEvaluator.kt:27)\n at io.mockk.MockKDsl.internalVerify(API.kt:118)\n at io.mockk.MockKKt.verify(MockK.kt:139)\n at io.mockk.MockKKt.verify$default(MockK.kt:136)\n at com.tictac.ExampleUnitTest.logExecutued(ExampleUnitTest.kt:28)\n at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n at java.lang.reflect.Method.invoke(Method.java:498)\n at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)\n at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)\n at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)\n at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)\n at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)\n at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)\n at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)\n at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)\n at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)\n at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)\n at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)\n at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)\n at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)\n at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)\n at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)\n at org.junit.runners.ParentRunner.run(ParentRunner.java:413)\n at org.junit.runner.JUnitCore.run(JUnitCore.java:137)\n at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)\n at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)\n at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)\n at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)" ]
[ "android", "unit-testing", "kotlin", "mockk" ]
[ "How can I find a value's location in a matrix in Julia?", "I was using find with a 3D matrix A like this:\n\njulia> find(A.==1)\n2-element Array{Int64,1}:\n1\n234\n4567\n\n\nJulia gives me the location as an index instead of as an array of indices. For example, it returns 234 instead of (1,2,1).\n\nI looked at this question, but my matrix is very large and has a shape of (360,360,360). I can't use the method suggested there.\n\nI tried to study its index pattern and transform it using a function that I coded:\n\nfunction cmf_p(matrix)\n for a=1:length(matrix);\n aa=matrix[a]\n rd_u_m=ceil(aa/(360^2))\n rd_d_m=floor(aa/(360^2)-1)\n rd_d_t=(aa-rd_d_m*360)/360^2 \n rd_d_p=aa-rd_d_m*360^2-floor(rd_d_t)*360\n println(rd_u_m);\n println(ceil(rd_d_t)*360);\n println(ceil(aa-rd_d_m*360^2-floor(rd_d_t)*360))\n end \nend\n\n\nBut it gives me the wrong result.\n\nHow can I use the index and transform it to the location I want?" ]
[ "arrays", "matrix", "julia" ]
[ "My do while loop repeats forever when the user inputs a wrong character", "My code for a main menu isn't functioning correctly. I cant find out why the do while loop repeats forever when the user inputs, a bool is set to true, and it works, but if the user inputs a wrong character, the loop continues forever. and displays "Invalid character. Please try again." and doesn't allow the user to input.\nvoid mainmenu() {\nbool wrong = false;\n system("cls");\n\n cout << "Hello! Welcome to the menu. ";\n cout << "\\n\\n";\n cout << "What would you like to do?\\n";\n cout << "Options:\\n";\n cout << "1. Password generator\\n";\n int choice{ 0 };\n do {\n\n cin >> choice;\n\n\n if (choice == 1) {\n wrong = true;\n passgen();\n break;\n }\n\n else {\n cout << "Invalid character. Please try again." << endl;\n cin.clear();\n }\n \n } while (!wrong);\n \n \n\n}\nNote- I didnt include the #include in this snippet of code, but the error is within the loop repetition." ]
[ "c++", "loops", "while-loop" ]
[ "Edit form with default Jquery date values, jquery sets current date for field after page is loaded", "$(document).ready(function(){\n $('#data_nasterii').datepicker($.datepicker.regional['ro']); // romanian language\n $('#data_nasterii').datepicker('option', 'changeMonth', true); // dropdown with month\n $('#data_nasterii').datepicker('option', 'changeYear', true); // dropdown with year\n $('#data_nasterii').datepicker('option', 'yearRange', '1900:2020'); // selectable years\n $('#data_nasterii').datepicker('option', 'dateFormat', 'yy-mm-dd'); // date format(ex: 1981-07-25)\n\n});\n\n...\n// creating date field with php\n\necho \"<td><div align=\\\"left\\\"><input name=\\\"data_nasterii\\\" type=\\\"text\\\" id=\\\"data_nasterii\\\" value=\\\"\".$row['data_nasterii'].\"\\\" size=\\\"10\\\" maxlength=\\\"10\\\" /></div></td></tr>\";\n\n\nif i hit \"Clear form\" field gets the right value\n\nThank you in advance!" ]
[ "jquery", "forms", "datepicker", "default-value" ]
[ "Fixed number of columns in UICollectionView", "I am creating a chess board and want to use UICollectionView to do the grid layout. The problem is, I don't know how to set the number of columns to always be 8, so as to create a 8x8 grid. \n\nI understand that UICollectionViewDelegateFlowLayout can be implemented to control the size of the items, but my question is will it work across all iOS devices (iPhone 4s - iPhone 6+, iPads). From what I have seen, it looks like i need to handle the size of the cells individually by each device type.\n\nUICollectionView Set number of columns\n\nIs anyone aware of a better solution to the problem?" ]
[ "ios", "iphone", "uicollectionview" ]
[ "public uri automatically appears in the url laravel", "I am using shared hosting for hosting a laravel application.\nI have used a .htaccess file to redirect request to the public folder\n\nRewriteEngine on \nRewriteCond %{HTTP_HOST} ^(www.)?domain.com$ \nRewriteCond %{REQUEST_URI} !^/public/ \nRewriteRule ^(.*)$ /public/$1 \nRewriteCond %{HTTP_HOST} ^(www.)?domain.com$ \nRewriteRule ^(/)?$ public/index.php[L]\n\n\nthe laravel routing works perfectly but when i try to request a folder inside the public folder directly from the url a public uri automatically appears\n\neg:\nwhen i write \"www.domain.com/Uploads\" the url automatically becomes \"www.domain.com/public/Uploads\"" ]
[ "php", "laravel", ".htaccess", "shared-hosting" ]
[ "local variable inside the loop or outside the loop", "void main(){\n int a=1;\n\n for(int i=0;i<10;i++){\n int b=2;\n }\n}\n\n\nIn the loop, variable B will be created every time in the loop,right? If so, I check the address of variable b by using & operation and found that address is exactly the same. If it's not recreated, the b should be still in the stack. Every time it will declare a new variable b in the loop. why no redefinition error happened here?" ]
[ "c++" ]
[ "What is the complete list of properties supported by annotation @ActivationConfigProperty", "How to know all the set of valid properties supported by Java EE 6 JMS annotation spec\n@ActivationConfigProperty\n\nThe Java EE 6 Documentation for @ActivationConfigProperty\nIt lists only the standard properties, but what about \n\n\nendpointPoolMaxSize\nendpointPoolResizeCount\nendpointPoolSteadySize\nmaxSession\n\n\nhow do we know if the above are even valid?\nwhere to find the right documentation" ]
[ "java", "jms", "java-ee-6" ]
[ "Read Excel 2.0 to datatable", "I have an .xls file (Excel 2.0 1988 year format), which should be converted it into C# datatable. I tried to use an oledb and odbc providers and got no result. \n\nSo how can I read it programmatically? \n\nOledb connection string that I've tried out:\n\nProvider=Microsoft.Jet.OLEDB.4.0;Extended Properties='Excel 2.0; HDR=NO';Data Source=mypath;\nProvider=Microsoft.ACE.OLEDB.12.0;Extended Properties='Excel 12.0; HDR=NO';Data Source=mypath;\nProvider=Microsoft.ACE.OLEDB.12.0;Extended Properties='Excel 8.0; HDR=NO';Data Source=mypath;" ]
[ "c#", ".net", "excel", "oledb" ]
[ "MS DataGrid (WPF) : How to bind a combobox to a class?", "This might sound like a trivial question, but even here in Stackflow I only have found binding to a simple string collection.\n\nI have a Parent class with two properties Name and Age.\n\nI have a Child class with two properties ChildName and ChildAge.\n\nWithin MVVM pattern I am exposing these properties into the ViewModels and additionally I am also adding into the ParentViewModel also an ObservableCollection Children\n\nTherefore the ParentViewModel contains three exposed properties: Name, Age and Children.\n\n//Inside ParentViewModel\npublic ObservableCollection<ChildViewModel> Children\n\n\nMy Window.xaml is bound to the MainViewModel that is exposing a \n\npublic ObservableCollection<ParentViewModel> Parents { get; set; }\n\n\nThe Datagrid is defined like this:\n\n<DataGrid ItemsSource=\"{Binding Parents}\" AutoGenerateColumns=\"False\">\n <DataGrid.Columns>\n <DataGridTextColumn Header=\"Name\" Binding=\"{Binding Name}\" />\n <DataGridTextColumn Header=\"Age\" Binding=\"{Binding Age}\"/>\n <DataGridComboBoxColumn Header=\"Children\" \n DisplayMemberPath=\"ChildName\" \n SelectedValueBinding=\"{Binding Children.ChildName}\"\n SelectedValuePath=\"ChildName\"\n SelectedItemBinding=\"{Binding Children}\"\n >\n\n </DataGridComboBoxColumn>\n </DataGrid.Columns>\n </DataGrid>\n\n\nWhile Name and Age of parents show correctly, I dont see the Children combo box populated.\nI am confused and frustrated. Please help. :)" ]
[ "wpf", "datagrid", "datagridcomboboxcolumn" ]
[ "Why is there no margin at the bottom of my ul?", "No elements are floated, but only the bottom margin is displayed outside of the containing div. What is the reason for this and how can I fix it so that the margin is on the ul, inside its container?\n\nhttp://jsfiddle.net/krcoxq0v/1/\n\nhtml\n\n<div class=\"box\">\n <h2>Title</h2>\n <ul>\n <li>List item</li>\n <li>List item</li>\n <li>List item</li>\n </ul>\n</div>\n\n\ncss\n\ndiv {\n background:#aaa;\n width:300px;\n}\nul {\n margin:25px;\n padding:0;\n background:#ddd;\n}\nli {\n list-style:none;\n}" ]
[ "html", "css", "margin" ]
[ "Application runs into a Redirect Loop error WildFly8", "I was trying to migrate the server from Jboss 4.2.2 to WildFly-8.2.0. Facing some issues while deploying the war file. War is getting deployed, but url rewriting creates issues.\n\nFor 4.2.2 the same had been written in a file called rewrite.properties in side the localhost folder.\n\nRewriteCond %{REQUEST_URI} !^(.*)[.]([a-zA-Z]+)$\nRewriteRule ^/home/(.*)$ /home/index.php?q=$1 [L,QSA]\n\n\nAs per some documentations, I cam to know that we can create a undertow-handlers.conf to my ROOT.war/WEB-INF/ folder, and \n\nhow can I put the above in regex[] format in 'undertow-handlers.conf'\n\ntried this \n\nregex['/home/(.*)$'] -> rewrite['/home/index.php']\n\nIt seems the url is correctly loading and redirecting to the home page. But application runs into a Redirect Loop error. I was referring this\nand this docs. It seems we can configure http connector to prevent redirect loop like this:\n\n<connector name=\"http\" protocol=\"HTTP/1.1\" scheme=\"http\" socket-binding=\"http\" proxy-name=\"${env.OPENSHIFT_GEAR_DNS}\" proxy-port=\"443\" secure=\"true\"/>\n\n\nBut I dont know how to configure this in WildFly 8. \nSecondly, if this issue is due to the missing of RewriteCond in the new regex in 'undertow-handlers.conf'? \n\nERROR:\n[io.undertow.request] (default task-20) UT005023: Exception handling request to /home/index.php?q=: com.caucho.quercus.QuercusModuleException: java.io.IOException: \n\n\nAn existing connection was forcibly closed by the remote host\n\nPlease help me out to resolve this issues.\n\nMy web.xml:\n\n<servlet-mapping>\n <servlet-name>Quercus Servlet</servlet-name>\n <url-pattern>*.php</url-pattern>\n </servlet-mapping>\n\n <welcome-file-list>\n <welcome-file>index.php</welcome-file>\n </welcome-file-list>" ]
[ "jboss", "wildfly-8" ]
[ "sbt publish assembly jar with a pom", "I am able to build one of my multi-project's jars as a single jar and then publish it How do I publish a fat JAR (JAR with dependencies) using sbt and sbt-release?\n\nHowever, the associated pom.xml is not published with it.\n\nHow can I create and publish the pom.xml (and ivy file) descriptors for an sbt-assembly jar?\n\nMy project is lions-share." ]
[ "sbt", "pom.xml", "sbt-assembly" ]
[ "strange behavior getting count of records", "I know the fact that I can't get more than 128 records by one query and that this can be extended to 1024 if I use .Take(1024) but I have a new problem with this Code on the sample Database:\n\nvar albumCount = session.Query<Album>().Count();\nConsole.WriteLine(albumCount); // 246 as expected?!?\n\nvar somemoredata = session.Query<Album>();\nConsole.WriteLine(somemoredata.Count()); // 246 but it sould be 128\nint cnt = 1;\nforeach (var album in somemoredata)\n{\n Console.WriteLine(cnt++.ToString() + \" \" + album.Id); // repeats 128 counts\n}\n\n\nHow can this be? The Count of somemoredata is 246, but the foreach writes 128 Lines?!?\n\nWhere is the error?" ]
[ "ravendb" ]
[ "Finding every possible combination of a list of numbers divided in two sets", "I have a list of numbers eg.\n\n\n120\n233\n197\n400\n276\n356\n121\n\n\nFor the purpose of my program these numbers have to be arranged in two sets. Based on what numbers are in the set the program calculates the efficiency of each set. It then combines the efficiency quotients for the combination of the two sets. The two sets and its efficiency quotient then gets saved in an array.\n\nThe goal is to find the combination of sets where both the sets have the highest efficiency.\n\nMy problem: At the moment, i can't seem to wrap my head around the algorithm needed to check every possible set combination. As far as i can get it seems to need a form of recursion.\n\nIf you need more information let me know! Thanks in advance!" ]
[ "algorithm", "set", "filtering" ]
[ "Karate - GraphQL - How to verify schema and then response?", "I have finally gotten Karate working with GraphQL and able to verify a simple 200 response though I am having trouble verifying the schema and then a response. I am super new so I apologize (not a programmer, just a tester). I want to verify that the schema is correct and for example that the results simply return (providerID, firstName, lastName etc), not the data. I then want to verify the data itself separately. The other thing I do not understand is how to pass in data, for example where I could change the Latitude, Longitude, MaxDistance etc and have it be a variable. I see in the example how \"name\" as used as a variable yet these seem to be passed in differently so I'm unsure how to do it. Sorry for not knowing so much, I appreciate the help. \n\nScenario: simple graphql request\n #Verify 200 response status returned \n Given text query =\n \"\"\"\n {\n Results: getSearchResults(searchLatitude:\"38.942833\", \n searchLongitude: \"-119.984549\", providerType: \"Primary Care Physicians\", \n sortBy: \"distance\", maxDistance:\"600\",skip: 0, take: 10) {\n providerID\n firstName \n lastName\n mI\n title\n name\n nameLFMT\n status\n specialties\n locations\n institutions\n acceptNewPatient\n imageUri\n distanceToNearest\n }\n\n } \n\n \"\"\"\n And request { query: '#(query)' }\n When method post\n Then status 200\n\n # pretty print the response\n * print 'response:', response\n\n\n # the '..' wildcard is useful for traversing deeply nested parts of the \n json\n * def results = get[0] response..Results\n * match results contains { ProviderId: 520, firstName: 'Richard', \nlastName: 'Botto' }" ]
[ "java", "automated-tests", "cucumber", "graphql", "karate" ]
[ "Errod:Escaping AWK commands in subprocess", "I need to know what all I must escape here to get the subprocess command successful.\n\nI have already tried the other solutions provided at stack overflow.\n\n>>> stdin,stdout,stderr = sp.Popen([\"ps -ef |grep -i user1 |awk '{print $NF}'\"],shell=True,stdout=sp.PIPE).communicate()[0]\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nValueError: too many values to unpack" ]
[ "python", "subprocess" ]
[ "Decrypt Azure Function App Operation Secret", "I'm looking to get at an Azure function app's list of operational endpoints for each function, in particular the secret code that needs to be passed in to invoke the function.\nI've tried lots of current answers in SO but all only seem to work with Function App's which use Files as the secret storage type.\n\nWe have a requirement to use Blob storage which is also the default in V2 function apps.\n\nWhat I'm really after is the code piece that comes after the function name when it's retrieved from the Azure portal, I can manufacture all the other pieces before that myself.\n\nFor example https://mytestfunapp-onazure-apidev03.azurewebsites.net/api/AcceptQuote?code=XYZABCYkVeEj8zkabgSUTRsCm7za4jj2OLIQWnbvFRZ6ZIiiB3RNFg==\n\nI can see where the secrets are stored in Azure Blob Storage as we need to configure that anyway when we create all the resources in our scripts.\n\nWhat I'm really look for is how to decrypt the secret stored in the file. I don't care what programming language or script the solution may be written in, I'll work with it, or convert it to another language that we can use.\n\nHere's a snippet of what the stored secret looks like in Blob storage, it's just a JSON file.\n\n\n\nI'm wondering if anyone out there has some experience with this issue and may be able to help me out." ]
[ "azure", "azure-function-app" ]
[ "SQL Count Available Rooms", "I am a newbie using asp.net I have a problem on what I am going to use. The problem is that i should count the number of available rooms in a hotel using SQL I use count but it's not working is there any way to use?" ]
[ "asp.net" ]
[ "How can I make a custom conversion from an object to a dict?", "I have a Python class that stores some fields and has some properties, like\n\nclass A(object):\n def __init__(self, x, y):\n self.x = x\n self.y = y\n\n @property\n def z(self):\n return self.x+1\n\n\nWhat changes do I need to make to the class so that I can do\n\n>>> a = A(1,5)\n>>> dict(a)\n{'y':5, 'z':2}\n\n\nwhere I specify that I want to return y and z? I can't just use a.__dict__ because it would contain x but not z. I would like to be able to specify anything that can be accessed with __getattribute__." ]
[ "python" ]
[ "How to display a number with many decimal places? (Java)", "I was wondering if there is a way to \"cheat\" and work with numbers with way more decimal places than a double in Java, and then display it via [Graphics Object].drawString(number, 10, 10);\n\nCan I do this?" ]
[ "java", "numbers", "double", "decimal", "pi" ]
[ "How to fix ValueError: time data '18/02/2020 20:14:31' does not match format '%d/%m/%y %H:%M:%S' in Python?", "I am developing a web application with Flask Python.\nI have a Mysql table with a text column date:\n-- date --\n10/06/2020 18:50:17\n10/06/2020 18:55:10\n28/05/2020 22:18:06\n29/03/2020 20:47:01\n29/03/2020 21:29:14\n\nThese data above are date in string format.\nI need to convert these string dates into format dates.\nI did this in python :\nactions = Action.query.all() # This is SQLAlchemy request to get all the rows of table 'Action'\nfor action in actions:\n date=action.date\n # convert this date string in date format\n date_time_obj = datetime.strptime(date, '%d/%m/%y %H:%M:%S')\n print(date_time_obj)\n\nBut I get this error output:\nTraceback (most recent call last):\n File "j:/Dropbox/cff/Python/folder/test.py", line 18, in <module>\n date_time_obj = datetime.strptime(date, '%d/%m/%y %H:%M:%S')\n File "C:\\Users\\Nino\\AppData\\Local\\Programs\\Python\\Python37\\lib\\_strptime.py", line 577, in _strptime_datetime\n tt, fraction, gmtoff_fraction = _strptime(data_string, format)\n File "C:\\Users\\Nino\\AppData\\Local\\Programs\\Python\\Python37\\lib\\_strptime.py", line 359, in _strptime\n (data_string, format))\nValueError: time data '18/02/2020 20:14:31' does not match format '%d/%m/%y %H:%M:%S'\n\nI don't understand as '18/02/2020 20:14:31' corresponding perfectly to format '%d/%m/%y %H:%M:%S'\nWhat is wrong in my code? Did I miss something?" ]
[ "python", "python-3.x", "date" ]
[ "Migrating Db and Entity framework", "I have to take data from an existing database and move it into a new database that has a new design. So the new database has other columns and tables than the old one.\n\nSo basically I need to read tables from the old database and put that data into the new structure, some data won't be used anymore and other data will be placed in other columns or tables etc.\n\nMy plan was to just read the data from the old database with basic queries like \n\nSelect * from mytable\n\n\nand use Entity Framework to map the new database structure. Then I can basically do similar to this:\n\nwhile (result.Read())\n{\n context.Customer.Add(new Customer\n {\n Description = (string) result[\"CustomerDescription\"],\n Address = (string) result[\"CuAdress\"],\n //and go on like this for all properties\n });\n}\ncontext.saveChanges();\n\n\nI think it is more convenient to do it like this to avoid writing massive INSERT-statements and so on, but is there any problems in doing like this? Is this considered bad for some reason that I don't understand. Poor performance or any other pitfalls? If anyone has any input on this it would be appreciated, so I don't start with this and it turns out to be a big no-no for some reason." ]
[ "c#", "entity-framework" ]
[ "core.js:4197 ERROR TypeError: Cannot read property 'TwitterAuthProvider' of undefined", "var provider = new firebase.auth.TwitterAuthProvider();\n firebase.auth().signInWithPopup(provider).then(function(result) {\n // This gives you a the Twitter OAuth 1.0 Access Token and Secret.\n // You can use these server side with your app's credentials to access the Twitter API.\n // var token = result.credential.accessToken;\n // var secret = result.credential.secret;\n // The signed-in user info.\n var user = result.user;\n console.log(user);\n // ...\n }).catch(function(error) {\n // Handle Errors here.\n var errorCode = error.code;\n var errorMessage = error.message;\n // The email of the user's account used.\n var email = error.email;\n // The firebase.auth.AuthCredential type that was used.\n var credential = error.credential;\n // ...\n });\n\nI am getting\ncore.js:4197 ERROR TypeError: Cannot read property 'TwitterAuthProvider' of undefined\nerror while running the application" ]
[ "firebase", "twitter", "firebase-authentication" ]
[ "Spaces before values in array list when there aren't supposed to be", "I am having spaces before values in my randomize I made for a name, using prefix root and suffix. Here is a link to what I mean example on my website and if you look at the bottom of the plot it says the name, but with spaces in between, only sometimes. Which to me, makes no sense at all. I have been struggling with this for a while and I can't figure out how to fix this. I will provide links for my source of the PHP as well being inside text files. source for example Please help me as this problem may seem minor, but it continues to baffle me as it does not make sense." ]
[ "php", "arraylist", "shuffle" ]
[ "difference between ChildBrowser and InAppBrowser in cordova/phonegap", "I have to create new cordova/phonegap application, where I just need to open my websites which contains map and markers on it or any others.\n\nAfter searching I got plugin like ChildBrowser and InAppBrowser in cordova/phonegap.\n\nBut I am not sure which is best or which is latest and what exactly difference between them?\n\nPlease help me to find out solution or any references.\n\nThanks." ]
[ "cordova", "ionic-framework", "phonegap-plugins", "cordova-plugins", "phonegap" ]
[ "GAE Starting dynamic instance to serve requests instead of using idle resident instances", "I ve checked a bunch of other post about the same subject like this one : “Resident instance doesn't seem to work” but I couldn t find a working answer for my problem \n\nI have 4 F2 resident and whenever someone goes to my application, instead of using a resident instance, a new dynamic instance is mounted to answer the request. And so the person who is attempting to use my application will wait 20 seconds. Then all the new requests will come to the new dynamic instance. \nThe response time on my resident instances are inferior to my min pending latency (5 sec). \nMy app is in production since yesterday and if no one uses it for 5 minutes then the next guy who will connect will have to wait 20 sec ! \n\nFrom what I ve read, some would say that if I set min idle instance to 4 ( in order to have my resident instances) GAE will try to have 4 iddle instances all the time and so we ll start new instances; but then I would always have to wait 35 sec for all my first connections After 2 minutes of using the application everything is fine.\nA guy working at Google told me that there is a bug in the management of resident instances and that I have to have 3 resident instances to have a quick answer for my users. \nI m sure I haven t understood something. Anyone could help me let my users have a fair response time when they connect to my application and no one have connected for 5 minutes please ? \n\nThank you very much" ]
[ "java", "google-app-engine" ]
[ "Create a Reverse Proxy in NodeJS that can handle multiple secure domains", "I'm trying to create a reverse proxy in NodeJS. But I keep running the issue that in that I can only serve one one set of cert/key pair on the same port(443), even though I want to serve multiple domains. I have done the research and keep running into teh same road block:\n\n\nA node script that can serve multiple domains secure domain from non-secure local source (http local accessed and served https public)\nLet me dynamically server SSL certificates via domain header\nExample: \n\nhttps ://www.someplace.com:443 will pull from http ://thisipaddress:8000 and use the cert and key files for www.someplace.com\nhttps ://www.anotherplace.com:443 will pull from http ://thisipaddress:8080 and use the cert and key files for www.anotherplace.com \nect.\n\nI have looked at using NodeJS's https.createServer(options, [requestListener])\n\nBut this method supports just one cert/key pair per port\nI can't find a way to dynamically switch certs based on domain header \nI can't ask my people to use custom https ports\nAnd I'll run into browse SSL certificate error if I serve the same SSL certificate for multiple domain names, even if it is secure \n\nI looked at node-http-proxy but as far as I can see it has the same limitations\nI looked into Apache mod-proxy and nginx but I would rather have something I have more direct control of\n\n\nIf anyone can show me an example of serving multiple secure domains each with their own certificate from the same port number (443) using NodeJS and either https.createServer or node-http-proxy I would be indebted to you." ]
[ "node.js", "ssl", "proxy", "reverse-proxy" ]
[ "Regular expression usage", "I have a string which is a REST query string and it looks like this\n\n//new_requestSet?$select=new_ExternalStatus,new_name&$filter=new_ExternalStatusDirty eq true\n\n\nI am using a regex class posted here on StackOverFlow. It works well to find some positions in my input string above but I feel like my code to extract the actual values I need is inefficient. Is there a more efficient way using regex instead of IndexOf and SubString?\n\nint fieldPos = StringExtender.NthIndexOf(json, \"filter=\", 1);\n int firstSpace = StringExtender.NthIndexOf(json, \" \", 1);\n int secondSpace = StringExtender.NthIndexOf(json, \" \", 2);\n int entityPosEnd = StringExtender.NthIndexOf(json, @\"\\Set\", 1);\n int searchFieldStart = StringExtender.NthIndexOf(json, \"=\", 2);\n string searchField = json.Substring(searchFieldStart + 1, firstSpace - searchFieldStart - 1);\n string criteria = json.Substring(secondSpace+1);\n string entity = json.Substring(0, entityPosEnd);" ]
[ "c#", "regex", "string" ]
[ "How to use git branches", "being new to git, I have this dumb question - what is the correct way of using feature-branches ?\n\nFrom what I have gathered, this is how I thought it should be used:\n\ngot some 'develop' branch from which branches are checked out:\n\n\"feature-1\"\n\"feature-2\"\n\"feature-3\"\n\n\netc.\n\nNow, one or more developers would work on one or more feature branches, and when the team leader wants to glue everything back together and test he would then merge the features back into the 'develop' trunk. \nHowever, git appears to lack the ability to hand pick what changes to keep from each feature branch (tried recursive, patience and every other merge strategy) so in the end, sometimes each of the branch ends up overwriting what previous branches merged back into 'develop'.\nThings get even nastier as developers continue to work on their branches and team leader attempts to merge them into 'develop' from time to time to incorporate the changes.\n\nObviously this is not the right way to branch-for-feature. But what is the right way then ?\n\nthanks\n\nEDIT:\n\nJust to illustrate further, let's consider we have these files in develop branch:\n\nfileA (develop)\nfileB (develop)\nfileC (develop)\n\n\nNow merge back in \"feature-1\" which only touches fileA:\n\nfileA (conflict, theoretically solvable by the recursive/theirs strategy)\nfileB (develop)\nfileC (develop)\n\n\nNext merge back \"feature-2\" that only touches fileB:\n\nfileA (overwritten by feature-2!!!)\nfileB (conflict, theoretically solvable by the recursive/theirs strategy)\nfileC (develop)\n\n\nWhat to do about fileA ? I would want it to keep the \"feature-1\" version of it." ]
[ "git", "git-branch", "git-merge" ]
[ "Transport Stream - Record MPEG2", "I recorded a Channel with my DVB-Tuner (MPEG Transport Stream), i´m able to lookup the PAT/PMT Tables inside of the Channel and determ the VideoPIDs and AudioPIDs. \nNow i want to record one Video/Audio stream to a \"normal\" MPEG \"*.mpg\" File.\n\nIf i lookup the internet i dont get any ... hmm \"simple\" Informations how to make this, does anybody have an hint for me ? I dont want to use FFDShow or any external tool, i want to code the part for myself... :)\n\nGreets\nChristian" ]
[ "video", "mpeg", "video-recording" ]
[ "How to structure ajax call", "At the moment I have two static array of javascript values (d1 and d2) which are then passed into a javascript object (data).\n\n$(function () {\n\n var d1, d2, data\n d1 = [\n [1424131200000,20151],[1424217600000,22448],[1424304000000,27000],[1424390400000,30622],[1424476800000,30844],[1424563200000,23140],[1424649600000,20555]\n ]\n d2 = [\n [1424131200000,18664],[1424217600000,19149],[1424304000000,20415],[1424390400000,24617],[1424476800000,30278],[1424563200000,28808],[1424649600000,22032]\n ]\n\n data = [{ \n label: \"This Year\", \n data: d1\n }, {\n label: \"Last Year\",\n data: d2\n }]\n var holder = $('#line-chart')\n if (holder.length) {\n $.plot(holder, data, chartOptions )\n } \n}) \n\n\nI would like to change my code to achieve the same thing but load the values from two ajax calls instead of statically defining the values. But I am having troubles achieiving this. Could someone please help me with how I can modify what I have below to achieve what I have defined staticlly above. \n\nHere is what I have so far...\n\n$(function () {\n var data\n fetchData(function (data) {\n console.log(data);\n }); \n var holder = $('#line-chart')\n if (holder.length) {\n $.plot(holder, data, chartOptions )\n } \n}) \n\nfunction fetchData(callback) {\n\n $.when(fetchThisYearsData(), fetchLastYearsData()).done(function (dataThisYear, dataLastYear) {\n var data = [];\n data.push(dataThisYear[0]);\n data.push(dataLastYear[0]);\n callback(data);\n });\n}\n\nfunction fetchThisYearsData() {\n return $.ajax({\n url: \"service/tranAnalysis/tranCounts.json?siteId=1&yearOffset=0\",\n dataType: 'json',\n async: false\n }); \n}\n\nfunction fetchLastYearsData() {\n return $.ajax({\n url: \"service/tranAnalysis/tranCounts.json?siteId=1&yearOffset=1\",\n dataType: 'json',\n async: false\n }); \n}\n\n\nThe two ajax calls return the following json...\n\n{\"label\":\"This Year\",\"data\":[[1424131200000,20151],[1424217600000,22448],[1424304000000,27000],[1424390400000,30622],[1424476800000,30844],[1424563200000,23140],[1424649600000,20555]]}\n\n{\"label\":\"Last Year\",\"data\":[[1424131200000,18664],[1424217600000,19149],[1424304000000,20415],[1424390400000,24617],[1424476800000,30278],[1424563200000,28808],[1424649600000,22032]]}\n\n\nWhen I debug in firebug it looks like the ajax calls are happening and inside the callback function the data variable is populated. But then when I get to the call to $plot, the data variable is empty/null.\n\nthanks" ]
[ "jquery", "ajax" ]
[ "Pandas dataframe: summing cell data from a group of rows, storing in a new column", "As a part of a treatment for a health related issue, I need to measure my liquid intake (along with some other parameters), registring the amount of liquid every time I drink. I have a dataframe, of several months of such registration.\nI want to sum my daily amount in an additional column (in red, image below)\nAs you may see, I wish like to store it in the first column of the slice returned by df.groupby(df['Date'])., for all the days.\nI tried the following:\ndf.groupby(df.Date).first()['Total']= df.groupby(df.Date)['Drank'].fillna(0).sum()\n\nBut seems not to be the way to do it.\nGreatful for any advice.\nThanks\nMichael" ]
[ "python", "pandas", "dataframe" ]
[ "Pycharm Unexpected Result Output", "I'm a beginner at Pycharm. I'm using Flask web framework to develop a basic web application. I have written a simple code to display \"Hello\" on my browser, which it did. Strangely, when I add something to 'Hello', such as 'Hello my name is Yusef' and re-run the program; it won't show any changes, it still appears with message 'Hello' on my browser. Any idea, what I'm missing? \n\nBelow is my code:\n\nfrom flask import Flask\n\napp = Flask(__name__)\n\[email protected]('/')\ndef hello():\n return \"hello world\"\n\nif __name__ == \"__main__\":\n app.run()" ]
[ "python", "web-applications", "flask", "pycharm" ]
[ "how to set AlarmManager for specific date, hour, minute and second", "the alarm doesn't work at the specified time\n(20 December 2018, 12:10:02)\n\nwhat is the problem with this code?\n\nCalendar c = Calendar.getInstance();\nc.set(Calendar.MONTH,12);\nc.set(Calendar.YEAR,2018);\nc.set(Calendar.DAY_OF_MONTH,20);\nc.set(Calendar.HOUR_OF_DAY,12);\nc.set(Calendar.MINUTE,10);\nc.set(Calendar.SECOND,2);\n\nIntent intent = new Intent(ProfileList.this, IntentBroadcastedReceiver.class);\nPendingIntent pintent = PendingIntent.getService(ProfileList.this, 0, intent, 0);\nAlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);\nalarm.setRepeating(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), 30*1000, pintent);" ]
[ "java", "android", "datetime", "time", "java-time" ]
[ "Trying to render a page with two textbox and login button i react js", "i am trying to render a page with two textbox and login button in react js with Asp.net MVc as follows but only image is rendering nothing else rendering.\nin \nindex.cshtml\n inside head section css rendered\n and in body section react cdn and reactjs file has been added\n\n@{\n Layout = null;\n}\n<html>\n<head>\n</head>\n<body>\n <div class=\"wrapper\" id=\"signup\"></div>\n <link href=\"Assets/Css/bootstrap.min.css\" rel=\"stylesheet\" />\n <script src=\"~/Assets/JS/jquery.min.js\" type=\"text/javascript\"></script>\n <script src=\"~/Assets/JS/react.js\"></script>\n <script src=\"~/Assets/JS/react-dom.js\"></script>\n <script src=\"~/Assets/JS/remarkable.min.js\"></script> \n <script type=\"text/jsx\" src=\"@Url.Content(\"~/Assets/JS/login.jsx\")\"></script> \n</body>\n <!-- Core JS Files -->\n<script src=\"~/Assets/JS/jquery.min.js\" type=\"text/javascript\"></script>\n</html>\n\n\nlogin.jsx\n\nclass NameForm extends React.Component {\n constructor(props) {\n render() {\n return (\n <form onSubmit={this.handleSubmit}>\n </form>\n );\n }\n}\n\nReactDOM.render(<NameForm />,document.getElementById('signup'));\n\n\nAll design part mentioned but while declaring class the error\n\"JSX:Parser Unable to communicate with jsx parser\". Error is occuring..So Any idea how to create login form in react js using asp.net mvc. would be appreciated" ]
[ "asp.net-mvc", "reactjs" ]
[ "Component instance variable value not updating inside subscribe Angular 7", "I am trying to get the current and previous URL of the component and update a component variable based on the URL. When I debug the application, it appears that the components value is getting updated but actually it is not.\n\nThe gist of My code below:\n\ndashboard.component.ts\n\nshow = true;\n constructor(private heroService: HeroService, private router: Router) {}\n ngOnInit() {\n this.getHeroes();\n this.router.events\n .pipe(\n filter(evt => evt instanceof NavigationEnd),\n pairwise(),\n take(1)\n )\n .subscribe((events: [NavigationEnd, NavigationEnd]) => {\n console.log(\"Prev\", events[0].url);\n console.log(\"Cur\", events[1].url);\n if (events[1].url === \"/dashboard\" && events[0].url === \"/detail/12\") {\n console.log(\"Came here\");\n this.show = false;\n }\n });\n}\n\n\ndashboard.component.html\n\n{{show}}\n\nPlease find the stackblitz example of my code:\n\nhttps://stackblitz.com/angular/qvvrbgrmmda?file=src%2Fapp%2Fdashboard%2Fdashboard.component.html\n\nSteps to reproduce: \nNavigate to any hero page by clicking on the hero name and go back to the dashboard component by clicking on the 'goback' button. Observe in the console.\n\nNote: Imports are ignored, all the import statements are handled properly\n\nExpected Result: The template should display 'false' after updating the component variable.\n\nActual Result: The template shows 'true' without updating the variable, even if the condition is true.\n\nAll of my services are providedIn: 'root' and ChangeDetectionStrategy is Default, but I don't think it will impact anything. \n\nI have tried changeDetector.detectChanges();, changeDetector.markForCheck(); and ngZone.run();. But nothing seems to be working. Please suggest to me, what I am doing wrong. Thanks for any help in advance." ]
[ "angular" ]
[ "cabal sandbox with stackage", "I want to point my global cabal config to use stackage LTS only.\n\nDoes cabal sandbox provide any value in that case?\n\nAs I understand there should be no cabal hell anymore as all projects will use a predetermined set of package that are guaranteed to build together.\n\nIs there any way to prebuild all stackage LTS packages to speed up all future project builds?" ]
[ "haskell", "cabal", "stackage" ]
[ "Is it possible to see app downloads by country?", "Is it possible to see app downloads by country?\n\nI checked \n\nSales and Trends\nView and download your sales and trends information.\n\npart but it only seems to show the region. Is it possible to somehow learn which countries downloaded my application?" ]
[ "ios", "app-store-connect" ]
[ "Python: Iterate over files in directory and use the filenames as variables", "Dear stackoverflow users,\n\nI'm struggling with figuring out the following problem:\n\nI have a directory with multiple files such as\n\ndatasets/\n dataset1.txt\n dataset2.txt\n dataset3.txt\n dataset4.txt\n dataset5.txt\n\n\nand to read out the files and assign their content to a variable that is their filename without the file type extension. To be explicit: The content of dataset1.txt should be saved to a variable dataset1, the content of dataset2.txt should be saved to the variable dataset2 and so on.\n\nI know that I can iterate over the content of my folder with the following function:\n\nfor root, dirs, files in os.walk('.'):\nprint(files)\n\n\nbut at the end it should do something like the folling:\n\nfor root, dirs, files in os.walk('.'):\nfor file in files:\nfile.split('.')[0] = numpy.loadtxt(file) # here it should create e.g. a variable dataset1 and read content of dataset1 into it.\n\n\nHow is this possible?\n\nRegards,\n\nJakob" ]
[ "python-3.x", "numpy" ]
[ "Django models: How to filter by multiple values at once?", "I'm working on a social network project for learning purposes and I'm trying to figure out the best way to make this query:\ndef following(request, user_username):\n user = User.objects.get(username=user_username)\n try:\n following_users = user.following.all()\n following_posts = []\n for following_user in following_users:\n following_posts.append(Post.objects.filter(username=following_user.username))\n except:\n return JsonResponse({"error": "There was an error loading the following posts"}, status=400)\n following_posts = following_posts.order_by("-timestamp").all()\n return JsonResponse([post.serialize() for post in following_posts], safe=False)\n\nI'm trying to get the posts of the users that the user is following in the social media, ordered by reverse chronological order ("timestamp"). And, to do that, I tried first getting all the users that the user follows (following_users = user.following.all()) and then getting all the posts these users have one by one (in the for loop). The problem is that the order_by function only works with QuerySet, and the following_posts is a list. Not only that, I don't think that this is a good way to make this query even if it worked. Can I get all these posts at once without a for loop?\nAnyway, these are the models that are involved in this query:\nclass User(AbstractUser):\n profile_picture = models.CharField(max_length=100, default="https://cdn.onlinewebfonts.com/svg/img_568656.png")\n followers = models.ManyToManyField('self', blank=True)\n following = models.ManyToManyField('self', blank=True)\n join_date = models.DateTimeField(auto_now_add=True)\n def serialize(self):\n return {\n "id": self.id,\n "username": self.username,\n "email": self.email,\n "followers": [user.username for user in self.followers.all()],\n "following": [user.username for user in self.following.all()],\n "join_date": self.join_date.strftime("%b. %d, %Y, %H:%M %p"),\n "profile_picture": self.profile_picture\n }\n\nclass Post(models.Model):\n autor = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True, default="", related_name="user_post")\n content = models.TextField(max_length=240)\n likers = models.ManyToManyField(User, related_name="posts_liked")\n timestamp = models.DateTimeField(auto_now_add=True)\n def serialize(self):\n return {\n "id": self.id,\n "autor": self.autor.username,\n "content": self.content,\n "likers": [user.username for user in self.likers.all()],\n "timestamp": self.timestamp.strftime("%b. %d, %Y, %H:%M %p"),\n "autor_profile_pic": self.autor.profile_picture\n }" ]
[ "django", "django-models", "django-queryset" ]
[ "Simple AJAX Submit and update mysql", "I am stumped, I am tossing out my code and I need help with a cross browser ajax submit.\nCan anyone PLEASE give me a simple working ajax submit script for updating mysql? The one I have is all bad. \n\nWorks in FF and Safarai (iphone), but in IE7, it has caching problem and in IE8 it doesn't even submit." ]
[ "php", "javascript", "mysql", "ajax" ]
[ "Replacing false in excel if function with existing values in a table", "I am trying to use an if statement in excel to organize data gotten from GPS car tracker.\n\n\n\n=IF(B1=\"A 300 rd\", \"parking lot\", \"leave it as it is\",IF(B1=\"A 600 rd\", \"Car wash\", \"leave as it is\"))\n\n\nI need the expression not to replace the data if the expression evaluates to false i.e. if false then \"leave as it is\"." ]
[ "excel" ]
[ "How to debug \"exit status 1\" error when running exec.Command in Golang", "When I run the code below:\n\ncmd := exec.Command(\"find\", \"/\", \"-maxdepth\", \"1\", \"-exec\", \"wc\", \"-c\", \"{}\", \"\\\\\")\nvar out bytes.Buffer\ncmd.Stdout = &out\nerr := cmd.Run()\nif err != nil {\n fmt.Println(err)\n return\n}\nfmt.Println(\"Result: \" + out.String())\n\n\nI am getting this error:\n\n\n exit status 1\n\n\nHowever this is not helpful to debug the exact cause of the error.\n\nHow to get more detailed information?" ]
[ "error-handling", "command", "go", "exec" ]
[ "json get subfolders info", "i have this code:\nimport json\nimport requests\n\ndef crawl():\n response = requests.get('https://swapi.dev/api/planets/?search=kamino')\n api_results = json.loads(response.content)\n print(api_results["results"])\ncrawl()\n\nthat gives this output:\n{\n "count": 1,\n "next": null,\n "previous": null,\n "results": [\n {\n "name": "Kamino",\n "rotation_period": "27",\n "orbital_period": "463",\n "diameter": "19720",\n "climate": "temperate",\n "gravity": "1 standard",\n "terrain": "ocean",\n "surface_water": "100",\n "population": "1000000000",\n "residents": [\n "http://swapi.dev/api/people/22/",\n "http://swapi.dev/api/people/72/",\n "http://swapi.dev/api/people/73/"\n ],\n "films": [\n "http://swapi.dev/api/films/5/"\n ],\n "created": "2014-12-10T12:45:06.577000Z",\n "edited": "2014-12-20T20:58:18.434000Z",\n "url": "http://swapi.dev/api/planets/10/"\n }\n ]\n}\n\nhow can I get name diameter and terrain? i have searched quite a bit but I haven't found anything that can help can you guys help me?" ]
[ "python", "json", "python-jsons" ]
[ "C makefile and header confusion", "I have a couple of general questions about Make files, headers, and including files in C, and am hoping to get an easy to interpret answer because all the tutorials go from \"ok I understand this\" to \"what the heck is this\" just in a couple lines. \nLets say I have a program I want to create a makefile for.\n\n**fileA.c** contains the main and calls functions in **fileB.c** and **fileC.c**\n\n**fileB.c** contains getopts and stdlib but no other file or function from other file\n\n\n(so normal headers, correct? nothing linking to any other file since it doesn't call anything. Or should it have fileA.c header since it is called from there?)\n\n**fileC.c** contains functions that call header1.h (given header file for library)\n\n\nI am just confused what headers are included and what I put in the make file to support make/clean functions. Since fileA.c calls functions from fileB.c and fileC.c do i create headers for them and #include them in fileA.c or do I write that into the makefile?\n If I include a header for something in the file and then create a makefile for the file, does it go to the pre-processor twice?\n\nI think I may just be confused in the actual purpose of the makefile vs the header file, and that is causing me to lose my mind.\n\nThanks for taking the time to read and any help would be greatly appreciated.\n\nedit:\n\nfor reference,\n\nfileA.o: fileA.c fileA.h\n${CC} ${CFLAGS} -c fileA.c\n\n\nso, since fileA isn't called by anything this would be correct (I do pass address from fileA to both fileB and fileC)?\n\nwould fileB.o: contain fileB.c fileB.h and thats it? or would it have the other headers?" ]
[ "c", "makefile", "header", "include" ]
[ "GetOpenFileName function in ms project VBA", "I'm trying to use the GetOpenFileName function, in vba for ms project. Is it available only in excel? no option to use it in ms project?\nThanks." ]
[ "vba", "excel", "ms-project", "ms-project-server-2013" ]
[ "bllim / laravel4-datatables-package -> get the id from the query", "I'm trying to get the ID from the query when I use edit_column but I get it only for the 'id' column, when I try to get it for the 'operations' column I get the html markup of the 'id' column.\n\nHere is the code:\n\npublic function ajaxGetAllPages()\n{\n $pages = Page::select(array('id','title','updated_at','status'));\n return Datatables::of($pages)\n ->edit_column('id', '<input type=\"checkbox\" class=\"checkboxes tooltips\" value=\"{{ $id }}\" data-placement=\"left\" data-original-title=\" אינדקס # {{ $id }} \" />')\n ->edit_column('title','<a href=\"{{ URL::route( \\'admin.pages.index\\') }}\">{{ $title }}</a>')\n ->edit_column('updated_at', '{{ date(\"d-m-Y | H:i\",strtotime($updated_at)) }}')\n ->edit_column('status', '{{ $status }}')\n ->edit_column('operations',\n '<a href=\"#\" data-id=\"{{ $id }}\" class=\"btn btn-xs blue btn-editable tooltips\" data-placement=\"top\" data-original-title=\"עריכה\"><i class=\"fa fa-pencil\"></i></a>\n <a href=\"#\" data-id=\"{{ $id }}\" class=\"btn btn-xs dark btn-trash tooltips\" data-placement=\"top\" data-original-title=\"לארכיון\"><i class=\"fa fa-trash-o\"></i></a>\n <a href=\"#\" data-id=\"{{ $id }}\" class=\"btn btn-xs red btn-removable tooltips\" data-placement=\"top\" data-original-title=\"מחיקה\"><i class=\"fa fa-times\"></i></a>\n <div class=\"btn-group\">\n <button class=\"btn default btn-xs dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\">עוד <i class=\"fa fa-angle-down\"></i></button>\n <ul class=\"dropdown-menu pull-right\" role=\"menu\">\n <li><a href=\"#\">פעולה</a></li>\n <li><a href=\"#\">פעולה</a></li>\n </ul>\n </div>'\n )\n ->make();\n}\n\n\nMarkup result - http://screencast.com/t/nIefrpqc8\n\nAm I doing something wrong or is it a bug?\n\nThanks,\nChen" ]
[ "laravel-4", "datatables" ]
[ "generate 9 byte alphunumeric from a seed of 10 digits number", "I have a unique 10 digits phone number, I want to generate a 9 character unique alphanumeric id from it. It doesn't need to be reversible, but the same unique alphanumeric id should be generated from the same phone number." ]
[ "random", "uniqueidentifier" ]
[ "MongoDB - How to delete expired documents except last one", "We're working on audit log solution for one of our projects and would appreciate your help.\n\nWe have media entity which contains media id (numeric), action (string, eg. PUBLISH) and occurred on date with time representing date and time when action happened. \n\nRequirement is to delete logs that are older than 90 days but to keep log with last action on media entity.\n\nWe are using Mongo 3.2 and we need help how to organize our collection since we need to support reads and writes on collection that will contain 200-300 millions of documents.\n\nWe tried several approaches but couldn't figure out a simple way on how to do it. \n\nFirst approach\n\nWe tried to solve it with flat collection with document format:\n\n{\n _id: ObjectId(\"570b3cf65eac4e48e92b4e20\"),\n mediaId: 10000,\n action: \"PUBLISH\",\n occurredOn: ISODate(\"2016-04-04T12:42:07.000Z\")\n}\n\n\nwhere insert is easy but we have problem with deletion of documents.\n\nSecond approach\n\nWe also tried to solve it with documents that contain array of actions and dates:\n\n{\n _id: 10000,\n actions: [\n {\n action:\"PUBLISH\", \n occurredOn: ISODate(\"2016-04-04T12:42:07.000Z\")\n }, \n ...\n ]\n}\n\n\nwhere insert is also easy but again we have problem with deletion of documents.\n\nAny suggestions on how to organize schema for this scenario?" ]
[ "mongodb" ]
[ "How to exclude login url from rails admin and devise?", "I have a system written in RoR and Devise, and I use rails admin as my admin system.\n\nThe problem is that, since I used devise as authentication service, and login url is /admins/sign_in, however, all urls start with /admin is managed by rails admin and need to be logged in, so this is a dead loop.\n\nWhat I want to do is to use /admin/sign_in as login url and /admin/sign_out as logout url.\n\nAny idea how to exclude these urls from rails admin?" ]
[ "ruby-on-rails", "devise", "rails-admin" ]
[ "MYSQL #1136 - Column count doesn't match value count at row 1 though they are equal", "I keep getting the following error though no. of columns and no. of values match, so I wonder can someone help ?\n\nINSERT INTO `user_dates` (`id`, `date`, `user_id`) VALUES(26545, '2016-04-28', 35);\n\n\nMy Table structure is:\n\nCREATE TABLE `user_dates` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `date` date NOT NULL,\n `user_id` int(10) unsigned NOT NULL,\n PRIMARY KEY (`id`),\n KEY `user_dates_user_id_foreign` (`user_id`),\n CONSTRAINT `user_dates_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=10459 DEFAULT CHARSET=utf8;" ]
[ "php", "mysql" ]
[ "How to generate surrogate key for source file(csv) in python", "If there is any possibility of generating surrogate key for source file(csv) in python or python modules?\nIf it's possible means,Plz post sample script." ]
[ "python" ]
[ "Writing to file (Prolog)", "I've been trying to loop through a list and writing it to a file, why is the following not working? \n\nloop_through_list(List) :-\n member(Element, List),\n write(Element),\n write(' '),\n fail. \n\nwrite_list_to_file(Filename,List) :-\n tell(Filename), % open file to be written \n loop_through_list(List),\n told. % flush buffer" ]
[ "prolog" ]