texts
sequence | tags
sequence |
---|---|
[
"Concatenate int and byte",
"First, I am very new to c#, so please, bear with me. I am trying to set 3 ints and 4 bytes to a computer via UDP. I've used this thread to help with concatenating my variables Best way to combine two or more byte arrays in C#. Currently, I am having an error trying to BlockCopy the bytes into an array. My array is 12 bytes long and I need bytes 9, 4, 5 and 6. My code is \n\nbyte[] UDPPacket = new byte[16];\nBuffer.BlockCopy(button[9],0,UDPPacket,0,1);\n\n\nand it is erroring with\n\n(parameter)byte[]buttons\n\n\nI believe the BlockCopy method works for a bytewise copy of one array to the other. Any insight into what I'm doing wrong?"
] | [
"c#",
"udp"
] |
[
"How to strictly keep text block together in one line of Paragraph",
"For the first part in red, it's kept together in one line.\nBut for the second part in red, it's splitted to multiple lines, which is not pure text but composed by Text & Link.\nHere is the code:\nPdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));\nDocument doc = new Document(pdfDoc, PageSize.A4, false);\ndoc.SetMargins(55f, 55f, 45f, 55f);\n\nvar pageWidth = doc.GetPageEffectiveArea(PageSize.A4).GetWidth();\nvar pageHeight = doc.GetPageEffectiveArea(PageSize.A4).GetHeight();\n\nvar text1 = "Our PDF toolkit offers you one of the best-documented and most versatile PDF engines in the world (written in Java and .NET), which allows you to not only integrate PDF functionalities into your workflow, but also in your applications, processes products";\nvar text2 = "We have an active community of partners, customers, and contributors, that help us every day to improve our products, documentation and support. We see them as part of our iText family, and hope you will join our family too.";\n\nvar riseText = "[12,13,14,15]";\n\nvar link1 = new Link("12", PdfAction.CreateURI("http://123.com"));\nlink1.SetTextRise(3).SetFontColor(ColorConstants.ORANGE);\nlink1.GetLinkAnnotation().SetBorder(new PdfAnnotationBorder(0, 0, 0));\n\nvar link2 = new Link("13", PdfAction.CreateURI("http://123.com"));\nlink2.GetLinkAnnotation().SetBorder(new PdfAnnotationBorder(0, 0, 0));\nlink2.SetTextRise(3).SetFontColor(ColorConstants.ORANGE);\n\nvar link3 = new Link("14", PdfAction.CreateURI("http://123.com"));\nlink3.GetLinkAnnotation().SetBorder(new PdfAnnotationBorder(0, 0, 0));\nlink3.SetTextRise(3).SetFontColor(ColorConstants.ORANGE);\n\nvar link4 = new Link("15", PdfAction.CreateURI("http://123.com"));\nlink4.GetLinkAnnotation().SetBorder(new PdfAnnotationBorder(0, 0, 0));\nlink4.SetTextRise(3).SetFontColor(ColorConstants.ORANGE);\n\n\nvar p1 = new Paragraph();\np1.SetWidth(200f).SetMarginBottom(20).SetTextAlignment(TextAlignment.JUSTIFIED);\np1.Add(text1);\np1.Add(new Text(riseText).SetTextRise(3).SetFontSize(9));\np1.Add(text2);\n\nvar p2 = new Paragraph();\np2.SetWidth(200f).SetTextAlignment(TextAlignment.JUSTIFIED);\np2.Add(text1);\np2.Add(new Text("[").SetTextRise(3).SetFontSize(9))\n .Add(link1.SetFontSize(9))\n .Add(new Text(",").SetTextRise(3).SetFontSize(9))\n .Add(link2.SetFontSize(9))\n .Add(new Text(",").SetTextRise(3).SetFontSize(9))\n .Add(link3.SetFontSize(9))\n .Add(new Text(",").SetTextRise(3).SetFontSize(9))\n .Add(link4.SetFontSize(9))\n .Add(new Text("]").SetTextRise(3).SetFontSize(9));\np2.Add(text2);\n\ndoc.Add(p1);\ndoc.Add(p2);\n\ndoc.Close();\n\nSo my question is how to strictly keep text block (Text + Link) together in one line of Paragraph?\n(For iText5, I think it can be achieved by utilizing Phrase.)"
] | [
"c#",
"itext",
"itext7"
] |
[
"Create a List of objects with for nicely",
"I was wondering what is the nicest way to create a List of objects.\n\nWhat I was able to come up with is either converting the used Range to List:\n\nval objs: List[String] =\n for (i <- 1.to(100).toList)\n yield new String(\"\" + i)\n\n\nor to convert the whole result wit toList:\n\nval objs: List[String] =\n (for (i <- 1 to 100 )\n yield new String(\"\" + i)).toList\n\n\nBut none of them looks smooth enough for me. Is there any easier way to do this? The variable must be of type List because it is used elsewhere in the code I'm playing with. Thanks in advance!"
] | [
"scala",
"scala-collections"
] |
[
"How do I turn sendfile off in a docker instance",
"I have a nginx docker instance running. In the docker instance there is a file called\n/etc/nginx/nginx.conf\n\nIt has the following settings\n\nhttp {\n include /etc/nginx/mime.types;\n default_type application/octet-stream;\n\n log_format main '$remote_addr - $remote_user [$time_local] \"$request\" \n\n access_log /var/log/nginx/access.log main;\n\n sendfile on;\n ....\n}\n\n\nI run the docker instance by running with the following command.\n\ndocker run -d -P -v /Users/user/site:/usr/share/nginx/html --name mysite nginx\n\n\nHow would I run the above command but have it change the config setting to turn off sendfile?\n\nThis answer looks similar to mine. Would I need to create a build file? Im a bit confused."
] | [
"linux",
"nginx",
"configuration",
"docker",
"sendfile"
] |
[
"Unit testing and faking static method using Moq",
"Here is the scenario-\n\nClass 1 is helper class :\n\nclass Helper\n{\n IInterface abc\n {\n // some code in get and set\n get;set;\n }\n public static string Method1(){\n return abc.method();\n }\n}\n\n\nNow I have a controller class that have an action method:\n\npublic virtual string GetStrFromMethod\n{\n get \n {\n return Helper.Method1();\n }\n}\n\npublic ViewResult Action() {\n // here I am calling Method1 like this\n var str = GetStrFromMethod;\n}\n\n\nNow I want to fake the virtual property from test class and hence I am doing this :\n\nvar mock = new Moq<ControllerClass>();\nmock.SetupGet(x => x.GetStrFromMethod).Returns(\"str\");\n\n\nWhen I run this test, I am expecting when the action looks for property GetStrFromMethod , it should return fake value set in moq test. But I am getting following error in helper class abc propertry:\n\n\"The catalog of assemblies have not been set up.\"\n\nI know one way to fake static method is to wrap in virtual method which I have done. What am I missing here ?"
] | [
"c#",
"asp.net-mvc",
"unit-testing",
"moq"
] |
[
"How to update timestamp column moving date forward",
"what I am looking for is some help with a query.\n\nI have a MySql field with unixtime in it representing a date in each of the next few dozen months. I have to move the dates forward to the first day of the next month for each entry in the table.\n\nThe dates are all the 20th of each month, and so I want to move June 20 to July 1, July 20 to August 1, and so on. I can't just add 11 days, because that wouldn't be the first day of the next month when considering months with 31 days and February.\n\nI have been playing with ideas like this:\n\nupdate table set column = UNIX_TIMESTAMP(column + MONTH(column)+1,DAY(1)) where index_column = '1234'\n\n\nbut I am pretty sure that won't work. I could use something like this to convert it, then try to convert it back:\n\nupdate table set column = DATEFORMAT(column,'%Y-$c-%d %H:%i:%s') where index_column == '1234'\n\n\nI still think there has to be a better way. Frankly, I would update the few dozen manually, but I know this will come up frequently, and don't want to have to do it manually every time. \n\nI prefer not to use code, but would instead like to just do it directly into MySql. I hope there is someone out there that can help me figure this out.\n\nThank you in advance."
] | [
"mysql"
] |
[
"How to Migrate Twitter API from v1 to v1.1?",
"till now i was using twitter api v1,but my application suddenly stopped twitting,it shows me login failed every time i try to login,when i show response it gives me msg like\n\n{\"errors\": [{\"message\": \"The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.\", \"code\": 68}]}\n\nthis is written on twiter developer console\n\nDeprecation of v1.0 of the API\n\nMost developers won't need to do much work to transition from v1.0 to v1.1, but we want to make sure there is ample time to do so. We will be providing a 6 month window before turning off v1.0. After retirement (see the platform calendar for dates), the 1.0 endpoints will no longer be available.\n\ni am using twitter4j-core-2.1.11.jar,*signpost-core-1.2.1.1.jar*, & signpost-commonshttp4-1.2.1.1.jar\n\nso i tried to migrate my code from v1 to v1.1,i tried to find solution on twitter developer console regarding this,but could not get a proper way how to do it.\n\nI hope Some one will help me to solve this issue\n\nthanks\n\nISSUE RESOLVED:\nPEOPLE WHO ARE FACING TWITTER API MIGRATION ISSUE CAN DOWNLOAD UPDATED API WORKING TWITTER CODE FROM HERE\n\n-change your consumer key and consumer secret key"
] | [
"android",
"twitter",
"twitter-oauth"
] |
[
"What is the purpose of Woocommerce Rest Api wrapper",
"Please help understanding what's the purpose of woocommerce rest api wrapper.\n\nSince we can access the Woocommerce Rest Api directly by calling endpoints from front end framework like reat/angular, what's the purpose for different Woocommerce Rest Api wrapper like for python, node.js ,php?"
] | [
"wordpress",
"rest",
"woocommerce",
"wordpress-rest-api",
"woocommerce-rest-api"
] |
[
"Ruby: If Values in a hash are equal if statement. Need a hint if possilbe?",
"Hi there: Ruby Beginner.\nSo I'm working on a little exercise.\nI have this\ndonation = {\n "Randy" => 50,\n "Steve" => 50,\n "Eddie" => 9,\n "Bill" => 12\n}\n\ndonation.max_by.first { |name, money| money.to_i }\nname, money = donation.max_by { |name, money| money.to_i }\nputs "#{name} donated the most, at $#{money}!"\n\nBut there's a little bug. "Randy" and "Steve" both donated the max, but it outputs "Randy" (because they're the first in key in the for hash, I assume?) and they get all the credit!\nI'm thinking the way to go is, I need an IF ELSE statement; IF any? of the "money" values are equal, it moves on. Else, it puts the statement.\nSO i guess I am wondering how to compare values?"
] | [
"ruby",
"if-statement",
"hash"
] |
[
"Could it be accomplished in fewer lines of code and when to avoid using control flow?",
"The task was based on the date entered by a user to determine:\n\nWhether the date is valid(proper format, plus the month number to not exceed 12, and the date number not to exceed the number of days that each single month have)\nWhat day of the week that specific day was(or will be)\nWhich day in row of that specific year that day was( or will be)\nWhether that specific year is leap or simple year\nWhich specific day of the week in row of that specific year and month the day enter was(or will be)?!( Example date 2020-12-31, 31 of December 2020 was Thursday and it was 53 Thursday of the year 2020, and 5 th Thursday of the month of December 2020)\n\nI resolved the task successfully, but I'm still excessively using control flow and if statements which it seems to me consume me a lot of lines of codes! Could all of this be accomplished by fewer lines of code and without excessive using of control flow? When is unavoidable to use control flow and when it could be avoided? Here is my code:\nvar flag = false;\nwhile(!flag){\n var anydate = prompt('Enter the date!', anydate);\n let parts = anydate.split('-');\n yyyy = Number(parts[0]);\n mm = Number(parts[1]);\n dd = Number(parts[2]);\nif ((yyyy<0)||(mm<1)||(mm>12)||(dd>31)||(typeof(anydate)==='undefined')||(yyyy%1!==0)|| (mm%1!==0)||(dd%1!==0)||((mm===2)&&(dd>29))||((mm===4)&&(dd>30))||((mm===6)&&(dd>30))||((mm===9)&&(dd>30))||((mm===11)&&(dd>30))){\n alert('Your date is invalid! Please enter valid date!');\n continue;\n flag = false;\n}else{\n alert('OK! You can continue with process!');\n break;\n};\n}\nif (yyyy%4===0){\n alert('This is leap year! The month of February has 29 days!');\n}else{\n alert('This is simple year! The month of February has 28 days!');\n}\nanydate = new Date(anydate);\nvar weekday = new Array(7);\n weekday[0] = "Sunday";\n weekday[1] = "Monday";\n weekday[2] = "Tuesday";\n weekday[3] = "Wednesday";\n weekday[4] = "Thursday";\n weekday[5] = "Friday";\n weekday[6] = "Saturday";\n\n dayoftheweek = weekday[anydate.getDay()]\n d = anydate.getDate();\n m = anydate.getMonth();\n console.log(weekday[anydate.getDay()]);\n console.log(anydate.getMonth()+1);\n console.log(anydate.getDate());\n console.log(anydate.getFullYear());\n console.log(anydate);\n var start = new Date(anydate.getFullYear(), 0, 0);\n var diff = (anydate - start) + ((start.getTimezoneOffset() - anydate.getTimezoneOffset()) * 60 * 1000);\n var oneDay = 1000 * 60 * 60 * 24;\n var day = Math.floor(diff / oneDay);\n alert('This is the day ' + day + ' of the year!');\n var q = Math.floor(day/7)+1;\n q = Number(q);\n var q1 = Math.floor(d/7)+1;\n q1 = Number(q1);\n if(dayoftheweek==='Friday'){\n alert('This is ' + q + ' Friday of the year and ' + q1 + ' Friday of the month ' + mm);\n }else if(dayoftheweek==='Saturday'){\n alert('This is ' + q + ' Saturday of the year and '+ q1 + ' Saturday of the month '+ mm);\n }else if(dayoftheweek==='Sunday'){\n alert('This is ' + q + ' Sunday of the year and '+ q1 + ' Sunday of the month ' + mm);\n }else if(dayoftheweek==='Monday'){\n alert('This is ' + q + ' Monday of the year and '+ q1 + ' Monday of the month ' + mm);\n }else if(dayoftheweek==='Tuesday'){\n alert('This is ' + q + ' Tuesday of the year and '+ q1 + ' Tuesday of the month ' + mm);\n }else if(dayoftheweek==='Wednesday'){\n alert('This is ' + q + ' Wednesday of the year and '+ q1 + ' Wednesday of the month ' + mm);\n }else if(dayoftheweek==='Thursday'){\n alert('This is ' + q + ' Thursday of the year and '+ q1 + ' Thursday of the month ' + mm);\n }else{\n alert('Done!');\n }\n console.log(day);"
] | [
"javascript",
"date",
"if-statement",
"while-loop"
] |
[
"remove tag parent who contain a specific tag",
"I'm trying to delete all <p> who contains <br> tags. I'm using this jQuery code but it's wrong -- the code doesn't want delete br, I need to delete parent who have br.\n\nneed your help, I saw many remove script but it doesn't work.\n\n\r\n\r\njQuery(function($) {\r\n $('#singlecomment54').find('br').each(function() {\r\n $(this).remove();\r\n });\r\n});\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js\"></script>\r\n<div id=\"singlecomment54\" class=\"ql-container ql-disabled\">\r\n\r\n <div class=\"ql-editor\" data-gramm=\"false\" contenteditable=\"false\">\r\n <p>ghjkghjk</p>\r\n <p>GHJK</p>\r\n <p>GHJK</p>\r\n <p><br></p>\r\n <p><br></p>\r\n </div>\r\n\r\n <div class=\"ql-clipboard\" contenteditable=\"true\" tabindex=\"-1\"></div>\r\n</div>"
] | [
"javascript",
"jquery"
] |
[
"Kendo ui inline editing and adding new record don't work in the correct way",
"We are facing some problems with Kendo UI inline grid while adding a new record and editing a record. The problem with adding a new record is the following: when I add a record it is being added to the database but not showing up on the grid until the page is refreshed; in case of editing: the update doesn't take place until the page is refreshed. \nBelow you can see the code I'm using:\n\nvar crudServiceBaseUrl = window.location.href.split('?')[0];\n dataSource = new kendo.data.DataSource({\n transport: {\n read: {\n url: crudServiceBaseUrl + \"/GetList\",\n dataType: \"json\",\n type: \"GET\",\n contentType: \"application/json; charset=utf-8\"\n },\n update: {\n url: crudServiceBaseUrl + \"/Update\",\n dataType: \"json\",\n type: \"POST\", \n contentType: \"application/json; charset=utf-8\", \n complete: function (e) {\n $(\"#grid\").data(\"kendoGrid\").dataSource.read();\n }\n },\n create: { \n url: crudServiceBaseUrl + \"/Create\",\n dataType: \"json\",\n type: \"POST\",\n contentType: \"application/json; charset=utf-8\",\n complete: function (e) {\n $(\"#grid\").data(\"kendoGrid\").dataSource.read();\n }\n },\n parameterMap: function (options, operation) {\n if (operation !== \"read\" && options) { \n return JSON.stringify({ data: options }); \n }\n }\n },\n\n pageSize: 20,\n schema: {\n data: \"d\",\n model: {\n id: \"ListColId\",\n fields: {\n ListColId: { editable: false, nullable: true, type:\"number\" },\n ListId: {type:\"number\"},\n ColumnTitle: { type: \"string\" },\n DataFieldName: { type: \"string\" },\n DataFieldId:{type:\"number\"}, \n Enabled: { type: \"boolean\" },\n Ordering: { type: \"number\" },\n CreatedOn: { type: \"Date\", editable: false }\n }\n },\n type: 'json'\n }\n });\n\n $(\"#grid\").kendoGrid({\n dataSource: dataSource,\n pageable: true,\n height: 550,\n toolbar: [\"create\"],\n columns: [\n {field:\"ListId\",title:\"List ID\"},\n { field: \"ColumnTitle\", title: \"Column Title\", width: \"120px\"},\n { field: \"DataFieldName\", title: \"Data Field name\"}, \n { field: \"Enabled\", title: \"Enabled\", width: \"120px\"},\n { field: \"Ordering\", title: \"Order\", width: \"120px\"},\n { field: \"CreatedOn\", title: \"Created On\", width: \"120px\", format: \"{0:yyyy-MM-dd}\"},\n { command: [\"edit\", \"destroy\"], title: \"&nbsp;\", width: \"250px\" }],\n editable: \"inline\"\n\n\n\n });\n\n\nThank you in advance for helping me out!"
] | [
"kendo-ui",
"kendo-grid",
"inline-editing"
] |
[
"Is it possible to use external libraries in the dialogflow inline editor?",
"I'm using the Dialogflow inline editor and I was wondering if it was possible to use external libraries?\n\nFor example, I was looking to use the Twilio programmable SMS to send an SMS when a certain intent was triggered. I noticed they have their own node.js library which makes what I want to do super simple.\n\n\nI assume if this isn't possible then the next best would be using the Actions SDK and using external libraries?\n\n\nIs this possible?\n\nThanks for any suggestions!"
] | [
"javascript",
"node.js",
"twilio",
"dialogflow-es",
"actions-on-google"
] |
[
"Will replacing the primary key clustered index with another index cause issues?",
"Using SQL Server 2008/2012, I currently have two tables, like so:\n\ntblAccount (accountID BIGINT, accountActive BIT)\n\ntblSite (siteID BIGINT, accountID BIGINT, siteActive BIT)\n\n\nCurrently, accountID on tblAccount is the primary key and a clustered index.\n\nAnd siteID on tblSite is the primary key and clustered index\n\nMost of my queries will take the form:\n\nSELECT <fields>\nFROM <some table> X\nINNER JOIN tblSite s ON s.siteID = X.siteID\nINNER JOIN tblAccount a ON a.accountID = s.accountID\nWHERE \n x.<field> = SOMETHING \n AND a.accountActive = 1 \n AND s.siteActive = 1\n\n\nMy understanding, is that to optimise these queries, it would be better to put new clustered indexes on tblAccount and tblSite. \n\nSomething like:\n\nCREATE CLUSTERED INDEX ON tblAccount (accountActive,accountID) WITH .....\n\nCREATE CLUSTERED INDEX ON tblSite (siteActive,siteID) WITH .....\n\n\nObviously, to do this, I'll have to drop the PK clustered indexes for both tables. \n\nIs there a possibility that this could cause issues further down the line? As I'm assuming (taking the account table) the table is now optimised for \n\nSELECT * \nFROM tblAccount \nWHERE accountID = X \n AND accountActive = Y\n\n\nso just doing \n\nSELECT * \nFROM tblAccount \nWHERE accountID = X\n\n\nwill be highly unoptimised?\n\nThere are two other indexes I've created on the account table, I don't know how much these will have an impact on the above indexes & queries:\n\nCREATE UNIQUE NONCLUSTERED INDEX idx_account_session \n ON tblAccount (accountSessionKey,accountActive,accountAffirmed,accountLastAction) \n INCLUDE (accountID) \n WITH (STATISTICS_NORECOMPUTE=OFF,SORT_IN_TEMPDB=ON,FILLFACTOR=80)\n\nCREATE NONCLUSTERED INDEX idx_account_login \n ON tblAccount (accountEmail,accountPassword,accountAffirmed,accountActive) \n INCLUDE (accountID,accountSaltHash) \n WITH (STATISTICS_NORECOMPUTE=OFF,SORT_IN_TEMPDB=ON,FILLFACTOR=80)\n\n\nI've put these on to optimise the authentication stored procedures.\n\nMany thanks for your help."
] | [
"sql",
"sql-server",
"join",
"indexing"
] |
[
"How to get a complete (eager) match with module Str in OCaml",
"For hours I am trying to find the right function for this standard problem, example in Tcl shell:\n\nstr@suse131-intel:~> tclshi\n% regexp -inline {[0-9]+} \"I am trying this for the 1001. time!!\"\n1001\n%\n\n\nI have tried quite a lot, and I can find the start and end of the match, but this can't be it! I only get a minimal match, not an eager match. Am I supposed to pick the match out by hand, so to say? Ocaml interactive:\n\n# let s1 = \"this is the 1001. time I am trying this.\";;\nval s1 : string = \"this is the 1001. time I am trying this.\"\n# search_forward (regexp \"[0-9]+\") s1 0;;\n- : int = 12\n# group_beginning 0;;\n- : int = 12\n# group_end 0;;\n- : int = 16\n\n\nSub question: all these functions referring to the last match (\"returns the substring of s that was matched by the last call to one of the following\" as the doc says) like matched_string do not look very FP, but exactly the opposite. I this reentrant and task switch save code?\n\nEdit: In my session yesterday I only got one number back. Now I wanted to copy the strange behavoir into this question, but it is working fine. The problem was maybe a mixup of different let definitions.\n\nComplete example:\n\n# #require \"str\";;\n/usr/lib64/ocaml/str.cma: loaded\n# open Str;;\n# let s1 = \"this is the 1001. time I am trying this.\";;\nval s1 : string = \"this is the 1001. time I am trying this.\"\n# search_forward (regexp \"[0-9]+\") s1 0;;\n- : int = 12\n# matched_string s1;;\n- : string = \"1001\""
] | [
"regex",
"ocaml"
] |
[
"Memory layout in Java",
"I went through a Java test at my high school. One question bothered me too much as I was blank as how would I solve it.\n\nConsider the following Java code:\n\ninterface Pingable {\n public void ping();\n}\n\nclass Counter implements Pingable {\n int count=0;\n public void ping(){++count;}\n public int val(){return count;}\n}\n\npublic class Ping {\n public static void main(string args[])\n {\n Counter c=new Counter();\n c.ping();c.ping();\n int v=c.val();\n System.out.println(v);\n } \n}\n\n\nAssume that this is to be compiled to native code on a machine with 4 byte addresses. Draw a picture of the layout in memory for counter object. Show all virtual function tables."
] | [
"java",
"interface",
"memory-layout"
] |
[
"How can I get VSCode to connect to Xdebug with Docker",
"PHP version: 7.2\nXdebug version: 2.6.0\nAdapter version: 1.12.1\nExample Repo: https://github.com/makeshift3ds/vscode-xdebug-docker\n\nI am having trouble getting VSCode to connect to Xdebug running in Docker. I've followed examples and tutorials but feel like something is missing. \n\nNotes:\n- if I start the debugger in VSCode, the debugger output says success: true in the object. But the xdebug logs in the docker container show no activity. However, if I run the PHP script from the php-fpm container Xdebug logs look healthy.\n\nLog opened at 2018-03-13 15:29:11\nI: Checking remote connect back address.\nI: Checking header 'HTTP_X_FORWARDED_FOR'.\nI: Checking header 'REMOTE_ADDR'.\nI: Remote address found, connecting to 172.18.0.1:9001.\nI: Connected to client. :-)\n-> <init xmlns=\"urn:debugger_protocol_v1\" xmlns:xdebug=\"http://xdebug.org/dbgp/xdebug\" fileuri=\"file:///var/www/html/index.php\" language=\"PHP\" xdebug:language_version=\"7.2.3\" protocol_version=\"1.0\" appid=\"7\" idekey=\"VSCODE\"><engine version=\"2.6.0\"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>\n\n-> <response xmlns=\"urn:debugger_protocol_v1\" xmlns:xdebug=\"http://xdebug.org/dbgp/xdebug\" status=\"stopping\" reason=\"ok\"></response>\n\nLog closed at 2018-03-13 15:29:11\n\n\n\nif I attempt a connection in VSCode and try to evaluate some code it says there is no connection.\nphp-fpm is running on port 9000 so I setup Xdebug on 9001. I can see the ports are open.\n\n\n-\n\nvpnkit 59029 makeshift 19u IPv4 0x7784b9d434951b53 0t0 TCP *:9001 (LISTEN)\nvpnkit 59029 makeshift 20u IPv6 0x7784b9d42c30a203 0t0 TCP [::1]:9001 (LISTEN)\nCode\\x20Helper 99786 makeshift 27u IPv6 0x7784b9d42c30bec3 0t0 TCP *:9001 (LISTEN)"
] | [
"php",
"docker",
"visual-studio-code",
"xdebug"
] |
[
"Copying NSDictionary value in UITextview",
"I have the following code, where the global variable var fullDict = \"\" stores dictionary of values.\n\nlet resultsArray = dicData[\"value\"] as! NSDictionary\nfor (x, y) in resultsArray {\n self.fullDict += \"(\\(x): \\(y))\\n\"\n}\n\n\nI want to print this value as it is in UITextview. I tried, \n\nuserResult_txtView.text = self.fullDict\n\n\nbut, this is showing build error as \"use of unresolved identifier userResult_txtView\" and also \"use of unresolved identifier self\" \n\nCould you please tell me how to copy that value (self.fullDict) in UITextview? I am using Swift 3.\n\nCode starts like this,\n\nclass ViewController: UIViewController {\n\n @IBOutlet var table:UITableView!\n @IBOutlet var userID_txtField:UITextField!\n @IBOutlet var userName_txtField:UITextField!\n @IBOutlet var userAccountNo_txtField:UITextField!\n @IBOutlet var userAccType_txtField:UITextField!\n @IBOutlet var userAccAddress_txtField:UITextField!\n @IBOutlet var userResult_txtView:UITextView!\n\n var mainArray:[Any] = []\n var fullDict = \"\"\n\n override func viewDidLoad() {\n super.viewDidLoad()"
] | [
"ios",
"swift"
] |
[
"Make an api with node.js",
"I have tried build an api using node.js (+express). \nThe Firefox display it but when I try to load it with loadJSON from p5.js it shows weird error.\nHere is node.js code (based on this: modulus: create api with node.js ):\n\nexpress = require(\"express\");\napp = express();\napp.listen(4000);\n\nvar quotes = [\n { author : 'Audrey Hepburn', text : \"Nothing is impossible, the word itself says 'I'm possible'!\"},\n { author : 'Walt Disney', text : \"You may not realize it when it happens, but a kick in the teeth may be the best thing in the world for you\"},\n { author : 'Unknown', text : \"Even the greatest was once a beginner. Don't be afraid to take that first step.\"},\n { author : 'Neale Donald Walsch', text : \"You are afraid to die, and you're afraid to live. What a way to exist.\"}\n];\n\n\napp.get('/', function(req, res){\n res.json(quotes);\n})\n\n\np5.js:\n\nfunction setup() {\n loadJSON(\"http://localhost:4000/\", getJson, error1);\n}\n\nfunction getJson(data) {\n console.log(\"json get\");\n console.log(data)\n}\n\nfunction error1(err) {\n console.log(\"Error: \");\n console.log(err);\n}\n\n\nError:\n\n\"Error: \"\n{\n \"statusText\": \"\",\n \"status\": 0,\n \"responseURL\": \"\",\n \"response\": \"\",\n \"responseType\": \"\",\n \"responseXML\": null,\n \"responseText\": \"\",\n \"upload\": {\n \"ontimeout\": null,\n \"onprogress\": null,\n \"onloadstart\": null,\n \"onloadend\": null,\n \"onload\": null,\n \"onerror\": null,\n \"onabort\": null\n },\n \"withCredentials\": false,\n \"readyState\": 4,\n \"timeout\": 0,\n \"ontimeout\": null,\n \"onprogress\": null,\n \"onloadstart\": null,\n \"onloadend\": null,\n \"onload\": null,\n \"onerror\": null,\n \"onabort\": null\n}\n\n\nI have tried using 'jsonp' but it shows this:\n\n5209: Uncaught TypeError: Cannot read property 'responseText' of undefined\n\n\nI have node.js v4.2.2 and p5.js v0.5.4 October 01, 2016."
] | [
"node.js",
"p5.js"
] |
[
"How can I add user defined metadata in TensorFlow.js model?",
"I saw the API getUserDefinedMetadata in the client-side of TensorFlow.js.\nBut I could not find the API to set metadata in the converter-side of TensorFlow.js.\nHow can I add user defined metadata?"
] | [
"tensorflow.js"
] |
[
"How to send password while using ssh command in os.system?",
"For example, I have the code below:\n\ncmd = \"ssh <host>\"\nos.system(cmd)\n\n\nHow I can send the password in the python script so that I don't have to type the password every time?"
] | [
"python",
"ssh"
] |
[
"clicking function in android",
"How do I apply clicking action on listview in android?"
] | [
"android"
] |
[
"FbxAnimCurve has different behavior between SDK 2016 and 2009 version",
"I upgraded my FBX SDK to 2016, but got a bug.\n\nOld code is:\n\nKFbxCamera * FBXPopulator::GetActiveCamera( KTime & a_Time ) const\n{\n KFbxCameraSwitcher* cameraSwitcher = m_Scene->GetGlobalCameraSettings().GetCameraSwitcher();\n if ( cameraSwitcher )\n {\n KFCurve* curve = cameraSwitcher->CameraIndex.GetKFCurve( NULL, m_Scene->GetCurrentTakeName() );\n if ( curve )\n {\n int32_t index = static_cast< int32_t >( curve->Evaluate( a_Time ) - 1 );\n return m_DeclaredCameras[ index ]->GetCamera();\n }\n }\n return NULL;\n}\n\n\nCurrent code is:\n\nFbxCamera * FBXPopulator::GetActiveCamera(FbxTime & a_Time) const\n{\n FbxCameraSwitcher* cameraSwitcher = m_Scene->GlobalCameraSettings().GetCameraSwitcher();\n if (cameraSwitcher)\n {\n //Is it right here?\n FbxAnimCurve* curve = cameraSwitcher->CameraIndex.GetCurve(m_Scene->GetCurrentAnimationStack()->GetMember());\n if (curve)\n {\n int32_t index = static_cast< int32_t >(curve->Evaluate(a_Time) - 1);\n return m_DeclaredCameras[index]->GetCamera();\n }\n }\n return NULL;\n}\n\nIs it wrong?\n\nI got index == 0 in 2009 version while index == 1 in 2016 version.\n\nAny suggestions?\nThank you!"
] | [
"fbx"
] |
[
"NumPy array iterator: use nditer or not?",
"I'm new to Python. I understand that there are two ways to iterate through a numpy array.\n\nFirst way, \n\na = np.array([1,2,3,4,5])\nfor i in a:\n print i\n\n\nSecond way,\n\na = np.array([1,2,3,4,5])\nfor i in np.nditer(a):\n print i\n\n\nIf i don't need any fancy utilities provided by nditer, does it matter which way to choose? nditer's manual page is helpful, but it doesn't explain my question. I guess the first way is syntactic sugar of the second way? I'd like confirmation from you guys."
] | [
"python",
"arrays",
"numpy",
"iterator"
] |
[
"checkbox condition leads to another page",
"I want to create conditions on the checkbox.\n\nif you select 1 then it will be to his next page\nIf you select 2 and 3 it will be to a thank you page\n\ncan help me\n\n <input type=\"checkbox\" name=\"number[]\" id=\"\" value=\"1\">1 <br />\n<input type=\"checkbox\" name=\"number[]\" id=\"\" value=\"2\">2 <br />\n<input type=\"checkbox\" name=\"number[]\" id=\"\" value=\"3\">3\n\n<?php\nif (\n (\n ($number == '1') && ($number == '2')\n ) \n || \n (\n ($number == '1') && ($number == '3')\n ) \n || \n (\n ($number == '1') && ($number == '2') && ($number == '3')\n )\n )\n\n {\n header(\"Location: next.php\"); /* Redirect browser */\n } else {\n header(\"location: thank-you.php\");\n }"
] | [
"php"
] |
[
"EOFException in objectinputstream readobject",
"i want to make a server client application. i set everything up and i get this error. i want the app to wait till i get more data.\n\njava.io.EOFException\nat java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Source)\nat java.io.ObjectInputStream.readObject0(Unknown Source)\nat java.io.ObjectInputStream.readObject(Unknown Source)\n\n\non the line:\n\nlistener.Received(inputstream.readObject(), id.ID);\n\n\nServer code:\n\nisrunning = true;\n Thread input = new Thread(new Runnable(){\n @Override\n public void run() {\n try{\n ServerSocket Server = new ServerSocket(LocalPort);\n while(isrunning){\n Socket socket = Server.accept();\n ObjectOutputStream outputstream = new ObjectOutputStream(socket.getOutputStream());\n ObjectInputStream inputstream = new ObjectInputStream(socket.getInputStream());\n Object obj = inputstream.readObject();\n if(obj instanceof ID){\n ID id = (ID) obj;\n if(connctedChecker(id.ID)){\n ID myid = new ID(ID, LocalIP, LocalPort);\n outputstream.writeObject(myid);\n connect(id.IP, id.Port);\n listener.Connected(id.ID);\n do{\n listener.Received(inputstream.readObject(), id.ID);\n }while(socket.isConnected());\n listener.Disconnected(id.ID);\n closeConnection(id.ID);\n }\n }\n inputstream.close();\n outputstream.close();\n socket.close();\n }\n Server.close();\n }catch(Exception e){\n e.printStackTrace();\n }\n\n }\n });\n input.start();\n\n\nClient code:\n\noutput = new Thread(new Runnable(){\n @Override\n public void run(){\n try {\n socket = new Socket(RemoteIP, RemotePort);\n inputstream = new ObjectInputStream(socket.getInputStream());\n outputstream = new ObjectOutputStream(socket.getOutputStream());\n ID id = new ID(ID, LocalIP, LocalPort);\n outputstream.writeObject(id);\n outputstream.flush();\n Object obj = inputstream.readObject();\n if(obj instanceof ID){\n ID inid = (ID) obj;\n RemoteID = inid.ID;\n }\n while(socket.isConnected()){\n Object object = queue.take();\n outputstream.writeObject(object);\n outputstream.flush();\n }\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n\n\nthe listener:\n\npublic class Listener {\n\npublic void Connected(UUID ID){\n\n}\n\npublic void Received(Object object, UUID ID){\n\n}\n\npublic void Disconnected(UUID ID){\n\n}\n\n}"
] | [
"java",
"objectinputstream",
"eofexception"
] |
[
"Atomic swap function using gcc atomic builtins",
"Is this a correct implementation for a generic atomic swap function? I'm looking for a C++03-compatible solution on GCC.\n\ntemplate<typename T>\nvoid atomic_swap(T & a, T & b) {\n static_assert(sizeof(T) <= sizeof(void*), \"Maximum size type exceeded.\");\n T * ptr = &a;\n b =__sync_lock_test_and_set(ptr, b);\n __sync_lock_release(&ptr);\n}\n\n\nIf not, what should I do to fix it?\n\nAlso: is the __sync_lock_release always necessary? When searching through other codebases I found that this is often not called. Without the release call my code looks like this:\n\ntemplate<typename T>\nvoid atomic_swap(T & a, T & b) {\n static_assert(sizeof(T) <= sizeof(void*), \"Maximum size type exceeded.\");\n b = __sync_lock_test_and_set(&a, b);\n}\n\n\nPS: Atomic swap in GNU C++ is a similar question but it doesn't answer my question because the provided answer requires C++11's std::atomic and it has signature Data *swap_data(Data *new_data) which doesn't seem to make sense at all for a swap function. (It actually swaps the provided argument with a global variable that was defined before the function.)"
] | [
"c++",
"atomic"
] |
[
"Java - while loop for scanner validation results in failed input",
"I am trying to add the following scanner validation as follows;\n\npublic void promptFilmRating() {\n while (!filmScanner.hasNextInt()) {\n System.out.println(\"Please enter a number instead of text.\");\n filmScanner.next();\n }\n while (filmScanner.nextInt() > 5 || filmScanner.nextInt() < 1) {\n System.out.println(\"Your number is outside of the rating boundaries, enter a number between 1 and 5.\");\n filmRatingOutOfFive = filmScanner.nextInt();\n }\n\n}\n\n\nHowever when using the code that relates to the integer between value validation, repeated inputs are needed in order to record the original input and I am unsure on how to correct this, any advice would be fantastic."
] | [
"java",
"class",
"intellij-idea",
"while-loop",
"java.util.scanner"
] |
[
"error when searching posts from my database",
"I'm getting an error when I am searching through my database for certain posts.\nit says this: Trying to get property 'title' of non-object on line 83\nBelow is the bit of code it refers to, I'm fairly new to PHP and PDO so bear with me.\n$search = '%post%';\n$sql = 'SELECT * FROM pages WHERE title LIKE ?';\n$stmt = $conn->prepare($sql);\n$stmt->execute([$search]);\n$pages = $stmt->fetchAll();\n\nforeach($pages as $page){\necho $page->title . '<br>' ;\n}"
] | [
"php",
"database",
"pdo"
] |
[
"Entity Framework: Add Unique Constraint to existing property",
"I have an existing model, SomeModel, which contains a property Prop. I'd like to enforce that the values of Prop be unique.\n\nTo this end, I'm adding the following to my model:\n\npublic static void OnModelCreating(ModelBuilder modelBuilder)\n{\n modelBuilder.Entity<SomeModel>()\n .HasAlternateKey(a => a.Prop);\n}\n\n\nbut ef migrations isn't picking up the change.\n\nHow can I correct this?"
] | [
"entity-framework",
"entity-framework-core"
] |
[
"How to navigate back main page gpicontroller task use other machine",
"Pleas explain where can we put in program. \n\nNavigationCacheMode = NavigationCacheMode.Required;\nFrame.navigate(typeof(otherpage));"
] | [
"uwp",
"gpio"
] |
[
"Reading/writing of reference typed field by multiple threads WITHOUT lock",
"Context: highly threaded server-side application with many reads, occasional writes.\n\nLet us consider the following simple code:\n\n[Serializable]\npublic class BusinessObject\n{\n // ... lot's of stuff, all READ ONLY!!!\n}\n\npublic class BusinessObjectHost\n{\n private BusinessObject bo;\n public BusinessObject BO\n {\n get { return this.bo; }\n set { this.bo = value; }\n }\n\n}\n\n\nThe intended use is as follows: The BusinessObject is immutable. If I occasionally want to change it, I just need to replace BusinessObjectHost.bo field with a new instance. \n\nQ1: What happens if I do not apply any lock in BusinessObjectHost.BO property and there is a thread conflict between read and write on BusinessObjectHost.bo field? \nWill the thread throw exceptions? If yes, which one? \n\nQ2: If thread crash causes exception, would the following code work?\n\npublic class BusinessObjectHost\n{\n private BusinessObject bo;\n public BusinessObject BO\n {\n get \n { \n int i = 5; // Max 5 tries\n while (i-- > 0)\n {\n try { return this.bo; }\n catch (WhateverThreadConflictException) {}\n }\n throw new MyException(); \n }\n set \n { \n int i = 5; // Max 5 tries\n while (i-- > 0)\n {\n try { this.bo = value; return; }\n catch (WhateverThreadConflictException) {}\n }\n throw new MyException(); \n }\n }\n\n}\n\n\nQ3: If the above solution is not good, what would you recommend?"
] | [
".net",
"multithreading",
"locking"
] |
[
"While loop not catching (Java)",
"See title.\nWhen i enter the pin 02020 or any 5 digit number starting with 0, I get this back:\n\nPIN 2020 accepted!\n\n\nMy code should be catching this with a while loop and asking for the pin again. Why isn't it?\n\nCode:\n\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n System.out.println(\"Enter 4 Digit 1111PIN: \");\n Scanner keyboard = new Scanner(System.in);\n int pin = keyboard.nextInt();\n int lengththing = String.valueOf(pin).length();\n while(lengththing < 4 || lengththing > 4) {\n System.out.println(\"Incorrect pin. Re-enter PIN: \");\n pin = keyboard.nextInt();\n lengththing = String.valueOf(pin).length();\n }\n System.out.println(\"PIN \" + pin + \" accepted! Welcome retr0_err!\");\n //Joke username\n }\n}\n\n\nThanks in advance!"
] | [
"java"
] |
[
"Sequelize - Foreign key that references same table primary key",
"Is it possible to construct the following in Sequelize model syntax? The use being you want to have nested data.\n\nCREATE TABLE Data\n(\n `id` INT AUTO_INCREMENT PRIMARY KEY,\n ...\n `parentId` INT,\n FOREIGN KEY(parentId) REFERENCES Data(id)\n);\n\n\nEDIT: Yes it is\n\nconst Data = sequelize.define('Data', {\n id: {\n type: Sequelize.INTEGER,\n primaryKey: true,\n autoIncrement: true,\n },\n})\n\nData.belongsTo(Data, { foreignKey: 'id' });"
] | [
"sequelize.js"
] |
[
"Item cannot be found in the collection corresponding to the requested name or ordinal error",
"I've looked at a bunch of posts regarding this error, but can't find a solution to handle my issue. Here's what I'm facing:\n\nSub test()\n Initialize\n Query_Run \"select distinct([key status]) from controls\"\nEnd Sub\n\nFunction Query_Run(qstring)\n Set rs = New ADODB.Recordset\n Application.ODBCTimeout = 120\n rs.Open qstring, Cn, adOpenStatic\nEnd Function\n\n\nInitialize creates a new connection to the database.\n\nQuery_Run creates a new record set and runs the sql query to store whatever the query would return. However, it is giving me the error mentioned in the title. \n\nI've used Query_Run in numerous other areas in the project and it still works, but anything new I write gets the error mentioned in the title. [key status] exists and isn't misspelled, same with controls. Not sure what I'm missing here."
] | [
"sql",
"vba"
] |
[
"Java heap space when adding documents to List of documents",
"I am using import org.w3c.dom.Document; for document.\n\nI have this block of code that parses the xml file from the arraylist fileList, there are more than 2000 xml files to be parsed and size of the xml files are around 30-50 Kb, I have no problem parsing the files:\n\n try {\n for(int i = 0; i < fileList.size(); i++) {\n DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();\n DocumentBuilder builder = factory.newDocumentBuilder();\n Document doc = builder.parse(fileList.get(i)); //<------ error will point here when docList.add(doc) is uncommented.\n docList.add(doc); \n }\n } catch (ParserConfigurationException | SAXException | IOException e) {\n e.printStackTrace();\n }\n\n\nbut whenever I add them to the list this error comes up:\n\nException in thread \"main\" java.lang.OutOfMemoryError: Java heap space\n at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.createChunk(Unknown Source)\n at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.ensureCapacity(Unknown Source)\n at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.createNode(Unknown Source)\n at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.createDeferredTextNode(Unknown Source)\n at com.sun.org.apache.xerces.internal.parsers.AbstractDOMParser.characters(Unknown Source)\n at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)\n at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)\n at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)\n at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)\n at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)\n at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)\n at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)\n at com.test.parser.Parser.getDocs(Parser.java:146)\n at com.test.parser.Parser.main(Parser.java:50)\n\nuncommenting the docList.add(doc) does not produce this exception, any idea why this is happening?\n\nEDIT: I added -Xmx1024M to VMArguments in Run Configurations and it worked."
] | [
"java",
"xml",
"out-of-memory"
] |
[
"Tensorflow installation from source for tensorflow.examples.learn modules",
"The above said modules are not build into the site-packages. I am using Python3.5 for it, and followed all the steps for the building from the source, that are given on the website.\n\nI did search on the Internet, but there is no apparent solution found.\n\nThe following is the configuration used during ./configure:\n\n./configure\n..................\nYou have bazel 0.5.2 installed.\nPlease specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3\nFound possible Python library paths:\n /usr/lib/python3/dist-packages\n /usr/local/lib/python3.5/dist-packages\nPlease input the desired Python library path to use. Default is [/usr/lib/python3/dist-packages]\n\nUsing python library path: /usr/lib/python3/dist-packages\nDo you wish to build TensorFlow with MKL support? [y/N] y\nMKL support will be enabled for TensorFlow\nDo you wish to download MKL LIB from the web? [Y/n] Y\nmklml_lnx_2018.0.20170425.tgz\nPlease specify optimization flags to use during compilation when bazel option \"--config=opt\" is specified [Default is -march=native]: \nDo you wish to use jemalloc as the malloc implementation? [Y/n] y\njemalloc enabled\nDo you wish to build TensorFlow with Google Cloud Platform support? [y/N] y\nGoogle Cloud Platform support will be enabled for TensorFlow\nDo you wish to build TensorFlow with Hadoop File System support? [y/N] y\nHadoop File System support will be enabled for TensorFlow\nDo you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] y\nXLA JIT support will be enabled for TensorFlow\nDo you wish to build TensorFlow with VERBS support? [y/N] y\nVERBS support will be enabled for TensorFlow\nDo you wish to build TensorFlow with OpenCL support? [y/N] n\nNo OpenCL support will be enabled for TensorFlow\nDo you wish to build TensorFlow with CUDA support? [y/N] n\nNo CUDA support will be enabled for TensorFlow\nDo you wish to build TensorFlow with MPI support? [y/N] n\nMPI support will not be enabled for TensorFlow\nConfiguration finished\n\n\nAfter which I proceed with the steps given in the following website: https://www.tensorflow.org/install/install_sources#ConfigureInstallation\n\nI am using Ubuntu 16.04 LTS 64 bit.\n\nThere are no error messages, just the modules are not getting built for using! This: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/learn \n\nI want to understand the text_classification code by running it, so I had to install tensorflow from source, but in the site-packages/tensorflow, these modules are not there.\n\nI want to understand why such thing happened, even when I did the steps right."
] | [
"tensorflow",
"bazel"
] |
[
"How to create link in in jquery?",
"I need like following\n\n <td>\n <a href=\"/Employee/Edit/1001320\">Edit</a> |\n </td>\n\n\nI wrote like following\n\nvar employeeaction = $('<td>').append('<a href=\"/Employee/Edit/'\n +element.id+'\">Edit</a> |');\n\n\nI parse table by the following code and took element.id\n\n$('#EmployeeTable tr:not(:nth-child(1), :nth-child(2))').each(function () {\n // alert($(this).find('td').eq(0).text());\n var employee = {};\n employee.id = $(this).find('td').eq(0).text();\n employee.presenAddress = $(this).find('td').eq(1).text();\n employee.shortName = $(this).find('td').eq(2).text();\n employee.mobileNumber = $(this).find('td').eq(3).text();\n employee.department = $(this).find('td').eq(4).text();\n employee.designation = $(this).find('td').eq(5).text();\n employee.action = $(this).find('td').eq(6).text();\n employeeList.push(employee);\n }); \n\n\nwhen I click in it it gives me like \n\n\n localhost:10845/Employee/Edit/%201001097\n\n\nI need \n\n\n localhost:10845/Employee/Edit/1001097\n\n\nBut it is not working. How can I do it?"
] | [
"javascript",
"jquery"
] |
[
"AttributeError: 'ResourceSummaryWriter' object has no attribute 'get_logdir'",
"I am trying to run some code written in tensorflow v1.0 in tensorflow 2.1 library package. So I have to rewrite some of the code. I have been facing some problem with one line of the codes\n\nLOG_DIR='./'\nsummary_writer = tf.summary.FileWriter(LOG_DIR)\n\n\nnow I understand that in v2.0, tf.summary has been deprecated and I was to write the new code instead\n\nsummary_writer = tf.summary.create_file_writer(LOG_DIR) \n\n\nbut whenever i start to run \n\nlogdir = summary_writer.get_logdir()\n\n\nIt gives me an error of \n\nAttributeError: 'ResourceSummaryWriter' object has no attribute 'get_logdir'\n\n\nI search around and found no solution. What can be the problem? Isn't it just stating the LOG_DIR (which I have done)\n\nRegards"
] | [
"python",
"tensorflow"
] |
[
"cakephp with external View files",
"I am required to employ webEdition as the CMS for a web presence, which shall contain a form realised with CakePHP.\n\nUnfortunately, both systems employ directory structures, which are incompatible with each other: CakePHP requires an \"app\"-folder with several subfolders, \"Model\", \"View\", \"Controller\", whereas webEdition provides (php) template files, from which the frontend (html) files are generated via a http-backend that must stay functional (as it is the point of using webEdition in the first place).\n\nAs such, while I can put the model and controller files into their respective CakePHP-folders, I need to write the view code into the webEdition templates. CakePHP offers configuration files to move its whole \"app\"-folder into arbitrary places, but this is arguably not what I require.\n\nTo summarise, the situation looks as follows:\n\n\nwebEdition needs the templates to go to [webroot]/webedition/we/templates/[file].php\nCakePHP needs the View files to go to [arbitrary]/app/View/[controller name]/[file].[extension]\nthe View code must go into the template\nreferences to the View code must reference the published files [webroot]/[file].html\n\n\nObviously these requirements are incompatible. Mayhap my understanding is wrong to begin with, but even if not, there should (hopefully) exist an alternate way to realise this."
] | [
"cakephp"
] |
[
"Simple click counter with php and js",
"Trying to make a very simple counter which updates the value in a mysql database table by 1 each time a user clicks on a link. \n\n<a href='http://somesupersite.com' id='246' class='track'>My Link</a>\n\n\nThe javascript that should get the id and pass it to the php script:\n\n$(document).ready(function(){\n$('a.track').click(function() {\n$.post('http://mysupersite.com/sys/tracker.php', {id:this.id});\n});\n});\n\n\nThe php script tracker.php should get the post variable and update the mysql database table column:\n\n$id = $_POST['id'];\n$con = mysqli_connect($mysqlHost, $mysqlUser, $mysqlPassword, $mysqlDatabase);\nmysqli_query($con, \"UPDATE table SET clicks = clicks + 1 WHERE id = $id\");\n\n\nI don't get any errors but the database does not update either."
] | [
"php",
"jquery",
"mysql",
"click",
"counter"
] |
[
"How to replace 'special' characters in a string of code with an expanded piece of that same code?",
"I'm creating a chrome extension that basically finds a string of text such as this (note the different numbers):\n\nid%22%3A99986%2C%22name%22%3A%22null%22%7D%2C%7B%22id%22%3A1002938%2C%22name%22%3A%22null%22%7D%2C%7B%22\n\n\nand then usese javascript to swap that text above with this:\n\nid%22%3A77764%2C%22name%22%3A%22null%22%7D%2C%7B%22id%22%3A77984%2C%22name%22%3A%22null%22%7D%2C%7B%22id%22%3A87746%2C%22name%22%3A%22null%22%7D%2C%7B%22\n\n\nI can't manage to make this work whatsoever. All I'm able to do is swap out the ID numbers and replace individual parts of the code whereas I want to improve it by replacing with larger pieces of code. Can someone help me get past this because I'm confused. \n\nHere is the code that works for me:\n\ndocument.body.innerHTML = document.body.innerHTML.replace(/99986/g, '77764');\n\n\nWhat I'm trying to do is to replace one piece of code with two pieces of code (obviously wrong but it's clear what I'm trying to do):\n\ndocument.body.innerHTML = document.body.innerHTML.replace(/id%22%3A99986%2C%22name%22%3A%22null%22%7D%2C%7B%22/g, 'id%22%3A77764%2C%22name%22%3A%22null%22%7D%2C%7B%22id%22%3A77984%2C%22name%22%3A%22null%22%7D%2C%7B%22');\n\n\nUpdate 1:\n\nThank you Emeeus, your code worked great! Unfortunately I made an error in my example so I had to fix it up a bit from my end. This is the new code using your layout:\n\n var strA = \n\"%7Bid%22%3A1001%2C%22name%22%3A%22The+Antique+Store%22%7D%2C%7B%22id%22%3A1010%2C%22name%22%3A%22Clothes%22%7D%2C%7B%22id%22%3A1349%2C%22name%22%3A%22Old+Store%22%7D\";\n\n var strB = \"%7Bid%22%3A1001%2C%22name%22%3A%22The+Modern+Store%22%7D%2C%7B%22id%22%3A1010%2C%22name%22%3A%22Clothes%22%7D%2C%7B%22id%22%3A1349%2C%22name%22%3A%22New+Store%22%7D\";\n\n var arrA = JSON.parse(decodeURIComponent(',{\"\"' + strA + '\",:\"\"}'));\n\n var arrB = JSON.parse(decodeURIComponent(',{\"\"' + strB + '\",:\"\"}'));\n\nconsole.log(arrA)\nconsole.log(arrB)\n\nvar res = Object.assign(arrA, arrB);\n\nconsole.log(encodeURIComponent(JSON.stringify(res)))\n\n\nBut I'm met with this error \"Error: Unexpected token , in JSON at position 0\". Any ideas?"
] | [
"javascript",
"replace",
"google-chrome-extension"
] |
[
"How to scroll PyGTK ScrolledWindow to a certain row of a nested table?",
"I have a program in PyGTK which has a ScrolledWindow and a Table nested in it. The table rows can be of a different height. What I'm trying to find is a way to scroll the view so it begins from the selected row. I know how to move the scrollbar to a certain position using the scrolled_window.get_vadjustment().set_value(), but I do not know how to find the scroll position of the table rows.\n\nAlternatively, maybe I'm using wrong widget and someone can point me to the right one? I'm trying to achieve the following behaviour: the screen shows the rows of a table, the top row is the currently selected object, when the user presses up or down buttons, the whole table scrolls down or up, so the previous or the next row becomes the top row."
] | [
"pygtk",
"scrolledwindow"
] |
[
"RX getting a IObservable> to an IObservable",
"I'm pretty new to RX and cannot figure this out.\n\nI have an IObservable<List<T>> where List<T> is guaranteed to have one element.\n\nHow do I convert this to an IObservable<T>.\n\nI thought it would have something to do with Single but that is listed as obsolete, and also doesn't return an IObservable<T> anyway (as pretty sure it would return the Single List<T> element.\n\nIs there some SelectMany magic I can do here?"
] | [
"c#",
".net-4.5",
"system.reactive"
] |
[
"Live Audio Streaming from Webpage",
"I am working on a Swing radio project in which the user types in a URL, and my Java Program will take live audio from the given link and play it live for the user. The issue is that the user may type in a live radio URL that may not be formatted as an .mp3/.wav/.aiff file, it could just be a website-link that plays audio when launched through an online media player, such as in BBC Radio One (http://www.bbc.co.uk/radio/player/bbc_radio_one). \n\nI have tried the Java Sound API, however, it only supports URLs that are directed to music files (ex. foo.com/bar.wav/). The sound API cannot support URLs such as http://www.bbc.co.uk/radio/player/bbc_radio_one because they are not audio files. If you were to go to the BBC Radio One link, you would find that it automatically starts playing live audio. That live audio is what I'd like to have played in my Java program. \n\nOn StackOverflow, I had found people who had similar issues to mine, but they were using .mp3/.wav/.aiff/ etc URLs, which is good, but does not work for me.\n\nI had also found a page on Program Creek that had shown multiple methods of playing audio through URLs. I had tried to use many of the examples on there, but none of them would work because of either the format of my URL or Stream Errors. For instance, I had slightly modified one of the methods (from example 4 on Program Creek):\n\n /**\n * Plays the audio file specified in the 'url' parameter.\n * @param url URL for Audio Loading\n */\npublic void play(final String url) {\n try {\n InputStream in = getClass().getResourceAsStream(url);\n InputStream buf = new BufferedInputStream(in);\n AudioInputStream ain = AudioSystem.getAudioInputStream(buf);\n AudioFormat format = ain.getFormat();\n DataLine.Info info = new DataLine.Info(Clip.class, format);\n Clip clip = (Clip) AudioSystem.getLine(info);\n clip.open(ain);\n clip.start();\n } catch (Exception e) {\n e.printStackTrace();\n }\n}\n\n\nAnd I'd get the following error (here) when I'd give the BBC Radio One URL (http://www.bbc.co.uk/radio/player/bbc_radio_one) for it to play.\n\nIs there any way I could either get rid of this IOException error, or use a non-audio-file URL to receive a live audio stream a different way? Would you be able to lead me into the right path to figuring this out?\n\nThanks."
] | [
"java",
"swing",
"audio",
"stream",
"audio-streaming"
] |
[
"Google Apps Script: Retrieve Date from Spreadsheet and write to Contacts",
"Using Google Apps script, I'm trying to take a date written in a spreadsheet and add it as a date field to a Contact. Specifically, I cannot seem to convert the month of the javascript date read from the spreadsheet into a month enum that the contact.addDate method can use. \n\nvar months = ContactsApp.Month.values;\nvar birthdate = new Date( spreadsheet_date );\nvar month = months[ birthdate.getMonth() ];\ncontact.addDate(ContactsApp.Field.BIRTHDAY, \n month, birthdate.getDate(), birthdate.getFullYear() );"
] | [
"google-apps-script",
"google-contacts-api"
] |
[
"Telerik OpenAccess linq Any and Count() error with AND",
"I am working with Telerik OpenAccess entityframework and need to make Any work correctly. The following expression is needed but fails due to Any. (Count(..)=0 also fails:\n\nusing (var context = new Data())\n{\n var g = context.GetRxByDate(tencounter, groupid).ToList();\n\n foreach (var v in rxs)\n {\n //Telerik \"Any\" linq extension fails for &&\n\n if (g.Any(c => c.Cform == v.rx.Cform\n && c.Cmedname == v.rx.Cmedname\n && c.Csig == v.rx.Cmedname\n && c.Idisp == v.rx.Idisp\n && c.Nrefills == v.rx.Nrefills\n && c.Tstop == null\n && c.Groupid == v.encounter.groupid))\n {\n\n\nAnyone know a solution or a work-around? Thanks in advance."
] | [
"c#",
"linq",
"entity-framework",
"telerik"
] |
[
"v-for object in objects doesn't rerender when this.objects changes",
"I have a mounted() with reloadComparisons() and this tag:\n\n<li v-for=\"comparison in comparisons\">C: [[ comparison.area ]]</li>\n\n\nThe problem is that this is rendered only when comparisons is defined in data, when I load new array, it doesn't work.\n\nI tried already Vue.set(this.comparisons,comparisons) but it doesn't react neither.\n\nDo you know what to do?\n\nEDIT\n\nvar app = new Vue({\n delimiters: ['[[', ']]'],\n el: '#vue',\n data: {\n comparisons: [{'area': 'xxxx'}],\n },\n mounted() {\n this.reloadComparisons()\n },\n methods: {\n reloadComparisons: function () {\n console.log('reloadComparisons');\n axios.get(\"http://127.0.0.1:8000/alex/api/pricemap_comparisons/\").then(function (response) {\n console.log(response);\n if (response.status === 200) {\n this.comparisons = response.data.results;\n Vue.set(this.comparisons, response.data.results);\n console.log(this.comparisons);\n }\n }).catch()\n }\n }\n });"
] | [
"javascript",
"vue.js",
"v-for"
] |
[
"android load fragments do imposible access to imageview",
"In OnCreate I call this fragment: \n\nif(internet == true){\n Fragment fragment = null;\n fragment = new PasarProjectos();\n\n /*if(esLandscape == true){\n contenedor_salvado = findViewById(R.id.contenedor_info);\n }*/\n\n if (fragment != null) {\n\n FragmentManager fm = getSupportFragmentManager();\n Bundle args = new Bundle();\n args.putBoolean(\"esLandscape\", esLandscape);\n fragment.setArguments(args);\n fm.beginTransaction().add(R.id.container, fragment).commit();\n\n }\n findViewById(R.id.imageView17).setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n startActivity(new Intent(PasarProjNoMenu.this, InicioNoLogin.class));\n }\n });\n }else{\n startActivity(new Intent(PasarProjNoMenu.this, InicioNoLogin.class));\n }\n\n\nand finish the method of onCreate\n\nLater, I call another method that I try localize to another view\n\npublic void ensenarProjMismaPantalla(String id_s) { //un inflate rellenando los datos y punto\n\n Log.d(\"La acción \",\"rellenar campo primero\");\n\n ImageView imageView = (ImageView) findViewById(R.id.fotoProj);\n\n}\n\n\nThe imageview I know is continuous;y on the screen, because I can see it when the app runs, but the app throws a nullpointerexception error"
] | [
"android",
"android-fragments",
"nullpointerexception"
] |
[
"How can I scrape for certain html classes in python",
"I'm trying to scrape a random site and get all the text with a certain class off of a page.\nfrom bs4 import BeautifulSoup\nimport requests\nsources = ['https://cnn.com']\n\nfor source in sources:\n page = requests.get(source)\n\n soup = BeautifulSoup(page.content, 'html.parser')\n results = soup.find_all("div", class_='cd_content')\n for result in results:\n title = result.find('span', class_="cd__headline-text vid-left-enabled")\n print(title)\n\nFrom what I found online, this should work but for some reason, it can't find anything and results is empty. Any help is greatly appreciated."
] | [
"python",
"html",
"python-3.x",
"beautifulsoup"
] |
[
"angularjs filter not working with $http",
"I'm new to angular.js, but I cannot figure out how to make | filter:xxx work with data generated through $http service.\n\nIn the following code, I simply cannot get the filter to work with data generated by $http - it simply does nothing when I type inside input box. However, the filter DOES WORK if I hard code some data inside $scope function.\n\n<div ng-controller=\"UserCtrl\">\n\n <input ng-model=\"search\">\n <ul>\n\n <li ng-repeat=\"user in users| filter:search\">\n {{user.id}}\n {{user.firstname}}\n {{user.lastname}}\n </li>\n </ul>\n\n</div>\n\n<script>\n\nfunction UserCtrl($scope, $http) {\n$http.get('actions.php?action=get_user_list').success(function(data) {\n $scope.users = data;\n });\n\n}\n\n</script>"
] | [
"angularjs"
] |
[
"How to properly retrieve package name of the app that inserted data to Google Fit?",
"I have a following code I am using to retrieve a list of user's activities from Google Fit:\n\npublic void getActivitiesData(Date from, Date till) {\n DataReadRequest readRequest = new DataReadRequest.Builder()\n .aggregate(DataType.TYPE_ACTIVITY_SEGMENT, DataType.AGGREGATE_ACTIVITY_SUMMARY)\n .bucketByTime(1, TimeUnit.DAYS)\n .setTimeRange(from.getTime(), till.getTime(), TimeUnit.MILLISECONDS)\n .build();\n\n Fitness.HistoryApi.readData(apiClient, readRequest).setResultCallback(new com.google.android.gms.common.api.ResultCallback<DataReadResult>() {\n @Override\n public void onResult(DataReadResult dataReadResult) {\n Status status = dataReadResult.getStatus();\n if (status.isSuccess()) {\n\n for (Bucket bucket : dataReadResult.getBuckets()) {\n if (!bucket.getDataSets().isEmpty()) {\n DataSet dataSet = bucket.getDataSets().get(0);\n String sourceAppPackageName = getSourceAppPackageNameFromDataSet(dataSet);\n for (DataPoint dp : dataSet.getDataPoints()) {\n for (Field field : dp.getDataType().getFields()) {\n String fieldName = field.getName();\n if (fieldName != null && fieldName.equals(\"activity\")) {\n String type = FitnessActivities.getValue(dp);\n Date from = new Date(dp.getStartTime(TimeUnit.MILLISECONDS));\n Date till = new Date(dp.getEndTime(TimeUnit.MILLISECONDS));\n\n // store retrieved values to the data object, omitted\n }\n }\n }\n }\n }\n }\n }\n });\n}\n\nprivate static String getSourceAppPackageNameFromDataSet(DataSet dataSet) {\n String result = null;\n\n if (dataSet.getDataSource() != null) {\n result = dataSet.getDataSource().getAppPackageName();\n }\n\n return result;\n}\n\n\nTo insert activities into Google Fit, I've used the Google Fit app and Runkeeper (right now, these apps seem to be only ones that are integrated with Fit).\n\nMy code retrieves these activities as expected, however, for each activity, my getSourceAppPackageNameFromDataSet() method returns \"com.google.android.gms\" as a package name. As per Data Attribution section in Google Fit documentation, I would expect the method to return a package name of either Runkeeper or Google Fit, but this does not happen.\n\nAm I doing something horribly wrong, or is this a bug in Google Fit?"
] | [
"android",
"google-play-services",
"google-fit",
"google-fit-sdk"
] |
[
"SQL query: same rows",
"I'm having trouble finding the right sql query. I want to select all the rows with a unique x value and if there are rows with the same x value, then I want to select the row with the greatest y value. As an example I've put a part of my database below.\n\n ID x y\n 1 2 3\n 2 1 5\n 3 4 6\n 4 4 7\n 5 2 6\n\n\nThe selected rows should then be those with ID 2, 4 and 5.\n\nThis is what I've got so far\n\nSELECT *\nFROM base\nWHERE x IN\n (\n SELECT x \n FROM base\n HAVING COUNT(*) > 1\n )\n\n\nBut this only results in the rows that occur more than once. I've added the tags R, postgresql and sqldf because I'm working in R with those packages."
] | [
"sql",
"r",
"postgresql",
"sqldf"
] |
[
"SL 5 exception using FileSystem",
"Working on an OOB app.\n\ndynamic fileSystem = AutomationFactory.CreateObject(\"Scripting.FileSystemObject\");\ndynamic drives = fileSystem.Drives;\n\nforeach (var drive in drives)\n{\nDriveCollection.Add(new Drive{\n VolumeName = drive.VolumeName,\n DriveLetter = drive.DriveLetter,\n TotalSpace = drive.TotalSize,\n FreeSpace = drive.FreeSpace\n });\nlistBox.Items.Add(string.Format(\"{0} {1}\", drive.DriveLetter, drive.VolumeName));\n}\n\n\nWhen run in the debugger, 'C' drive is enumerated, then an exception is thrown:\n\n\"Exception from HRESULT: 0x800A0047\"\nWhen I run the app from the desktop, no drives are enumerated before the exception is thrown. \n\nAny hints on how to protect against this exception? Somehow checking the validity of the 'drive' object before referencing it in the Drive constructor?"
] | [
"filesystems",
"silverlight-5.0",
"out-of-browser"
] |
[
"Maximize consumption Energy",
"There are three types of foods were provided i.e. meat, cake and pizza \nand N different stores selling it where, i can only pick one type of food from\neach store. Also I can only buy items in A, B and C numbers where 'A' means, Meat from total 'A' number of different stores (see example). My task is\nto consume food, so that i can have maximum amount of energy.\nexample,\n\n10 <= number of stores <br>\n5 3 2 <= out of 10 stores I can pick meat from 5 stores only. Similarly,\n I can pick cake from 3 out of 10 stores...\n56 44 41 1 <= Energy level of meat, cake and pizza - (56, 44, 41) for first store.<br> \n56 84 45 2\n40 98 49 3\n91 59 73 4\n69 94 42 5\n81 64 80 6\n55 76 26 7\n63 24 22 8\n81 60 44 9\n52 95 11 10\n\n\nSo to maximize my energy, I can consume...\n\n\nMeat from store numbers:\n\n[1, 4, 7, 8, 9] => [56, 91, 55, 63, 81]\n\nCake from store numbers:\n\n[3, 5, 10] => [98, 94, 95]\n\nPizza from store numbers:\n\n[2, 6] => [45, 80]\n\n\n\nThis leads me to eventually obtain a maximum energy level of 758.\n\n\n\nAs I am new to dynamic programming, I tried to solve it by generating unique combinations like,\n\n10C5 * (10-5)C3 * (10-5-3)C2 = 2520\n\nHere is my code,\n\nnStores = 10\na, b, c = 5, 3, 2\nmatrix = [\n [56,44,41],\n [56,84,45],\n [40,98,49],\n [91,59,73],\n [69,94,42],\n [81,64,80],\n [55,76,26],\n [63,24,22],\n [81,60,44],\n [52,95,11]\n]\n\ncount = a + b + c\ndata = []\nallOverCount = [i for i in range(count)]\ndef genCombination(offset, depth, passedData, reductionLevel = 3):\n if (depth == 0):\n first = set(data)\n if reductionLevel == 3:\n return genCombination(0,b,[i for i in allOverCount if i not in first], reductionLevel=2)\n elif reductionLevel == 2:\n return genCombination(0,c,[i for i in allOverCount if i not in first], reductionLevel=1)\n elif reductionLevel == 1:\n xAns = 0\n for i in range(len(data)):\n if i < a:\n xAns += matrix[data[i]][0]\n elif i < a + b:\n xAns += matrix[data[i]][1]\n else:\n xAns += matrix[data[i]][2]\n return xAns\n oneData = 0\n for i in range(offset, len(passedData) - depth + 1 ):\n data.append(passedData[i])\n oneData = max(oneData, genCombination(i+1, depth-1, passedData, reductionLevel))\n del data[-1]\n return oneData\npassedData = [i for i in range(count)]\nfinalOutput = genCombination(0,a,passedData)\nprint(finalOutput)\n\n\nI know this is not the right way to do it. How can I optimize it?"
] | [
"python",
"algorithm",
"dynamic-programming",
"linear-programming"
] |
[
"Enabling the use of Bing between two forms using a Button, Web browser & Textbox",
"Hi I have written a piece of a code which takes the postcode from my textbox then searches it within Bing for the user, at the moment all of it is on Form1 and works as it should, I'm looking to improve on the idea by allowing the user to press a button on Form1 then the web browser appearing in Form2, so far my attempts to figure this out have failed and was wondering if anyone had any ideas. Just as a side note this a slow progression of my programming as I'm a beginner and in the future I will be looking into implementing a Google or Bing API\n\nI have attached a copy of my code which all works within in one Form\n\nPublic Class Form1\n\nDim Automate As Boolean\n\n\n\nPrivate Sub BTNMap_Click_1(sender As Object, e As EventArgs) Handles BTNMap.Click\n\n\n\n Automate = True\n\n WebBrowser1.Navigate(\"http://www.bing.com\")\n\n\n\n\nEnd Sub\n\n\nPrivate Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted\n If Automate = True Then Automate = False Else Exit Sub\n Dim txt As HtmlElement = WebBrowser1.Document.GetElementById(\"q\")\n Dim btn As HtmlElement = WebBrowser1.Document.GetElementById(\"go\")\n\n txt.SetAttribute(\"value\", PostcodeTextBox.Text)\n btn.InvokeMember(\"click\")\nEnd Sub\n\n\nThank you for reading any advice is welcome."
] | [
"vb.net",
"forms",
"winforms",
"bing-maps",
"bing"
] |
[
"Close entire app when back button clicked twice?",
"I'm using this code:\n\n private static long back_pressed;\n\n @Override\n public void onBackPressed() {\n\n if (back_pressed + 2000 > System.currentTimeMillis()) super.onBackPressed();\n else Toast.makeText(getBaseContext(), \"click again to leave\", Toast.LENGTH_SHORT).show();\n back_pressed = System.currentTimeMillis();\n }\n\n\nIt only closes the current Activity, how to close the entire app when back button is clicked twice?"
] | [
"java",
"android",
"android-studio"
] |
[
"R Leaflet map - Draw Line for each row of dataframe",
"I am trying to create lines on a map with Leaflet between latitude/longitude points. Here is a sample input data:\n\n segment_id latitude1 longitude1 latitude2 longitude2 len\n1 1 48.15387 17.07388 48.15396 17.07387 10.98065\n2 1 48.15396 17.07387 48.15404 17.07377 11.31327\n3 1 48.15404 17.07377 48.15410 17.07364 11.74550\n4 1 48.15410 17.07364 48.15412 17.07349 11.48138\n5 1 48.15412 17.07349 48.15412 17.07334 11.63625\n6 2 48.15424 17.07307 48.15432 17.07299 10.79304\n\n\nThe result of this should be 6 lines lat1,lng1 -> lat2,lng2. I have a hard time working with addPolylines, it is creating extra unwanted lines and I am not sure why. \n\n\n\nThis is how it should look like, without the extra lines stacked on top of each other :D\n\nHere's my code so far but it's garbage:\n\n drawEdges <- function(x) {\n d <- cbind(x$latitude1,x$latitude2)\n s <- rep(1:nrow(x), each = 2) + (0:1) * nrow(x)\n latitudeOut <- d[s]\n e <- cbind(x$longitude1,x$longitude2)\n t <- rep(1:nrow(x), each = 2) + (0:1) * nrow(x)\n longitudeOut <- e[t]\n mymap <<- addPolylines(map = mymap,data = x, lng = ~longitudeOut, lat = ~latitudeOut)\n }\n\n if (!is.null(edges)){\n segments <- split( edges , f = edges$segment_id )\n segments\n sapply(segments, drawEdges)\n}\n\n\nThank you for helping"
] | [
"r",
"leaflet"
] |
[
"What are the code convention for parameters/return values (collections)",
"I had a little discussion with a friend about the usage of collections in return/input values of a method. He told me that we have to use\n- the most derived type for return values.\n- the least derived type for input parameters.\n\nSo, it means that, for example, a method has to get a ReadOnlyCollection as parameter, and as return a List.\n\nMoreover, he said that we must not use List or Dictionary in publics API, and that we have to use, instead Collection, ReadOnlyCollection, ... So, in the case where a method is public, its parameters and its return values must be Collection, ReadOnlyCollection, ...\n\nIs it right ?"
] | [
"c#"
] |
[
"AWS Amplify get Stream ARN from a DynamoDB Table created with api category",
"I´m trying to get the ARN from a DynmoDB table created with @model from the api category. \n\nThe ARN is an output from the autogenerated cloudformation template under /amplify/backend/api/{api-name}/build/stacks. \n\nI tried to import the ARN with the following statement in the EventSourceMapping for my Lambda function: \n\n\"EventSourceArn\": {\n \"Fn::ImportValue\": {\n \"Fn::Join\": [\n \":\",\n [\n {\n \"Ref\": \"apiGraphQLAPIIdOutput\"\n },\n \"GetAtt\",\n \"CustomerTable\",\n \"StreamArn\"\n ]\n ]\n }\n },\n\n\nBut this throws the an error when pushing to the cloud: \n\nOutput 'GetAttCustomerTableStreamArn' not found in stack 'arn:aws:cloudformation:eu-central-1:124149422162:stack/myapp-stage-20191009174227-api-SHBHD6GIS7SD/5fb78d10-eaac-11e9-8a4c-0ac41be8cd2e'\n\nI also added a dependsOn in the backend-config.json, which doesn’t resolve the problem\n\nSo, what would be the correct way to get this stream ARN in a cloudformation template of a lambda function?"
] | [
"aws-lambda",
"amazon-cloudformation",
"aws-amplify",
"amazon-dynamodb-streams"
] |
[
"Email Field returns blank string",
"I am using devise in my Rails3 application.The problem I am facing is the email field is being returned as a blank string after save.\n\n resource.save\n Rails.logger.info p resource\n\n\nThis returns me \n\n#<User id: 1850, email: \"\", encrypted_password: \"$2a$10$EZnvzTKpgYyN2K8I20vXBuk6OZ.XQ6gfOCbOUyfkDKx/...\", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, confirmation_token: \"6e6c41315002a24cf63e4512ab94f693ef9d419218e1cbb9a2d...\", confirmed_at: nil, confirmation_sent_at: \"2015-07-02 04:49:23\", unconfirmed_email: \"[email protected]\", company_code: \"WNZQIFHN\", partner_id: nil, partner_type: nil, super_admin_id: nil, super_admin_type: nil, device_token: nil, is_active: nil, is_disabled: false, total_session_time: \"0:0:0\", status: \"pending\", created_at: \"2015-07-02 04:49:20\", updated_at: \"2015-07-02 04:49:20\", doctor_id: nil, last_notified_offer_id: nil, is_deleted: false, remove_reason: nil, active_at: nil, deactivated_at: nil, was_disabled: false, is_first_menu_selection: true, is_default_filter: true>\n\n\nBut when I query the console it gives me the correct response.\n\n#<User id: 1850, email: \"[email protected]\", encrypted_password: \"$2a$10$EZnvzTKpgYyN2K8I20vXBuk6OZ.XQ6gfOCbOUyfkDKx/...\", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, confirmation_token: \"6e6c41315002a24cf63e4512ab94f693ef9d419218e1cbb9a2d...\", confirmed_at: nil, confirmation_sent_at: \"2015-07-02 04:49:23\", unconfirmed_email: \"[email protected]\", company_code: \"WNZQIFHN\", partner_id: nil, partner_type: nil, super_admin_id: nil, super_admin_type: nil, device_token: nil, is_active: nil, is_disabled: false, total_session_time: \"0:0:0\", status: \"pending\", created_at: \"2015-07-02 04:49:20\", updated_at: \"2015-07-02 04:49:20\", doctor_id: nil, last_notified_offer_id: nil, is_deleted: false, remove_reason: nil, active_at: nil, deactivated_at: nil, was_disabled: false, is_first_menu_selection: true, is_default_filter: true>\n\n\nWhy does this happen?Am I doing anything wrong here?"
] | [
"ruby-on-rails",
"ruby-on-rails-3",
"devise"
] |
[
"Failed to load AppCompat ActionBar constraints layout Android Studio 3.1.3",
"This was my first time using Android studio and I don't know what are those errors mean and i saw many solution include change appcomat to alpha1 and change theme into base.theme and many but no one is working\n\nRender Problem\n \"Failed to find style 'coordinatorLayoutStyle' in current theme Tip: Try to refresh the layout. \"\n\nGradle Scripts>build.gradle\n\n\n dependencies {\n implementation fileTree(dir: 'libs', include: ['*.jar'])\n implementation 'com.android.support:appcompat-v7:28.0.0-rc01'\n implementation 'com.android.support.constraint:constraint-layout:1.1.2'\n implementation 'com.android.support:design:28.0.0-rc01'\n testImplementation 'junit:junit:4.12'\n androidTestImplementation 'com.android.support.test:runner:1.0.2'\n }\n \n res>values>style.xml\n style name=\"AppTheme\" parent=\"Base.Theme.AppCompat.Light.DarkActionBar\"\n \n @color/colorPrimary\n @color/colorPrimaryDark\n @color/colorAccent\n \n\n\n\nImage 1\n\n\nImage 2"
] | [
"android",
"android-layout",
"android-studio",
"android-fragments",
"android-constraintlayout"
] |
[
"JavaScript Prompt/Alert issue",
"This is pretty basic...\n\nI'm stuck on what to do though.\n\nalert(\"The capital of \" + n + \" is \" + capitals.n);\n\n\ncapitals.n in the alert comes out as undefined. What can I do to fix that?"
] | [
"javascript"
] |
[
"Error in converting argument from 'const_Ty' to const custom struct",
"I have a custom comparator and I pass in two const references of a custom struct to be compared, however, I get the following error:\n\n\n 'bool cmp::operator()(const LogObjects &, const LogObjects &)' cannot convert argument 2 from 'const_Ty' to 'const LogObjects &'.\n\n\nI've tried adding and removing const, and references but it didn't work.\n\nbool cmp::operator()(const LogObjects &a, const LogObjects &b) { // body }\n\nstruct LogObjects {\n string category;\n string message;\n string timestamp;\n long long int time;\n int entry_id;\n\nsort(master.begin(), master.end(), cmp());\nauto it1 = lower_bound(master.begin(), master.end(), time, cmp());\nauto it2 = upper_bound(master.begin(), master.end(), time, cmp());\n\n};\n\n\n(master is a vector of LogObjects and time is a long long int)"
] | [
"c++11"
] |
[
"how can i download a set of variable images in flex/as3 and display them?",
"suppose i have 10 image variables like this\n\nvar image1:String = http://somewhere.com/image1.jpg\nvar image2:string = .....image2.jpg\nvar image3:string = .....image3.jpg\nand so forth.........\n\n\ni have a timer that displays each variable as an image one a time ....\n\nhow do i \"buffer\" the image and display them instead of going out each time the timer runs? im asking because sometimes the server could slow or some other reason. so what i want to do is to download all those images and then display them from the clients computer. some sort like @Embed ???\n\ncomplete newbie.. so please go slow on me ... :p"
] | [
"apache-flex",
"actionscript-3",
"adobe"
] |
[
"Dynamics CRM Online - push data when a contact is created",
"We are trying to push data to Azure Service Bus Queue when a contact is created in \"Dynamics CRM Online\". We have implemented it using a plugin by registering it with Plugin Registration Tool. But somehow its throwing an error while saving the contact. \nHere is the code which we have implemented in plugin:\n\npublic void Execute(IServiceProvider serviceProvider)\n {\n try\n { \n IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));\n Entity entity = (Entity)context.InputParameters[\"Target\"];\n if (entity.LogicalName.Equals(\"account\"))\n {\n QueueDescription qd = new QueueDescription(\"testQ\");\n\n qd.MaxSizeInMegabytes = 5120;\n qd.DefaultMessageTimeToLive = new TimeSpan(0, 1, 0);\n\n string connectionString =\n CloudConfigurationManager.GetSetting(\"Endpoint=sb://test.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=secretcode=\");\n\n var namespaceManager =\n NamespaceManager.CreateFromConnectionString(connectionString);\n if (!namespaceManager.QueueExists(\"testQ\"))\n {\n namespaceManager.CreateQueue(\"testQ\");\n }\n\n QueueClient Client =\n QueueClient.CreateFromConnectionString(connectionString, \"testQ\");\n\n BrokeredMessage message = new BrokeredMessage(entity);\n\n message.Properties[\"FirstName\"] = \"ABC\";\n message.Properties[\"LastName\"] = \"Z\";\n\n Client.Send(message);\n }\n }\n catch (Exception e)\n {\n throw;\n }\n}"
] | [
"dynamics-crm-2011",
"dynamics-crm",
"dynamics-crm-online",
"azureservicebus",
"azure-servicebus-queues"
] |
[
"python multidimensional boolean array?",
"it would contain at most 1000 x 1000 x 1000 elements, which is too big for python dictionary.\n\nwith dict, around 30 x 1000 x 1000 elements, on my machine it already consumed 2gb of memory and everything got stoned.\n\nany modules that can handle 3-dimension array whose value would be only True/False? I check bitarray http://pypi.python.org/pypi/bitarray, which seems reasonable and coded in C, however it seems more like a bit-stream instead of an array, since it supports only 1 dimension."
] | [
"python",
"arrays",
"boolean"
] |
[
"render element base on conditon of select box reactjs",
"I want to change element base on render condition select value, how can I do this? When the value of select box change, I want to replace element below of my code by another, someone may help me with react rendering condition?\n\n<Col span={12}>\n <Form.Item\n label='Số lượng'\n {...formItemLayout}\n labelAlign='left'\n >\n <Select\n onChange={this.handleChangeSelectDUC}\n defaultValue=\"Đơn lẻ\" \n >\n <Option\n value=\"Đơn lẻ\"\n >\n Đơn lẻ\n </Option>\n <Option\n value=\"Số lượng lớn\"\n >\n Số lượng lớn\n </Option>\n </Select>\n </Form.Item>\n </Col>\n <Col span={12}>\n {\n conditon if select value = \"Đơn lẻ\"\n ?\n (\n <FormItem\n label='Số ĐT'\n {...formItemLayout}\n labelAlign='left'\n >\n <Input\n name='title'\n onChange={this.handleChangeInput}\n />\n </FormItem>\n ):(\n <FormItem\n label='DS khách hàng'\n {...formItemLayout}\n labelAlign='left'\n >\n <Upload {...props}>\n <Button>\n <Icon type=\"upload\" /> Tải lên tệp\n </Button>\n </Upload>,\n </FormItem>\n )\n }\n </Col>"
] | [
"javascript",
"reactjs"
] |
[
"GCloud compute instance halting but not stopping",
"I want to run a gcloud compute instance only for the duration of my startup script. My startup script calls a nodejs script which spawns sudo halt or shutdown -h 0. Observing the serial port the system comes to a halt but remains in the RUNNING state, never going into STOPPING or TERMINATED:\n\n Starting Halt...\n[[0;32m OK [0m] Stopped Monitoring of LVM2 mirrors,…sing dmeventd or progress polling.\n Stopping LVM2 metadata daemon...\n[[0;32m OK [0m] Stopped LVM2 metadata daemon.\n[ 34.560467] reboot: System halted\n\n\nHow is it possible that the system can halt completely but the instance doesn't register as such?"
] | [
"google-cloud-platform",
"gcloud",
"gcloud-compute"
] |
[
"Access One to One Relationship Table",
"I am trying to build several tables based on one single table(parent table) : the idea is that the first 3 columns of all the child tables will be the same as the parent table and each child table has a few more information provided. Whatever change made in the parent table will reflect in the child table. For example, if previous one row in the parent table is harry True Happy is changed to Harry True Sad, the child tables will also be changed . Also if a record in the parent table is deleted, the corresponding rows in the child tables will also be deleted. A new record in the parent table is created, the child table will also generate one row of record reflecting the update. \n\nI think the one-to-one relationship in Access will be a good way to achieve that. Will that be feasible as I don't have much theoretical understanding about the database. Thanks."
] | [
"ms-access"
] |
[
"MVP examples for Windows Forms",
"Is there good example code or a test project for explaining the Model–view–presenter (MVP) pattern. There are a lot of explanation links, but I want to have some good example code to show others without reinventing the wheel."
] | [
"c#",
".net",
"winforms",
"mvp"
] |
[
"If and else if in PHP, colon style",
"One function of PHP that I like to use is the colon-style if statement (I don't know what it's actually called.)\n\n<?php if(something):?>\n <html stuff>\n<?php endif;?>\n\n\nBut I recently tried to do this with multiple cases:\n\n<?php if(something):?>\n <html stuff>\n<?php else if(something):?>\n <html stuff>\n<?php endif;?>\n\n\nAnd I get an error on the third line (the else if):\n\n\n Unexpected T_IF\n\n\nIs it possible to make an if-else if this way?"
] | [
"php"
] |
[
"Loop all siblings div and update its id",
"I have list of DIV as following.\n\n<div id=\"div_0\">Some Content</div>\n<div id=\"div_1\">Some Content</div>\n<div id=\"div_2\">Some Content</div>\n<div id=\"div_3\">Some Content</div>\n<div id=\"div_4\">Some Content</div>\n<div id=\"div_5\">Some Content</div>\n<div id=\"div_6\">Some Content</div>\n\n\nI have written code to remove any of this div on the fly. So my problem is I want to update ID of next all div by -1 in ID. So If I click cross icon which removes <div id=\"div_2\"> I want to update my other div's as following.\n\n<div id=\"div_0\">Some Content</div>\n<div id=\"div_1\">Some Content</div>\n<div id=\"div_2\">Some Content</div>\n<div id=\"div_3\">Some Content</div>\n<div id=\"div_4\">Some Content</div>\n<div id=\"div_5\">Some Content</div>\n\n\nRemoving code working fine. I just want to update ID's of other div. You can see, there are only 5 DIV now with updated ID. I am not very good at jQuery.\n\nPlease help me. Thank you."
] | [
"jquery",
"html"
] |
[
"Setting Default font size in an RTF file",
"Is there any Command in C through which i can set a particular font size of a .RTF file while creating a file.\nActually what i am doing is i am creating a file on Pen drive using usb Host interface with LPC2468.I am using File handling Commands for creating the file.When i open a file after creating it,i have to change the font size to view it properly."
] | [
"rtf",
"file-handling"
] |
[
"I'm having an if-statement issue",
"I already written the program and ran it but I don't know how to prevent both println statements to show up when I run it with an invalid digit. It's basically a program in which you input the month & day (in numerical value) and the output would be the season. Here's the code:\n\npublic class Solstice {\npublic static void main(String[] args){\n Scanner in = new Scanner(System.in);\n\n int month;\n int day;\n String season = \"seasons\";\n\n System.out.println(\"Enter a month: \");\n month = in.nextInt();\n\n System.out.println(\"Enter a day: \");\n day = in.nextInt();\n\n String winter = \"winter\";\n String spring = \"spring\";\n String summer = \"summer\";\n String fall = \"fall\";\n\n System.out.println(\"Month=\"+ month +\" Day= \"+day);\n\n\n if (month <= 3)\n {\n season = winter;\n }\n else if (month <= 6)\n {\n season = spring;\n }\n else if (month <= 9)\n {\n season = summer;\n }\n else if (month <= 12)\n {\n season = fall;\n } else {\n System.out.println(\"The value is invalid.\");\n }\n\n System.out.println(season);\n }\n}"
] | [
"java",
"eclipse"
] |
[
"Python list comprehension: return value matching multiple if statements, else return other value",
"I'm working on list comprehension in python, and am having difficulty condensing my code into a single list comprehension statement.\n\nI'm writing a function to search a list of movie dictionaries that looks like this:\n\n movies = [\n {\n \"name\": \"Usual Suspects\", \n \"imdb\": 7.0,\n \"category\": \"Thriller\"\n },\n {\n \"name\": \"Hitman\",\n \"imdb\": 6.3,\n \"category\": \"Action\"\n },\n {\n \"name\": \"Dark Knight\",\n \"imdb\": 9.0,\n \"category\": \"Adventure\"\n }\n ]\n\n\nI'm trying to write a function that takes in an input of a movie name, checks the imdb score, and returns True if the score > 5.5, but returns false if the score doesn't meet this criteria. \n\nWriting in traditional code, I accomplished this like the following:\n\n def good_movie(movie_name):\n for m in movies: #for each item in movies...\n if m[\"name\"] == movie_name: #see if movie_name == \"name\", if it does...\n if m[\"imdb\"] > 5.5: # See if the movie's score is greater than 5.5...\n return \"True\" # If it is, return \"true\"\n else: #otherwise\n return \"False\" #return false\n\n\nI've been able to write this in list comprehension to return true, but can't get the function to work if I also want to return false when the movie doesn't meet the proper score criteria.\n\nThe short version that works is:\n\n def good_movie(movie_name):\n return [\"True\" for m in movies if m[\"name\"] == movie_name if m[\"imdb\"] > 5.5]\n\n\nHowever, I'd like to be able to return a value of False if the movie_name doesn't meet both of the if statements listed here. I've tried it a few different ways, but can't figure out how to make it work. \n\nSomething like this DOESN'T work:\n\n def good_movie(movie_name):\n return [\"True\" if m[\"imdb\"] > 5.5 and if m[\"name\"] == movie_name else \"False\" for m in movies]\n\n\nI thought maybe adding the \"and\" between the if statements would help (otherwise, it would think of the if statements as independent, rather than connected). \n\nI've worked with this back and forth a number of times, but any assistance anyone could provide would help me better understand how these sorts of list comprehensions work in the future.\n\nThanks for your help!\n\nEDIT: Thanks everyone for your replies. This was my first post on stack overflow, and I'm already blown away by the amount of response I've gotten for my small request. I understand that list comprehension is not the best way to address this problem in a real-world application, I am just in the process of learning list comprehension, and wanted to see how I could solve this problem in normal python, without importing pandas, etc. Thank you again to everyone who contributed!"
] | [
"python",
"list",
"function",
"if-statement"
] |
[
"Kotlin - How to read JSON string on url",
"I am new to Kotlin and I find library Klaxon to parse JSON. I can not find how to execute url(http://localhost:8080/items/2), read JSON string and save data to variables and print them to console. CreatedAt and UpdatedAt I do not need to save.\n\nJSON from url:\n\n{\n \"brand\": \"Ferrero\",\n \"name\": \"Nutella\",\n \"healthy\": false,\n \"date\": \"2017-03-14T00:00:00.000Z\",\n \"id\": 2,\n \"createdAt\": \"2018-03-14T13:33:22.000Z\",\n \"updatedAt\": \"2018-03-20T21:23:44.000Z\"\n}\n\n\nCode:\n\nclass DetailItem : AppCompatActivity() {\n var itemId : String = \"\"\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_detail_item)\n itemId = intent.getStringExtra(\"itemId\")\n }\n\n override fun onResume() {\n super.onResume()\n example()\n }\n\n private fun parse(name: String) : Any{\n val cls = Parser::class.java\n val inputStream = cls.getResourceAsStream(name)!!\n return Parser().parse(inputStream)!!\n }\n\n private fun example(){\n val url = \"http://192.168.99.100:8080/items/\" + itemId\n val obj = parse(\"url\") as JsonObject\n\n val brand = obj.string(\"brand\")\n val name = obj.string(\"name\")\n println(brand + name)\n }"
] | [
"kotlin",
"klaxon"
] |
[
"libACE with gcc linking",
"i am having a problem while compiling the code exemple in this link on debian OS :\nhttp://touch-base.com/documentation/API-GettingStarted.htm\nand this is the result :\n\nuser@debian:~/Téléchargements/touchscreen$ g++ main.cpp libACE-5.6.3.so libtbapi.so -lX11\n libtbapi.so: undefined reference to `ACE_Reactor::instance(ACE_Reactor*, int)'\n libtbapi.so: undefined reference to `ACE_Task_Base::activate(long, int, int, long, int, ACE_Task_Base*, unsigned long*, void**, unsigned long*, unsigned long*)'\n libtbapi.so: undefined reference to `XineramaQueryScreens'\n libtbapi.so: undefined reference to `XineramaIsActive'\n libtbapi.so: undefined reference to `ACE_OS::thr_create(void* (*)(void*), void*, long, unsigned long*, unsigned long*, long, void*, unsigned long, ACE_Base_Thread_Adapter*)'\n libtbapi.so: undefined reference to `ACE_Reactor::ACE_Reactor(ACE_Reactor_Impl*, int)'\n collect2: error: ld returned 1 exit status\n\n\nthanks for your answer."
] | [
"c++",
"gcc"
] |
[
"Fill Array with XML-Strings",
"My problem is that sendXML has more than one bracket in the beginning:\n\n> sendXML: <<<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Table_info><table_id>1</table_id><action_id>3</action_id><Bestellliste><item><categorie>getraenke</categorie><item_id>102</item_id><menge>3</menge></item>item><categorie>getraenke</categorie><item_id>101</item_id><menge>2</menge></item>/Bestellliste></Table_info>\n\n\nbut it should be:\n\nsendXML: <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Table_info><table_id>1</table_id><action_id>3</action_id><Bestellliste><item><categorie>getraenke</categorie><item_id>102</item_id><menge>3</menge></item><item><categorie>getraenke</categorie><item_id>101</item_id><menge>2</menge></item></Bestellliste></Table_info>\n\n\nMy code:\n\nNSMutableArray * objectAttributes = [NSMutableArray arrayWithCapacity:100];\n\nNSString *headerXML = [NSString stringWithFormat:\n @\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\"\n \"<Table_info>\"\n \"<table_id>1</table_id>\"\n \"<action_id>3</action_id>\"\n \"<Bestellliste>\"];\n\nNSMutableArray *bodyXML = [NSMutableArray arrayWithCapacity:200];\n\nNSString *endXML = [NSString stringWithFormat:\n @\"</Bestellliste>\"\n \"</Table_info>\"];\n\nfor(int i=0, j=0; i<getraenkeArray.count; i++)\n{\n [objectAttributes addObject:[[getraenkeArray objectAtIndex:i] categorie]];\n [objectAttributes addObject:[[getraenkeArray objectAtIndex:i] item_id]];\n [objectAttributes addObject:[[getraenkeArray objectAtIndex:i] menge]];\n\n [bodyXML addObject:[NSString stringWithFormat:\n @\"<item>\"\n \"<categorie>%@</categorie>\"\n \"<item_id>%@</item_id>\"\n \"<menge>%@</menge>\"\n \"</item>\",\n [objectAttributes objectAtIndex:j],\n [objectAttributes objectAtIndex:j+1],\n [objectAttributes objectAtIndex:j+2]]];\n j=j+3;\n}\n\n\nNSMutableString *sendXML = [NSMutableString stringWithCapacity:500];\nint i=0;\n\n[sendXML insertString: endXML atIndex: 0]; // Final-XML\n\n// If no object is in getraenkeArray, bodyXML gets an empy standard-string\nif (getraenkeArray.count == 0) {\n [bodyXML addObject:[NSString stringWithFormat:\n @\"<item>\"\n \"<categorie></categorie>\"\n \"<item_id></item_id>\"\n \"<menge></menge>\"\n \"</item>\"]];\n [sendXML insertString: [bodyXML objectAtIndex:i] atIndex: i+1];\n NSLog(@\"if\");\n}\nelse\n{\n for(i=0; i<(getraenkeArray.count); i++)\n {\n [sendXML insertString: [bodyXML objectAtIndex:i] atIndex: i+1]; NSLog(@\"i: %d\", i);\n }\n NSLog(@\"else\");\n}\n\n[sendXML insertString: headerXML atIndex: i];\nNSLog(@\"XML: %@\", sendXML);"
] | [
"ios",
"xml",
"xcode",
"object",
"nsmutablearray"
] |
[
"C3.js Legend Labels using JSON data",
"I have a donut graph, with a legend, that I made in C3.js.\nActually, I do this to fill the chart. \n\nvar chartDonut = c3.generate({....});\nchartDonut.load({\n columns: [\n ['Parfait', 190],\n ['Bien', 120],\n ['Trop court', 32],\n ['Trop long', 22],\n ],\n names: {\n 'Parfait': 'Parfait (entre 50 \\340 60 car.)',\n 'Bien': 'Bien (entre 40 \\340 49 ou 61 \\340 69 car.)',\n 'Trop court': 'Trop court (inf\\351rieur \\340 40 car.)',\n 'Trop long': 'Trop long (sup\\351rieur \\340 79 car.)' \n },\n});\n\n\nEverything works the way that I want it to, but I want to use JSON data.\nI do this \n\nchartDonut.load({\n json: [\n {\"Parfait\": 190},\n {\"Bien\": 190},\n {\"Trop court\": 190},\n {\"Trop long\": 190}\n ],\n keys: {\n value: ['Parfait', 'Bien', 'Trop court', 'Trop long']\n },\n});\n\n\nbut I have not found how to have the names properties in JSON format.\nCan someone help me? Thanks!"
] | [
"json",
"d3.js",
"legend",
"c3.js"
] |
[
"Ruby TCPSocket Server - Can I tell to what host a client was connecting?",
"I have a ruby server based on TCPSocket (non-HTTP).\n\nI have 2 different domains, both pointing with an A-Record to my servers IP Address (the same one). So, there are clients connecting to one of those domains.\nIs it possible to tell which domain a client was connecting to?\n\nI saw that this is possible in other protocols, but I'm not sure if this is based on manually added headers or really extracted from the basic tcp/ip connection. E.g. in PHP there is $_SERVER[\"HTTP_HOST\"] which shows to which domain a client was connecting."
] | [
"ruby",
"sockets",
"tcpsocket"
] |
[
"Angular 2 ng2-charts doenst seem to work with Angular 2 RC 6 AoT Compiler",
"I have recently upgraded my project to Angular 2 RC 6 and trying Angular 2 RC 6 AoT compilation. \n\nIn my project I am using ng2-charts (https://github.com/valor-software/ng2-charts) but now when I try to compile my project with Angular 2 Ahead of Time Compilation (AoT) using ngc it throws below error:\n\nError: Unexpected value 'CHART_DIRECTIVES' declared by the module 'AppModule'\n\n\nCan anyone please guide how to fix this error?"
] | [
"angular",
"angular2-directives",
"angular2-services",
"ng2-charts"
] |
[
"How can I detect the error state of my DFA?",
"Input template: 0+[0-9]+1+\n\nInput events: A, B, C\n\nInput string: C7584A7584AC7584A\n\nI'm trying to find all the patterns (following the template) in the input string. The \"0+\" and \"1+\" are placeholders where it can be any letter from the events (A, B, C). So the patterns can be A+[0-9]+A+, A+[0-9]+B+, A+[0-9]+C+, B+[0-9]+A+, B+[0-9]+B+, B+[0-9]+C+, C+[0-9]+A+, C+[0-9]+B+, C+[0-9]+C+. All these regexes correspond to a DFA and are stored in a 2D matrix (3rows x 3columns).\n\nEach time a pattern is found, a counter for that pattern in recorded. Also every time an element from the input string is consumed, the DFA only provides if the current state is success or not.\n\nfor (int i = 0; i < input.length; i++) {\n int _index = this.events.indexOf((char) input[i]);\n\n if (_index == -1) {\n for (int j = 0; j < this.events.length(); j++) {\n for (int k = 0; k < this.events.length(); k++) {\n dfaMatrix[j][k].startTraversal(input[i]);\n dfaMatrix[k][j].startTraversal(input[i]);\n }\n }\n } \n else {\n for (int j = 0; j < this.events.length(); j++) {\n dfaMatrix[_index][j].startTraversal(input[i]);\n dfaMatrix[j][_index].startTraversal(input[i]);\n\n if (dfaMatrix[_index][j].isSuccess()) {\n count[_index][j] += 1;\n flag = true;\n break;\n } else if (dfaMatrix[j][_index].isSuccess()) {\n count[j][_index] += 1;\n flag = true;\n break;\n }\n }\n if (flag) {\n for (int k = 0; k < this.events.length(); k++) {\n for (int m = 0; m < this.events.length(); m++) {\n dfaMatrix[k][m].reinitialize();\n dfaMatrix[m][k].reinitialize();\n }\n }\n flag = false;\n for (int j = 0; j < this.events.length(); j++) {\n dfaMatrix[_index][j].startTraversal(dfaMatrix[_index][j].getDfat(), input[i]);\n dfaMatrix[j][_index].startTraversal(dfaMatrix[j][_index].getDfat(), input[i]);\n }\n }\n }\n }\n\n\nMy expected results are:\n\n[A][A] : 1\n[A][B] : 0\n[A][C] : 0\n[B][A] : 0\n[B][B] : 0\n[B][C] : 0\n[C][A] : 2\n[C][B] : 0\n[C][C] : 0\n\n\nBut I'm getting\n\n[A][A] : 2\n[A][B] : 0\n[A][C] : 0\n[B][A] : 0\n[B][B] : 0\n[B][C] : 0\n[C][A] : 1\n[C][B] : 0\n[C][C] : 0\n\n\nFor some reason when the DFA is consuming the second C, the DFA is not reinitialising where logically it should be reaching error state. Can anyone tell me where I'm going wrong?"
] | [
"java",
"logic",
"dfa"
] |
[
"How can I use Left join in linq that we use in sql?",
"How can I use Left join in Linq that I write SQL query?\n\nselect \n p.Name, p.Family,\n E.EmployTypecode, E.employtypeName, E.EmplytyppeTye \nfrom \n personnel as p\nleft join \n Employee as E on E.EmployTypecode = p.EmployTypecode"
] | [
"c#",
"sql",
"linq"
] |
[
"Accessing Calendar API on using Plugin",
"I'm working on a program to take a work schedule from a website and put into Google calendar. I've been attempting to figure out the code for OAuth, but it seems I can't use their API. I found this page: https://developers.google.com/google-apps/calendar/v1/developers_guide_javascript but I can't get it working. It tells me it doesn't understand any of the commands I'm trying to run.\n\nIf you know of an extension doing something like this I would like to look at the source code and hopefully figure this out."
] | [
"javascript"
] |
[
"C# - Generalized SQL Server stored procedure calls",
"I'm trying something new (for me, at least) and, rather than having specific functions for calling individual stored procedures (1-to-1 ratio of data access functions to stored procedures), I'm trying to write generalized functions that are passed a stored procedure name, as well as string arrays of parameter names and parameter values as arguments.\n\nFor example:\n\npublic DataTable CallQuery(string spName, string[] paramNames, string[] paramValues, string connString)\n{\n DataTable dt = new DataTable();\n SqlConnection conn = new SqlConnection(connString);\n\n try\n {\n //create a command and assign it to the passed stored procedure name\n SqlCommand cmd = new SqlCommand();\n cmd.Connection = conn; // new SqlConnection(connString); ;\n cmd.CommandText = spName;\n\n //add any and all parameters to the command\n for(int i = 0; i < paramNames.Length; i++)\n {\n SqlParameter temp = new SqlParameter(paramNames[i], paramValues[i]);\n cmd.Parameters.Add(temp);\n //cmd.Parameters.AddWithValue(paramNames[i], paramValues[i]);\n }\n\n //get the data and return it\n SqlDataAdapter da = new SqlDataAdapter(cmd);\n da.Fill(dt);\n\n return dt;\n }\n catch (Exception)\n {\n return dt;\n }\n}\n\n\nUnfortunately, for some reason, when I call this function with parameter values (i.e. paramNames[0] = \"@Provider\" and paramValues[0] = \"AT&T\") and make the database call, I catch an exception saying that the stored procedure was expecting the parameter @Provider.\n\nI've stepped through and verified that the parameters are being added with their values, but I'm still getting the same exception. Am I missing something simple here?\n\nThe reason I'm passing in the string arrays is because there could be anywhere from 0 to 5 parameters per stored procedure (so far...)."
] | [
"c#",
"sql-server"
] |
[
"Thread safe access to private field",
"So I have the following scenario (can't share the actual code, but it would be something like this):\n\npublic class Test\n{\n private Object obj;\n\n public void init()\n {\n service.registerListener(new InnerTest());\n }\n\n public void readObj()\n {\n // read obj here\n }\n\n private class InnerTest implements Listener\n {\n public synchronized void updateObj()\n {\n Test.this.obj = new Object();\n // change the obj\n }\n }\n}\n\n\nThe InnerTest class is registered as listener in a service. That Service is running in one thread the calls to readObj() are made from a different thread, hence my question, to ensure consistency of the obj is it enough to make the UpdateObj() method synchronized?"
] | [
"java",
"multithreading",
"concurrency",
"thread-safety"
] |
[
"How do I Check for the Key Pressed in GTK3 (C)?",
"We're trying to filter keys in the key press event in C using glade. But we can't figure out how to filter those keys. Here is the code:\n\n // called when key pressed\nvoid on_window_main_key_press_event()\n{\n\n}"
] | [
"c",
"gtk3",
"glade"
] |
[
"iOS - UIImagePickerController crashes on device",
"This code runs fine in the simulator, but crashes every time on the device (iPhone 3GS), right when I take the picture. Is there something wrong with this code? When I Profile with Allocations, active memory is only 3-4 MB when it crashes, so it doesn't seem that the app is running out of memory. I'm using ARC.\n\n-(IBAction)chooseImageNew:(UIButton*)sender\n{\nif ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])\n{\n\n UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];\n imagePicker.delegate = self;\n\n imagePicker.allowsEditing = YES;\n imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;\n\n [self presentModalViewController:imagePicker animated:YES];\n}\nelse {\n UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@\"Error\" message:@\"No Camera Available.\" delegate:self cancelButtonTitle:@\"OK\" otherButtonTitles:nil];\n [alert show];\n}\n\n\n}\n\n- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {\nUIImage *img = [info objectForKey:@\"UIImagePickerControllerEditedImage\"];\nself.userPicture.image = img;\n[self.images replaceObjectAtIndex:0 withObject:img];\n\n[self dismissModalViewControllerAnimated:YES];\n\n}"
] | [
"ios",
"crash",
"uiimagepickercontroller"
] |
[
"Does ApiGen 5 support multiple file extensions?",
"I am using ApiGen 5.0.0-RC3, and I cannot figure out how to get it to search for .class files and .inc files as well as .php files.\n\nMy question is twofold: firstly, is it possible to get ApiGen to recognize .class files, and secondly, if it is possible, how would one go about it?"
] | [
"php",
"apigen"
] |
[
"Counting non-zero elements in a sparse matrix using breeze",
"I'm new to breeze. I can't seem to be able to count the number of non-zero element per row in a CSCMatrix.\nLet's take the following example :\nval matrix = CSCMatrix.tabulate(3, 2)((x,y) => x*y)\n\nThis is a sparse matrix of dimension 3x2:\n|0|0|\n|0|1|\n|0|2|\n\nWhat I want is to compute the number of non-zero elements per row, so the output should be a vector of the form:\n|0|\n|1|\n|1|\n\nIt would be easy to do it with numpy, but I can't seem to be able to do it with breeze."
] | [
"scala",
"scala-breeze"
] |
[
"How to handle potentially missing packages without putting everything in a try/except block?",
"I am developing a Python library with a module that depends on a third-party package not available through PyPi or Anaconda. \nThe module should expose some functions if the dependency is available on the system, and otherwise fail gracefully with an appropriate message.\n\nFor now, I am handling this as follows: \n\ntry:\n import the_dependency as td\n\n def foo(x):\n return td.bar(x)\n\nexcept ImportError:\n print('Failed to import the_dependency, the whole module will not be available')\n\n\nThis works, for now, but I don't like the idea of having function declarations inside the try block (it seems messy). \nI've looked at other libraries that have this behavior, and I've found this solution:\n\ntry:\n import the_dependency as td\nexcept ImportError:\n td = None\n\ndef foo(x):\n if td is None: \n raise ImportError('the_dependency is required to run foo')\n return td.bar(x)\n\n\nbut again, it looks messy and requires duplicating code/error messages.\n\nIs there a better way to handle this, in Python?\n\nThanks"
] | [
"python",
"dependencies",
"python-import"
] |
[
"find matching cells from two columns and populate corresponding cells from third column to a fourth corresponding column",
"I am trying to update price change for over 800 items. Need to search for matching cells in ColumnA and ColumnC and copy corresponding row/cell from ColumnB to corresponding cell in ColumnD. ColumnC will have more than one cell with same value... I have tried several formulas, but come up with errors. \n\n(Basically, if cell in A = cell in C then change A's corresponding row/cell in B to cell in C's corresponding D cell) hope that makes sense:)\nAny help would be very much appreciated. \n\nExample of file below\n\nexample"
] | [
"excel"
] |
[
"Image open in Windows Photo Viwer with python3",
"I am a begginer...\nI am using Python 3.6.2 and I am trying to open a jpg in Windows Photo Viwer(the default set program in windows) but instead it is opening in photoshop. This is the code I have:\n\nfrom PIL import Image\n\nimage=Image.open('Tulips.jpg')\nimage.show()\n\nThank you!"
] | [
"image",
"python-3.x"
] |
[
"How to trigger a method 200ms after an event is called?",
"I want to trigger a method 200ms after the onTouchUp event in android is called. I don't want to stop the current thread and I want to access the global variables in the method. I am also getting accelerometer data continuously so I don't want to stop or delay that. How do I do this?"
] | [
"java",
"android",
"multithreading",
"timer"
] |
[
"Insert transaction if not exists in SQL Server",
"I want to insert in the table only if I do not have the specific column it is a track table with different titles and I want to add different titles with one procedure I did the try catch and I have problem in my where not exists condition, I don't know where to put the values term:\n\nBEGIN TRANSACTION [Tran1]\nBEGIN TRY\n\nINSERT INTO [s15guest59].[dbo].[track](track_topic)\nvalues(@par1)\n WHERE NOT EXISTS (SELECT track_topic FROM [track]\n WHERE track_topic=@par1)\nCOMMIT TRANSACTION [Tran1]\nEND TRY\nBEGIN CATCH\n ROLLBACK TRANSACTION [Tran1]\nEND CATCH \n\nGO\n\n\nI don't know what to write in the middle for it to work \n\n\n Msg 137, Level 15, State 2, Line 2\n Must declare the scalar variable \"@par1\"."
] | [
"sql",
"sql-server",
"insert",
"transactions",
"procedures"
] |
[
"How to disable hide when mouse click on Ajax Magnific Popup?",
"I am beginner and starting use ajax magnific popup. I have downloaded library of magnific pop and created an example to use popup but my problem is when I click the link to pop it display well but I click on popup it hide So I don't wanted it hide. I just wanted click only the black background it hide.\n\nThis is my code as following:\n\nindex.html \n\n<!DOCTYPE html>\n<html>\n<head>\n <script type=\"text/javascript\" src=\"http://code.jquery.com/jquery-2.1.1.min.js\"></script>\n <script type=\"text/javascript\" src=\"js/jquery.magnific-popup.js\"></script>\n\n <link rel=\"stylesheet\" href=\"css/magnific-popup.css\" />\n</head>\n<body>\n\n <div class=\"example gc3\">\n <h3>Ajax popup</h3>\n <div class=\"html-code\">\n <a class=\"simple-ajax-popup\" href=\"site-assets/test-ajax-2.html\" >Load another content via ajax</a>\n </div>\n <script type=\"text/javascript\">\n $(document).ready(function() {\n\n $('.simple-ajax-popup-align-top').magnificPopup({\n type: 'ajax',\n alignTop: true,\n overflowY: 'scroll' // as we know that popup content is tall we set scroll overflow by default to avoid jump\n });\n\n $('.simple-ajax-popup').magnificPopup({\n type: 'ajax'\n });\n\n });\n </script>\n </div>\n</body>\n</html>\n\n\nPlease help me. Thank you."
] | [
"javascript",
"jquery",
"ajax",
"popup",
"magnific-popup"
] |
[
"Exception from HRESULT: 0x800AC472",
"when i set Excel apllications displayalert propery to true this exception is fired...\nwhy?"
] | [
"vb.net"
] |
[
"Error on redux suddenly",
"I have a strange error for couple of hours and really couldn't figure out what it is. The app was working fine and then after I've changed the name of a page headline gave me this error.\n\nTypeError: null is not an object (evaluating 'todo._id')\n\nThis error is located at:\n\nin TodoList (created by Connect(TodoList))\nin Connect(TodoList) (at NavigatorIOS.ios.js:862)\nin RCTNavItem (at NavigatorIOS.ios.js:854)\nin StaticContainer (at NavigatorIOS.ios.js:853)\nin RCTNavigator (at NavigatorIOS.ios.js:52)\nin NavigatorTransitionerIOS (at NavigatorIOS.ios.js:882)\nin StaticContainer (at NavigatorIOS.ios.js:881)\nin RCTView (at View.js:78)\nin View (at NavigatorIOS.ios.js:917)\nin NavigatorIOS (at Main.js:26)\nin Main (at App.js:25)\nin RCTView (at View.js:78)\nin View (at App.js:34)\nin App (created by Connect(App))\nin Connect(App) (at App.js:12)\nin Provider (at App.js:11)\nin todoListAuth (at registerRootComponent.js:35)\nin RootErrorBoundary (at registerRootComponent.js:34)\nin ExpoRootComponent (at renderApplication.js:35)\nin RCTView (at View.js:78)\nin View (at AppContainer.js:102)\nin RCTView (at View.js:78)\nin View (at AppContainer.js:122)\nin AppContainer (at renderApplication.js:34)\n\n\n\napp/components/TodoList.js:74:30 in \napp/components/TodoList.js:72:34 in renderTodos\napp/components/TodoList.js:99:11 in TodoList_render\nnode_modules/react-native/Libraries/Renderer/ReactNativeRenderer-dev.js:8707:21 in finishClassComponent\nnode_modules/react-native/Libraries/Renderer/ReactNativeRenderer-dev.js:11771:25 in performUnitOfWork\n... 22 more stack frames from framework internals\n\n\nSince that time I've tried to fix it somehow even to get a repo from yesterday but same thing without changing everything. Is that something with redux package?\n\nThanks\n\nEDIT\n\nCode I've changed\n\n<View style={styles.container}>\n <View style={styles.topBar}>\n <TouchableOpacity onPress={this.onBack}>\n <Icon name=\"chevron-left\" size={20} color=\"white\"/>\n </TouchableOpacity>\n <Text style={styles.title}>\n New To-Do // This is the text I've changed\n </Text>\n <TouchableOpacity onPress={this.addNewTodo}>\n <Icon name=\"check\" size={20} color=\"white\"/>\n </TouchableOpacity>\n </View>\n\n\nError lines\n\nvar renderTodos = () => {\n return this.props.todos.map((todo) => { // Line 72\n return (\n <TodoItem key={todo._id} text={todo.text} id={todo._id}/> // Line 74\n )\n })\n}\n{renderTodos()} // Line 99"
] | [
"javascript",
"reactjs",
"redux"
] |
[
"Mysql SQL query to get Last word in text",
"I have a text similar to the below in my database\n\nthis is my car\nhow are you,doing\nhow is your)health\nthis is not(working\n\n\nwhen I query database I should get the last words from this text. In this example\n\n1st row should return \"car\"\n2nd row should return \"doing\"\n3rd row should return \"health\"\n4th row should return \"working\"\n\n\nany idea on how to get this?\n\nThanks for your help\n\nRegards\n\nKiran"
] | [
"mysql",
"string",
"substring"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.