texts
list | tags
list |
---|---|
[
"How can I send an email containing a link with parameter in C#?",
"I'm new in asp.net. I'm building a web-based application with C#, and I thought a lot about how to authenticate the user by his ID using the email.\n\nI searched about it and I tried this code but it didn't worked because it sends a page rather than link with ID.\n\n string URI = \"http://localhost:49496/Activated.aspx\";\n string myParameters = \"param1=\"+id.Text;\n string HtmlResult = \"\";\n using (WebClient wc = new WebClient())\n {\n wc.Headers[HttpRequestHeader.ContentType] = \"application/x-www-form-urlencoded\";\n HtmlResult = wc.UploadString(URI, myParameters);\n }\n\n MailMessage o = new MailMessage(\"[email protected]\", EMPemail, \"KAUH Account Activation\", \"Hello, \" + name + \"<br /> Your KAUH Account about to activate click the link below to complete the activation process <br />\" + HtmlResult);\n\n NetworkCredential netCred = new NetworkCredential(\"[email protected]\", \"______\");\n SmtpClient smtpobj = new SmtpClient(\"smtp.live.com\", 587);\n smtpobj.EnableSsl = true;\n o.IsBodyHtml = true;\n smtpobj.Credentials = netCred;\n smtpobj.Send(o);\n\n\nI need the ID in the activation page to change the \"Activated\" column from NO to YES.\n\nNow my question: is the idea to authenticate the user by sending the ID secure?if it is,How can I perform it?"
]
| [
"c#",
"visual-studio",
"smtp",
"visual-studio-2013"
]
|
[
"startActivity crashes if I do not open the activity from another path",
"So I have 2 ways an activity can be opened. One is from the activity flow of: \n\n\n Main > Tracks > Day > Topic > TrackSelect > TrackInfo\n\n\nand the other is:\n\n\n Main > MySchedule > TrackInfo\n\n\nIf I try to get TrackInfo to open up via the second path, it crashes the app.\nHowever, If I go from the first path, then all the way back to the main, then through the second path, it works perfectly. Is there something weird going on?\n\nAndroidManifest:\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package=\"fayko.conference_app\">\n\n<uses-permission android:name=\"android.permission.INTERNET\" />\n<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>\n<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>\n<application\n android:allowBackup=\"true\"\n android:icon=\"@mipmap/ic_launcher\"\n android:label=\"Conference-App\"\n android:supportsRtl=\"true\"\n android:theme=\"@style/AppTheme\">\n <activity\n android:name=\".mainSelection\"\n android:label=\"@string/app_name\">\n <intent-filter>\n <action android:name=\"android.intent.action.MAIN\" />\n\n <category android:name=\"android.intent.category.LAUNCHER\" />\n </intent-filter>\n </activity>\n <activity\n android:name=\".topicScreen\"/>\n <activity\n android:name=\".myScheduleScreen\" />\n <activity android:name=\".trackSelection\" />\n <activity android:name=\".mainScreen\" />\n <activity android:name=\".daySelection\" />\n <activity android:name=\".trackInfoScreen\" />\n <activity android:name=\".mapChoose\" />\n <activity android:name=\".sponsorScreen\" />\n <activity android:name=\".committeeScreen\" />\n <activity android:name=\".welcomeScreen\"></activity>\n</application>\n\n</manifest>\n\n\nCode from TrackSelect > Track Info:\n\nIntent intent = new Intent(trackSelection.this,trackInfoScreen.class);\nstartActivity(intent);\n\n\nCode from MySchedule > TrackInfo:\n\nIntent intent = new Intent(myScheduleScreen.this,trackInfoScreen.class);\nstartActivity(intent);\n\n\nI appreciate any help you guys can give me."
]
| [
"java",
"android",
"android-intent",
"android-activity"
]
|
[
"MSComm and use of DLL to upload data VB6",
"I have a VB6 script that creates a MSComm with my device, once communication is create I go and upload a file to the device via DLL file that is included within VB6 script\n\nThe problem that I am facing is that my VB6 somehow hijacking device and I am unable to upload a file. Rather than taking 1 minute to upload a file application takes forever.\n\nI have tried following, after communication was created and MSComm1.OpenPort = True to set MSComm1.OpenPort = False but communication is still hijacked, so I need re plug my device into USB port and still nothing works (however sometimes it did work for an unknown reason, but i did have to wait a while)\n\nHowever, when I trigger file uplaod without VB6 script creating MSComm communication with device my file is uploaded successfully. \n\nI presume that this is something to do with MSComm and I presume that I need to shut it down somehow??\n\nI need to have MSComm initially because I want to fetch some data about my device.\n\n\n\nI run a command that finds a port number that I can use within VB6 after that i run MSComm.PortOpen = false; afterwards I put in file location and port number into function from DLL and run command. \n\nOn the initial run i receive an error that device is not connected, so i reconnect device, but on the second run everything seems to work except i have to wait and nothing happens. when i run DLL on its own process returns success in under 1 minutes\n\nMy settings for MS Comm within VB6\n\nDTREnable = True\nEOFEnable = False\nHandshaking = 0\nInBufferSize = 3200\nInputLen = 0\nInputMode = 0\nLeft = 6120\nOutBufferSize = 0\nRThreshold = 0\nRTSenable = False\nSettings = 2400,n,8,2\nSThreshold = 0"
]
| [
"vb6",
"mscomm32"
]
|
[
"File Uploading using Server.MapPath() and FileUpload.SaveAs()",
"I have a website admin section which I'm busy working on, which has 4 FileUpload controls for specific purposes. I need to know that , when I use the Server.MapPath() Method Within the FileUpload control's SaveAs() methods, Will it still be usable on the web server after I have uploaded the website? As far as I know, SaveAs() requires an absolute path, that's why I map a path with Server.MapPath()\n\nif (fuLogo.HasFile) //My FileUpload Control : Checking if a file has been allocated to the control\n {\n int counter = 0; //This counter Is used to ensure that no files are overwritten.\n string[] fileBreak = fuLogo.FileName.Split(new char[] { '.' });\n logo = Server.MapPath(\"../Images/Logos/\" + fileBreak[0] + counter.ToString()+ \".\" + fileBreak[1]); // This is the part Im wondering about. Will this still function the way it should on the webserver after upload?\n if (fileBreak[1].ToUpper() == \"GIF\" || fileBreak[1].ToUpper() == \"PNG\")\n {\n while (System.IO.File.Exists(logo))\n {\n counter++; //Here the counter is put into action\n logo = Server.MapPath(\"../Images/Logos/\" + fileBreak[0] + counter.ToString() + \".\" + fileBreak[1]);\n }\n }\n else\n {\n cvValidation.ErrorMessage = \"This site does not support any other image format than .Png or .Gif . Please save your image in one of these file formats then try again.\";\n cvValidation.IsValid = false;\n }\n if (fuLogo.PostedFile.ContentLength > 409600 ) //File must be 400kb or smaller\n {\n cvValidation.ErrorMessage = \"Please use a picture with a size less than 400 kb\";\n cvValidation.IsValid = false;\n\n }\n else\n {\n\n if (fuLogo.HasFile && cvValidation.IsValid)\n {\n fuLogo.SaveAs(logo); //Save the logo if file exists and Validation didn't fail. The path for the logo was created by the Server.MapPath() method.\n }\n\n }\n }\n else\n {\n logo = \"N/A\";\n }"
]
| [
"c#",
"asp.net"
]
|
[
"twitter.stream is not a function in node.js?",
"I cannot able to monitor the twitter.I followed the procedure to do the sentiment analysis (twitter) in node.js code.It verified my twitter account correctly.but it shows stream is not a function. I enclosed the code .can anyone solve this issue.Thanks in advance...\n\n\r\n\r\napp.get('/watchTwitter', function (req, res) {\r\n const twitter = new twitterAPI({\r\n consumerKey: \"asas\",\r\n consumerSecret: \"sdcscs\"\r\n });\r\n const accessToken = \"cdccd\";\r\n const accessTokenSecret = \"csdcs\";\r\n var stream;\r\n var testTweetCount = 0;\r\n var phrase = 'bieber';\r\n twitter.verifyCredentials(accessToken, accessTokenSecret, params, function (error, data, response) {\r\n if (error) {\r\n console.log(error);\r\n } else {\r\n console.log(data[\"screen_name\"]);\r\n stream = twitter.stream('statuses/filter',\r\n {\r\n 'track': phrase\r\n }, function (stream) {\r\n res.send(\"Monitoring Twitter for \\'\" + phrase + \"\\'... Logging Twitter traffic.\");\r\n stream.on('data', function (data)\r\n {\r\n testTweetCount++;\r\n if (testTweetCount % 50 === 0)\r\n {\r\n console.log(\"Tweet #\" + testTweetCount + \": \" + data.text);\r\n }\r\n });\r\n });\r\n }\r\n });\r\n});\r\napp.listen(8086,function()\r\n{\r\n console.log(\"port is listen on 8086\");\r\n});"
]
| [
"node.js",
"twitter"
]
|
[
"Dijkstra algorithm to find shortest path between two nodes in big graph?",
"Dijkstra Algorithm says\n\n\n For a given source node in the graph, the algorithm finds the shortest\n path between that node and every other\n\n\nI got the algorithm to find the shortest path between that node and every other. But my question if I need to find the shortest\npath b/w two specic node(say N1 and N2) for big graph like Linkedin/facebook do I need to calculate the distance between that node N1 and every other Node(user which means billion of users) on linkedin first, store it in cache memory and then return it from cache whenever shortest distance\nb/w two nodes is asked ?\nIs dijkstra algorithm performs better there or any other algorithm like BFS better makes sense there ? \n\nI came across similar question Java - Find shortest path between 2 points in a distance weighted map\nbut this question refers the very small sample set and uses the dijkstra algorithm here."
]
| [
"java",
"graph"
]
|
[
"Electro Mechanical Relay Input to Arduino",
"I have a 220 V electro mechanical relay (Normally open by default).\nI want to read input from Arduino when my relay goes to normally close state from normally open or vice verson.\nIf I have more then 10 relay I want read 10 input from Arduino board.\n\nIs is possible if yes please explain."
]
| [
"arduino",
"iot"
]
|
[
"How to get UTF-8 conversion for a string",
"Frédéric in java converted to Frédéric.\nHowever i need to pass the proper string to my client.\nHow to achieve this in Java ?\n\nDid tried \n\nString a = \"Frédéric\";\nString b = new String(a.getBytes(), \"UTF-8\");\n\n\nHowever string b also contain same value as a.\nI am expecting string should able to store value as : Frédéric\nHow to pass this value properly to client."
]
| [
"java"
]
|
[
"Allow URL's in subdirectory of Wordpress",
"I have an installation of WordPress in public_html, also I have a folder there containing a crm system.\nThe problem is that everything works fine but I get an 404 error when trying to load the crm system, specifically the JS and CSS files wont load. PHP works fine.\nHere is the main .htaccess in public_html.\nSeems like WordPress does not allow me to fetch the files inside the subdirectory and throws 404 errors.\nRewriteEngine On\nRewriteCond %{HTTPS} !=on\nRewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]\n\n<IfModule mod_rewrite.c>\nRewriteEngine On\nRewriteRule ^wp-admin/includes/ - [F,L]\nRewriteRule !^wp-includes/ - [S=3]\nRewriteRule ^wp-includes/[^/]+\\.php$ - [F,L]\nRewriteRule ^wp-includes/js/tinymce/langs/.+\\.php - [F,L]\nRewriteRule ^wp-includes/theme-compat/ - [F,L]\nRewriteRule ^index\\.php$ - [L]\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule . index.php [L]\nOptions +FollowSymlinks\n</IfModule>\n\n<IfModule Litespeed>\nSetEnv noabort 1\n</IfModule>\n\n<IfModule mod_rewrite.c>\nRewriteEngine On\nRewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]\nRewriteBase /\nRewriteRule ^index\\.php$ - [L]\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule . /index.php [L]\n</IfModule>"
]
| [
"wordpress",
".htaccess",
"mod-rewrite",
"subdirectory",
"litespeed"
]
|
[
"Complex query for searching in solr",
"We are storing data for product entity in below format in solr search engine.\n\n{\n\nid:unique_id,\n\n...\n\n...\n\n...\n\nprice_per_quant: [\n \"1-50|1\",/* here price per quantity is save in key value pari e.g for quantity 1 to 50 price should be 1*/\n \"51-100|2\",\n \"101-150|3\",\n \"151-200|4\"\n]\n\n\n}\n\n\nCase I need to follow \n\n\nif I search for quantity 20 then above result should display.\nif I search for price 1 then above result should display.\nif I search for price 3 and quantity 60 then above result should\nnot display.\n\n\nAnd one more thing: how can I manage the facet search on those price_per_quant field?\n\nI am using Solarium-project php library for connecting with solr."
]
| [
"php",
"solr",
"solarium"
]
|
[
"What happens if master node dies in kubernetes? How to resolve the issue?",
"I've started learning kubernetes with docker and I've been thinking, what happens if master node dies/fails. I've already read the answers here. But it doesn't answer the remedy for it.\nWho is responsible to bring it back? And how to bring it back? Can there be a backup master node to avoid this? If yes, how?\nBasically, I'm asking a recommended way to handle master failure in kubernetes setup."
]
| [
"docker",
"kubernetes"
]
|
[
"Useful Entry-Level Resources for Machine Learning",
"I am looking for some entry level posts about machine learning. Can anyone suggest anything for somebody new to this subject?"
]
| [
"machine-learning"
]
|
[
"How to set the decimal places to auto according user entries in VB.NET?",
"I have textbox receives number by the user.\nthe problem is that I want to format this textbox to show the numbers as the next face:\n15000.25 >> 15,000.25\nI used FormatNumber Function:\ndim x as double\nx = FormatNumber(textbox1.text,2)\ntextbox1.text = x\n\nbut here the problem is I want to keep the decimal places as entered by the user, examples:\n\n15000.225 >> 15,000.225 NOT 15,000.22\n0.00083 >> 0.00083 NOT 0\n\nI hope my problem is clear."
]
| [
"vb.net"
]
|
[
"Django - Site matching query does not exist",
"Im trying to get the admin site of my app in Django working. Ive just sync`d the DB and then gone to the site but I get the error ...\n\nSite matching query does not exist.\n\n\nAny ideas ?"
]
| [
"python",
"django",
"django-models"
]
|
[
"How to save log in session and other cookies to access a website some time later?",
"I know we can enable cookies in scrapy setting to navigate to different pages of a website without re-log-in every time once we successfully log in to that website. But, this is limited to a single execution or run of a spider. So, my concern is can we save those cookies in a file or in a database and use that later whenever we want to access to the website unless the session expires? Thanks."
]
| [
"python",
"web-scraping",
"scrapy",
"session-cookies"
]
|
[
"jQuery hover issue on second function (mouseout)",
"Having an issue with .hover() on mouse'ing out. Doesn't seem to work. It works on the fade in, but not out. I am basically fading in another image on top of it. The 'clone' has a lower z-index to start, and I bring it forward and then fade it in on hover. Both images are stacked.\n\nThe fiddle: http://jsfiddle.net/C6AfM/\n\nThe JavaScript:\n\n$.fn.hoverImage = function() {\n //add event handler for each image (otherwise it will add the same event handler for all images all at once)\n this.each(function() {\n var img = $(this);\n var magnifyImage = img.next();\n\n //hover: first function is for mouseover, second is on mouseout\n img.hover(function() {\n magnifyImage.css(\"z-index\", 2).animate({\n opacity:0.8 \n }, 200);\n }, function() {\n magnifyImage.css(\"z-index\", -200).animate({\n opacity:0\n }, 200);\n });\n });\n}\n\n\nThe HTML:\n\n<span class=\"img-span\"> \n <img src=\"(url)\" class=\"project-img\"> \n <img src=\"(url)\" class=\"project-img-clone\"> \n <figcaption>Caption</figcaption>\n</span>\n\n\nThe CSS:\n\n.img-span {\n width:27.08333333333333%; /* 260 / 960 */\n margin-right:3.009259259259259%; /* 26 / 864 */\n display:inline-block;\n vertical-align: top; \n position:relative;\n}\n\n.project-img {\n max-width:100%;\n}\n\n.project-img-clone {\n position:absolute;\n top:0;\n left:0;\n max-width: 100%;\n z-index:-200;\n opacity:0;\n}"
]
| [
"javascript",
"jquery",
"html",
"css"
]
|
[
"Dataframe Row(sum(fld)) to a discrete value",
"I have this:\n\ndf = sqlContext.sql(qry)\ndf2 = df.withColumn(\"ext\", df.lvl * df.cnt)\nttl = df2.agg(F.sum(\"ext\")).collect()\n\n\nwhich returns this:\n\n[Row(sum(ext)=1285430)]\n\nHow do devolve this down to just the discreet value 1285430 without it being a list Row(sum())?\n\nI've researched and tried so many things I'm totally stymed."
]
| [
"dataframe"
]
|
[
"Saving form values to another PHP page",
"I have this piece of Javascript:\n\n<script type=\"text/javascript\" src=\"sha512.js\"></script>\n<script type=\"text/javascript\" src=\"forms.js\"></script>\n\n<script>\n function loadXMLDoc(form, password) \n {\n var xmlhttp;\n if (window.XMLHttpRequest)\n {// code for IE7+, Firefox, Chrome, Opera, Safari\n xmlhttp=new XMLHttpRequest();\n }\n else\n {// code for IE6, IE5\n xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n }\n xmlhttp.onreadystatechange=function()\n {\n if (xmlhttp.readyState==4 && xmlhttp.status==200)\n {\n document.getElementById(\"myDiv\").innerHTML=xmlhttp.responseText;\n formhash(form, password);\n }\n }\n xmlhttp.open(\"POST\",\"post.php\",true);\n xmlhttp.send();\n }\n</script>\n\n\nAnd some HTML:\n\n<div id=\"myDiv\">\n <form action=\"register.php\" method=\"post\">\n Email: <input type=\"text\" name=\"email\" /><br />\n Username: <input type=\"text\" name=\"username\" /><br />\n Password: <input type=\"password\" name=\"p\" id=\"password\" /><br />\n <input type=\"button\" value=\"Register\" onclick=\"loadXMLDoc(this.form, this.form.password);\" />\n </form>\n</div>\n\n\nThe Javascript code above has the job to run some Ajax with PHP and after that, run a encryption function (formhash).\nWhen the Ajax is run, it reads a page named \"post.php\" the post.php's job is to check if any of the fields are empty, before the password is encrypted.\n\nMy problem is that post.php can't remember that there is any values from the Register form which I posted above. post.php has to remember what the user typed in the fields, in order to see if they are empty or not. Any ideas on, how I can transfer those values to the post.php file?"
]
| [
"javascript",
"php",
"jquery",
"ajax"
]
|
[
"Add token to existing prismjs language",
"I'm trying to add to prismjs's markup language, to add a new token as follows:\n{something}\n^\\_______/^\n| | `---punctuation\n| `---variable\n`---punctuation\n\nSo that this code block ....\n<div class="blah">\n {test} {sit_date_ran}\n</div>\n\n... would be highlighted as ...\n\n... here's what I've tried ...\nconst lang = cloneDeep(languages.markup);\n\n lang.interpolation = {\n pattern: /^\\{.+?\\}$/,\n inside: {\n punctuation: /[\\{\\}]/,\n variable: /^\\{(?:)\\}$/,\n }\n };"
]
| [
"javascript",
"syntax-highlighting",
"prismjs"
]
|
[
"Consuming Soap OTA_AirAvailRQ service from Sabre",
"I'm implementing a call to Sabre OTA_AirAvailRQ. After going thorugh the documentation i have the request but Sabre keep responding:\n\n <stl:ApplicationResults status=\"Unknown\">\n <stl:Error type=\"Application\" timeStamp=\"2017-07-04T11:55:36-05:00\">\n <stl:SystemSpecificResults>\n <stl:Message>Sending request to the Host failed</stl:Message>\n <stl:ShortText>ERR.SWS.HOST.CONNECTOR_ERROR</stl:ShortText>\n </stl:SystemSpecificResults>\n </stl:Error>\n </stl:ApplicationResults>\n\n\nThe sample is from Sabre Site.\n\nAny idea what is wrong with the request ?\n\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<SOAP-ENV:Envelope xmlns:ns=\"http://webservices.sabre.com/sabreXML/2011/10\" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <SOAP-ENV:Header>\n <eb:MessageHeader xmlns:eb=\"http://www.ebxml.org/namespaces/messageHeader\" SOAP-ENV:mustUnderstand=\"0\">\n <eb:From>\n <eb:PartyId eb:type=\"urn:x12.org:IO5:01\">132654</eb:PartyId>\n </eb:From>\n <eb:To>\n <eb:PartyId eb:type=\"urn:x12.org:IO5:01\">56465</eb:PartyId>\n </eb:To>\n <eb:CPAId>IPCC</eb:CPAId>\n <eb:ConversationId>12340</eb:ConversationId>\n <eb:Service eb:type=\"sabreXML\"></eb:Service>\n <eb:Action>OTA_AirAvailLLSRQ</eb:Action>\n <eb:MessageData></eb:MessageData>\n </eb:MessageHeader>\n <wsse:Security xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2002/12/secext\">\n <wsse:BinarySecurityToken>Shared/IDL:IceSessXXXXXXXXXX</wsse:BinarySecurityToken>\n </wsse:Security>\n </SOAP-ENV:Header>\n <SOAP-ENV:Body>\n <ns:OTA_AirAvailRQ Version=\"2.4.0\">\n <ns:OriginDestinationInformation>\n <ns:FlightSegment DepartureDateTime=\"12-12\">\n <ns:DestinationLocation LocationCode=\"DFW\"/>\n <ns:OriginLocation LocationCode=\"HNL\"/>\n </ns:FlightSegment>\n </ns:OriginDestinationInformation>\n </ns:OTA_AirAvailRQ>\n </SOAP-ENV:Body>\n</SOAP-ENV:Envelope>"
]
| [
"sabre"
]
|
[
"ActionScript - setTextFormat() More Than Once on Same String?",
"i'm unsuccessfully attempting to assign a textFormat to two different parts of the same string, but the second time it doesn't register and remains the default text format. both styles (regular and bold) of the font are embedded.\n\n//Create Text Field\nprivate function createAboutWindowTextField():TextField\n {\n var aboutWindowFont:Font = new AboutWindowFont();\n\n var regularFormat:TextFormat = new TextFormat();\n var boldFormat:TextFormat = new TextFormat();\n\n regularFormat.size = boldFormat.size = 12;\n regularFormat.font = boldFormat.font = aboutWindowFont.fontName;\n regularFormat.align = boldFormat.align = TextFormatAlign.CENTER;\n boldFormat.bold = true;\n\n var result:TextField = new TextField();\n result.antiAliasType = AntiAliasType.ADVANCED;\n result.autoSize = TextFieldAutoSize.LEFT;\n result.defaultTextFormat = regularFormat;\n result.embedFonts = true;\n result.multiline = true;\n result.selectable = false;\n result.type = TextFieldType.DYNAMIC;\n\n result.text = \"First Header\\n\" +\n \"Version 1.0\\n\" + \n \"Copyright © 2011\\n\\n\" +\n\n \"Second Header:\\n\" +\n \"Other info\"; \n\n result.setTextFormat(boldFormat, result.text.indexOf(\"First Header\"), (\"First Header\").length);\n result.setTextFormat(boldFormat, result.text.indexOf(\"Second Header:\"), (\"Second Header:\").length);\n\n return result;\n }\n\n\nthe above code should result in both \"First Header\" and \"Second Header:\" becoming bold, but only \"First Header\" will be set as bold while \"Second Header:\" seems to be simply ignored. what's the problem?"
]
| [
"actionscript-3",
"text",
"format",
"set"
]
|
[
"subplot matplotlib wrong syntax",
"I am using matplotlib to subplot in a loop. For instance, i would like to subplot 49 data sets, and from the doc, i implemented it this way;\n\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nX1=list(range(0,10000,1))\nX1 = [ x/float(10) for x in X1 ]\nnb_mix = 2\n\nparameters = []\n\nfor i in range(49):\n\n param = []\n\n Y = [0] * len(X1)\n\n for j in range(nb_mix):\n\n mean = 5* (1 + (np.random.rand() * 2 - 1 ) * 0.5 )\n var = 10* (1 + np.random.rand() * 2 - 1 )\n scale = 5* ( 1 + (np.random.rand() * 2 - 1) * 0.5 )\n\n Y = [ Y[k] + scale * np.exp(-((X1[k] - mean)/float(var))**2) for k in range(len(X1)) ] \n param = param + [[mean, var, scale]]\n\n\n\n ax = plt.subplot(7, 7, i + 1)\n ax.plot(X1, Y)\n\n parameters = parameters + [param]\n\nax.show()\n\n\nHowever, i have an index out of range error from i=0 onwards.\n\nWhere can i do better to have it works ?\n\n-- this is the error i get\n\nTraceback (most recent call last):\n File \"F:\\WORK\\SOLVEUR\\ALGOCODE\\PYTHON_\\DataSets\\DataSets_DONLP2_gaussians.py\", line 167, in <module>\n ax = plt.subplot(7, 7, i + 1)\n File \"C:\\Python27\\lib\\site-packages\\matplotlib\\pyplot.py\", line 766, in subplot\n a = fig.add_subplot(*args, **kwargs)\n File \"C:\\Python27\\lib\\site-packages\\matplotlib\\figure.py\", line 777, in add_subplot\n a = subplot_class_factory(projection_class)(self, *args, **kwargs)\n File \"C:\\Python27\\lib\\site-packages\\matplotlib\\axes.py\", line 8364, in __init__\n self._subplotspec = GridSpec(rows, cols)[int(num)-1]\n File \"C:\\Python27\\lib\\site-packages\\matplotlib\\gridspec.py\", line 175, in __getitem__\n raise IndexError(\"index out of range\")\nIndexError: index out of range\n\n\nThanks"
]
| [
"python",
"matplotlib",
"plot",
"outofrangeexception",
"subplot"
]
|
[
"string splitting with multiple values using re.split()",
"I have a string:\n\"2y20w2d2h2m2s\"\nI need to split it to be like that:\n[\"2y\",\"20w\",\"2d\",\"2h\",\"2m\"2s”]\nI tried to use re.split but i couldnt make it work\nthis was my attempt:\ntime = re.split(\"s m h d w y\", time)\n*time is the string above\nfinally, I will apricate of you would help understand how to make it work"
]
| [
"python",
"python-3.x",
"list",
"split",
"re"
]
|
[
"jQueryMobile running on Android / PhoneGap refuses .load / .ajax",
"I really hate asking questions that I feel were asked a thousand times before. This is one of those questions I feel others must have encountered, but having searched stack overflow, none of the supposed solutions work for me so I must be doing something wrong.....\n\nI have an extremely simple app setup. index.htm, and terms.htm. There is some textual data in test.htm. I set both $.support.cors = true; and $.mobile.allowCrossDomainPages = true; at the appropriate time after stuff has loaded.\n\nAt first I tried loading terms.htm's data into an element within index using $('#elementid').load('terms.htm'); (both test and index are in the same root /assets/www/ directory, and my webview loads index oncreate) but absolutely nothing was happening. So I opted to try .ajax so that I could at least get an error message, and all I get is 'error'. Surely, it is possible to load local textual assets with JQ on DroidGap?\n\n$('#header').load('terms.htm');\n$.ajax({\n type:\"GET\",\n timeout:10000,\n async: false,\n url: \"terms.htm\",\n success: function(data) {\n $('#header').html(data);\n },\n error: function(xhr,msg){\n alert( msg);\n }\n});"
]
| [
"android",
"jquery",
"jquery-mobile",
"cordova"
]
|
[
"total tracking varible using sqlite fetchone",
"I am, having problems trying to sore the output of an sqlite query in a python variable to keep track of a total. I have looked around and seen examples using the c.fetchone() method but I cannot seem to get it to work , I keep getting the error TypeError: 'NoneType' object has no attribute '___getitem____' . I don't understand what this means . can anyone help?\n\n i = -1\n i = i + 1\n\n self.t = pytesseract.image_to_string(PIL.Image.open('test2.jpg'))\n self.c.execute(\"SELECT name FROM item WHERE code = '%s'\" % self.t)\n self.listbox.insert(i,self.c.fetchone())\n self.listbox1.insert(i,\"£\")\n self.c.execute(\"SELECT price FROM item WHERE code = '%s'\" % self.t)\n self.listbox2.insert(i,self.c.fetchone())\n\n self.y=self.c.fetchone()[i]\n print self.y"
]
| [
"python",
"sqlite"
]
|
[
"MSSQL | Joining records that span a date range to a Calendar to distribute the element into the Calendar bins",
"Good day,\n\nInformation: I have a Calendar table, with a monthly grain. Excerpt:\n\nID StartDate EndDate Year Month\n1 2000-01-01 2000-01-31 2000 200001\n2 2000-02-01 2000-02-29 2000 200002\n3 2000-03-01 2000-03-31 2000 200003\n4 2000-04-01 2000-04-30 2000 200004\n5 2000-05-01 2000-05-31 2000 200005\n\n\nI then have a Task table, where the records comprise of a TaskId, an arbitrary start date, arbitrary end date and a number of attributes. An example excerpt:\n\nTaskId Start End Attr1 Attr2 Attr3\n1 2025-03-13 2026-11-27 1 2 3\n2 2027-08-19 2030-02-21 4 5 6\n3 2017-06-04 2018-07-30 7 8 9\n\n\nThe output I desire is something along the following lines:\n\nTaskId Month Start End DaysInPeriod Attr1 Attr2 Attr3\n1 202503 2025-03-13 2025-03-31 19 1 2 3\n1 202504 2025-04-01 2025-04-30 30 1 2 3\n.\n.\n1 202611 2026-11-01 2026-11-27 27 1 2 3\n\n\nSo far, I'm able to get the start month and end month for each of the tasks, but I'm battling to make the leap of logic required to distribute the tasks across the entire range."
]
| [
"tsql",
"join",
"sql-server-2014",
"date-range"
]
|
[
"How to detect screen on the image?",
"I need to detect a screen on the photo. It can be a laptopt screen, tv, etc. For now, I use tensorflow's deeplab to get a mask, and then opencv to get corners.\nIt works ok, but I'm pretty sure there should be a better wayto do it. All I need is to get those 4 corners or an array of fourths. Maybe I could use another model to remove the opencv part?\nThat's how it looks now:"
]
| [
"flutter",
"tensorflow",
"neural-network",
"image-segmentation"
]
|
[
"add a scrollable jpanel to a gridlayout",
"I'm building a grid filled with labels. One of them contains html-text and should resize to maximum format and be scrollable. I found how to add a JScrollPane but it stays one line height, I just can't find how to resize it even when I give it a size of 400x400 ...\n\nRemoving getViewport() gives the same result.\n\nJPanel grid = new JPanel(new GridLayout(1,2));\n\n// first cell of the grid\ngrid.add(new JLabel(\"title\"));\n\n// second cell of the grid, this should be the scrollable one \nJScrollPane scroll = new JScrollPane();\nscroll.getViewport().setSize(400, 400);\nscroll.getViewport().add(new JLabel(\"<html>long<br>html<br>text</html>\"));\ngrid.add(scrollVersion, BorderLayout.CENTER); \n\n\nAny ideas ?\n\nThanks a lot ..."
]
| [
"java",
"swing",
"jpanel",
"jscrollpane"
]
|
[
"Javascript: How exactly do network IOs impact the execution?",
"Let's consider a Javascript web app that opened a network data channel with another peer. Now, let our app send 10 (relatively large) messages:\n\nfor (let i = 0; i < 10; i++) {\n otherPeer.channel.send(message[i])\n}\n\n\nFrom my understanding of the Javascript event loop, this will not block the code execution but will just queue some IO tasks. But intuitively, those messages will take some time to be sent, probably some time relative to the available upload capacity. \n\nSo which component will be responsible to buffer and spend the time to send these messages? Will it be in a completely separate thread, or process, or will it also affect and delay the Javascript Event queue? Even if the messages are really big and the network slow?\n\nWhat happens (in term of CPU usage and execution threads) if instead of sending 10 messages, I'd send thousands of them?\nWhat should the Javascript app do to avoid overwhelming the network?\n\nI am interested in this because I'm trying to build a simulated/virtualized environment for my Javascript app. In order to run relevant simulations, I need to virtualize the network channels of the running agents and thus, I need to understand precisely how sending messages through the network will impact the execution of the agent."
]
| [
"javascript",
"multithreading",
"networking",
"io"
]
|
[
"Android ObjectAnimator background Colour and text",
"I currently have a list view and I want to have the animation change colour depending on a status from the network. Sio far this is working, but it doesn't look too fluid, would there be a way to have so it would go from transparent, to the colour normal but without a long fade in between.\n\nHere is my code so far.\n\nList<ObjectAnimator> arrayListObjectAnimators = new List<ObjectAnimator>();\n\nObjectAnimator bgColor = ObjectAnimator.OfInt(\n DoorItemLayoutView,\n \"backgroundColor\",\n Color.Transparent, \n color,\n color,\n Color.Transparent);\nbgColor.SetEvaluator(new ArgbEvaluator());\n\nObjectAnimator doorTxtColor = ObjectAnimator.OfInt(\n doorName,\n \"textColor\", \n Color.White, \n textChangeColour, \n textChangeColour, \n Color.White);\ndoorTxtColor.SetEvaluator(new ArgbEvaluator());\n\nObjectAnimator siteTxtColor = ObjectAnimator.OfInt(\n doorSiteName, \n \"textColor\",\n Color.White, \n textChangeColour, \n textChangeColour, \n Color.White);\nsiteTxtColor.SetEvaluator(new ArgbEvaluator());\n\nObjectAnimator doorIconBackground = ObjectAnimator.OfInt(\n doorImage.Background,\n \"background\", \n Color.Transparent, \n Resource.Drawable.door_active_background,\n Resource.Drawable.door_active_background,\n Color.Transparent);\ndoorIconBackground.SetEvaluator(new ArgbEvaluator());\n\narrayListObjectAnimators.Add(bgColor);\narrayListObjectAnimators.Add(doorTxtColor);\narrayListObjectAnimators.Add(siteTxtColor);\narrayListObjectAnimators.Add(doorIconBackground);\n\nvar objectAnimators = arrayListObjectAnimators.ToArray();\nAnimatorSet animSetXY = new AnimatorSet();\nanimSetXY.PlayTogether(objectAnimators);\nanimSetXY.SetDuration(2000);\nanimSetXY.Start();"
]
| [
"c#",
"android",
"xamarin",
"xamarin.android"
]
|
[
"How can I export score data from a Flash Game (still in development)",
"The game will be on a school VLE (virtual learning environment) like 'Moodle'. Can you export to email? Spreasheet? Or can it only be done with php? Do not want to be spending weeks on it!"
]
| [
"flash",
"actionscript",
"export"
]
|
[
"Android Navigation Architecture Component - Is Navigation Architecture Component meant to use Single Activity Only?",
"I currently learning on the new Android Navigation Architecture Component (https://developer.android.com/topic/libraries/architecture/navigation/).\n\nI kind of confuse with its motive and concept, here are my uncertainties:\n\n\nIs Android Navigation Architecture Component designed to eliminate the need of using multiple Activity in a single apps? Which mean, the whole apps just need a Single Activity and all other page will be Fragment?\nDoes using Multiple Activities in the apps, but in the same time using the Android Navigation Architecture Component to navigate the Fragment actually violate the purpose of Android Navigation Architecture Component?\n\n\nExample Scenario for Question 2:"
]
| [
"android",
"kotlin",
"navigation",
"android-jetpack",
"android-architecture-navigation"
]
|
[
"Extend Python list by assigning beyond end (Matlab-style)",
"I want to use Python to create a file that looks like\n\n# empty in the first line\nthis is the second line\nthis is the third line\n\n\nI tried to write this script\n\nmyParagraph = []\nmyParagraph[0] = ''\nmyParagraph[1] = 'this is the second line'\nmyParagraph[2] = 'this is the third line'\n\n\nAn error is thrown: IndexError: list index out of range. There are many answers on similar questions that recommend using myParagraph.append('something'), which I know works. But I want to better understand the initialization of Python lists. How to manipulate a specific elements in a list that's not populated yet?"
]
| [
"python",
"list"
]
|
[
"When a notification email should be sent?",
"I have a number of action a user can preform in a social network website, like adding friends following people and such.\n\nNow these actions are done by Ajax, and the user could easily undo them(when say following someone, the follow link is turned into unfollow and clicking it again -of course- results in unfollowing the user, and it -the link- turning back into follow).\n\nWhen these actions occur, the user (being followed) is notified by via email. and the code that sends the email is run in the same ajax call.\nThat results in two problems, one is that the email is sent even if the user decides to unfollow the other person at once. And two, multiple emails are sent if the user hits the follow/unfollow link multiple times.\n\nI thought of using a session variable to store users'actions and then at \"some point\" check on that variable and preform accordingly. My struggle is in finding that \"some point\", thought of when the user logs out, but I can't guarantee that the user will actually log out.\n\nany suggestions?"
]
| [
"php",
"email",
"notifications"
]
|
[
"Python: 'NoneType' object is not subscriptable' error",
"I'm new to databases in Python, so to practice some key skills I'm building a login screen that writes usernames and hashed passwords to the database, and then checks the user's inputs against what's in the database. However, when trying to pull the usernames and passwords from the database and storing them in variables, I keep getting the \"'NoneType' object is not subscriptable\" error.\n\nHow can I fix this?\n\nThis is the function from my program that contains the error\n\ndef login():\nusernameAttempt = input(\"Enter your username: \")\npasswordAttempt = input(\"Enter your password: \")\n\nusernameSql = \"\"\"SELECT Username FROM Details WHERE Password = '%s'\"\"\" % (passwordAttempt) # Selecting username in database\ncur.execute(usernameSql)\nusernameSql = cur.fetchone()\nuserFetched = usernameSql[0] # Pulling the item from the database\n\npasswordSql = \"\"\"SELECT Password FROM Details WHERE Username = '%s'\"\"\" % (usernameAttempt)\ncur.execute(passwordSql)\npasswordSql = cur.fetchone()\npassFetched = passwordSql[0]\n\ndbPassword, dbSalt = passFetched.split(\":\")\n\nreturn dbPassword, dbSalt, passwordAttempt, usernameAttempt, userFetched, passFetched\n\n\nI expected the variables userFetched and passFetched to be assigned the values held at indexes 0 in the username and password columns, but the error messages are as follows:\n\nTraceback (most recent call last):\n\nFile \"C:\\Users\\laure\\Documents\\Login screen.py\", line 57, in \n dbPassword, dbSalt, passwordAttempt, usernameAttempt, userFetched, passFetched = login()\n\nFile \"C:\\Users\\laure\\Documents\\Login screen.py\", line 34, in login\n userFetched = usernameSql[0] # Pulling the item from the database\nTypeError: 'NoneType' object is not subscriptable"
]
| [
"python",
"python-3.x",
"nonetype"
]
|
[
"hive beeline use ACID transaction manager",
"I'm trying to run this command using beeline. \n\ncreate table <table_1> like <table_2>\n\n\nbut it appears my Hive is configured to run in ACID mode. So this query fails with \n\n\n Error: Error while compiling statement: FAILED: SemanticException\n [Error 10265]: This command is not allowed on an ACID table \n with a non-ACID transaction manager. Failed command: create table\n like (state=42000,code=10265)\n\n\nWhat's correct syntax to run beeline query using ACID transaction manager without changing any global configuration ? \n\nmy beeline command is :\n\nbeeline -u <jdbc_con> -e \"create table <table_1> like <table_2>\";\n\n\nI suppose I should use something like \n\nhive>set hive.support.concurrency = true;\nhive>set hive.enforce.bucketing = true;\nhive>set hive.exec.dynamic.partition.mode = nonstrict;\nhive>set hive.txn.manager = org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;\nhive>set hive.compactor.initiator.on = true;\nhive>set hive.compactor.worker.threads = a positive number on at least one instance of the Thrift metastore service;\n\n\nBut how should I include this into beeline ? \nWhen I tried \n\nbeeline -u $jdbc_con -e \"set hive.support.concurrency = true; create table <table_1>_test like <table_2>\";\n\n\nIt seems it's not possible to change theses parameter this way.\n\n\n Error: Error while processing statement: Cannot modify\n hive.support.concurrency at runtime. It is not in list of params that\n are allowed to be modified at runtime (state=42000,code=1)\n\n\nThank you for any help."
]
| [
"hive",
"hortonworks-data-platform",
"beeline"
]
|
[
"How to get expiration notification of an auto-renewable subscription of the In-App Purchase?",
"I've implemented a purchase of the auto-renewable subscription type in my iOS app, however I can't find a good way to get the expiration notification of the subscription when a user unsubscribed it and the already purchased subscription expires.\n\nOne of the method I can think of is to call [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]\nrepeatedly, this method will retrieve all completed transactions from iTunes connect and I can figure out if the corresponding subscription has expired or not buy validate its receipt,but the side effect is it will bring up an alert view asking the user for the password of his/her AppStore account,this could be very annoying to users so seems it's not a good idea.\n\nSo,my question is...How can I get the expiration notification without disturbing the user?"
]
| [
"ios",
"in-app-purchase"
]
|
[
"How can I detect web pages completely?",
"A few months back I had changed the url structure of my webpages as follows:\n\nOld : www.xyz.com/productname.php?id=XYZ\n\nNew : www.xyz.com/product/XYZ\n\nBut at the same time, the url structure of some of the other pages which are not associated with productname.php page has been created.\n\ne.g. www.xyz.com/product/about-us.php has been created for page www.xyz.com/about-us.php and that new page sends the user to 404 error page.\n\nIs there any way to get rid of this?"
]
| [
"url-redirection"
]
|
[
"Handling class initialization failure in Swift extension",
"I'm rewriting an Objective C category below to Swift:\n\n@implementation UIImage (Extra)\n\n+ (UIImage *)validImageNamed:(NSString *)name\n{\n UIImage *image = [self imageNamed:name];\n NSAssert(image, @\"Unable to find image named '%@'\", name);\n return image;\n}\n\n\nThis asks to be implemented as an convenience init, but how can I check if designated initializer self.init(named:) succeeds?\n\nextension UIImage {\n convenience init(validateAndLoad name: String!) {\n self.init(named: name)\n\n // need to assert here if self.init fails\n }\n\n\nWhen self.init(named:) call fails, extension's init stops executing.\n\nI've tried creating an UIImage instance and assigning it to self, but this doesn't compile.\n\nOf course, a helper method can be used like in ObjC version:\n\nextension UIImage {\n\n class func validImage(named name: String) -> UIImage {\n var image = UIImage(named: name)\n assert(image == nil, \"Image doesn't exist\")\n return image\n }\n\n\nBut is there a way to implement this using an initializer?"
]
| [
"ios",
"swift",
"swift-extensions"
]
|
[
"Display Properties in UserControl",
"I have a class with a lot of properties like:\n\npublic class Person\n{\n public string Firstname{get;set;}\n public string Lastname{get;set;}\n public string Address{get;set;}\n public string City{get;set;}\n public int ZIPCode{get;set;}\n public string Country{get;set;}\n}\n\n\nI want to create a UserControl, where I can pass an instance of Person and show for each Property a TextBlock with the PropertyName and a TextBox with the Property-Value.\n\nMy first idea would be to use a grid with two columns and 6 rows. But this is a lot of \"work\" to type this down. \n\nIs there a \"easy\" way to achieve this? Can I do this with datatemplates or so?"
]
| [
"c#",
"wpf",
"class"
]
|
[
"Windows Terminal not accepting input/text or commands after Vmmem fix",
"Apologies if this is not the correct place to ask but I've been searching for a solution for a couple days now.\nIt started with trying to solve Vmmem eating all of my memory whether anything was running or not. I followed the instructions from https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig and once I did that Vmmem did drop considerably but when I launched Windows Terminal Ubuntu and Kali gave the error\nThe system cannot find the path specified. [process exited with code 4294967295]\nand would not except any input.\nSo after not being able to find someone with similar issues I deleted the file C:\\Users.wslconfig hoping all would just go back and I could try to start over. That was not the case though, after deleting the file Windows Terminal and distros seemed to load normally however they still would not accepting any input.\nThen tried uninstalling and reinstalling Windows Terminal but still same results loads but no inputs are recognized whether typing text or ctrl f to bring up the search I just tried that to see if other commands besides text would work.\nAn the individual terminals seem to be fine.\nI am a newbie so I'm sure it is something simple but I am looking for help before I make it worse. Also please keep the fix as elementary as possible but details on the why would be appreciated. I posted on their github as well but I thought someone here may have better or quicker insight.\nThank you in advance for your time and help."
]
| [
"input",
"text",
"terminal",
"wsl-2",
"windows-terminal"
]
|
[
"JPA use stored procedure in criteria query",
"I'm trying to define a criteria query with a function in select and in where statement.\n\nThe SQL query is:\n\nselect s.*, contr_topay(s.id) as rest\nfrom spedizionestd s\nwhere contr_topay(s.id) >0\n... other conditions\n... optional order by\n\n\ncontr_topay is the procedure in the database (Postgresql). I've defined a NamedStoredProcedure:\n\n@NamedStoredProcedureQuery(\n name = \"MovimentoContrassegno.contr_topay\",\n procedureName = \"contr_topay\",\n parameters = {\n @StoredProcedureParameter(mode = ParameterMode.IN, queryParameter = \"idsped\", type = Long.class, optional = false),\n @StoredProcedureParameter(mode = ParameterMode.OUT, queryParameter=\"importo\", type=Double.class, optional = false),\n }\n)\n\n\nand called it with success:\n\nStoredProcedureQuery query = this.em.createNamedStoredProcedureQuery(\"MovimentoContrassegno.contr_dapagare\");\n query.setParameter(\"idsped\", myid);\n query.execute();\n return (Double) query.getOutputParameterValue(2);\n\n\nNow, how can I put the procedure in the select clause and in the where condition inside a criteria query?\n\nNB: i need criteria query because I build dynamic query with additional where conditions and \"order by\" choised by the user at runtime\n\n(I'm using eclipselink 2.6.0)"
]
| [
"postgresql",
"jpa",
"eclipselink",
"criteria-api"
]
|
[
"subprocess.check_output is returning an enclosing b' ' string",
"git --git-dir=/path/to/project/.git --work-tree=/path/to/project describe --abbrev=0 --tags\n\nreturns release-11.5.5\nI have in my Python 3 code to get the latest release :\ngd = '--git-dir=' + os.path.join(BASE_DIR, '.git');\nwt = '--work-tree=' + BASE_DIR;\nlatest_release = subprocess.check_output(["git", gd, wt, "describe", "--abbrev=0", "--tags"]).strip()\n\nreturns b'release-11.5.5'\nFrom where did the enclosing b'' come from ?"
]
| [
"python"
]
|
[
"SQL query for operation between rows under some condition",
"Its little complicated query as it contains some conditions. \n\nI have tables like this:\n\ntable DC - which contains one row for one northing-easting pair\nColumns - Id Northing Easting \nPossibleValues - Guid Std value Std value\n\ntable DCR - which contains multiple rows for each row in DC. Each row here corresponds to data on each pass on that exact location.\nColumns - Id VibStatus DrivingDir CompactionValue UtcDate\nPossibleValues - Guid 0/1 Forward/Reverse/Neutral +ve integers Timestamp\n\ntable DCMappings - which contains mapping between both tables.\nDCId DCRId\n\n\nThe output I need should contain fields like this:\n\nResultTable\nDCId DCRId Northing Easting VibStatus DrivingDir CompValue Position CompProgress\n\n\nHere, Position is its position in chronological order when sorted by UtcDate grouped by DC.Id(See query at end to understand more). \n\nAnd CompProgress has some conditions which is making it complicated.\n\nCompProgress is percentage increase/decrease in CompValue compared to its previous row which was in same driving direction when arranged in ASC order of UtcDate(chronological) where the rows to be considered here should only be the ones with VibStatus set to ON(1) grouped by DCId's.\n\nEach row in DC has multiple rows in DCR. So if row 1 in DC has 10 rows in DCR, the CompProgress should consider these 10 rows alone for calculation and then for row 2 in DC, etc...\n\nI have written following query to extract needed fields except calculation of CompProgress. Please help me in this.\n\nSELECT DC.Id, DCR.Id, Northing, Easting, VibStatus, DrivingDir, CompValue, ROW_NUMBER() OVER (PARTITION By dcm.\"DCId\" ORDER BY dcr.\"UtcDate\") as passNo\nFROM \"DCR\" dcr LEFT JOIN \"DCMappings\" dcm ON \"Id\" = dcm.\"DCRId\"\n LEFT JOIN \"DC\" dc ON dc.\"Id\" = dcm.\"DCId\"\n\n\nNeed evaluation of CompProgress in this query.\n\nSorry for lot of text. But it was necessary to make others understand what is needed."
]
| [
"mysql",
"postgresql"
]
|
[
"Delete ActiveMQ queue after stopping a Camel Route",
"I have an issue on deleting an ActiveMQ queue because due to the error\n\nDestination still has an active subscription: queue://MyQueue\n\n\nThe reason is that there's a consumer attached to the queue, this is what I see from the ActiveMQ console, but the consumer should not be there and be active (IMHO, but having the issue I'm surely wrong), because :\n\nT0 : queue MyQueue having messages and no consumer attached\nT1 : a Spring TaskScheduler execute a code that create a Camel Route in charge to move messages in another queue with this code\n\n....\n//context is a CamelContext instance autowired\ncontext.addRoutes(new RouteBuilder() {\n\n public void configure() {\n\n from(myQueueURI)\n .id(myQueueURI)\n .to(destinationQueueURI); \n }\n\n\nT2 : on a specific fixed interval, another Spring TaskScheduler is in charge to query MyQueue in order to understand if it's empty, and in this case, try to remove the queue.\n\n....\n....\n@Autowired\npublic CachingConnectionFactory localCachingConnectionFactory;\n....\n....\nremoveCamelRoutes(queueName, routeId);\n\nprivate boolean removeCamelRoutes(String queueName, String routeId) throws JMSException{\n\n if (isQueueEmpty(queueName)){\n try {\n //context is a CamelContext instance autowired\n context.stopRoute(routeId);\n context.removeRoute(routeId);\n deleteQueue(queueName);\n } catch (Exception e) {\n //logs \n return false;\n }\n }\n ....\n ....\n}\n\nprivate boolean isQueueEmpty(String queueName) throws JMSException{\n ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) localCachingConnectionFactory.getTargetConnectionFactory();\n ActiveMQConnection connection = (ActiveMQConnection) activeMQConnectionFactory.createConnection();\n connection.start();\n Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);\n ActiveMQQueue queue = (ActiveMQQueue) session.createQueue(queueName);\n QueueBrowser queueBrowser = session.createBrowser(queue);\n try {\n if (queueBrowser.getEnumeration().hasMoreElements()){\n queueBrowser.close();\n return false;\n }\n return true;\n }\n finally {\n if (queueBrowser != null) {\n queueBrowser.close(); \n }\n session.close();\n connection.close();\n }\n}\n\n\nprivate void deleteQueue(String queueName) throws Exception {\n\n ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) localCachingConnectionFactory.getTargetConnectionFactory();\n ActiveMQConnection connection = (ActiveMQConnection) activeMQConnectionFactory.createConnection();\n connection.start();\n Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);\n ActiveMQQueue queue = (ActiveMQQueue) session.createQueue(queueName);\n\n try {\n //HERE is where the operation is failing\n connection.destroyDestination(queue);\n } \n finally {\n session.close();\n connection.close();\n }\n\n}\n\n\nI ask for some hints on where I miss something about the still alive consumer, I was thinking about the consumer related to Camel Route but it should be closed automatically with the Route, it could be the consumer attached on querying the queue, but I should have closed correctly Session and Connection.\n\nCamel version 2.15.1, ActiveMQ 5.9.0, Spring 4.1.3\n\nThanks a lot in advance."
]
| [
"java",
"spring",
"jms",
"apache-camel",
"activemq"
]
|
[
"Any similar thing of quick fixing in intellij like in eclipse",
"eclipse's quick fixing is very useful, is there any similar function in intellij ? I didn't find it, could you help on this ? thanks"
]
| [
"intellij-idea"
]
|
[
"Sequelize Connection Pool Creates huge number of connections in AWS-RDS databases",
"I am using Sequelize.js ORM Nodejs framework to connect the AWS RDS database. However, I noticed that, as and when I add connection pool setting in Sequelize.js configuration, It creates a huge number of connections on the RDS side and it does not even get closed automatically, until and unless I kill my nodejs process. I am using Sequelize 5.22.3.\nAnyone has faced this problem earlier or know any quick solution for it?"
]
| [
"node.js",
"amazon-web-services",
"sequelize.js"
]
|
[
"Why Abstract Class Required?",
"Can anybody tells me the significance of abstract class when we can achieve the the inheritance feature by normal class? \n\nThanks,\nPrashant N"
]
| [
"oop"
]
|
[
"\"Fontconfig error: Cannot load default config file\" on Ubuntu 16.04",
"I'm using python 2.7 on Anaconda, on Ubuntu 16.04, installed in a virtual machine with VMware Player on Windows 10.\n\nWhen running the following code, I get the following error:\n\n>>> import networkx as nx\n>>> G = nx.complete_graph(4)\n>>> pos = nx.nx_pydot.graphviz_layout(G)\nFontconfig error: Cannot load default config file\n\n\nI have tried setting the path as suggested here, both in the root and on the conda environment, I have tried to reinstall fontconfig both in the root and on the conda environment, and I have also tried the answer suggested here, and I have exited the console, and restart the machine several times, and I still get the same error.\n\nI will very much appreciate any help to solve this problem."
]
| [
"python-2.7",
"fonts",
"anaconda",
"networkx",
"ubuntu-16.04"
]
|
[
"CSS3: Cube with shadow",
"I think images speak louder than words in this case.\n\nI want to get this effect:\n\n\n\nBut the best I can do with CSS3 is this:\n\n\n\nAnd the code for this is absolutely terrible:\n\nbox-shadow: 1px 1px hsl(0, 0%, 27%),\n 2px 2px hsl(0, 0%, 27%),\n 3px 3px hsl(0, 0%, 27%),\n 4px 4px hsl(0, 0%, 27%),\n 5px 5px hsl(0, 0%, 27%),\n 6px 6px hsl(0, 0%, 27%),\n 7px 7px hsl(0, 0%, 27%),\n 8px 8px hsl(0, 0%, 27%),\n ...\n\n\nIs there any way that I can create an effect like this with pure CSS3? I don't mind having it be 3D, but isometric would be preferred.\n\nI don't need to place content onto the sides of the box, just onto the front face, so I'm working with just a single <div> element.\n\nHere's what I have so far: http://jsfiddle.net/X7xSf/3/\n\nAny help would be appreciated!"
]
| [
"html",
"css",
"cube",
"isometric"
]
|
[
"cakePHP complex find query",
"how do I build a find() query in cakePHP using these conditions:\n\nFind where \nMyModel.x = 1 and MyModel.y = 2 OR \nMyModel.x = 1 and MyModel.y value does not exist (or is equal to empty string)\n\n\nCan somebody tell me how I can go about building such find query?"
]
| [
"php",
"sql",
"cakephp",
"cakephp-1.3"
]
|
[
"how to center 2 images in bootstrap",
"I am getting use to the responsiveness of bootstrap and I have hit a small snag, normally I would have more than 2 images to display, but as of right now I only have 2 images and I would like to center them on this page link below for the time being and have them be responsive also.\n\nhttp://dagrafixdesigns.com/2019/industrial-darker/graphics.html\n\nClick on RAFTERS TAB\n\nI know I can do this with margins or padding, but I don't want to also have to make a media css to get it to look right on devices etc.\n\nIs there a easy add to the element to make this happen? It seems text-align inline html did nothing nor did center tag.\n\nThank you\nDean\n\nCODE SNIP of how it is currently\n\n<div class=\"row project-listing\">\n<div class=\"col-md-4 project-block\"><!--Project block start-->\n <div class=\"pro-thumb\"><!--Pro thumb start--> \n <a href=\"images/Hang/PG_ZOOM.png\" class=\"image-link\" title=\"Project Light Box Gallery Title\"> <img src=\"images/Hang/PG_ZOOM.png\" alt=\"\" class=\"img-responsive\"> </a> \n </div>\n <!--Pro thumb start--> \n</div>\n<!--Project block start-->\n<div class=\"col-md-4 project-block\"><!--Project block start-->\n <div class=\"pro-thumb\"><!--Pro thumb start--> \n <a href=\"images/Hang/AB_ZOOM.png\" class=\"image-link\" title=\"Project Light Box Gallery Title 2\"><img src=\"images/Hang/AB_ZOOM.png\" alt=\"\" class=\"img-responsive\"></a> \n </div>\n <!--Pro thumb start--> \n</div>\n<div class=\"hiderafters\">\n <div class=\"col-md-3 project-block\"><!--Project block start-->\n <div class=\"pro-thumb\"><!--Pro thumb start--> \n <a href=\"images/gallery-zoom.jpg\" class=\"image-link\" title=\"Project Light Box Gallery Title 3\"><img src=\"images/thumb.jpg\" alt=\"\" class=\"img-responsive\"></a> \n </div>\n <!--Pro thumb start--> \n </div>\n<div class=\"col-md-3 project-block\"><!--Project block start-->\n <div class=\"pro-thumb\"><!--Pro thumb start--> \n <a href=\"images/gallery-zoom.jpg\" class=\"image-link\" title=\"Project Light Box Gallery Title 4\"><img src=\"images/thumb.jpg\" alt=\"\" class=\"img-responsive\"></a> \n </div>\n <!--Pro thumb start--> \n</div>\n<div class=\"col-md-3 project-block\"><!--Project block start-->\n <div class=\"pro-thumb\"><!--Pro thumb start--> \n <a href=\"images/gallery-zoom.jpg\" class=\"image-link\" title=\"Project Light Box Gallery Title 5\"> <img src=\"images/thumb.jpg\" alt=\"\" class=\"img-responsive\"> </a> \n </div>\n <!--Pro thumb start--> \n </div>\n <!--Project block start-->\n <div class=\"col-md-3 project-block\"><!--Project block start-->\n <div class=\"pro-thumb\"><!--Pro thumb start--> \n <a href=\"images/gallery-zoom.jpg\" class=\"image-link\" title=\"Project Light Box Gallery Title 6\"><img src=\"images/thumb.jpg\" alt=\"\" class=\"img-responsive\"></a> \n </div>\n <!--Pro thumb start--> \n </div>\n <div class=\"col-md-3 project-block\"><!--Project block start-->\n <div class=\"pro-thumb\"><!--Pro thumb start--> \n <a href=\"images/gallery-zoom.jpg\" class=\"image-link\" title=\"Project Light Box Gallery Title 7\"><img src=\"images/thumb.jpg\" alt=\"\" class=\"img-responsive\"></a> \n </div>\n <!--Pro thumb start--> \n </div>\n <div class=\"col-md-3 project-block\"><!--Project block start-->\n <div class=\"pro-thumb\"><!--Pro thumb start--> \n <a href=\"images/gallery-zoom.jpg\" class=\"image-link\" title=\"Project Light Box Gallery Title 8\"><img src=\"images/thumb.jpg\" alt=\"\" class=\"img-responsive\"></a> \n </div>\n </div>\n <!--Pro thumb start--> \n</div>\n</div>"
]
| [
"html",
"css",
"twitter-bootstrap",
"centering"
]
|
[
"jquery mutiple text field update in form",
"i need to create a html form where upon entering value on one input text field should automatically enter calculated value in another input text field using jquery.I found a source http://pastie.org/2607417,where i have input text value which output in a paragraph... Any help would be greatly appreciated"
]
| [
"javascript",
"jquery",
"jquery-ui",
"jquery-selectors"
]
|
[
"Scala for-yield with multiple conditions",
"I have a bitmap object that is a 3-dimensional array with third dimension equal to 3. I want to split it into 64x64x3 blocks. For this I have the following code snippet:\n\nval tiles: someType = for {\n\n x <- bitmap.indices by 64\n y <- bitmap(0).indices by 64\n\n\n data = for {\n //For all X and Y within one future tile coordinates\n tx <- x until x + 64\n ty <- y until y + 64\n } yield bitmap(tx)(ty)\n\n...\n}\n\n\nIn the data for loop yield will cause an ArrayIndexOutOfBoundsException at the last chunk. How can I check, whether x and y don't exceed array borders in this loop? Is it possible to have multiple until conditions for the same variable in the same loop?"
]
| [
"scala"
]
|
[
"Terragrunt for_each value, can't retrieve data in other resources",
"I have an issue with my terragrunt/terraform code as below.\nI don't know the right way to retrieve my both crawlers created by my for_each loop.\nNormally I create it with for and count.\nI can't retrieve the correct values in my action triggers (main.tf).\nterragrunt file (input):\ninputs = {\n glue_crawler = {\n crawler = {\n crawler_name = "test",\n description = "test crawler"\n },\n crawler1 = {\n crawler_name = "test2",\n description = "test2 crawler"\n }\n }\n}\n\nmain.tf\n#crawler declaration\nresource "aws_glue_crawler" "default" {\n for_each = var.glue_crawler\n\n database_name = aws_glue_catalog_database.database.name\n name = "Crawler_${each.value.crawler_name}"\n description = each.value.description\n role = aws_iam_role.svc-glue-crawler.id\n table_prefix = "raw_"\n tags = var.tags\n\n s3_target {\n path = "${var.s3_glue_name}/${each.value.crawler_name}"\n }\n\n configuration = jsonencode(var.crawler_configuration)\n}\n\n...\n\n#trigger\nresource "aws_glue_trigger" "my_trigger" {\n name = var.trigger_name\n schedule = "cron(00 01 * * ? *)"\n type = "SCHEDULED"\n enabled = "false"\n tags = var.tags\n\n actions {\n job_name = aws_glue_crawler.default[0].name\n }\n\n actions {\n job_name = aws_glue_crawler.default[1].name\n }\n\n\nvariable.tf\nvariable "glue_crawler" {\n type = map(object({\n crawler_name = string\n description = string\n }))\n default = {}\n description = "glue crawler definitions."\n}\n\nWhen i run this code i have the following errors:\nError: Invalid index\n\n on main.tf line 294, in resource "aws_glue_trigger" "my_trigger": 294: job_name = aws_glue_crawler.default[0].name\n |----------------\n | aws_glue_crawler.default is object with 2 attributes\n\nThe given key does not identify an element in this collection value.\n\n\nError: Invalid index\n\n on main.tf line 298, in resource "aws_glue_trigger" "my_trigger": 298: job_name = aws_glue_crawler.default[1].name\n |----------------\n | aws_glue_crawler.default is object with 2 attributes\n\nThe given key does not identify an element in this collection value."
]
| [
"amazon-web-services",
"terraform",
"terraform-provider-aws",
"terragrunt"
]
|
[
"changing content depending on different media queries",
"This is the second attempt at this question as I have worked on this since I last asked so hopefully I'll make more sense this time.\n\nI'm creating a responsive layout for my coming soon page. The main body header changes depending on the size of the browser and the device.\n\n <h1><span class=\"main__header--changer\">COMING SOON</span></h1>\n\n\n... and the CSS\n\n @media (max-width: 75em) {\n h1:before {\n content: \"HOLD ONTO YOUR HATS\";\n }\n .main__header--changer {\n display: none;\n }\n }\n\n @media (max-width: 64em) {\n h1:before {\n content: \"NOT LONG TO GO\";\n }\n .main__header--charger {\n display: none;\n }\n }\n\n\n... and so on and son on, the different variations of coming soon contains less letters as the size goes down, right down to 'nigh'.\n\nThe only thing my way of doing this means that screen readers wont read the heading because of the display:none. Is there a different way to hide the heading but not from screen readers but that the content is shown from the css?\n\nThanks"
]
| [
"html",
"css",
"media-queries"
]
|
[
"Transform SQL Query Results",
"I need to take some query results and flatten them out for a report.\n\nDECLARE @randomTable table (ID int, OtherID int, Val varchar(max))\n\ninsert into @randomTable(ID, OtherID, Val)\nvalues (1, 100, 'Some Value 1'), (2, 100, 'Some Other 2'),\n (3, 100, 'Some Value 3'), (4, 200, 'Some Other 4'),\n (5, 200, 'Some Value 5'), (6, 300, 'Some Other 6'),\n (7, 300, 'Some Value 7'), (8, 300, 'Some Other 8'),\n (9, 400, 'Some Value 9'), (10, 500, 'Some Other 10') \n\nselect OtherID, Val from @randomTable\n\n\nresults:\n\n-- 100 | Some Value 1\n-- 100 | Some Other 2\n-- 100 | Some Value 3\n-- 200 | Some Other 4\n-- 200 | Some Value 5\n-- 300 | Some Other 6\n-- 300 | Some Value 7\n-- 300 | Some Other 8\n-- 400 | Some Value 9\n-- 500 | Some Other 10\n\n\nIs there an SQL way to change this to select as:\n\n-- 100 | Some Value 1 | Some Other 2 | Some Value 3\n-- 200 | Some Other 4 | Some Value 5\n-- 300 | Some Other 6 | Some Value 7 | Some Other 8\n-- 400 | Some Value 9\n-- 500 | Some Other 10\n\n\nNOTE: The above is an example. My real data is not static. Also, in my real data the OtherID is a string value and Val values are images stored as varbinary.\n\nI would of course have to limit how many columns I am going to allow. I am thinking a max of 5 (after that I am fine to lose the extra rows).\n\nIs there any way to do this?"
]
| [
"sql",
"sql-server",
"sql-server-2008"
]
|
[
"How to run Spring boot scheduler even after executor.shutdownNow(); statement execute",
"I'm trying to implement a Spring boot scheduler to test Callable and ExecutorService interfaces.\n\nIn my app I have:\n\n@Bean(\"fixedThreadPool\")\npublic ExecutorService fixedThreadPool() {\nreturn Executors.newFixedThreadPool(5);\n}\n\n\nThen:\n\n **@Scheduled(fixedRate = 60000)**\npublic void removeUserIds(Set<String> userIds) {\nUriComponentsBuilder builder = UriComponentsBuilder.fromUriString(\"http://localhost:8080/remove\");\nfinal List<Callable<String>> callables = new ArrayList<>(); \nuserIds.forEach(userId -> {\n final List<Callable<String>> callables = new ArrayList<>();\n userIds.forEach(userId -> {\n final Callable<String> task = () -> {\n try{ \n log.info(\"Calling service to remove user id node : \"+userId);\n callServiceToRemoveNode(url,userId);\n } catch(ServiceException e ){ \n log.error(\"Error while calling service: \"+e.getCause());\n **executor.shutdownNow();**\n\n }\n return \"\";\n }; //Call to remote service using RestTemplate\n callables.add(task);\n});\n\ntry {\n final List<Future<String>> futureList =\n executor.invokeAll(callables);\n\n futureList.forEach(future -> {\n try {\n log.info(future.get());\n } catch (final Exception e) {\n log.error(\"Error : \"+ e.getMessage());\n } \n });\n} catch (final Exception e) {\n log.error(\"Error Error Error : \"+ e.getMessage());\n} finally {\n executor.shutdown();\n}\n}\n\n\nWhen I am calling removeUserIds() method with 100 userIds, It is working fine in happy flow, but if service is unavailable or down, error is getting printed 100th time and to avoid this I have used executor.shutdownNow(); so that further call will not happen to service for other user ids. But scheduler is not working and not executing after time interval if executor.shutdownNow(); statement executes. Could you please help me here to find out solution to avoid scheduler shutdown so even after executor.shutdownNow(); statement executes in before run of scheduler, it should run? or suggest feasible solution here?"
]
| [
"java",
"spring",
"spring-boot",
"executorservice",
"java.util.concurrent"
]
|
[
"AngularJS: Different Views and Different Controller by Data",
"Lets assume I want to make a quiz page. I have different question types. I.e. the task is to find the right order, to choose one answer, to choose multiple answers, or to fill some spaces with predefined words and so on. So, I have 5 questions in my data context. 2 of them are multiple-choice, 1 is a right order question and the other 2 are clozes. The main point is: I have no clue how many different question types are in the current quiz. All of them need an own view, an own controller and an own data model, because there is no universal data model that applies for clozes and for right-order-questions at the same time (correct me, if I am wrong). \n\nWhat is the best way in AngularJS and MVC-pattern in general to do this? Is this even applicable? Does this contradicts the MVC-pattern in general?"
]
| [
"angularjs",
"model-view-controller"
]
|
[
"KVM Switch and Happy Hacking Keyboard Pro 2",
"I have been using HHKB Pro 2 for almost a year, one at home and one at work. Now I have to work with two computers (PC and Mac) for which I decided to buy KVM switch.\nI picked one and expected nothing wrong with that, but when I plugged it in, HHKB was not working either with PC nor with Mac. I tried several keyboards and all worked flawlessly expect the mentioned HHKB. I tried the second one with the same result. With that in mind, I purchased another KVM switch, which was hardware switched (the previous one listened to ScrollLock which is supported by HHKB by using Fn key). To my surprise, it didn't work either. \nNow I have tho KVM switches that work flawlessly with any keyboard BUT that damned HHKB Pro 2.\nIs there any KVM switch that can handle this (or to be more precise, is there any that HHKB can deal with, because obviously there's something wrong with HHKB, not with KVMs).\n\nDo you have any experience with that?\nThanks."
]
| [
"keyboard"
]
|
[
"problems connecting with bitcoin RPC",
"I was setting up a faucet to give away some btc at nobanchan.com/faucet\n\nThe problem I am having is \n Fatal error: Uncaught BitcoinClientException: [0]: Connect error: Connection refused (111) thrown in on line 0\n\nI have the RPC username/password/port in bitcoin.conf exactly the same as I do on config.php for the faucet. \n\nI have forwarded the port from my WAN to my private IP in my router. \n\nI have reopened bitcoin a few times. Also, I have set rpcallowip= my local IP, and my websites IP. \n\nWhat else should I check?!"
]
| [
"php",
"api",
"rpc",
"bitcoin"
]
|
[
"How to replace an IN statement in SQL Server?",
"I am trying to re-write the following query (not created by myself) as this throws an execution error: \n\nOld Query:\n\n SELECT LastName + ', ' + FirstName AS 'Teamleader'\n FROM dbo.EmpTable\n WHERE EmpID IN (\n SELECT SupEmpID\n FROM dbo.EmpTable\n WHERE \n SupEmpID = (\n SELECT EmpID \n FROM EmpTable \n WHERE SupEmpID = (\n SELECT EmpID \n FROM EmpTable \n WHERE NTID = @NTID\n )\n )\n )\n ORDER BY TeamLeader\n\n\nI thought of using JOIN instead of the nested query but I am not sure how to apply this when there is an IN statement involved. \nSo far I have the following but this is returning the same error (probably as I still have the IN statement in there). \n\nNew Query (attempt): \n\n SELECT A.LastName + ', ' + A.FirstName AS TeamLeader\n FROM dbo.EmpTable AS A\n WHERE A.EmpID IN\n (\n SELECT D.SupEmpID\n FROM dbo.EmpTable AS B\n INNER JOIN dbo.EmpTable AS C\n ON C.SupEmpID = B.EmpID\n INNER JOIN dbo.EmpTable AS C\n ON D.SupEmpID = C.EmpID\n WHERE B.NTID = @NTID\n )\n ORDER BY TeamLeader\n\n\nWould someone explain the IN statement here, and let me know what I could do to fix this ?"
]
| [
"sql",
"sql-server",
"select",
"stored-procedures",
"sql-order-by"
]
|
[
"Open new popup chrome window without tab section",
"Sometimes surfing the web with chrome,I encounter a website or web app,when click on an <a> or <button> element it opens a new popup browser window which does not have tab section while I do not have any Chrome Extension installed:\n\nmain window:\n\n\n\npopup new window:\n\n\n\nMy question is,How to do this using JavaScript?\n\nThanks."
]
| [
"javascript",
"jquery",
"html",
"google-chrome",
"browser"
]
|
[
"Perform different calculation on each element of an array",
"I have an array. I need to perform a different calculation on each element. I thought I could do something like the following:\n\ndef calc(a, b, c)\n arr = [a, b, c]\n arr.map { |i| (i[0] * 600), (i[1] * 800), (i[2] * 1000) }\nend\n\ncalc(5, 8, 15)\n\n\nbut this does not work. How can I perform different calculations on each element of a single array?"
]
| [
"arrays",
"ruby"
]
|
[
"How to pass the column of a second dataframe into a UDF in PySpark 1.6.1",
"Here's what I'm trying to do. I want to perform a comparison between each entry of two columns in two different dataframes. The dataframes are shown below:\n\n>>> subject_df.show()\n+------+-------------+\n|USERID| FULLNAME|\n+------+-------------+\n| 12345| steve james|\n| 12346| steven smith|\n| 43212|bill dunnigan|\n+------+-------------+\n\n>>> target_df.show()\n+------+-------------+\n|USERID| FULLNAME|\n+------+-------------+\n|111123| steve tyler|\n|422226| linda smith|\n|123333|bill dunnigan|\n| 56453| steve smith|\n+------+-------------+\n\n\nHere is the logic I tried using:\n\n# CREATE FUNCTION \ndef string_match(subject, targets):\n for target in targets:\n <logic>\n return logic_result\n\n# CREATE UDF\nstring_match_udf = udf(string_match, IntegerType())\n\n# APPLY UDF\nsubject_df.select(subject_df.FULLNAME, string_match_udf(subject_df.FULLNAME, target_df.FULLNAME).alias(\"score\"))\n\n\nThis is the error I get when running the code in a pyspark shell:\n\npy4j.protocol.Py4JJavaError: An error occurred while calling o45.select.\n: java.lang.RuntimeException: Invalid PythonUDF PythonUDF#string_match(FULLNAME#2,FULLNAME#5), requires attributes from more than one child.\n\n\nI think the root of my problem is trying to pass in the second column to the function. Should I be using RDDs? Keep in mind that the actual subject_df and target_df are both over 100,000 rows. I'm open to any advice."
]
| [
"python",
"apache-spark",
"pyspark",
"spark-dataframe",
"pyspark-sql"
]
|
[
"How to combine 3 SQL queries in to 1?",
"I have products stored over 3 tables and product prices stored over 3 tables. At the moment I run each SQL query and then manually merge the data together in Microsoft Excel but is it possible to merge these queries so that I can get all results in one hit?\n\nI was thinking about just using 3 sub queries but I'm not sure whether that is the correct way to do it or not.\n\n1. Query\n\nSELECT\n kust_adr.KU_NAME AS \"Customer Name\",\n lzr_daten.LZR_BEZ AS \"Product Name\",\n lzr_przu.LZR_PR AS \"Price\"\nFROM kust_adr,\n lzr_daten,\n lzr_przu\nWHERE lzr_przu.LZR_KUNR = kust_adr.KU_NR\nAND lzr_daten.LZR_IDNR =\nlzr_przu.LZR_IDNR\nAND (lzr_daten.LZR_IDNR IN (85)\nAND kust_adr.KU_ADR_ART = 0)\n\n\n2. Query\n\nSELECT\n kust_adr.KU_NAME AS \"Customer Name\",\n glas_daten_basis.GL_BEZ AS\n \"Product Name\",\n os_przu.ZUM2 AS \"Price\"\nFROM glas_daten_basis,\n kust_adr,\n os_przu\nWHERE os_przu.KUNR = kust_adr.KU_NR\nAND glas_daten_basis.IDNR = os_przu.IDNR\nAND (glas_daten_basis.IDNR IN (4, 104, 9, 109, 309, 311)\nAND kust_adr.KU_ADR_ART =\n0)\n\n\n3. Query\n\nSELECT\n kust_adr.KU_NAME AS \"Customer Name\",\n gas_daten.GAS_BEZ AS \"Product Name\",\n gas_przu.GAS_MIN_M2 AS \"Price\"\nFROM kust_adr,\n gas_daten,\n gas_przu\nWHERE gas_przu.GAS_KUNR = kust_adr.KU_NR\nAND gas_daten.GAS_IDNR =\ngas_przu.GAS_IDNR\nAND (kust_adr.KU_ADR_ART = 0)"
]
| [
"sql",
"oracle"
]
|
[
"Unexpected result of NATURAL JOIN and USING Clause",
"So I am learning about obtaining data from multiple tables and I have a question regarding NATURAL JOIN and the USING clause. So I have 2 tables that I'm extracting data from; employees and departments.\n\nSQL> describe employees \nName Null? Type\n ----------------------------------------- -------- ------------------------\n EMPLOYEE_ID NUMBER(6)\n FIRST_NAME VARCHAR2(20)\n LAST_NAME NOT NULL VARCHAR2(25)\n EMAIL NOT NULL VARCHAR2(25)\n PHONE_NUMBER VARCHAR2(20)\n HIRE_DATE NOT NULL DATE\n JOB_ID NOT NULL VARCHAR2(10)\n SALARY NUMBER(8,2)\n COMMISSION_PCT NUMBER(2,2)\n MANAGER_ID NUMBER(6)\n DEPARTMENT_ID NUMBER(4)\n\nSQL> describe departments\n Name Null? Type\n ----------------------------------------- -------- ------------------------\n DEPARTMENT_ID NOT NULL NUMBER(4)\n DEPARTMENT_NAME VARCHAR2(30)\n MANAGER_ID NUMBER(6)\n LOCATION_ID NUMBER(4)\n\n\nWhen I use NATURAL JOIN and USING in two different expressions, I have two different outputs. I know that USING matches specifically one column in both tables, but how does this affect the output? How come the expression with USING produces one extra value compared to the NATURAL JOIN? \n\nSELECT department_id, manager_id, last_name, location_id\nFROM employees NATURAL JOIN departments\nWHERE department_id = 80\nORDER BY location_id desc;\n\nDEPARTMENT_ID MANAGER_ID LAST_NAME LOCATION_ID\n------------- ---------- ------------------------- -----------\n 80 149 Abel 2500\n 80 149 Grant 2500\n 80 149 Taylor 2500\n\nSELECT department_id, departments.manager_id, last_name, location_id\nFROM employees JOIN departments\nUSING (department_id)\nWHERE department_id = 80\nORDER BY location_id desc;\n\nDEPARTMENT_ID MANAGER_ID LAST_NAME LOCATION_ID\n------------- ---------- ------------------------- -----------\n 80 149 Zlotkey 2500 <-Additional Line*\n 80 149 Grant 2500\n 80 149 Taylor 2500\n 80 149 Abel 2500\n\n\nAny help and advice is appreciated!"
]
| [
"sql",
"database",
"oracle"
]
|
[
"How to avoid performing a firebase function on folders on cloud storage events",
"I'm trying to organize assets(images) into folders with a unique id for each asset, the reason being that each asset will have multiple formats (thumbnails, and formats optimized for web and different viewports).\n\nSo for every asset that I upload to the folder assets-temp/ is then moved and renamed by the functions into assets/{unique-id}/original{extension}.\n\nexample: assets-temp/my-awesome-image.jpg should become assets/489023840984/original.jpg.\n\nnote: I also keep track of the files with their original name in the DB and in the original's file metadata.\n\nThe issue: The function runs and performs what I want, but it also adds a folder named assets/{uuid}/original/ with nothing in it...\n\nThe function:\n\nexports.process_new_assets = functions.storage.object().onFinalize(async (object) => {\n // Run this function only for files uploaded to the \"assets-temp/\" folder.\n if (!object.name.startsWith('assets-temp/')) return null;\n\n const file = bucket.file(object.name);\n const fileExt = path.extname(object.name);\n const destination = bucket.file(`assets/${id}/original${fileExt}`);\n const metadata = {\n id,\n name: object.name.split('/').pop()\n };\n\n // Move the file to the new location.\n return file.move(destination, {metadata});\n});"
]
| [
"node.js",
"firebase",
"firebase-storage"
]
|
[
"User can send SMS at scheduled time",
"I need some guidance for setting up and allowing a user to send a scheduled message to all subscribers of the twilio number. Should I make model that takes in a string for date and time? I really don't know how to do this at all and I'm pretty new to rails. Any suggestions/ideas would be wonderful!"
]
| [
"ruby-on-rails",
"sms",
"twilio"
]
|
[
"Unity3d + WebGL = Cross-Origin Request Blocked",
"I was wondering if anyone could briefly explain how you get the REST api to function with Unity3D project built to WebGL platform. I just started changing my project over today thinking I could use REST to get around Parse's use of threading in a WebGL build I need to make. I promptly ran into the CORS problem though and not being familiar with it, I am unsure how to go about fixing the issue.\n\nCurrently I make use of the WWW class to send the request from within Unity.\n\nAn Example of \"Logging In\" a user would be:\n\n WWWForm form = new WWWForm();\n\n var headers = form.headers;\n headers[\"Method\"] = \"GET\";\n headers[\"X-Parse-Application-Id\"] = AppID;\n headers[\"X-Parse-REST-API-Key\"] = RestID;\n headers[\"X-Parse-Revocable-Session\"] = \"1\";\n headers[\"Content-Type\"] = \"application/json\";\n\n WWW www = new WWW(\"https://api.parse.com/1/login?username=\"+name+\"&password=\"+password, null, headers);\n\n\nThis works fine in the Editor but after building to WEBGL and uploading to my Host at Parse the following happens...\n\nI receive the following error in FireFox:\n\nCross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.parse.com/1/login?username=jleslie5159&password=Osulator5159!. This can be fixed by moving the resource to the same domain or enabling CORS.\n\n\nAnd something similar in Chrome..."
]
| [
"unity3d",
"parse-platform",
"cors"
]
|
[
"Saved an image sequence as a Tiff file but cannot view or open it outside of Matlab",
"Im trying to save an image sequence as a Tiff file to be later used in another program. I read each image in, applied color thresholding to get the mask, and then append that to my 3d array that I initialized earlier.\n\nI read up on the Tiff class needed to write Tiff images and I think I set all the tags properly, but although the file gets created, I cannot open it in an image viewer. I get the error: \n\n\n Invalid or Unsupported Tif file\n\n\nThere are 290 images in folder, so tiff file will have 290 planes. Below is how I am saving the tiff file:\n\nclear;\npath = 'D:\\complete stack';\nimg_list = dir(fullfile(path, '*.tif'));\n\nimg = imread(fullfile(img_list(1).folder, img_list(1).name));\ntiff_array = zeros(size(img, 1), size(img, 2), numel(img_list), 'uint8');\nclear img;\n\nfor i = 1:numel(img_list)\n img = imread(fullfile(img_list(i).folder, img_list(i).name));\n [bw, ~] = createMask(img);\n tiff_array(:,:,i) = bw;\nend\nt = Tiff('myfile.tif', 'w');\nsetTag(t,'Photometric',Tiff.Photometric.Mask);\nsetTag(t, 'Compression', Tiff.Compression.None);\nsetTag(t,'BitsPerSample',8);\nsetTag(t,'SamplesPerPixel',size(tiff_array, 3));\nsetTag(t,'ImageLength',size(tiff_array, 1));\nsetTag(t,'ImageWidth',size(tiff_array, 2));\nsetTag(t,'PlanarConfiguration',Tiff.PlanarConfiguration.Chunky);\nwrite(t, tiff_array);\nclose(t);\n\n\nthanks\n\nedit:\n\nA more reproducible, more minimal example:\n\nclear;\n\n\nimg = ones(750, 750, 'uint8');\ntiff_array = zeros(size(img, 1), size(img, 2), 290, 'uint8');\nclear img;\n\nfor i = 1:290\n bw = ones(750, 750, 'uint8');\n % [bw, ~] = createMask(img);\n tiff_array(:,:,i) = bw;\nend\nt = Tiff('myfile.tif', 'w');\nsetTag(t,'Photometric',Tiff.Photometric.Mask);\nsetTag(t, 'Compression', Tiff.Compression.None);\nsetTag(t,'BitsPerSample',8);\nsetTag(t,'SamplesPerPixel',size(tiff_array, 3));\nsetTag(t,'ImageLength',size(tiff_array, 1));\nsetTag(t,'ImageWidth',size(tiff_array, 2));\nsetTag(t,'PlanarConfiguration',Tiff.PlanarConfiguration.Chunky);\nwrite(t, tiff_array);\nclose(t);"
]
| [
"image",
"matlab",
"tiff",
"libtiff"
]
|
[
"ONLY_FULL_GROUP_BY disabled but still getting error 1055",
"I'm testing mysql server 5.7.17 and I have defined sql-mode as \n\nsql-mode=\"STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\"\n\n\nRunning each of these gives me the sql-mode defined:\n\nSELECT @@sql_mode;\nSELECT @@GLOBAL.sql_mode;\nSELECT @@SESSION.sql_mode;\n\n\nBut using mysql .net connector 6.9.8 with EF6 on my vs2012 desktop app i always get the error\n\nInnerException: MySql.Data.MySqlClient.MySqlException\n HResult=-2147467259\n Message=Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'punto_dia.Id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by\n Source=MySql.Data\n ErrorCode=-2147467259\n Number=1055\n StackTrace:\n en MySql.Data.MySqlClient.MySqlStream.ReadPacket()\n en MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)\n en MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)\n en MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)\n en MySql.Data.MySqlClient.MySqlDataReader.NextResult()\n en MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)\n en MySql.Data.Entity.EFMySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)\n en System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\n en System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)\n en System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)\n en System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)\n en System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)\n en System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\n en System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)\n\n\nI know that fixing the query to use GROUP BY properly i solve the error, but if want to use the query as i used with mysql server 5.6.35 why i can't ?\n\nThe sql-mode not define the only_full_group_by, so i don't understand why get this error.\n\nAny ideas ?\nThanks"
]
| [
"mysql",
"entity-framework-6",
"mysql-connector",
"sql-mode"
]
|
[
"Highcharts error when using ES6",
"I am importing Highcharts and Highchart more in the following way:\n\nimport highcharts from 'highcharts';\nimport highchartsMore from 'highcharts-more';\nhighchartsMore(highcharts);\n\n\nAfter the graph loads I get the following error:\n\nError: <rect> attribute width: Expected length, \"NaN\".\n\nNote:\nnot critical, yet annoying."
]
| [
"highcharts",
"ecmascript-6"
]
|
[
"Excel DATEVALUE function not working for today's date",
"I need to convert today's date to number value in Excel cell Formula.\n\n=DATEVALUE(TODAY())\n\n\nReturns:\n\n\n #VALUE!\n\n\nBut if i use =DATEVALUE(\"03-12-2012\"), returns:\n\n\n 41246\n\n\nCould anyone please tell me how to get date number value of today's date...."
]
| [
"excel",
"excel-formula"
]
|
[
"How to create loadbalancer in openstack for kubernetes cluster",
"I want to create VMs in openstack and install kubernetes on them and use openstack loadbalancer in kubernetes.But i do not know how to communicate with openstack.I ask it in ask.openstack.org but no one can answer that so i ask it here."
]
| [
"kubernetes",
"openstack"
]
|
[
"Decorators: 'NoneType' object is not callable",
"I ran the following Python code except for the last line: 'display()':\ndef decorator_function(original_function):\n def wrapper_function():\n print('message')\n return original_function()\n return wrapper_function()\n\n@decorator_function\ndef display():\n print('Display function ran')\n\ndisplay()\n\n\nSurprisingly, it displayed the right messages as if I would have run the command 'display()', but when I tried to run this command also, the following error showed: 'line 11, in \ndisplay()\nTypeError: 'NoneType' object is not callable\nWhat could be causing this? Thanks!"
]
| [
"python",
"compiler-errors",
"decorator"
]
|
[
"Scraping text with subscripts with BeautifulSoup in Python",
"all! I'm working on my first web scraper ever, which grabs author names, URLs, and paper names from PMC, when given a \"CitedBy\" page like this\n\nMy program works fine for getting the author names and the URL's, however I can only get some of the paper titles, which I suspect is due to subscripts and superscripts.\n\nHere's what I've got so far:\n\n import requests\n from bs4 import BeautifulSoup\n import re\n\n url = 'http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2593677/citedby/?page=0'\n req = requests.get(url)\n plain_text = req.text\n soup = BeautifulSoup(plain_text, \"lxml\") #soup object\n\n titles_list = []\n\n for items in soup.findAll('div', {'class': 'title'}):\n title = items.string\n if title is None:\n title = (\"UHOH\") #Problems with some titles\n #print(title)\n titles_list.append(title)\n\n\nWhen I run this part of my code, my scraper gives me these results:\n\n\nFinding and Comparing Syntenic Regions among Arabidopsis and the Outgroups Papaya, Poplar, and Grape: CoGe with Rosids\nUHOH\nComprehensive Comparative Genomic and Transcriptomic Analyses of the Legume Genes Controlling the Nodulation Process\nUHOH\nDosage Sensitivity of RPL9 and Concerted Evolution of Ribosomal Protein Genes in Plants\n\n\nAnd so on for the whole page...\n\nSome papers on this page that I get \"UHOH\" for are:\n\n\nComparative cell-specific transcriptomics reveals differentiation of C4 photosynthesis pathways in switchgrass and other C4 lineages\nThe genome sequence of the outbreeding globe artichoke constructed de novo incorporating a phase-aware low-pass sequencing strategy of F1 progeny\nCross-Family Translational Genomics of Abiotic Stress-Responsive Genes between Arabidopsis and Medicago truncatula\n\n\nThe first two I've listed here I believe are problematic because of \"C4\" and \"F1\" are actually \"C subscript 4\" and \"F subscript 1\". For the third one, \"Medicago truncatula\" is in an \"em\" HTML tag, so I suspect that this is why my scraper cannot scrape it. \n\nThe only alternative solution I've thought of is making my \"soup.findAll\" more specific, but that didn't end up helping me. I tried:\n\nfor items in soup.findAll('div', {'class': 'title'}):\n title = items.string\n if title is None:\n for other in soup.findAll('a', {'class': 'view'}):\n title = other.string\n\n\nBut sadly, this didn't work... So I'm not exactly sure how to approach this. Does anybody know how to handle special cases like these? Thank you so much!"
]
| [
"python",
"web-scraping",
"beautifulsoup"
]
|
[
"Unable to get JSONObject from a url",
"I am developing an android app which requires a \"token\" to login. This token is available along with some other details at https://demo.vtiger.com/webservice.php?operation=getchallenge&username=admin. I tried to fetch the data by JSON parsing but it is not working properly. Please help me. Thanks. This how I coded:-\n\n//MainActivity.java\npackage com.example.login1;\n\nimport java.math.BigInteger;\nimport java.security.MessageDigest;\nimport java.security.NoSuchAlgorithmException;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\nimport android.app.Activity;\nimport android.os.AsyncTask;\nimport android.os.Bundle;\nimport android.os.StrictMode;\nimport android.util.Log;\nimport android.view.View;\nimport android.widget.Button;\nimport android.widget.EditText;\nimport android.widget.TextView;\npublic class MainActivity_old extends Activity {\n\n//URL to get JSON Array\nprivate static String url = \"http://demo.vtiger.com/webservice.php?operation=getchallenge&username=admin\";\n//JSON Node Names\nprivate static final String TAG_RESULT = \"result\";\nprivate static final String TAG_TOKEN = \"token\";\nString token = null;\n\nEditText userid, accesskey;\nButton login;\nTextView gettoken;\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n\n if (android.os.Build.VERSION.SDK_INT > 9) {\n StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();\n StrictMode.setThreadPolicy(policy);\n }\n\n this.gettoken = (TextView)findViewById(R.id.lblToken);\n\n new AsyncTask<Void, Void, Void>() {\n\n JSONArray result;\n\n @Override\n protected Void doInBackground(Void... params) {\n\n // Creating new JSON Parser\n JSONParser jParser = new JSONParser();\n // Getting JSON from URL\n JSONObject json = jParser.getJSONFromUrl(url);\n try {\n // Getting JSON Array\n result = json.getJSONArray(TAG_RESULT);\n JSONObject json_result = json.getJSONObject(TAG_RESULT);\n // Storing JSON item in a Variable\n token = json_result.getString(TAG_TOKEN);\n //Importing TextView\n\n } catch (JSONException e) {\n e.printStackTrace();\n }\n\n return null;\n }\n\n @Override\n protected void onPostExecute(Void aVoid) {\n super.onPostExecute(aVoid);\n //Set JSON Data in TextView\n gettoken.setText(token);\n }\n }.execute();\n\n userid = (EditText) findViewById(R.id.txtUserid);\n accesskey = (EditText) findViewById(R.id.txtPassword);\n\n Button login = (Button) findViewById(R.id.btnLogin);\n\n login.setOnClickListener(new View.OnClickListener() {\n\n @Override\n public void onClick(View arg0) {\n /* This code get the values from edittexts */\n String useridvalue = userid.getText().toString();\n String accesskeyvalue = accesskey.getText().toString();\n\n /*To check values what user enters in Edittexts..just show in logcat */ \n Log.d(\"useridvalue\",useridvalue);\n Log.d(\"accesskeyvalue\",accesskeyvalue);\n\n String md=md5(accesskeyvalue + token);\n System.out.println(md);\n }\n\n public String md5(String s) \n {\n MessageDigest digest;\n try \n {\n digest = MessageDigest.getInstance(\"MD5\");\n digest.update(s.getBytes(),0,s.length());\n String hash = new BigInteger(1, digest.digest()).toString(16);\n return hash;\n } \n catch (NoSuchAlgorithmException e) \n {\n e.printStackTrace();\n }\n return \"\";\n }\n });\n\n }\n}"
]
| [
"java",
"android",
"json"
]
|
[
"Append a string from fscanf to linked list in C",
"I want to read a file and put each words in a linked list. When I read the file, the linked list have the good number of nodes but all the node are equal to the last word.\n\nAn example, if my text file is : \n\nHello good sir\n\n\nMy linked list will look like this : \n\n[sir,sir,sir]\n\n\nAnd should be like this :\n\n[Hello, good, sir]\n\n\nMy main.c\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n\ntypedef struct NodeTag {\n char *data;\n struct NodeTag *next;\n} Node;\n\nNode *Node_create();\n\ntypedef struct ListTag {\n struct NodeTag *first;\n} List;\n\nList *List_create();\nvoid List_append(List *list, char *str);\nvoid List_print(List *list);\n\nint main(void) {\n char word[100];\n FILE *file = fopen(\"file.txt\", \"r\");\n\n if(file == NULL) {\n printf(\"error in opening file\\n\");\n return 1;\n }\n\n List *l = List_create();\n\n while(fscanf(file, \"%s\", word) == 1){\n List_append(l, word);\n }\n return 0;\n}\n\n\nHere are my functions. I removed the destroy and free functions to make it more clear.\n\nNode *Node_create() {\n Node *node = malloc(sizeof(Node));\n assert(node != NULL);\n\n node->data = \"\";\n node->next = NULL;\n\n return node;\n}\n\nList *List_create() {\n List *list = malloc(sizeof(List));\n assert(list != NULL);\n\n Node *node = Node_create();\n list->first = node;\n\n return list;\n}\n\nvoid List_append(List *list, char *str) {\n assert(list != NULL);\n assert(str != NULL);\n\n Node *node = list->first;\n while (node->next != NULL) {\n node = node->next;\n }\n\n node->data = str;\n node->next = Node_create();\n}\n\nvoid List_print(List *list) {\n assert(list != NULL);\n\n printf(\"[\");\n Node *node = list->first;\n while (node->next != NULL) {\n printf(\"%s\", node->data);\n node = node->next;\n if (node->next != NULL) {\n printf(\", \");\n }\n }\n printf(\"]\\n\");\n}\n\n\nIf I do something like this, it will work properly. So I guess I append only the pointer of word so its pointing to the same place again and again ?\n\n List_append(l, \"test1\");\n List_append(l, \"test2\");\n\n\nOutput :\n\n [test1, test2]"
]
| [
"c",
"string",
"data-structures",
"linked-list"
]
|
[
"bit type : default to '0' instead of NULL",
"By default sql server assigns boolean fields a NULL value.\nHow can I tell it to use '0' as default?\nI tried setting the default value to ((0)) but it still persists on the NULL."
]
| [
"sql-server"
]
|
[
"Taking mysql data backup with php5",
"I am using php5 and mysql5.- in my local server \n\n\nI want to take mysql database backup ( in my local server ) - just by copying the\ndatafile ( located in mysql server in the folder data )\nI have copied a particular table name account.frm file - but it is not working \nIt is showing the table name but it is showing error that ( I checked in the mysql\nquery browser )\nthat cannot fetch the table details.\nI have used mysqldump it is also not working.\n\n\nPlease help me to take backup and work correctly."
]
| [
"php",
"mysql",
"backup"
]
|
[
"Docker cant´t find, pull images : server mis behaving",
"Docker toolbox installed for windows 10 Home Edition. Docker toolbox for this OS is installed. But when I can start learning the program, it gives me these errors. I cannot create an image or run an image. At the end of each error message it tells me that I have a server misbehaving. At the moment of running an image gives me the following error:\n\nUnable to find image 'busybox:latest'\nlocally\nlatest: Pulling from library / busybox\nd9cbbca60e5f: Pulling fs layer C: \\Program Files\\ Docker Toolbox\\ docker.exe: error pulling image configuration: Get https: //registry-1.docker.io/v2/library/busybox/blobs/sha256:78096d0a54788961ca68393e5f8038704b97d8af374249dc5c8faec1b8045e42: dial tcp: lookup registry-1.docker.io on 10.0.2.3:53: server misbehaving.\n See 'C:\\Program Files\\Docker Toolbox\\docker.exe run --help'.\n\n\n\n\nAnd at the momento to pulling and image, i got this: \n\n$ docker pull busybox\nUsing default tag: latest\nlatest: Pulling from library/busybox\nd9cbbca60e5f: Pulling fs layer error pulling image configuration: Get https://registry-1.docker.io/v2/library/busybox/blobs/sha256:78096d0a54788961ca68393e5f8038704b97d8af374249dc5c8faec1b8045e42: dial tcp: lookup registry-1.docker.io on 10.0.2.3:53: server misbehaving\n\n\n\n\nThis is my docker info :\n\n$ docker info Client:\n Debug Mode: false\n\nServer:\n Containers: 0\n Running: 0\n Paused: 0\n Stopped: 0\n Images: 0\n Server Version: 19.03.5\n Storage Driver: overlay2\n Backing Filesystem: extfs\n Supports d_type: true\n Native Overlay Diff: true\n Logging Driver: json-file\n Cgroup Driver: cgroupfs\n Plugins:\n Volume: local\n Network: bridge host ipvlan macvlan null overlay\n Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog\n Swarm: inactive\n Runtimes: runc\n Default Runtime: runc\n Init Binary: docker-init\n containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339\n runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657\n init version: fec3683\n Security Options:\n seccomp\n Profile: default\n Kernel Version: 4.14.154-boot2docker\n Operating System: Boot2Docker 19.03.5 (TCL 10.1)\n OSType: linux\n Architecture: x86_64\n CPUs: 1\n Total Memory: 989.5MiB\n Name: default\n ID: ANYM:Q52D:BUAW:R6IO:HTFN:S4I6:JLX6:WVNK:QEGO:OHCZ:PCHP:NWJN\n Docker Root Dir: /mnt/sda1/var/lib/docker\n Debug Mode: false\n Username: dsabillon94\n Registry: https://index.docker.io/v1/\n Labels:\n provider=virtualbox\n Experimental: false\n Insecure Registries:\n 127.0.0.0/8\n Live Restore Enabled: false\n Product License: Community Engine\n\n\n\n\nDocker version\n\n$ docker version\nClient:\n Version: 19.03.1\n API version: 1.40\n Go version: go1.12.7\n Git commit: 74b1e89e8a\n Built: Wed Jul 31 15:18:18 2019\n OS/Arch: windows/amd64\n Experimental: false\n\nServer: Docker Engine - Community\n Engine:\n Version: 19.03.5\n API version: 1.40 (minimum version 1.12)\n Go version: go1.12.12\n Git commit: 633a0ea838\n Built: Wed Nov 13 07:28:45 2019\n OS/Arch: linux/amd64\n Experimental: false\n containerd:\n Version: v1.2.10\n GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339\n runc:\n Version: 1.0.0-rc8+dev\n GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657\n docker-init:\n Version: 0.18.0\n GitCommit: fec3683"
]
| [
"docker",
"docker-machine",
"docker-registry",
"docker-image",
"docker-run"
]
|
[
"Angular wait data before continuing function",
"Here is my code:\n\nApp-component.html\n\n<router-outlet (activate)=\"onActivate($event)\"></router-outlet>\n\n\nApp-component.ts\n\nnode;\nngOnInit() {\n this.loadData();\n}\nloadData() {\n return service.getData().subscribe(res => this.node = res)\n}\nonActivate(event) {\n // wait node get data then continue this function\n\n}\n\n\n2 functions run at the same time, so is there any way to wait node get data from loadData() then continue onActivate function?"
]
| [
"angular",
"asynchronous"
]
|
[
"Enter event to an input box invokes button click action",
"I have an input box which invokes a button action when Enter key is pressed.\n\n <h:inputText value=\"#{myBean.fname}\" id=\"name\" onkeydown=\"callClickEvent(event);\"></h:inputText>\n\n\n**Js function is**\n--------------\n\nfunction callClickEvent(event){\n if (event.keyCode == 13 || event.which==13) {\n document.getElementById('dataForm:btnA').click();\n }\n\n }\n\n\nIn my xhtml i have two button\n\n<h:commandButton action=\"#{myBean.actionPerform}\" id=\"btnA\"\"/>\n<h:commandButton action=\"#{myBean.updateAction}\" id=\"btnB\"/>\n\n\nnow the problem is , this code runs fine in chrome and firefox but not working as expected in IE9;\n\nin IE 9 , when I hit enter key it invokes both buttons action.\n\nsuggested solution in stack overflow were:\n(1) add type =\"button\"\n(2) add e.preventDefault() inside javascipt function.\n\nwhen i add type=\"button\", action method dosen't invoke when i click second button.\n\nand when i add e.preventDefault(), it does'nt let me type anything side input box.\n\nany help would be appreciated."
]
| [
"javascript",
"html",
"jsf"
]
|
[
"Skip module in step while debugging Haskell with GHCi",
"I am debugging a Haskell program with GHCi. I am using :step along with :list. There is a point where the program starts to pass repeatedly through the same functions within a Parser.hs module.\n\nI was wondering if there is any way to resume the program with :continue till it exits this Parser.hs module, i.e.\n\n\ngoes back to the next step where it entered it before\n\n\nor\n\n\ncalls function within another package.\n\n\nSomething like hidding this module from the debugger (I wouldn't mind to hide it for the complete execution). I couldn't find anything in the suggested commands with :help but I don't have a lot of experience with GHCi so I thought to try it here.\n\nCheers"
]
| [
"haskell",
"ghci"
]
|
[
"Migrate service's volume from v2 to v3",
"Below is an v2 mongodata volume based on tianon/true image:\n\nversion: \"2\" \nservices: \n mongo:\n container_name: mongo\n image: mongo\n ports:\n - \"27017:27017\"\n volumes_from:\n - mongodata\n\n mongodata:\n image: tianon/true\n volumes:\n - /data/db\n\n\nHow to migrate it to a v3? My take below didn't work. Probably because this volume is not based to the image?\n\nversion: \"3\"\nservices:\n mongo:\n container_name: mongo\n image: mongo\n ports:\n - \"27017:27017\"\n volumes:\n - mongodata:/data/db\n\nvolumes:\n mongodata:"
]
| [
"docker",
"docker-compose"
]
|
[
"Cannot access endpoints API from chrome extension",
"I am using a chrome extension that calls the chrome.identity api to get an access token (using google plus login scope). \n\nI then try to call a Google endpoints API with this token. For this, I set a request header with 'Authorization'='Bearer <token>' format.\n\nI have added the client_id from the manifest.json of my chrome extension to the list of allowed client ids for the endpoints API. But, I still cannot connect to it, even when I run the API on localhost.\n\nThe allowed list of client ids includes those clients that I defined on the API credentials page on Google Developers Console. My chrome extension is present as a client in that list, but it's client_id is different.\n\nThe error I keep getting on the server side:\n\nWARNING 2016-04-22 03:01:35,068 users_id_token.py:372] Oauth token doesn't include an email address.\n\n\nCan anyone please give me some pointers to try? Please let me know if any clarification is necessary."
]
| [
"javascript",
"google-chrome",
"google-app-engine",
"google-chrome-extension",
"google-cloud-endpoints"
]
|
[
"How to call JavaScript after PrimeFaces DataTable row click",
"I wanted to use the features from PrimeFaces DataTable so I've implemented the framework and rebuilt my current table (built with JSF) with the DataTable. Now I have a problem in that I don't know how I can call a JS function on row click. \n\nThis was my previous implementation:\n\nonclick=\"onRowClick(this, event)\"\n\n\nWith a JSF component it was possible to detect a row click. Now I want to implement this with PrimeFaces to detect the exactly the same row click in the DataTable. \n\nIs there any simple way to deal with this? onclick is not available for this PrimeFaces component so I can't just copy this."
]
| [
"javascript",
"jquery",
"jsf",
"primefaces"
]
|
[
"Facebook extended access token doesn't work - but everything seems to be fine (?)",
"I try to get 60 days facebook access token from server side request. After user is loged in I check access token through getAccessToken() function from Facebook SDK and after that I use getExtendedAccessToken() which I found somewhere here: How to extend access token validity since offline_access deprecation to ask for 60 days access token:\n\n public function getExtendedAccessToken() {\n\n try {\n // need to circumvent json_decode by calling _oauthRequest\n // directly, since response isn't JSON format.\n $access_token_response =\n $this->_oauthRequest(\n $this->getUrl('graph', '/oauth/access_token'),\n $params = array( 'client_id' => $this->getAppId(),\n 'client_secret' => $this->getApiSecret(),\n 'grant_type'=>'fb_exchange_token',\n 'fb_exchange_token'=>$this->getAccessToken(),\n ));\n\n } catch (FacebookApiException $e) {\n // most likely that user very recently revoked authorization.\n // In any event, we don't have an access token, so say so.\n return false;\n }\n\n if (empty($access_token_response)) {\n return false;\n }\n\n $response_params = array();\n parse_str($access_token_response, $response_params);\n if (!isset($response_params['access_token'])) {\n return false;\n }\n\n return $response_params['access_token'];\n }\n\n\nUnfortunanely it still won't work my access token expired after 2 hours so I tried also this:\n\n public function getSimpleExtendedAccessToken(){\n\n $request = 'https://graph.facebook.com/oauth/access_token?\n client_id='. $this->getAppId(). \n '&client_secret=' .$this->getApiSecret(). \n '&grant_type=fb_exchange_token\n &fb_exchange_token=' .$this->getAccessToken();\n\n $response = file_get_contents($request);\n $params = null;\n parse_str($response, $params);\n return $params['access_token'];\n}\n\n\nand this one also expired after 2 hours. But when I checked what was inside the array $params in the second function there was written:\n\n\n Array ( [access_token] => AAAFM5sO7[...] [expires] => 4897 )\n\n\n(That part: \"AAAFM5sO7[...]\" is of course my access token number)\n\nAll access tokens which I received are the same: first one from getAccessToken(), second one from getExtendedAccessToken() and third one from getSimpleExtendedAccessToken(). \n\nOf course when I ask addtionaly more and more for extended access token the expiration number doesn't renew but it's counting down, and that is correct from the point of view of the Facebook documentation, because you can't ask for new access token each minute, but why I can't get 60 days access token?\n\nCan anyone help me because I'm a bit cofused?"
]
| [
"php",
"facebook",
"oauth-2.0",
"access-token"
]
|
[
"When will invokedynamic be available in the standard JDK?",
"I'm eager to start working with dynamic languages on top of Java.\n\nHow long before this is part of the standard JDK?"
]
| [
"java",
"dynamic-languages",
"invokedynamic"
]
|
[
"Test many conditions using mocha",
"What's the best way to test methods like the following using mocha gem?\n\ndef can_create?(user)\n opened? && (owner?(user) || member?(user))\nend\n\n\nIs a best practice to test \"AND\" and \"OR\" conditions? Should I create many tests to cover all possibilities or one expects options to cover all?\n\n\n\nI'm using rails 4 + test unit.\n\nWhen i have tests only with &&, for instance:\n\ndef can_update?(user)\n opened? && owner?(user)\nend\n\n\nI'm testing:\n\ngroup = Group.new\nuser = User.new\ngroup.expects(:opened?).returns(true)\ngroup.expects(:owner?).returns(true)\nassert group.can_update?(user)\n\n\nThe problem is when I have \"OR\" conditions. With the first method ( can_create? ) I can't do that:\n\ngroup = Group.new\nuser = User.new\ngroup.expects(:opened?).returns(true)\ngroup.expects(:owner?).returns(true)\ngroup.expects(:member?).returns(true)\nassert group.can_create?(user)\n\n\nBecause ( owner? and member? methods can be true/false )."
]
| [
"ruby-on-rails",
"ruby",
"ruby-mocha"
]
|
[
"Deselect table view row when returning to app",
"I have a table view and one of the table view cells opens another app. When I return to my app the table view cell is still highlighted. What is the best way to deselect a table view cell when returning to the app?\n\nEdit: The issue is that -viewWillAppear or -viewDidAppear does not get called when returning from an app since the view is already visible."
]
| [
"ios",
"uitableview"
]
|
[
"Jenkins2 installer in macOS change home directory",
"I am new to Jenkins, and I have the following problem\n\njust installed Jenkins2 on MacOS Sierra (10.12.6) \nand a new user has been created under /Users/Shared/Jenkins/,\nbut when I try to run a maven compile command, through a new Job\nI have the following error:\n\n[atmosphere] $ mvn -f spring-boot-samples/spring-boot-sample-atmosphere/pom.xml compile\nFATAL: command execution failed\njava.io.IOException: error=2, No such file or directory\n\n\nI try to run the command manually and got the following:\n\nCaused by: org.apache.maven.shared.filtering.MavenFilteringException:\n Cannot create resource output directory: \n/Users/Shared/Jenkins/Home/workspace/atmosphere/spring-boot-samples/spring-boot-sample-atmosphere/target/classes\n\n\nHow could I solve this ? \nI guess I have to change the workspace permissions, but I don't know how to do that.\n\nPlease help !"
]
| [
"jenkins",
"macos-sierra"
]
|
[
"Reorder Kendo grid row with angular 6",
"I have used the same code as used to implement the row reorder feature in the example given \nhere https://www.telerik.com/kendo-angular-ui/components/grid/how-to/row-reordering\n\nprivate handleDragAndDrop(): Subscription {\nconst sub = new Subscription(() => { });\nlet draggedItemIndex;\n\nconst tableRows = Array.from(document.querySelectorAll('.k-grid-content \ntr'));\ntableRows.forEach(item => {\nthis.renderer.setAttribute(item, 'draggable', 'true');\nconst dragStart = fromEvent(item, 'dragstart');\nconst dragOver = fromEvent(item, 'dragover');\nconst drop = fromEvent(item, 'drop');\n\nsub.add(dragStart.pipe(\ntap(({ dataTransfer }) => {\ntry {\n// Firefox won't drag without setting data\ndataTransfer.setData('application/json', {});\n} catch (err) {\n// IE doesn't support MIME types in setData\n}\n})\n).subscribe(({ target }) => {\ndraggedItemIndex = target.rowIndex;\n}));\n\nsub.add(dragOver.subscribe((e: any) => e.preventDefault()));\n\nsub.add(drop.subscribe((e: any) => {\ne.preventDefault();\nconst dataItem = this.gridData.data.splice(draggedItemIndex, 1)[0];\nconst dropIndex = closest(e.target, tableRow).rowIndex;\nthis.zone.run(() =>\nthis.gridData.data.splice(dropIndex, 0, dataItem)\n);\n}));\n});\n\n\n`--------------------------\nI am receiving below error for the above code \n\nerror TS2459: Type 'Event' has no property 'dataTransfer' and no string index signature.\nerror TS2339: Property 'rowIndex' does not exist on type 'EventTarget'."
]
| [
"angular",
"drag-and-drop",
"kendo-grid"
]
|
[
"Facebook Ads not showing while testing",
"Whenever I test app with test ads of facebook it shows test ads but when i replace with the real ads they dont show. Can you help me to know because of why this would be happening."
]
| [
"android-studio",
"facebook-ads"
]
|
[
"Web Interface for SSAS",
"We have several SSAS cubes - we want these cubes to be accessible via HTTP on the local network so that they can be viewed over iPads. Excel is our go-to utility for this, but since Excel is not available for iPad, it is not an option here.\n\nAre there any other ways that I can display cubes on IIS and have iPad viewers be able to access them?"
]
| [
"sql",
"iis",
"sql-server-2008-r2",
"ssas",
"windows-server-2008-r2"
]
|
[
"Docker stop responding under load",
"notice that docker stop responding under load. Here is the steps to reproduce the issue:\n\n\n docker-machine create -d virtualbox web\n \n docker-machine ip web\n\n\n192.168.99.253\n\n\n\n eval $(docker-machine env web)\n \n docker run --name app -d -p 3000:3000 ragesh/hello-express\n \n ab -n 100000 -c 100 http://192.168.99.253:3000/\n\n\nServer Hostname: 192.168.99.253\nServer Port: 3000\n\nDocument Path: /\nDocument Length: 207 bytes\n\nConcurrency Level: 100\nTime taken for tests: 145.726 seconds\nComplete requests: 100000\nFailed requests: 0\nTotal transferred: 38900000 bytes\nHTML transferred: 20700000 bytes\nRequests per second: 686.22 [#/sec] (mean)\nTime per request: 145.726 [ms] (mean)\nTime per request: 1.457 [ms] (mean, across all concurrent requests)\nTransfer rate: 260.68 [Kbytes/sec] received\n\nConnection Times (ms)\n min mean[+/-sd] median max\nConnect: 0 0 0.2 0 15\nProcessing: 32 145 14.1 140 237\nWaiting: 32 145 14.1 140 237\nTotal: 36 146 14.1 140 237\n\nPercentage of the requests served within a certain time (ms)\n 50% 140\n 66% 146\n 75% 151\n 80% 155\n 90% 165\n 95% 173\n 98% 185\n 99% 196\n 100% 237 (longest request)\n\n\nEverything looks good even -n 100000.\n\n\n docker-machine create -d virtualbox router\n \n eval $(docker-machine env router)\n \n vi nginx.conf\n\n\nupstream web {\n server 192.168.99.253:3000;\n}\n\nserver {\n listen 80;\n\n location / {\n proxy_pass http://web;\n }\n} \n\n\n\n docker run --name router -p 80:80 -v $(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf:ro -d nginx\n \n docker-machine ip router\n\n\n192.168.99.252 \n\n\n\n ab -n 10000 -c 100 http://192.168.99.252:80/\n\n\nServer Software: nginx/1.9.14\nServer Hostname: 192.168.99.252\nServer Port: 80\n\nDocument Path: /\nDocument Length: 207 bytes\n\nConcurrency Level: 100\nTime taken for tests: 32.631 seconds\nComplete requests: 5957\nFailed requests: 0\nTotal transferred: 2448327 bytes\nHTML transferred: 1233099 bytes\nRequests per second: 182.56 [#/sec] (mean)\nTime per request: 547.773 [ms] (mean)\nTime per request: 5.478 [ms] (mean, across all concurrent requests)\nTransfer rate: 73.27 [Kbytes/sec] received\n\nConnection Times (ms)\n min mean[+/-sd] median max\nConnect: 0 2 52.6 0 3048\nProcessing: 2 168 56.2 164 3002\nWaiting: 2 168 56.2 163 3002\nTotal: 2 169 97.7 164 5032\n\nPercentage of the requests served within a certain time (ms)\n 50% 164\n 66% 171\n 75% 176\n 80% 178\n 90% 185\n 95% 192\n 98% 199\n 99% 209\n 100% 5032 (longest request)\n\n\nExpect the Requests per second will drop, but not except it drop so dramatically. And run ab several times, got connection error very often.\n\nDid I do something wrong?"
]
| [
"nginx",
"docker"
]
|
[
"Seeming contradiction typechecks in Idris",
"I have the following definition of a predicate on vectors that identifies if one is a set (has no repeated elements) or not. I define membership with a type-level boolean:\n\nimport Data.Vect\n\n%default total\n\ndata ElemBool : Eq t => t -> Vect n t -> Bool -> Type where\n ElemBoolNil : Eq t => ElemBool {t=t} a [] False\n ElemBoolCons : Eq t => ElemBool {t=t} x1 xs b -> ElemBool x1 (x2 :: xs) ((x1 == x2) || b)\n\ndata IsSet : Eq t => Vect n t -> Type where\n IsSetNil : Eq t => IsSet {t=t} []\n IsSetCons : Eq t => ElemBool {t=t} x xs False -> IsSet xs -> IsSet (x :: xs)\n\n\nNow I define some functions that allow me to create this predicate:\n\nfun_1 : Eq t => (x : t) -> (xs : Vect n t) -> (b : Bool ** ElemBool x xs b)\nfun_1 x [] = (False ** ElemBoolNil)\nfun_1 x1 (x2 :: xs) = \n let (b ** prfRec) = fun_1 x1 xs\n in (((x1 == x2) || b) ** (ElemBoolCons prfRec)) \n\nfun_2 : Eq t => (xs : Vect n t) -> IsSet xs \nfun_2 [] = IsSetNil\nfun_2 (x :: xs) = \n let prfRec = fun_2 xs\n (False ** isNotMember) = fun_1 x xs\n in IsSetCons isNotMember prfRec\n\n\nfun_1 works like a decision procedure over ElemBool.\n\nMy problem is with fun_2. Why does the pattern matching on (False ** isNotMember) = fun_1 x xs typecheck?\n\nEven more confusing, something like the following typechecks too:\n\nexample : IsSet [1,1]\nexample = fun_2 [1,1]\n\n\nThis seems like a contradiction, based on the definition of IsSet and ElemBool above.\nThe value for example idris evaluates is the following:\n\ncase block in fun_2 Integer\n 1\n 1\n [1]\n (constructor of Prelude.Classes.Eq (\\meth =>\n \\meth =>\n intToBool (prim__eqBigInt meth\n meth))\n (\\meth =>\n \\meth =>\n not (intToBool (prim__eqBigInt meth\n meth))))\n (IsSetCons ElemBoolNil IsSetNil)\n (True ** ElemBoolCons ElemBoolNil) : IsSet [1, 1]\n\n\nIs this an intended behaviour? Or is it a contradiction? Why is the value of type IsSet [1,1] a case block? I have the %default total annotation at the top of the file so I don't think it has anything to do with partiality, right?\n\nNote: I'm using Idris 0.9.18"
]
| [
"proof",
"dependent-type",
"idris",
"type-level-computation"
]
|
[
"Swift: cannot override class function in local scope",
"When I write this:\n\nfunc testMock() {\n class MockAPI: API {\n var expectation: XCTestExpectation?\n\n init(expectation: XCTestExpectation) {\n self.expectation = expectation\n }\n\n override func method() {\n expectation!.fulfill()\n }\n }\n\n let mockAPI = MockAPI(expectation: self.expectationWithDescription(\"API: method should be called\"))\n\n ...\n\n self.waitForExpectationsWithTimeout(1, handler: nil)\n}\n\n\nI get the error: Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1\n\nAny ideas?\n\nJust to clarify a little, since OCMock doesn't work with swift, I'm trying to replicate the mock behavior described here NSHipster / Test (it's at the end of the blog post).\n\nSomething else worth mentioning is that initially what I wanted was:\n\nfunc testMock() {\n let expectation = self.expectationWithDescription(\"API: method should be called\")\n\n class MockAPI: API {\n override func method() {\n expectation.fulfill()\n }\n }\n\n let mockAPI = MockAPI()\n\n ...\n\n self.waitForExpectationsWithTimeout(1, handler: nil)\n}\n\n\nBut I was getting \"SourceKitService Crashed\", similar to this problem I think SourceKitService Terminated"
]
| [
"ios",
"swift"
]
|
[
"How to order WP_Query by meta key value but first remove letters?",
"I'm trying to sort my WP_Query by a meta key but the problem is that the meta key is a string and not a number. What i want to do is somehow remove the letters from the string and then order by this value. \n\nFor example, 'meta_key' contains letters before the number like FOR04. Is it possible to somehow remove the letters from this within the $args? \n\nCan i do something like this?\n\n'meta_key' => preg_replace('/[^0-9]+/', 'test_2') \n\n\n $args = array(\n 'post_type' => 'property',\n 'meta_query' => array(\n array(\n 'key' => 'test_1',\n 'value' => $post->ID,\n 'compare' => 'IN',\n ),\n ),\n 'meta_key' => 'test_2',\n 'orderby' => 'meta_value_num',\n 'posts_per_page' => -1\n );\n\n\n\n\nI've tried this method but it's not sorting them correctly..\n\n $args['meta_key'] = preg_replace('/[^0-9]+/', '', 'db-id');\n $args = array(\n 'post_type' => 'property',\n 'meta_query' => array(\n array(\n 'key' => 'court',\n 'value' => $post->ID,\n 'compare' => 'IN',\n ),\n ),\n 'orderby' => 'meta_value_num',\n 'order' => 'DESC',\n 'posts_per_page' => -1\n );"
]
| [
"php",
"wordpress"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.