texts
list
tags
list
[ "code line lcd.scrollDisplayLeft (); no working", "I use the library \"LiquidCrystal_I2C.h\" and \"Wire.h\".\nThe code line lcd.scrollDisplayLeft (); does not run the function.\n\nDo I need to put this before / after the Lcd.print?\nShould I put in after delay?\nIs it related to the library?\nIt's just part of the code\n\n lcd.clear;\n lcd.scrollDisplayLeft();\n lcd.print(\"press Up to set turn on\");\n lcd.setCursor(0, 1);\n lcd.print(\"press down to set turn off\");\n Setting = true;\n\n\nThank you!" ]
[ "arduino", "arduino-uno", "arduino-ide", "lcd", "arduino-c++" ]
[ "Counting occurrences of a unique element in ArrayList", "So currently I have a\nstatic List<List<String>> lines = new ArrayList<>();\n\nwith the Arraylist containing values such as\n{["ID", "Last Name", "First Name", "Vaccine Type", "Vaccination Date", "Vaccine Location"]\n["12345", "Doe", "John", "Pfizer", "10/30/2020", "Argentina"]\n["54321", "Adam", "Marceline", "Pfizer", "11/19/2020", "Russia"]\n["70513", "Sitz", "Tomislav", "Moderna", "12/2/2020", "England"]\n["54371", "Lyndon", "Sergei", "Johnson&Johnson", "03/01/2021", "Israel"]\n["41027", "Chambers", "Wallis", "Moderna", "01/28/2021", "United States"]\n}\n\nI want to find the number of unique vaccine types as well as find the frequency of it. So for example this arraylist should return something like\n"Pfizer:2, Moderna:2, J&J:1" \n\nideally in it's own seperate data structure(array).\nI tried using a HashList but the way my arraylist is formatted is not supported.\nSet<String> unique = new HashList<String>(lines);\n for (String key : unique) {\n System.out.println(key + ": " + Collections.frequency(lines, key));\n }\n\nI get the error "the hashlist cannot be resolved to type"." ]
[ "java" ]
[ "Three.js canvas texture power of 2 but cropped", "In Three.js it's best practice to keep textures to be a power of 2, and actually a requirement for some older Chrome browsers e.g.\n32x32, 64x64 etc\nTherefore I need to create a canvas texture of power of 2 dimensions, but I need to have that Sprite clickable, which means it needs to be cropped somehow.\nConsider this example:\n\n\nBlack bg is the Three.js renderer\nRed bg is the required size of a canvas (to power of 2)\nWhite bg is the size of the text\n\nI would like to keep the texture at dimensions power of 2, but crop it to only show the white area. This is so the user can hover on the label for example. I don't want them hovering on the red area!\n\r\n\r\nvar scene = new THREE.Scene();\nvar camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);\ncamera.position.z = 400;\n\nvar renderer = new THREE.WebGLRenderer();\nrenderer.setSize(window.innerWidth, window.innerHeight);\ndocument.body.appendChild(renderer.domElement);\n\nvar config = {\n fontface: 'Arial',\n fontsize: 32,\n fontweight: 500,\n lineheight: 1,\n};\nvar text = 'Hello world!';\n\nfunction nextPowerOf2(n) {\n return Math.pow(2, Math.ceil(Math.log(n) / Math.log(2)));\n}\n\nvar canvas = document.createElement('canvas');\nvar ctx = canvas.getContext('2d');\nctx.font = `${config.fontweight} ${config.fontsize}px/${config.lineheight} ${config.fontface}`;\nconst textMetrics = ctx.measureText(text);\nvar textWidth = textMetrics.width;\nvar textHeight = config.fontsize * config.lineheight;\ncanvas.width = nextPowerOf2(textWidth);\ncanvas.height = nextPowerOf2(textHeight);\nctx.fillStyle = 'red';\nctx.fillRect(0, 0, canvas.width, canvas.height);\nctx.fillStyle = 'white';\nctx.fillRect(0, 0, textWidth, textHeight);\nctx.fillStyle = 'black';\nctx.textAlign = 'left';\nctx.textBaseline = 'top';\nctx.font = `${config.fontweight} ${config.fontsize}px/${config.lineheight} ${config.fontface}`;\nctx.fillText(text, 0, 0);\n\nconsole.log('canvas', canvas.width, canvas.height);\nconsole.log('text', textWidth, textHeight);\n\nvar texture = new THREE.Texture(canvas);\ntexture.needsUpdate = true;\nvar spriteMaterial = new THREE.SpriteMaterial({\n map: texture\n});\nvar sprite = new THREE.Sprite(spriteMaterial);\nsprite.scale.set(spriteMaterial.map.image.width, spriteMaterial.map.image.height, 1);\nscene.add(sprite);\n\n\nvar animate = function() {\n requestAnimationFrame(animate);\n renderer.render(scene, camera);\n};\n\nanimate();\r\nbody { margin: 0; }\r\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/three.js/110/three.min.js\"></script>\r\n\r\n\r\n\nHow is this possible? Somehow cropping the SpriteMaterial?" ]
[ "canvas", "three.js", "html5-canvas", "sprite" ]
[ "How to copy table to another table?", "I have a table with 1 000 000 records:\n\nCREATE TABLE [dbo].[x2](\n [session_id] [uniqueidentifier] NOT NULL,\n [node_id] [uniqueidentifier] NOT NULL,\n [id] [int] IDENTITY(1,1) NOT NULL,\n CONSTRAINT [PK_x2] PRIMARY KEY CLUSTERED \n(\n [id] ASC\n));\n\n\nI need to replace the field \n\n[id] [int] IDENTITY(1,1)\n\n\nwith \n\n[id] [bigint] IDENTITY(1,1)\n\n\nBut all data (including id values) should be copied to the new table and id should be IDENTITY but bigint. \n\nI have created the new table \n\nCREATE TABLE [dbo].[x2_new](\n [session_id] [uniqueidentifier] NOT NULL,\n [node_id] [uniqueidentifier] NOT NULL,\n [id] [bigint] IDENTITY(1,1) NOT NULL,\n CONSTRAINT [PK_x2_new] PRIMARY KEY CLUSTERED \n(\n [id] ASC\n));\n\n\nand tried to copy data:\n\ninsert into x2_new(session_id,node_id,id)\nselect session_id,node_id,id from x2;\n\n\nBut it is slow. How to copy data to the new table faster?" ]
[ "sql-server", "copy", "identity" ]
[ "undefined >>> 0 == 4294967295?", "Getting different results on different machines and wonder if this is expected behaviour or a potential error in implementation of '>>>' operation for certain CPUs?\n\nLinux qemux86-64 4.18.41-yocto-standard #1 SMP PREEMPT Tue Oct 8 20:33:31 UTC 2019 x86_64 GNU/Linux\nroot@qemux86-64:~# node --v8-options|head -n 1\nSSE3=1 SSSE3=1 SSE4_1=0 SAHF=1 AVX=0 FMA3=0 BMI1=0 BMI2=0 LZCNT=0 POPCNT=0 ATOM=0\nroot@qemux86-64:~# node -v \nv8.12.0\nroot@qemux86-64:~# node -e 'console.log(undefined >>> 0)'\n4294967295\n\n\n(undefined >>> 0) evaluates to 0 on other machines I tested.\nBut, then with CPU features enabled:\nAVX FMA3 BMI1 BMI2 LZCNT POPCNT" ]
[ "javascript", "node.js", "cpu", "v8" ]
[ "How to check if element in groovy array/hash/collection/list?", "How do I figure out if an array contains an element? \nI thought there might be something like [1, 2, 3].includes(1) which would evaluate as true." ]
[ "arrays", "list", "groovy" ]
[ "specifying start and end positions from python list", "I have a python list that is made up of positions and scores.\n\nI need to find a way to write a code that will specify start and end positions of regions with scores over a certain cutoff value. \n\nAny ideas as to how to filter through the list and find these regions?" ]
[ "python", "list" ]
[ "Android Espresso can't type in TYPE_TEXT_VARIATION_NORMAL?", "I have a TextInputEditText view in my android application, and I am setting it up programmatically (via Anko and Kotlin) like this:\n\n textInputEditText {\n id = R.id.text_input_id\n inputType = EditorInfo.TYPE_TEXT_VARIATION_NORMAL\n hint = resources.getText(R.string.text_hint)\n }\n\n\nThen in an Espresso test I call this line:\n\nonView(withId(R.id.text_input_id)).perform(typeText(textToType))\n\n\nWhich fails with this error: \n\nCaused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints:\n((is displayed on the screen to the user) and (supports input methods or is assignable from class: class android.widget.SearchView))\nTarget view: \"TextInputEditText{id=2131623954, res-name=text_input_id, visibility=VISIBLE, width=862, height=118, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, text=, input-type=0, ime-target=false, has-links=false}\"\n\n\nI've discovered that if I switch it from this:\n\n/**\n * Default variation of {@link #TYPE_CLASS_TEXT}: plain old normal text.\n */\npublic static final int TYPE_TEXT_VARIATION_NORMAL = 0x00000000;\n\n\nTo this:\n\n/**\n * Variation of {@link #TYPE_CLASS_TEXT}: entering a password, which should\n * be visible to the user.\n */\npublic static final int TYPE_TEXT_VARIATION_VISIBLE_PASSWORD = 0x00000090;\n\n\nIt suddenly magically works! But that doesn't make much sense. The normal text sounds like the right one to use until Espresso blows up in my face. Is this a bug with Espresso, or something I'm not understanding?" ]
[ "java", "android", "android-espresso" ]
[ "AngularJS access JSON index values dynamically", "My scope data:\n\n$scope.data = \n \"category\": [{\n\"name\": \"cat1\",\n\"behaviour\": \"normal\",\n\"selected\": 0,\n\"values\": [{\n \"label\": \"define\",\n \"count\": 6\n}]\n}, {\n\"name\": \"cat2\",\n\"behaviour\": \"normal\",\n\"selected\": 0,\n\"values\": [{\n \"label\": \"type\",\n \"count\": 6\n}]\n}, {\n\"name\": \"Company\",\n\"behaviour\": \"multi-select\",\n\"selected\": 0,\n\"values\": [{\n \"label\": \"VW\",\n \"count\": 4\n}, {\n \"label\": \"Renault\",\n \"count\": 1\n}, {\n \"label\": \"Fiat\",\n \"count\": 1\n}]\n}, {\n\"name\": \"Make\",\n\"behaviour\": \"multi-select\",\n\"selected\": 0,\n\"values\": [{\n \"label\": \"Gold\",\n \"count\": 3\n}]\n}, {\n\"name\": \"Color\",\n\"behaviour\": \"normal\",\n\"selected\": 0,\n\"values\": [{\n \"label\": \"White\",\n \"count\": 3\n}, {\n \"label\": \"Blue\",\n \"count\": 2\n}, {\n \"label\": \"Green\",\n \"count\": 1\n}]\n}]\n\n\nHow can I access the \"name\":\"value\" without using indexes? as the data might grow and change and I don't want to assign an index value anywhere? I'd still want to filter such as:\n\n| {name: 'Make'}: true)\n\n\nin my mark up to show" ]
[ "angularjs", "multidimensional-array", "angularjs-scope", "angularjs-ng-repeat" ]
[ "Ruby gui with charts", "I want to be able to do 2 things:\n\n\nHave a gui for ruby from which I can run some scripts/calculations. \nDisplay the results via a chart. \n\n\nResults will just be in a simple array. It would be best to have that all in the gui so it can function like a normal program.\n\nAny help would be greatly appreciated. \n\nThanks!\n\nEdit: I forgot to mention, the charts can be simple line charts. Nothing fancy. But they need to be able to display an array of results as large as say 100,000 points." ]
[ "ruby" ]
[ "Gradle: How to make a compile scope file dependency excluded in packaging?", "I have a multi-module gradle project with the following basic structure:\n\nroot\n core\n c-interface\n m-interface\n\n\nThe c-interface and m-interface both depend on the core project:\n\ncompile project(':root:core')\n\n\nc-interface and m-interface use the WAR plugin, but core does not and is just a jar.\n\nIn the core project, I am pulling in some file system dependencies with the following. One of these dependencies I cannot have packaged in the WARs generated by c-interface and m-interface. Previously I had this dependency in a nexus maven repository so I could exclude it by group,name,version in a providedRuntime configuration in c-interface and m-interface. \n\nI cannot figure out how to do the same for the file dependency. The gradle dependencies task does not list file dependencies so I don't know what I would put in a providedRuntime.\n\nI read http://issues.gradle.org/browse/GRADLE-471 but trying to use the idea there doesn't seem to remove the archive from my packages. Here is what I am currently defining (in core's build.gradle):\n\ncompile fileTree(dir: 'dependencies/compile/archive', include: '*.jar', exclude: 'management.jar')\ncompile(files('dependencies/compile/archive/management.jar')){ notPackaged = true } // Excludes it from all publications\n\n\nUpdate\n\nprovidedCompile without war plugin looked like a possibility. I set this up in the core build.gradle and it compiled fine, but c-interface and m-interface also needed the dependency at compile time. Including the file as providedCompile (or even a sanity check with compile) in c-interface and m-interface did not fix compile time errors related to missing the management.jar dependency. My speculation is because it was already scoped as providedCompile in core that the new declarations are ignored in c-interface and m-interface. \n\ncore/build.gradle:\n\nconfigurations { providedCompile }\n\ndependencies {\n providedCompile files('dependencies/compile/archive/management.jar')\n}\n\nsourceSets.main.compileClasspath += configurations.providedCompile\nsourceSets.test.compileClasspath += configurations.providedCompile\nsourceSets.test.runtimeClasspath += configurations.providedCompile\n\n\nc-interface/build.gradle:\n\nprovidedCompile files('dependencies/compile/archive/management.jar')" ]
[ "build", "dependencies", "gradle" ]
[ "To change icon and text-color of button on mouse hover in menu component", "I am using Menu with icons component in my project.On mouse hovering the menu items(ex: edit) i want to change both the text and icon color,something like this.\n\n\n\nBut i am able to give only background-color on mouse hover but unable to change the text-color on mouse hover.\n\n\n\nI tried giving color: !important; also, still no result.\n\nHere is the stackblitz link." ]
[ "css", "angular-material" ]
[ "Can I send a MediaStream from a PeerConnection to another?", "I'm using Chrome 23.0.1246.0 canary, the latest version.\nI want to send a MediaStream that reveived from a client via PeerConnection to another client via PeerConnection.\nI mean, the ClientA send its local media stream to me via the PeerConnection between us, and then, I send this media stream to ClientB via the PeerConnection between ClientB and me.\n\nThis is my code, but it doesn't work, when I click the AddVideo button for the second time, the \"gotRemoteStream\" function doesn't be invoked. I don't konw the reason.\n\nAnybody can help me?\n\n<!DOCTYPE html>\n<html>\n<head>\n<title>Video Link</title>\n<style type=\"text/css\">\n video { width: 200px;}\n</style>\n</head>\n<body>\n<input id=\"btnAddVideo\" type=\"button\" value=\"Add Video\" onclick=\"AddVideo();\" />\n<div id=\"videos\"></div>\n<script type=\"text/ecmascript\">\n var pcs = new Array();\n var pcr = new Array();\n var mediaStream = new Array();\n var msIndex = 0;\n navigator.webkitGetUserMedia({ audio: true, video: true }, gotStream, function () { alert('get MediaStream Error'); });\n function gotStream(stream) {\n mediaStream[0] = stream;\n }\n\n var pc1;\n var pc2;\n function AddVideo() {\n if (mediaStream[msIndex] == null) return;\n pc1 = new webkitPeerConnection00(null, iceCallback1);\n pc1.addStream(mediaStream[msIndex]);\n var offer = pc1.createOffer(null);\n pc1.setLocalDescription(256, offer);\n\n pc2 = new webkitPeerConnection00(null, iceCallback2);\n pc2.onaddstream = gotRemoteStream;\n pc2.setRemoteDescription(256, new SessionDescription(offer.toSdp()));\n var answer = pc2.createAnswer(offer.toSdp(), { has_audio: true, has_video: true });\n pc2.setLocalDescription(768, answer);\n\n pc1.setRemoteDescription(768, new SessionDescription(answer.toSdp()));\n pc2.startIce();\n pc1.startIce();\n\n pcs.push(pc1);\n pcr.push(pc2);\n }\n function iceCallback1(candidate, bMore) {\n pc2.processIceMessage(new IceCandidate(candidate.label, candidate.toSdp()));\n }\n function iceCallback2(candidate, bMore) {\n pc1.processIceMessage(new IceCandidate(candidate.label, candidate.toSdp()));\n }\n function gotRemoteStream(e) {\n var v = document.createElement('video');\n v.autoplay = 'autoplay';\n v.src = webkitURL.createObjectURL(e.stream);\n document.getElementById('videos').appendChild(v);\n mediaStream.push(e.stream);\n msIndex++;\n }\n</script>\n</body>\n</html>" ]
[ "webrtc" ]
[ "Pick random but unique array in JavaScript", "I am working on a project in which I need to create a simple html page questionnaire for work. Its been more that 8 years I have not done any programming. Now suddenly be given a project. Stack Overflow helped me in getting through most of the project. But now I have hit a wall. \n\nI need to pick a random but NO repeated question from array of questions. I am using JavaScript to display the questions and using this code example as basis for project.\n\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\"/>\n<title>Quiz</title>\n<style>\n\n</style>\n<script type=\"text/javascript\">\n\nvar pos = 0, test, test_status, question, choice, choices, chA, chB, chC, correct = 0, randomq=0;\n\n\nvar questions = [\n [\"What is 36 + 42\", \"64\", \"78\", \"76\", \"B\"],\n [\"What is 7 x 4?\", \"21\", \"27\", \"28\", \"C\"],\n [\"What is 16 / 4?\", \"4\", \"6\", \"3\", \"A\"],\n [\"What is 8 x 12?\", \"88\", \"112\", \"96\", \"C\"]\n ];\n\nfunction get(x){\n return document.getElementById(x);\n\n}\n\n\nfunction renderQuestion(){\n test = get(\"test\");\n\n\n if(pos >= questions.length){\n test.innerHTML = \"<h2>You got \"+correct+\" of \"+questions.length+\" questions correct</h2>\";\n get(\"test_status\").innerHTML = \"Test completed\";\n\n // resets the variable to allow users to restart the test\n pos = 0;\n correct = 0;\n\n // stops rest of renderQuestion function running when test is completed\n return false;\n }\n\n\n// shuffle questions\n\n random1 = Math.floor(Math.random() * (questions.length)) ;\n get(\"test_status\").innerHTML = \"Question \"+(pos+1)+\" of \"+questions.length;\n\n\n question = questions[random1][0];\n chA = questions[random1][1];\n chB = questions[random1][2];\n chC = questions[random1][3];\n test.innerHTML = \"<h3>\"+question+\"</h3>\";\n // the += appends to the data we started on the line above\n test.innerHTML += \"<input type='radio' name='choices' value='A'> \"+chA+\"<br>\";\n test.innerHTML += \"<input type='radio' name='choices' value='B'> \"+chB+\"<br>\";\n test.innerHTML += \"<input type='radio' name='choices' value='C'> \"+chC+\"<br><br>\";\n test.innerHTML += \"<button onclick='checkAnswer()'>Submit Answer</button>\";\n}\nfunction checkAnswer(){\n // use getElementsByName because we have an array which it will loop through\n choices = document.getElementsByName(\"choices\");\n for(var i=0; i<choices.length; i++){\n if(choices[i].checked){\n choice = choices[i].value;\n }\n }\n // checks if answer matches the correct choice\n if(choice == questions[random1][4]){\n //each time there is a correct answer this value increases\n correct++;\n }\n // changes position of which character user is on\n pos++;\n // then the renderQuestion function runs again to go to next question\n renderQuestion();\n}\nwindow.addEventListener(\"load\", renderQuestion, false);\n</script>\n</head>\n<body>\n<h2 id=\"test_status\"></h2>\n<div id=\"test\"></div>\n</body>\n</html>\n\n\nI am looking for a way that there is no repeated questions. \n\nPlease advice...\n\nThanks in advance." ]
[ "javascript", "html" ]
[ "Saving images in Python at a very high quality", "How can I save Python plots at very high quality?\nThat is, when I keep zooming in on the object saved in a PDF file, why isn't there any blurring?\nAlso, what would be the best mode to save it in?\npng, eps? Or some other? I can't do pdf, because there is a hidden number that happens that mess with Latexmk compilation." ]
[ "python", "graphics", "matplotlib", "save" ]
[ "Safe way to allow user generated expressions against SQL columns", "I am allowing users to generate expressions against predefined columns on the table. A user can create columns, tables, and can define constraints such as unique and not null columns. I also want to allow them to generate \"Calculated columns\". I am aware that PostgreSQL does not allow calculated columns so to get around that I'll use expressions like this:\n\nSELECT CarPrice, TaxRate, CarPrice + (CarPrice * TaxRate) AS FullPrice FROM CarMSRP\n\n\nThe user can enter something like this\n\n{{CarPrice}} + ({{CarPrice}} * {{TaxRate}})\n\n\nThen it gets translated to \n\nCarPrice + (CarPrice * TaxRate)\n\n\nNot sure if this is vulnerable to sql injection. If so, how would I make this secure?" ]
[ "c#", "postgresql" ]
[ "Imagemagick producing poor quality thumbnails", "Well, just noticed my imagick is producing blurry / poor quality thumbnails. Couldn't find a piece of code that I need to correct in order to make thumbs better quality. Any suggestions? It all happens in a PHP function below. Also 2 image samples are below as well.\n\ntry {\n\n$image = new Imagick($picfile);\n\nif ($image->getImageColorspace() == \\Imagick::COLORSPACE_CMYK) {\n $image->transformimagecolorspace(\\Imagick::COLORSPACE_SRGB);\n}\n\nImagick::setResourceLimit (6, 1);\n\n\n// hypothetical new h and w\n$new_w = round($o_height * $maxwidth / $maxheight);\n$new_h = round($o_width * $maxheight / $maxwidth);\n\n$ratio=round(($o_width/$o_height), 2);\n\nif($ratio < 1.25){$go_vertical=true;}\n\nif($o_width > $o_height && !$go_vertical){ // horizontal\n $image->cropThumbnailImage($maxwidth, $maxheight);\n\n\n\n $image->writeImage($path); $pathe=1;\n}\n\nif($o_width <= $o_height || $go_vertical){ // vertical\n $image2 = new Imagick();\n\n $image2->newImage($new_w, $o_height+2, \"white\");\n\n\n $x = round(abs(($new_w - $o_width) / 2))-1;\n\n echo $mode.\" x=\".$x.\" IMAGE (\".$new_w.\", \".$o_height.\")<br />\";\n $image2->compositeImage($image, imagick::COMPOSITE_DEFAULT, $x, 0);\n\n $image2->cropThumbnailImage($maxwidth, $maxheight);\n\n // Strip out unneeded meta data\n $image->stripImage();\n\n $image2->writeImage($path);\n $image2->destroy(); $pathe=2;\n}\n$image->destroy(); \n\n\nAs images do not directly insereted here, here are links:\n\nGood example: https://www.comfyco.com/temp/b/good.jpg\n\nBad example: https://www.comfyco.com/temp/b/bad.jpg\n\nIt doesn't look drastically different here but on actual website it's pretty bad sometimes. Any advice what parameter / line to add to make those thumbnails look better? \n\nThanks!" ]
[ "php", "imagemagick" ]
[ "How to publish google apps script to cloud for public?", "I have a apps script that uses bigquery service to fetch data from my bigquery account and builds visualizations/tables etc. I publish the app with following options\nExecute App as: User accessing web app\nWho has access to this app: Anyone\n\n\nWhen I open the link (one ending in exec not dev) in chrome incognito, I expect it to show the web app but it asks for google credentials. \nWhen I entering credentials of my other (different from the one hosting the project) account, I get a permissions error. \nI added this other account from my primary one under permissions option of google console - even that wasn't enough.\nI had to create a dummy project as this other user to accept the invitation from my primary account. After that the app showed up on this other account.\n\n\nMy question is, how do I publish my app for the consumers (even public) of this info without them having to create dummy project/accept my invite etc?\n\nThanks" ]
[ "authentication", "oauth", "google-apps-script", "google-bigquery" ]
[ "split json array response for each input field", "Sorry for the repost I just need it badly and it's important!\nI have other posts with the same but I flagged the question answered and I have still not figure out how to fix!\n\nI have this ajax response :\n\n[{\"error\":\"uname\",\"message\":\" \\u05e9\\u05dd \\u05de\\u05e9\\u05ea\\u05de\\u05e9 \\u05d0\\u05d9\\u05e0\\u05d5 \\u05d9\\u05db.\"},{\"error\":\"email\",\"message\":\" \\u05d0\\u05e0\\u05d0 \\u05d4\\u05db\\u05e0\\u05e1 \\u05d0\\u05d9\\u05de\\u05d9\\u05dc\"},{\"error\":\"password\",\"message\":\" \\u05e9\\u05d3\\u05d4 \\u05d6\\u05d47\"},{\"error\":\"oldpassinp\",\"message\":\" \\u05d4\\u05e7\\u05e9 \\u05e1\\u05d9\\u05e1\\u05de\\u05d0 \\u05e9\\u05dc.\"}]\n\n\nand my input fields like this : \n\n<input type=\"text\" id=\"fname\" name=\"fname\" value=\"\" class=\"inplaceError\"/><span id=\"fname_error\"></span>\n\n\nthe span holds the message errors.\n\nI use this in client side :\n\n var data_array = JSON.parse(\"[\"+data+\"]\");\n // tryed either var data_array = JSON.parse(data); not working too\n\n for (var i in data_array )\n {\n $(\"#\"+data_array[i].error+\"_error\").html(data_array[i].message);\n $(\"#\"+data_array[i].error).css({\"border\":\"1px solid red\"});\n } \n\n\nwhat wrong with that code ? It's not adding the errors for each field please any help.\n\nI am javascript newbie." ]
[ "javascript", "jquery", "ajax" ]
[ "How to override page styles without using !important, in a Greasemonkey script?", "I have a Greasemonkey script that applies styles with either .css() or GM_addStyle(). These styles are getting overwritten by the styles that are on the page, causing undesired effects. \n\nI know that I can fix this by using !important on all of my styles, but I really don't want to do this. Is there any way to do this w/o using !important?" ]
[ "javascript", "css", "greasemonkey" ]
[ "ValueError: negative dimensions are not allowed using pandas pivot_table", "I am trying to make item-item collaborative recommendation code. My full dataset can be found here. I want the users to become rows, items to become columns, and ratings to be the values.\n\nMy code is as follows:\n\nimport pandas as pd \nimport numpy as np \nfile = pd.read_csv(\"data.csv\", names=['user', 'item', 'rating', 'timestamp'])\ntable = pd.pivot_table(file, values='rating', index=['user'], columns=['item'])\n\n\nMy data is as follows:\n\n user item rating timestamp\n0 A2EFCYXHNK06IS 5555991584 5 978480000 \n1 A1WR23ER5HMAA9 5555991584 5 953424000\n2 A2IR4Q0GPAFJKW 5555991584 4 1393545600\n3 A2V0KUVAB9HSYO 5555991584 4 966124800\n4 A1J0GL9HCA7ELW 5555991584 5 1007683200\n\n\nAnd the error is:\n\nTraceback (most recent call last): \n File \"D:\\python\\reco.py\", line 9, in <module> \n table=pd.pivot_table(file,values='rating',index=['user'],columns=['item']) \n File \"C:\\python35\\lib\\site-packages\\pandas\\tools\\pivot.py\", line 133, in pivot_table \n table = agged.unstack(to_unstack) \n File \"C:\\python35\\lib\\site-packages\\pandas\\core\\frame.py\", line 4047, in unstack \n return unstack(self, level, fill_value)\n File \"C:\\python35\\lib\\site-packages\\pandas\\core\\reshape.py\", line 402, in unstack \n return _unstack_multiple(obj, level) \n File \"C:\\python35\\lib\\site-packages\\pandas\\core\\reshape.py\", line 297, in _unstack_multiple \n unstacked = dummy.unstack('__placeholder__') \n File \"C:\\python35\\lib\\site-packages\\pandas\\core\\frame.py\", line 4047, in unstack \n return unstack(self, level, fill_value) \n File \"C:\\python35\\lib\\site-packages\\pandas\\core\\reshape.py\", line 406, in unstack \n return _unstack_frame(obj, level, fill_value=fill_value) \n File \"C:\\python35\\lib\\site-packages\\pandas\\core\\reshape.py\", line 449, in _unstack_frame \n fill_value=fill_value) \n File \"C:\\python35\\lib\\site-packages\\pandas\\core\\reshape.py\", line 103, in __init__ \n self._make_selectors() \n File \"C:\\python35\\lib\\site-packages\\pandas\\core\\reshape.py\", line 137, in _make_selectors \n mask = np.zeros(np.prod(self.full_shape), dtype=bool) \nValueError: negative dimensions are not allowed" ]
[ "python", "pandas", "numpy", "dataframe", "scipy" ]
[ "Can i use a button to save data in sharedPreferences and another to retrieve it?", "Lets say i have an TextView that i want the user to view and then hit a save button. Then Hit display button and input the text into an editText field. \n\nHere's what Im trying but its not working\n\nTo Save info from a TextView...\n\n case R.id.save:\n\n\n SharedPreferences firsttunesettings = getSharedPreferences(\"tune1\", 0);\n SharedPreferences.Editor editor = firsttunesettings.edit();\n editor.putString(\"rh1\", rh1.getText().toString());\n editor.commit();\n\n\nthen to show the data in an EditText....\n\n case R.id.display:\nSharedPreferences firsttunesettings = getSharedPreferences(\"tune1\", 0);\n\n rh1.setText(firsttunesettings.getString(\"rh1\", \"\"));\n\n\nThe code doesnt throw any errors, it just doesnt seem to do anything. Any help is appreciated. Thanks." ]
[ "android", "button", "save", "sharedpreferences" ]
[ "How to add a user in a folder security tab", "Hi all I have a shared folder on which i have given the following permissions\n\nnet share $NetworkSharePath '/Grant:Administrators,FULL' '/Grant:IIS_IUSRS,FULL' | out-null\n\n\nbut this only creates user on shared permission tab I would like to add IIS user in security tab as well but dont have a clue how to do that\n\n$Networkshare_Name = 'Media'\n$NetworkShare_Path = 'Media=C:\\_Projects\\mediaFolder'\nnet share $NetworkSharePath '/Grant:Administrators,FULL' '/Grant:IIS_IUSRS,FULL' | out-null\n\n\n $acl = Get-Acl $NetworkSharePath\n $rule = New-Object \n System.Security.AccessControl.FileSystemAccessRule(\"IIS_IUSRS\",\"FullControl\", \n \"ContainerInherit,ObjectInherit\", \"None\", \"Allow\") \n\n $acl.AddAccessRule($rule)\n Set-Acl $NetworkSharePath $acl\n\n\nStill no luck with this\n\n $folder = \"C:\\_Projects\\mediaFolder\"\n $acl = Get-Acl $folder\n $permission = \"IIS_IUSRS\",\"FullControl\",\"Allow\"\n $rule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission\n $acl.AddAccessRule($rule)\n Set-Acl $folder $acl" ]
[ "powershell" ]
[ "Determining bro version from conn.log file", "Is there any way to determine the current bro version from the conn.log file? \n\nI have an application that parses conn.logs and I don't currently see anything in the header that details a version number" ]
[ "bro" ]
[ "Cannot send email through Hotmail / live.com / outlook.com", "I have read other answers on the stackoverflow. but none of the solutions work for me.\n\nI'm trying to send email through live.com, but unable to it.\n\nThe error message:\n\nmailbox unavailable. The server response was: 5.7.3 requested action aborted;\nuser not authenticated\n\n\nor error message:\n\nSystem.Net.Mail.SmtpException: Service not available, \nclosing transmission channel. \nThe server response was: Cannot connect to SMTP server 65.55.176.126 \n(65.55.176.126:587), NB connect error 1460\n\n\nThe code:\n\nMailMessage mail = new MailMessage();\nmail.From = new MailAddress(\"[email protected]\");\nmail.To.Add(\"[email protected]\");\nmail.Subject = \"hello\";\nmail.Body = \"awefkljj kawefl\";\nmail.IsBodyHtml = false;\n\nSmtpClient smtp = new SmtpClient(\"smtp.live.com\", 587);\nsmtp.EnableSsl = true;\nsmtp.Credentials = new NetworkCredential(\"[email protected]\", \"password\");\nsmtp.Send(mail);\n\n\nAre you able to send the email by using above code?\nIt works before, last year, but it is no more working now.\nI'm not sure what has been changed to live.com email server.\nWhat new settings or parameters should apply?" ]
[ "c#", "email", "hotmail" ]
[ "angular2 ng-template in a separate file", "angular2 how to use ng-template from a different file? When I place the ng-template within the same HTML where I use it works but when I move ng-template into a separate file then it won't work. Is there a way to move ng-template into its own file and use it in different html file?\n\ninfo-message.html\n\n<ng-template #messageTemplate>\n Hi\n</ng-template>\n\n<ng-container *ngTemplateOutlet=\"messageTemplate;\"></ng-container>\n\n\nabove is working fine because ng-template and the usage is in same file\n\nmessage-template.html\n\n<ng-template #messageTemplate>\n Hi\n</ng-template>\n\n\ninfo-message.html\n\n<ng-container *ngTemplateOutlet=\"messageTemplate;\"></ng-container>\n\n\nThis is not working. Is there a way to use \"messageTemplate\" which is in a separate file inside another html(Eg: info-message.html)\n\nThanks in advance." ]
[ "angular", "typescript", "ng-template" ]
[ "'Form1.myAxMap' is inaccessible due to its protection level", "Kind of stuck here.\nI am having the error message 'Form1.myAxMap' is inaccessible due to its protection level when I build my program.\n\nhere's the problem\n\nfrm1object.myAxMap.AddLayerFromFilename(outputshapefile, tkFileOpenStrategy.fosVectorLayer, true);\n\n\nCode for Form2.cs\n\nnamespace Buffer\n{\n public partial class frmbuffer : Form\n {\n Form1 frm1object;\n public frmbuffer(Form1 frm1loaded)\n {\n InitializeComponent();\n frm1object = frm1loaded;\n }\n\n private void Btnok_Click(object sender, EventArgs e)\n {\n string inputshapefile = inputshp.Text;\n double inputdistance = Convert.ToDouble(distance.Text);\n int inputsegment = Convert.ToInt16(segments.Text);\n bool inputselected = Convert.ToBoolean(selectedonly.Text);\n bool inputmerge = Convert.ToBoolean(mergeresults.Text);\n string outputshapefile = outputshp.Text;\n bool inputoverwrite = Convert.ToBoolean(checkboxoverwrite.Checked);\n\n Shapefile sf = new Shapefile();\n sf.Open(inputshapefile);\n\n var utils = new Utils();\n\n bool bufferprocess = utils.BufferByDistance(sf, inputdistance, inputsegment,\n inputselected, inputmerge,\n outputshapefile, inputoverwrite);\n\n\n if (bufferprocess == true)\n {\n MessageBox.Show(\"Completed\", \"Report\",\n MessageBoxButtons.OK);\n frm1object.myAxMap.AddLayerFromFilename(outputshapefile,tkFileOpenStrategy.fosVectorLayer, true);\n }\n else\n {\n MessageBox.Show(\"Failed\", \"Report\",\n MessageBoxButtons.OK);\n }\n }\n }\n}\n\n\nwhat should i do?\nThis is my first time so please help:(" ]
[ "c#" ]
[ "High CPU usage on Azure Storage Emulator", "I'm using Storage Emulator v 3.2 and I've just uploaded about 370.000 blobs totalling some 75GB. Now I'm experiencing constant CPU usage of between 35-40% by the emulator process just by doing nothing (i.e. not actively using the emulator).\n\nDoes anyone know what the emulator is doing \"when it's not doing anything\"? Is it doing some sort of indexing or anything? Would the constant CPU usage have something to do with the large number of files (if 370K files is considered large anyway) or large amount of storage used?" ]
[ "azure", "azure-storage-emulator" ]
[ "How to paginate aria control based table in Selenium web driver?", "I can generate a click in this table:\nhttps://datatables.net/examples/styling/bootstrap\nin order to advance to the next page using this code:\nnxt = driver.find_element_by_link_text("Next")\nhov = ActionChains(driver).move_to_element(nxt)\nhov.click().perform()\n\nAnd then get the url by appending the href to get the next table page.\nHowever, I'm not able to do the same when there is no href in a table like this:\nhttps://live.euronext.com/en/markets/amsterdam/equities/list\nI'm able to grab the "a" item and generate a click event without errors using the same code as above. But when I call driver.get(url) I will just get a copy of the current page rather than the next page.\nI guess this is because this page is using the some kind of (aria-control) Javascript to handle the click.\nHow how can I generate a click in this kind of table in order to advance to the next page using the Selenium web driver?" ]
[ "python-3.x", "selenium", "wai-aria" ]
[ "tkdiff how to ignore line endings", "Using tkdiff on unix platform, I've tried modifying whitespace option in the preferences window to be -w or -b, neither of which seem to ignore carriage return differences (unix/pc.) \n\n-w works with diff from the command line.\n\nAny thoughts would be greatly appreciated." ]
[ "tk" ]
[ "How to paint custom controls and then propagate events?", "For example, one widget I am trying to create is a mix of QToolButton and QLineEdit.\n\nWhen leaveEvent() occurs, it appears like a QToolButton with the icon/text on the left & the menu-arrow on the right (QToolButton.MenuButtonPopup). When enterEvent() occurs, the left half of the button (icon/text) becomes a QLineEdit, while the right half is still a drop down menu.\n\nI have been trawling through whatever forums google search brings up, and while I loosely understand how to paint it, how do I connect the events properly? If I paint the QLineEdit, how do I get that part of the custom widget to act and respond like a QLineEdit? (Python preferred, C++ is ok)\n\n[QComboBox will not work, and definitely the other widgets I'd like to create don't have any approximate equivalent. Also, I know I can build a widget with other simpler widgets, and then mess with the style sheets to achieve something similar looking, but I know there is an answer to the above, because Qt does it, and it would have better cross-system styling then writing custom style sheets.]" ]
[ "qt" ]
[ "Binding a UserControl to a custom BusyIndicator control", "I have a requirement to focus on a specific textbox when a new view is loaded.\n\nThe solution was to add this line of code to the OnLoaded event for the view:\n\nDispatcher.BeginInvoke(() => { NameTextBox.Focus(); });\n\n\nSo this worked for one view, but not another. I spent some time debugging the problem and realized that the new view I was working on had a BusyIndicator that takes focus away from all controls since the BusyIndicator being set to true and false was occuring after the OnLoaded event.\n\nSo the solution is to call focus to the NameTextBox after my BusyIndicator has been set to false. My idea was to create a reusable BusyIndicator control that handles this extra work. However, I am having trouble doing this in MVVM.\n\nI started by making a simple extension of the toolkit:BusyIndicator:\n\npublic class EnhancedBusyIndicator : BusyIndicator\n{\n public UserControl ControlToFocusOn { get; set; }\n\n private bool _remoteFocusIsEnabled = false;\n public bool RemoteFocusIsEnabled\n {\n get\n {\n return _remoteFocusIsEnabled;\n }\n set\n {\n if (value == true)\n EnableRemoteFocus();\n }\n }\n\n private void EnableRemoteFocus()\n {\n if (ControlToFocusOn.IsNotNull())\n Dispatcher.BeginInvoke(() => { ControlToFocusOn.Focus(); });\n else\n throw new InvalidOperationException(\"ControlToFocusOn has not been set.\");\n }\n\n\nI added the control to my XAML file with no problem:\n\n<my:EnhancedBusyIndicator\n ControlToFocusOn=\"{Binding ElementName=NameTextBox}\"\n RemoteFocusIsEnabled=\"{Binding IsRemoteFocusEnabled}\"\n IsBusy=\"{Binding IsDetailsBusyIndicatorActive}\"\n...\n> \n...\n <my:myTextBox (this extends TextBox)\n x:Name=\"NameTextBox\"\n ...\n />\n...\n</my:EnhancedBusyIndicator>\n\n\nSo the idea is when IsRemoteFocusEnabled is set to true in my ViewModel (which I do after I've set IsBusy to false in the ViewModel), focus will be set to NameTextBox. And if it works, others could use the EnhancedBusyIndicator and just bind to a different control and enable the focus appropriately in their own ViewModels, assuming their views have an intial BusyIndicator active.\n\nHowever, I get this exception when the view is loaded:\n\nSet property 'foo.Controls.EnhancedBusyIndicator.ControlToFocusOn' threw an exception. [Line: 45 Position: 26]\n\nWill this solution I am attempting work? If so, what is wrong with what I have thus far (cannot set the ControlToFocusOn property)?\n\n\n\nUpdate 1\n\nI installed Visual Studio 10 Tools for Silverlight 5 and got a better error message when navigating to the new view. Now I gete this error message:\n\n\"System.ArgumentException: Object of type System.Windows.Data.Binding cannot be converted to type System.Windows.Controls.UserControl\"\n\nAlso, I think I need to change the DataContext for this control. In the code-behind constructor, DataContext is set to my ViewModel. I tried adding a DataContext property to the EnhancedBusyIndicator, but that did not work:\n\n<my:EnhancedBusyIndicator\n DataContext=\"{Binding RelativeSource={RelativeSource Self}}\"\n ControlToFocusOn=\"{Binding ElementName=NameTextBox}\"\n RemoteFocusIsEnabled=\"{Binding IsRemoteFocusEnabled}\"\n IsBusy=\"{Binding IsDetailsBusyIndicatorActive}\"\n...\n>\n\n\n\n\nUpdate 2\n\nI need to change UserControl to Control since I will be wanting to set focus to TextBox objects (which implement Control). However, this does not solve the issue." ]
[ "c#", "silverlight-4.0", "mvvm", "busyindicator" ]
[ "How can gnome-keyring be modified to require quality master passwords?", "I am using CentOS 7. I have certain password quality requirements set up in pwquality.conf (related to the libpwquality package). In addition to these complexity constraints being applied to user logins, I'd like them to be applied to a Password Keyring's master passwords, as accessed e.g. via seahorse and the gnome-keyring-daemon, so that users cannot use weak passwords to protect their keyrings. I'm not concerned about the passwords inside the keyrings, just the passwords for the keyrings themselves.\n\nI have figured out how to make a call to the libpwquality API, particularly pwquality_check is the function I want. However, I am having difficulty retrieving the password in plaintext in the code, in order to pass it to pwquality_check. For example, in the code near gkd-secret-create.c line 211, if I try to capture the password that should be returned by gcr_prompt_password_finish, I only get a NULL.\n\ngchar *password;\n\npassword = gcr_prompt_password_finish (GCR_PROMPT (source), result, &error);\n\n// password is NULL\n\n\nI've stepped through all the code I can find in a debugger and am coming up empty: the password seems to be obscured away very well, or already hashed and discarded by this point. How can I get the password from this prompt and send it to libpwquality? Or is there a better way to enforce password complexity on GNOME's password manager/keyring?" ]
[ "c", "linux", "centos", "passwords", "gnome-keyring-daemon" ]
[ "Javascript app avoid server-side languages", "Have some experiments to build javascript app without support any server-side languages like php, python ... just javascript with a network database layer api. Used orchestrate.io, but the HTML5 CORS require strict headers response like Access-Control-Allow-Origin. Is there a way to build a kind of application stepping to DbaaS ?\n\nFor example nginx is configured to run only www/index.html.\nWe need to get .json data using REST API through the HTTP. This is our blog articles. JSON-P cant send http headers(?).\n\nWho knows this ?\n\nSetup:\n\nnginx\n\nserver {\n ...\n root /usr/local/www\n index index.html\n ...\n\n}\n\n\nindex.html\n\nfunction createCORSRequest(method, url) {\n var xhr = new XMLHttpRequest();\n if (\"withCredentials\" in xhr) {\n\n // Check if the XMLHttpRequest object has a \"withCredentials\" property.\n // \"withCredentials\" only exists on XMLHTTPRequest2 objects.\n xhr.open(method, url, true);\n\n } else if (typeof XDomainRequest != \"undefined\") {\n\n // Otherwise, check if XDomainRequest.\n // XDomainRequest only exists in IE, and is IE's way of making CORS requests.\n xhr = new XDomainRequest();\n xhr.open(method, url);\n\n } else {\n\n // Otherwise, CORS is not supported by the browser.\n xhr = null;\n\n }\n return xhr;\n}\n\nvar xhr = createCORSRequest('GET', url);\nif (!xhr) {\n throw new Error('CORS not supported');\n}\nxhr.withCredentials = true;\nvar url = 'https://api.service.io/article/1';\nvar xhr = createCORSRequest('GET', url);\n\nxhr.onload = function() {\n var responseText = xhr.responseText;\n console.log(responseText);\n // process the response.\n};\n\nxhr.onerror = function() {\n console.log('There was an error!');\n};\n\nxhr.send();\n\n\nand i need to send basic auth http headers ... thats all" ]
[ "javascript", "nginx" ]
[ "loading arcore in unity gives weird error", "I'm trying to load ARCore with unity but I keep getting this error. Anybody know what's causing it.\n\n\n Error building Player: TypeLoadException: Could not load type\n 'UnityEngine.XR.Tango.NativeImage' from assembly 'UnityEngine,\n Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'." ]
[ "unity3d", "arcore" ]
[ "Is Brandoo Wordpress safe for production environment?", "I have a Wordpress blog that is now running in Linux/MySQL. Now, I have seen a product called Brandoo Wordpress which let you run Wordpress on IIS + MSSQL.\nSince I am using Windows Server and MSSQL for all my other projects I would very much like to use it on my Wordpress blog too. The wordpress site is quite big and important. The blog is beloved for its adult content. It has a revenue on thousands of dollars/month so I don't want to rush in anything here.\n\nThe Brandoo Wordpress is a part of the application gallery in Windows Platform Installer and also in Windows Azure.\nSo my questions are:\nSince Brandoo Wordpress is a part of the apps in Azure, do you think it is quality assured by Microsoft?\nI guess before Microsoft adds a web app to Azure and Platform Installer it has to be safe and bug free? Right?\n\nI have tested my Wordpress locally with Brandoo Wordpress and it seems to work great so far." ]
[ "sql-server", "wordpress", "azure" ]
[ "Ruby wrapper for the deprecated Google search API", "I'm looking for the best ruby wrapper for the deprecated Google Web Search API. Anyone know of a good one with good documentation? Examples would be appreciated." ]
[ "ruby-on-rails-3", "google-search-api" ]
[ "Image appears to be flickering due to caching on iOS using Parse", "I am having issues with my tableviewcell's image appearing to flicker. I know what is causing the issue, I am just not sure of the best way to get around it.\n\nI am using Parse.\n\nThe flickering is caused by using the cache policy CacheThenNetwork, so the query checks the cache and then checks the network for any changes. This results in the query being run multiple times, and therefore the cellForRowAtIndexPath is called multiple times.\n\nIn cellForRowAtIndexPath, I set the image to nil to avoid duplicate images when the cells are dequeued. This is one of the main reasons that the flickering happens, and if it wasn't set to nil then the image wouldn't be disappearing and appearing again each time the query is called.\n\nSo my question is, is there a better way to handle the caching or the cellForRowAtIndexPath so that I can avoid this apparent flickering?\n\nI need to use this particular cache policy as it works best for what I am doing. I also need to avoid the duplicate images, so setting the image to nil works for me. If theres a better way of doing this though, please advise!\n\nThanks in advance.\n\nCode snippets below.\n\n-(void)loadTimeline\n{\n NSLog(@\"Loading timeline\");\n PFQuery *loadTimeline = [PFQuery queryWithClassName:@\"Timeline\"];\n [loadTimeline whereKey:@\"objectId\" notEqualTo:@\"\"];\n loadTimeline.cachePolicy = kPFCachePolicyCacheThenNetwork;\n //[loadTimeline clearCachedResult];\n [loadTimeline orderByDescending:@\"timestamp\"];\n [loadTimeline findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error)\n {\n if (!error)\n {\n _timelineArray = [NSMutableArray new];\n\n // Look through all objects in Timeline table\n for (PFObject *object in objects)\n {\n // For every object in the timeline, check the current user's favourites\n for (PFObject *favourite in [[Engine sharedInstance] favouritesArray])\n {\n if ([[object valueForKey:@\"club_objectId\"] isEqualToString:[favourite valueForKey:@\"club_objectId\"]])\n {\n [_timelineArray addObject:object];\n }\n }\n\n // If post is a Sporter announcement, add it to the array\n if ([[object valueForKey:@\"type\"] isEqualToString:@\"sporter_announcement\"])\n {\n [_timelineArray addObject:object];\n }\n }\n [[self tableView] reloadData];\n }\n }];\n}\n\n\nImage being set in cellForRowAtIndexPath:\n\n// Club badge image\n [cell.clubBadgeButton setImage:nil forState:UIControlStateNormal];\n PFFile *badgeImageFile = object[@\"badge_image\"];\n [badgeImageFile getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {\n if (!error) {\n UIImage *badgeImage = [UIImage imageWithData:imageData];\n [cell.clubBadgeButton setImage:badgeImage forState:UIControlStateNormal];\n }\n }];" ]
[ "ios", "xcode", "caching", "parse-platform", "uiimage" ]
[ "Bash Script to find, process and rename files?", "I am trying to put together a script which will run through all the files on my server (under various subdirectories) , look for .jpeg files and run them through a translator which converts them to non progressive jpgs.\n\nI have:\n\n find /home/disk2/ -type f -iname \"*.jpg\" \n\n\nWhich finds all the files.\n\nThen if it finds for example 1.jpg, I need to run:\n\n/usr/bin/jpegtrans /file location/1.jpg > /file location/1.jpg.temp\n\n\nThe jpegtrans app converts the file to a temp file which needs to replace the original file.\nSo then I need to delete the original and rename 1.jpg.temp to 1.jpg\n\n rm /file location/1.jpg\n mv /file location/1.jpg.temp /file location/1.jpg\n\n\nI can easily do this for single files but i need to do it for 100's on my server." ]
[ "linux", "bash" ]
[ "Generate dynamic series in select query with computed value", "Context :\n\nA value arises to new set of values based on the observation coefficient of that value.\n\ne.g. value A will create new sets of values A-1, A-2, A-3 when the user clicks some button to create, but before that, I need to provide them a preview.\n\nProblem: \n\nIf I have this table initially:\n\nid | value | observation\n-----------------------------------------------\n 1 | A | 3\n-----------------------------------------------\n 2 | B | 2\n\n\nI wish to display a computed set of new values to be added based on observation value (a preview before confirmation) to look like this: \n\nid | value | new value to be created | observation\n-----------------------------------------------\n1 | A | A-1 | 3\n-----------------------------------------------\n1 | A | A-2 | 3\n-----------------------------------------------\n1 | A | A-3 | 3\n\n\nIt's like joining a table with another table containing the computed values without the having the actual table/relation yet. \n\nWhat my thoughts are :\n\n\ncreate a temporary table where the computed values are and then do the join (but what if the number of rows is too large, it would be costly to insert a lot everytime)\nI've tried having the computed values as an array aggregate, but i need them in separate rows like the 2nd table i've shown.\n\n\nHow can I do this? Or is this even possible?" ]
[ "sql", "postgresql" ]
[ "How to align the elements of a ruby method call on Vim", "According to the ruby-style-guide, this is the preferable way to align the elements of a method call:\n\nmethod :arg1,\n :arg2,\n :arg3\n\n\nHowever, this is what I got when I try to indent the whole file using gg=G:\n\nmethod :arg1,\n :arg2,\n :arg3\n\n\nI'm currently using vim-ruby and vim-rails plugins.\n\nIs it possible to get vim indentation to work like the style guide suggests?" ]
[ "ruby", "vim", "indentation" ]
[ "Modify .js modal to make it work for several images", "I found this piece of code online to make a modal (popup) with an enlarged picture, when clicking on the thumbnail. The code is shown below and it uses the unique element ID of the thumbnail. \n\nI want to adapt this code so it works for every thumbnail without having to create unique ID's and multiple modals.\n\nHere is the original code using html elements' ID: \n\nvar modalImg = document.getElementById(\"img01\");\nvar captionText = document.getElementById(\"caption\");\nimg.onclick = function(){\n modal.style.display = \"block\";\n modalImg.src = this.src;\n captionText.innerHTML = this.alt;\n}\n\n\nI tried to turn this into working with classes. I realised that getElementsByClassName probably contains multiple items and put the into a list, so I added a for-loop: \n\nvar imgs = document.getElementsByClassName(\"tabs-img\");\nvar modalImg = document.getElementById(\"img01\");\nvar captionText = document.getElementById(\"caption\");\nfor (var img in imgs) {\n img.onclick = function(){\n modal.style.display = \"block\";\n modalImg.src = this.src;\n captionText.innerHTML = this.alt;\n }\n}\n\n\nHowever, when clicking the thumbnails, nothing happens. \n\nWhat is wrong with my adaptation?" ]
[ "javascript", "html" ]
[ "Download file in Android using ProgressbarDialog", "I am trying to develop a simple application for download using DownloadManager but I need to do some changes, I want to download using ProgressbarDialog so how to do.\n\nclass DownloadReceiver\n\nif(downloader == null) return;\n long completeId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);\n if(completeId == downloadTaskId){\n Query query = new Query();\n query.setFilterById(downloadTaskId);\n Cursor cur = downloader.query(query);\n if (cur.moveToFirst()) {\n int columnIndex = cur.getColumnIndex(DownloadManager.COLUMN_STATUS);\n if (DownloadManager.STATUS_SUCCESSFUL == cur.getInt(columnIndex)) {\n //Download the task has been completed, remove\n new VersionPersistent(context).clear();\n String uriString = cur.getString(cur.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));\n File apkFile = new File(Uri.parse(uriString).getPath());\n Intent installIntent = new Intent();\n installIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\n installIntent.setAction(Intent.ACTION_VIEW);\n installIntent.setDataAndType(Uri.fromFile(apkFile),\"application/vnd.android.package-archive\");\n context.startActivity(installIntent);\n\n } else {\n Toast.makeText(context, R.string.download_failure, Toast.LENGTH_SHORT).show();\n }\n }\n cur.close();\n\n\nand also \ndownload and install\n\nif ( latestVersion == null || !isNetworkActive() ) return;\n downloader = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);\n Query query = new Query();\n query.setFilterById(downloadTaskId);\n Cursor cur = downloader.query(query);\n // Download tasks already exists\n if(cur.moveToNext()) return;\n DownloadManager.Request task = new DownloadManager.Request(Uri.parse(latestVersion.targetUrl));\n String apkName = extractName(latestVersion.targetUrl);\n String title = String.format(\"%s - v%s\", apkName,latestVersion.name);\n task.setTitle(title);\n task.setDescription(latestVersion.feature);\n task.setVisibleInDownloadsUi(true);\n task.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);\n task.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, apkName);\n downloadTaskId = downloader.enqueue(task);\n\n\nThanks :)" ]
[ "java", "android", "android-studio" ]
[ "Differences between ItemizedOverlay and Overlay class", "Can someone tell my when to use Overlay or when to use ItemizedOverlay class!\n\nWhat are differences between this two classes?\n\nDraw methods do the same thing?\n\nCan I use only ItemizedOverlay class in my project or I must use and Overlay as base class!\n\nThanks" ]
[ "android", "android-mapview" ]
[ "Update textView from thread", "In my OnCreate method I have created a thread that listens to incoming message!\n\nIn OnCreate() {\n\n//Some code\n\nmyThread = new Thread() {\n\n @Override\n\n public void run() {\n\n receiveMyMessages();\n\n }\n };\nmyThread.start();\n\n// Some code related to sending out by pressing button etc.\n\n}\n\nThen, receiveMyMessage() functions…\n\nPublic void receiveMyMessage()\n{\n\n//Receive the message and put it in String str;\n\nstr = receivedAllTheMessage();\n\n// << here I want to be able to update this str to a textView. But, How?\n}\n\n\nI checked this article but it did not work for me, no luck!" ]
[ "android", "multithreading", "textview" ]
[ "git marks files as deleted", "I have a problem with Git. I am working on a small project for college. I updated Git a few days ago and it was working fine until yesterday when it started randomly marking some files as deleted. I can still work on them, but when I want to commit changes, it just deletes my files from the project. Is this something that I am doing, or is it a Git bug?\n\nLater Edit:\nThis happens in NetBeans. Running git status from the command line is ok, but in NB they are marked as deleted and they get deleted upon commit" ]
[ "php", "git", "netbeans" ]
[ "How to pass ArrayList to an activity in another application?", "I am trying to share data between two applications.. first I thought of saving a file to SD Card then read it.. but this solution won't work.. so I wan woundering if there is a way to send an ArrayList of an Object that implements Parcelable..\n\nwhat other way could be followed to achieve this?\n\nNOTE:\nActivities are not within the same application." ]
[ "android", "share" ]
[ "Possible memory leak in Square/Picasso for Android", "I am part of a team developing a commercial media app. Part of the functionality is to allow the user to customise a ViewGroup montage of ImageViews with their own images retrieved either from Gallery or direct from Camera. I am using the following Picasso call to do this:\n\n mPicasso.load(uri)\n .resize(newWidth, newHeight)\n .into(container);\n\n\nwhere mPicasso is Picasso.with(appContext()) and newWidth and newHeight are dimensions calculated from the source height and width such that aspect ratio is maintained and the resulting image is 1MP. Typically, the sources are between 8 and 16MP.\n\nIf I have a montage of say, eight ImageViews, and I keep adding images to each one in turn, the app eventually crashes. Device only has so much memory, right? Eventually if you keep adding infinite images you're going to run out. What really concerns me, however, is that the app will crash half-way through replacing the eight images. To be clear, you've added your eight images and you've gone back to the top and started replacing those images with different ones and you get to roughly the fourth before the crash.\n\nI would have expected that once an image has been replaced, the old one would be cleaned up. I can fix this by reducing the max size down to 100KP but the problem with that is I imagine I am just delaying the crash. Furthermore, the user has the ability to zoom the image and with such a low resolution, it starts to look knarly quite quickly.\n\nI have posted the crash log here:-\nhttps://gist.github.com/mylesbennett/452c992f6912039ea62d\nbecause it's too long to paste direcly in stackoverflow.\n\nAny suggestions of workarounds/ fixes etc. would be greatly appreciated.\n\n(the crash point in TemplateImageView.isScaleInitialised is where the app is attempting to allocate memory to a nine-value float array:\n\nfloat[] values = new float[9];\n\n\nso I am guessing that this is just the straw that broke the camel's back)" ]
[ "android", "memory-leaks", "picasso" ]
[ "Add custom class to jstree", "I need to add a class to all child and parent nodes in jstree.\n\ntried the below code but its not working.\n\n$('#data').jstree({\n 'core' : {\n 'data' : [{\"text\" : \"GROUPS\",\"state\":{\"opened\":true}, \n \"children\" : [{ \"text\" : \"USERS\", attributes : { class : \"desired_node_class\" }},{ \"text\" : \"ADMIN\"}]} \n ]\n }\n });\n\n\nWhat am i doing wrong?.\nHere's a fiddle to it\nhttp://jsfiddle.net/m6yxhnrg/\n\nCan someone correct me\n\nThanks in Advance!" ]
[ "php", "css", "html", "jquery-plugins", "jstree" ]
[ "Using one form input button to submit two values to Flask-SQLAlchemy for query?", "It was hard to even figure out how to title this question properly. Anyway, say I have a HTML input form that contains two text input fields but one submit button like so:\n\n<form action=\"/search_results\" method=\"post\">\n <fieldset>\n <legend>Inventory Search:</legend>\n Search by Item Name:<br>\n <input type=\"text\" name=\"user_item\" placeholder=\"tiger cowrie\"><br>\n Search by Item Price:<br>\n <input type=\"text\" name=\"user_price\" placeholder=\"1.99\"><br><br>\n <input type=\"submit\" value=\"Search\">\n </fieldset>\n</form>\n\n\nAnd the form action corresponds to my Flask main.py file:\n\[email protected]('/search_results', methods = ['POST'])\ndef item_search():\n user_search = request.form['user_item']\n results = Inventory.query.filter_by(item_name = user_search)\n return render_template(\"search_results.html\", results = Inventory.query.filter_by(item_name = user_search).all())\n\n\nCurrently, I'm only using the input box \"user_item\" to perform the SQLAlchemy query. But what if I wanted to query by using both the request.form['user_item'] AND request.form['user_price']? I can't quite figure out how I'm supposed to pass two variables with only one input button." ]
[ "python", "flask-sqlalchemy" ]
[ "How to save a 4D image series to a single DICOM file using ITKTools?", "I have a couple of 3D CT scans that I would to register using a groupwise registration method by Metz et al (2010) implemented in the elastix registration toolbox (http://elastix.bigr.nl/wiki/index.php/Par0012). The tool requires the 4D data (multiple 3D images) to be encapsulated in a single file. I know this can be achieved with the \"pxcastconvert\" tool of the ITKTools toolbox (because of a \"castconvert4d.cxx\" in github https://github.com/ITKTools/ITKTools/blob/master/src/castconvert/castconvert4D.cxx) but I can't figure out the right command line arguments. Usage is:\n\n<< \"pxcastconvert\\n\"\n<< \" -in inputfilename\\n\"\n<< \" -out outputfilename\\n\"\n<< \" [-opct] outputPixelComponentType, default equal to input\\n\"\n<< \" [-z] compression flag; if provided, the output image is compressed\\n\"\n<< \"OR pxcastconvert\\n\"\n<< \" -in dicomDirectory\\n\"\n<< \" -out outputfilename\\n\"\n<< \" [-opct] outputPixelComponentType, default equal to input\\n\"\n<< \" [-s] seriesUID, default the first UID found\\n\"\n<< \" [-r] add restrictions to generate a unique seriesUID\\n\"\n<< \" e.g. \\\"0020|0012\\\" to add a check for acquisition number.\\n\"\n<< \" [-z] compression flag; if provided, the output image is compressed\\n\\n\"\n\n\nIf possible, could you advice me on how to combine multiple 3D images in a single file DICOM or MHD file using pxcastconvert?" ]
[ "registration", "dicom", "itk", "elastix" ]
[ "x86_64-conda_cos6-linux-gnu-ld: cannot find -lc", "I cannot install most of new packages in R, because of the following error:\n\n\n x86_64-conda_cos6-linux-gnu-ld: cannot find -lc.\n\n\nin some cases it is cannot find \n\n\n x86_64-conda_cos6-linux-gnu-ld: cannot find -lm\n\n\nBased on this post, the -l option is for linking dynamic libraries. This post suggests sudo yum install glibc-static. But, I have no administration permission. \n\nAny help is highly appreciated." ]
[ "r", "linux", "ld" ]
[ "sorting a circular permutation using swap", "Some simple organisms have a circular DNA molecule as a genome, where the molecule has no beginning and no end. These circular genomes can be visualized as a sequence of integers written along the perimeter of a circle.\n\nThe swap sorting of permutation is a transformation of into the identity permutation by exchanges of adjacent elements. For example, 3142 ! 1342 ! 1324 ! 1234 is a three-step swap sorting of permutation 3124.\n\nnow the question is: \nDesign an algorithm for swap sorting that uses the minimum number of swaps to sort a circular permutation." ]
[ "algorithm", "bioinformatics" ]
[ "Cannot resolve host with CNAME but can directly?", "I don't understand why this CNAME is not working:\n\n$ curl test8-kounta.test.kounta.com\ncurl: (6) Couldn't resolve host 'test8-kounta.test.kounta.com'\n\n$ curl test8.kounta.com\n# Success\n\n$ curl 54.187.189.133\n# Success\n\n$ nslookup test8-kounta.test.kounta.com\n\nServer: 8.8.8.8\nAddress: 8.8.8.8#53\n\nNon-authoritative answer:\ntest8-kounta.test.kounta.com canonical name = test8.kounta.com.\nName: test8.kounta.com\nAddress: 54.187.189.133\nName: test8.kounta.com\nAddress: 54.69.18.31\n\n\nWhat am I missing?" ]
[ "dns", "amazon-route53" ]
[ "One to many relationship to fetch values in an alternate rows", "I am trying to fetch dates from sheet1 with common ID (there are multiple occurrences in sheet1) using an array formula in a cell (then dragging it to the right side to have all the dates belong to specific ID):\n=IF(COLUMNS($E2:E2)<=$D2,INDEX(Sheet1!$B$2:$B$13,SMALL(IF(Sheet1!$A$2:$A$13=Sheet2!$A2,\nROW(Sheet1!$A$2:$A$13)-ROW(Sheet1!$A$2)+1),COLUMNS($E2:E2))),\"\")\n\nBut, whenever I try to insert one column (for counting purposes) in b/w the columns, this formula doesn't work. I can't figure out the issue, would really appreciate the help?\n\nThank you." ]
[ "excel", "excel-formula" ]
[ "Jmeter extract data using BeanShell PreProcessor and add parameters", "Having the following request:\n\n\n\nFrom this I extract using the Regular Expression Extractor the following string:\n\n%5B1172%2C63%2C61%2C66%2C69%2C68%5D\n\nI decode this using the urldecode function: ${__urldecode(${Groups_g2})}\n\nDecoded: [1172,63,61,66,69,68]\n\nOn the following request I want to extract the values using the BeanShell PreProcessor to obtain a list of parameters like this one:\n\n\n\nI know that I have to use sampler.addArgument but i can't figure how to extract data from the list and add the values as parameters." ]
[ "jmeter", "beanshell" ]
[ "Tensorflow logits to one_hot Encoding", "I have applied full_connected layer in tensorflow which gives me output of [batch_size, 200, 15]. 200 is the number of tokens in my sentence. \n\nI am creating a tag (out of 15 tags) for each token in a sentence of 200 words. Now, my ground labels can be like [0,0,1,1,0,0,0,0,0,0,0,0,0,0,0]. It means that the tag for this token can have two possibilities. Now if the model predict tag and it is possible tag in label, the loss should be zero. \n\nFor calculating, i did as in the code below. But it cant be optimized as the error is that there are gradients. \n\nIs there a better way to do this ? \n\nI guess the error is because of tf.argmax() as by doing thing the connection between loss and previous model is broken. \n\nAnother question is this. If you apply softmax layer after fully connected layer, your output is like [0.5,0.3,0.05,0.15]. is there a way that i can convert this into [1,0,0,0] ?\n\nwith tf.name_scope('loss'):\nfor i in range(200):\n print('in losses')\n labels = tf.reshape(han.input_y[:,i,:], [64, 15])\n logits = tf.reshape(han.out[:, i, :], [64, 15])\n logits_max = tf.argmax(logits,-1)\n depth = 15\n one_hot = tf.contrib.layers.one_hot_encoding(logits_max, depth)\n mul = tf.math.multiply(labels, one_hot)\n loss = tf.reduce_mean(tf.subtract(1.0, tf.reduce_sum(mul, 1, keepdims=True)))\n\n\n losses.append(loss)\n\nlosses = tf.reshape(losses, [-1, 200])\ncost = tf.reduce_mean(losses)" ]
[ "python", "tensorflow" ]
[ "Extract date from filename", "I have files named in the format gtYYMMDD.txt like for example gt130422.txt, I'd like to extract the date from this file name in the format 2013/04/22.\n\nI'd like to precise that my script, when I execute it, it asks only for the date:\n\nfiletoread = \"/home/scripts/gt\"\nraw_input(\"Enter date, please. For example, 130415: \") + \".txt\"\n\n\nSo the date I want to get is a function of what the user types." ]
[ "python", "python-2.7" ]
[ "How to call a webservice method for testing, e.g. from a browser", "There is a dll webservice (made with Delphi) that has a method called List which returns a list of strings (widestring).\n\nIs there any method for calling that service without having to write a client application for consuming it?.\n\nEx.: http://misitio.com:8080/miwebservice.dll?methodname=list" ]
[ "web-services", "delphi", "dll", "service" ]
[ "How to avoid renderPlot to run more than once when updating multiple sliderInputs?", "I'm wondering if it's possible to avoid rendering the plot function below more than once when pressing the reset button, while allowing the plot to render when any of the sliders change.\n\nSo far the sliders update correctly. Whenever a slider value changes, the plot is rendered as it's supposed to. I would like to avoid the plot to render twice (one per updateSliderInput call) when I press the reset button. This is a simple example and perhaps the delay is not as noticeable, but this problem is particularly nagging when many more inputs affecting the plot are updated programmatically and the plot takes a significant time to render.\n\nReproducible example:\n\nserver.r\n\nlibrary(shiny)\n\nshinyServer(function(input, output, clientid, session) {\n\n x <- reactive({\n input$slider1\n })\n\n y <- reactive({\n input$slider2\n })\n\n output$distPlot <- renderPlot({\n plot(x(), y())\n })\n\n observe({\n if(input$resetButton != 0) {\n updateSliderInput(session, \"slider1\", value=30)\n updateSliderInput(session, \"slider2\", value=30)\n\n }\n })\n})\n\n\nui.r\n\nlibrary(shiny)\n\nshinyUI(fluidPage(\n\n # Application title\n titlePanel(\"Example\"),\n\n # Sidebar with a slider input for number of bins\n sidebarLayout(\n sidebarPanel(\n sliderInput(\"slider1\",\n \"X:\",\n min = 1,\n max = 50,\n value = 30),\n sliderInput(\"slider2\",\n \"y:\",\n min = 1,\n max = 50,\n value = 30),\n actionButton(\"resetButton\", \"Reset!\")\n ),\n # Show a plot of the generated distribution\n mainPanel(\n plotOutput(\"distPlot\")\n )\n )\n))" ]
[ "r", "shiny" ]
[ "archivedDataWithRootObject: always returns \"nil\"", "I have a class named Person and created a Person instance "person".\nPerson *person = [Person personWithName:@"Kyle", andAge:15];\n\nThen I tried to encode it using method archivedDataWithRootObject:requiringSecureCoding:error:.\nNSData *personData = [NSKeyedArchiver archivedDataWithRootObject:person \n requiringSecureCoding:YES error:nil];\n\nHowever, the personData always returns nil. Did I miss something?\nPerson.h\n@interface Person : NSObject<NSSecureCoding>\n@property (strong, nonatomic) NSString *name;\n@property (assign, nonatomic) NSInteger age;\n+ (instancetype)personWithName:(NSString *)name andAge:(NSInteger)age;\n@end\n\nPerson.m\n@implementation Person\n+ (instancetype)personWithName:(NSString *)name andAge:(NSInteger)age{\n Person *p = [Person new];\n p.name = name;\n p.age = age;\n return p;\n}\n+ (BOOL)supportsSecureCoding {\n return YES;\n}\n- (id)initWithCoder:(NSCoder *)coder {\n self = [super initWithCoder:coder]; // error: No visible @interface for 'NSObject' declares the selector 'initWithCoder'\n return self;\n}\n@end\n\n\nUpdate (after implementing +supportsSecureCoding in .m):\n\nClass 'Person' has a superclass that supports secure coding, but\n'Person' overrides -initWithCoder: and does not override\n+supportsSecureCoding. The class must implement +supportsSecureCoding and return YES to verify that its implementation of -initWithCoder: is\nsecure coding compliant." ]
[ "objective-c", "nskeyedarchiver" ]
[ "How to remove JSON object based on specific keyword", "am trying to build an API for that am creating a JSON data to collect that am using web scraping \n\nin the JSON file am also getting some bad objects for example \n\nJSON data I get \n\n[\n {\n \"order\":\"1588668201-56\",\n \"pagenation\":\"\",\n \"pagenation-href\":\"\",\n \"courseid\":\"Redeem Offer\",\n \"courseid-href\":\"https://www.valid.comxyz\"\n },\n {\n \"order\":\"1588668201-57\", \n \"pagenation\":\"\",\n \"pagenation-href\":\"\",\n \"courseid\":\"[Free] ClickHouse crash course. Conquer big data with ease\",\n \"courseid-href\":\"https://remove.com/xyz\"\n },\n {\n \"order\":\"1588668201-58\", \n \"pagenation\":\"\",\n \"pagenation-href\":\"\",\n \"courseid\":\"Redeem Offer\",\n \"courseid-href\":\"https://www.valid.com/xyz\"\n }\n]\n\n\nbut the output which I want \n\n[\n {\n \"order\":\"1588668201-56\",\n \"pagenation\":\"\",\n \"pagenation-href\":\"\",\n \"courseid\":\"Redeem Offer\",\n \"courseid-href\":\"https://www.valid.comxyz\"\n },\n {\n \"order\":\"1588668201-58\", \n \"pagenation\":\"\",\n \"pagenation-href\":\"\",\n \"courseid\":\"Redeem Offer\",\n \"courseid-href\":\"https://www.valid.com/xyz\"\n }\n]\n\n\nif inside the JSON object key courseid-href starts with https://www.invalid.com it should remove that complete object \n\nI have tried \nUPDATED\n\n test =[\n {\n \"order\":\"1588668201-56\",\n \"pagenation\":\"\",\n \"pagenation-href\":\"\",\n \"courseid\":\"Redeem Offer\",\n \"courseid-href\":\"https://www.valid.comxyz\"\n },\n {\n \"order\":\"1588668201-57\", \n \"pagenation\":\"\",\n \"pagenation-href\":\"\",\n \"courseid\":\"[Free] ClickHouse crash course. Conquer big data with ease\",\n \"courseid-href\":\"https://remove.com/xyz\"\n },\n {\n \"order\":\"1588668201-58\", \n \"pagenation\":\"\",\n \"pagenation-href\":\"\",\n \"courseid\":\"Redeem Offer\",\n \"courseid-href\":\"https://www.valid.com/xyz\"\n }\n ];\n\n const filtered = test.filter(d => d['courseid-href'].startsWith(\"https://remove.com/\"));\nconsole.log(filtered);\n\n\nbut gets the same JSON without removing \n\nplease help me to achieve it" ]
[ "javascript", "json" ]
[ "postorder using tail recursion", "i find this link, http://www.experts-exchange.com/Programming/Algorithms/Q_25205171.html, which suggests a way to do postorder tail recursion. however, it uses 2 stacks, is there a way to do this with only one stack. thanks!\n\nbelow is the java code pasted from the link above:\n\npublic static final <T> void postorder(Tree<T> root) {\n Stack<Tree<T>> stack = new Stack<Tree<T>>();\n Stack<Tree<T>> traversal = new Stack<Tree<T>>();\n stack.push(root);\n while (!stack.isEmpty()) {\n Tree<T> node = stack.pop();\n if (node.right != null) \n stack.push(node.right);\n }\n if (node.left != null) {\n stack.push(node.left);\n }\n traversal.push(node);\n }\n while (!traversal.isEmpty()) {\n System.out.println(traversal.pop().value.toString());\n }\n }" ]
[ "algorithm", "tail-recursion" ]
[ "Maven scm add to repository name of submodule", "I have a java application. It is built using maven, and it has parent and sub-modules.\n\nI need to push the commit release number to git when the app builds successfully.\n\nHere are my POMs:\n\nParent pom.xml\n\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n..\n <modules>\n...\n <module>server</module>\n...\n </modules>\n\n...\n <scm>\n <url>http://10.72.0.99:8081//service</url>\n <connection>scm:git:10.72.0.99:8081/projectname/service.git</connection>\n <developerConnection>scm:git:[email protected]:projectname/service.git</developerConnection>\n </scm>\n\n...\n</project>\n\n\nChild server/pom.xml\n\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n <parent>\n <artifactId>aka</artifactId>\n\n.....\n\n<name>SERVER</name>\n <artifactId>server</artifactId>\n <packaging>war</packaging>\n....\n\n<profiles>\n...\n <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-scm-plugin</artifactId>\n <version>1.8.1</version>\n <configuration>\n <message>${name.module.server}. ${commitMessage}</message>\n <workingDirectory>/</workingDirectory>\n </configuration>\n <executions>\n <execution>\n <phase>package</phase>\n <goals>\n <goal>checkin</goal>\n </goals>\n </execution>\n </executions>\n </plugin>\n...\n</profiles>\n\n\nMaven log\n\n[INFO] Executed tasks\n[INFO] \n[INFO] --- maven-scm-plugin:1.8.1:checkin (default) @ server ---\n[INFO] Executing: /bin/sh -c cd <dir> && git status --porcelain\n[INFO] Working directory: <dir> && git commit --verbose -F /tmp/maven-scm-1190574861.commit -a\n[INFO] Working directory: <dir>\n[INFO] Executing: /bin/sh -c cd <dir> && git symbolic-ref HEAD\n[INFO] Working directory: <dir>\n[INFO] Executing: /bin/sh -c cd <dir> && git push [email protected]:project/service.git/server master:master\n[INFO] Working directory: <dir>\n[ERROR] Provider message:\n[ERROR] The git-push command failed.\n[ERROR] Command output:\n[ERROR] warning: LF will be replaced by CRLF in server/src/main/resources/buildnumber.properties.\nThe file will have its original line endings in your working directory.\nwarning: LF will be replaced by CRLF in server/src/main/resources/buildnumber.properties.\nThe file will have its original line endings in your working directory.\nwarning: LF will be replaced by CRLF in server/src/main/resources/buildnumber.properties.\nThe file will have its original line endings in your working directory.\nGitLab: The project you were looking for could not be found.\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\n\nWhy maven-scm-plugin pushes into git push [email protected]:project/service.git/server master:master\n\nwhen right repository [email protected]:project/service.git\n\nHow to fix this feature?" ]
[ "java", "git", "maven", "maven-scm-plugin" ]
[ "Pandas: Find previous row of matching value", "I'm trying to create a column with values from one column, but based on matching another column with the previous value.\n\nHere is my current code:\n\nd = {'a':[1,2,3,1,2,3,2,1], 'b':[10,20,30,40,50,60,70,80]}\n\ndf = pd.DataFrame(d)\n\ndf['c'] = df['b'][df['a'] == df['a'].prev()]\n\n\nAnd my desired output:\n\n a b c\n0 1 10 NaN\n1 2 20 NaN\n2 3 30 NaN\n3 1 40 10\n4 2 50 20\n5 3 60 30\n6 2 70 50\n7 1 80 40\n\n\n...which I'm not getting because .prev() is not a real thing. Any thoughts?" ]
[ "python", "pandas" ]
[ "Titanium Alloy - How to run procedure after screen created", "I'm trying to update the current location on map view. I get the current location in controller:\n\nvar updateCurrentLocation = function updateCurrentLocation(e){\nTi.API.info(\"Update current location on map\");\n\n$.map.setLocation({\n latitude: e.coords.latitude,\n longitude: e.coords.longitude,\n latitudeDelta: 1,\n longitudeDelta: 1\n});\n}\n\n\nBut the problem is that at this time the code run, the map view has not been created yet, so it cannot update the current location.\nCan any one suggest some technique to solve this problem?\nThank you!" ]
[ "google-maps", "titanium-alloy" ]
[ "How is the final variable System.out changing its reference?", "import java.io.*;\n\nclass SetOutExample\n{\n public static void main(String...s)throws IOException\n {\n FileOutputStream fout=new FileOutputStream(\"abc123.txt\");\n PrintStream ps=new PrintStream(fout);\n System.out.println(\"hello\");\n System.setOut(ps);\n System.out.println(\"hi\");\n }\n}\n\n\nHere the output of hi is printed on a file abc123.txt. How does the PrintStream-type variable out which is final and has the reference to print on screen get modified and start pointing to file abc123.txt? How does setOut work." ]
[ "java" ]
[ "SQL: Getting day specific totals when totals are summed per week", "This is the first time I'm asking something on this site, so if this question was asked badly, I would appreciate the feedback.\n\nSo the problem is the following. \nIn my Table, let's call it \"Totals\", i have totals of sales. Every row has the complete total of that week, along with the individual totals of each day of the week. So those five totals add up to the weektotal. \nEvery row also has the week of the year in it (format: yyyyww).\n\nso it would look like this for example\n\nid|date |total|totalsu|totalmo|totaltu|totalwe|totalth|totalfr|totalsa\n-----------------------------------------------------------------------\n 1|201921| 50.0| 00.0 | 10.0 | 10.0 | 10.0 | 10.0 | 10.0 | 0.0 |\n 2|201922| 60.0| 00.0 | 15.0 | 10.0 | 15.0 | 10.0 | 10.0 | 0.0 |\n 3|201923| 70.0| 30.0 | 5.0 | 10.0 | 10.0 | 10.0 | 5.0 | 0.0 |\n 4|201924| 50.0| 00.0 | 10.0 | 10.0 | 10.0 | 10.0 | 10.0 | 0.0 |\n\n\nNow my question is, how would i get all of the totals from let's say wednesday in the week 201921 to tuesday in the week 201924 within one query? It would be great if I could get it within one query, but if it's absolutely impossible, two or three should be fine as well.\nThe expected output would be 180 if my math is correct." ]
[ "mysql", "sql" ]
[ "Freemarker insert String into Javascript code", "I would like to know how can I insert a string into a javascript code like in the example below:\n\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"Restaurant\",\n \"name\": \"Dave's Steak House\",\n \"address\": {\n \"@type\": \"PostalAddress\",\n \"streetAddress\": \"148 W 51st St\",\n \"addressLocality\": \"New York\",\n \"addressRegion\": \"NY\",\n \"postalCode\": \"10019\",\n \"addressCountry\": \"US\"\n }\n }\n </script>\n\n\nThe problem is that when I try to insert the String between js it appears interpreted as HTML code with %, &20 etc. I have tried with ?html, escape, no escape, ?string, ?js_string, etc.\n\nThat's the String: \n\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"Restaurant\",\n \"name\": \"Dave's Steak House\",\n \"address\": {\n \"@type\": \"PostalAddress\",\n \"streetAddress\": \"148 W 51st St\",\n \"addressLocality\": \"New York\",\n \"addressRegion\": \"NY\",\n \"postalCode\": \"10019\",\n \"addressCountry\": \"US\"\n }\n }\n\n\nAnd the code:\n\n${myString}" ]
[ "freemarker" ]
[ "How can I use a regular expression to grab a single word?", "For my work training they are training me in regular expressions, but the guy that is training me is very busy, and I don't want to bother him for help. I need to get just single words from the following sentence: \"Crazy Fredrick bought many very exquisite opal jewels.\"\nI am using the following format:\n\n\"Crazy Fredrick bought many very exquisite opal jewels.\".replace(//gi,\"\")\n\n\nFor getting crazy I used the following:\n\n\"Crazy Fredrick bought many very exquisite opal jewels.\".replace(/(\\s\\w+)+\\.$/gi,\"\")\n\n\nBut how do I query the rest of the words?" ]
[ "regex", "replace" ]
[ "Android app in unrooted phone and telephony API usage", "Is it possible using the telephony (or other) APIs on an unrooted Android phone, for an application to listen for the Telephony intents (ringing / Incoming-call), and if calling party matches a criteria (such as, from a black-list), disconnect the call, without requiring a confirmation by the user ?\n\nAlso, it is possible for an application on such (an unrooted) Android phone to initiate an outgoing call without user's intervention (s.a. at a particular time or when certain conditions are met) ?\n\nIn my research so far, I've found that I'd have to use a BroadcastReceiver with the right priority, to be able to \"trap\" the 'ringing event', and use ITelephony.aidl to reject the call. However, it wasn't clear if I can do the latter on an unrooted phone or not.\n\nFor the second requirement, it is not clear if app can make an going call -- again, on an unrooted Android phone." ]
[ "android", "telephonymanager" ]
[ "How do you Mark ASM code?", "I am trying to mark my ASM (generate by the compiler) to make a postpone analysis between my mark my analysis the corresponding .s file. The following MACRO works with GCC\n\n#define ASM_LABEL(label) asm (\"#\" label \"\\n\\t\")\n\n\nNevertheless with CLANG the label is removed.\n\nvoid kernel(double const * x, double * y){\n ASM_LABEL (START)\n y[0]+=x[1]+x[3]/x[4];\n y[1] = std::exp(x[0]);\n ASM_LABEL (STOP)\n}\n\n\nThe generated ASM (clang -O3 -S) gives:\n\n movq %rdi, -8(%rbp)\n movq %rsi, -16(%rbp)\n ## InlineAsm Start\n ## InlineAsm End <---- no START mark\n movq -8(%rbp), %rsi\n movsd 8(%rsi), %xmm0\n movq -8(%rbp), %rsi\n ..............\n\n\nThe label has been deleted. Do you have any suggestion ? Does exist an generic tips ? \n\nThank you" ]
[ "assembly", "clang" ]
[ "js and css not loading when hosting next application on GitHub pages", "Next.js builds all the static assets in _next folder but Github pages does not need to serve those files. I am 404 for static assets.\n\nExample repo: https://github.com/ajaymathur/ajaymathur.github.io\nMaster branch is hosted and dev branch is for development.\n\nAnd I guess github pages is not hosting paths starting with -. How can I get around this issue?" ]
[ "jekyll", "next.js", "github-pages" ]
[ "OpenMP in windows and Linux(CentOS)", "I have a pretty big piece of code written in C++ and integrated into MATLAB via mex functionality. It was originally written in a windows machine but now that I run it on the Linux machine, it gives wrong result.\n\nIs anyone aware of any difference between how Linux and Windows handles OS. It usually involves \n\n\n #omp pragma for\n\n\nI couldn't post the code here. I would really appreciate some insights into what might be wrong ." ]
[ "linux", "multithreading", "openmp", "mex" ]
[ "casting vs parameter passing", "I need to access x and y properties of object obj(of type some ClassA) in the event handling method subscribed to an event in object obj.\n\nOption1: Just make this event of type EventHandler, cast the sender.\n\n\nvoid handlingMethod(object sender, EventArgs e)\n{\n ClassA ca = sender as ClassA;\n Dosomething(ca.id, ca.x, ca.y);\n}\n\nRaiseEvent(this,null); //in ClassA\n\n\nOption2:\nMake a SpecialEventHandler1 so that casting can be avoided.\n\n\nvoid handlingMethod(SpecialEventArgs e)\n{\n Dosomething(e.id, e.x,e.y);\n}\n\nRaiseSpecialEvent1(new SpecialEventArgs(this.id, this.x,this.y));//in ClassA\n\n\nOption3:\nMake a SpecialEventHandler2 so that both casting and new SpecialEventArgs object creation can be avoided.\n\n\nvoid handlingMethod(ClassA sender)\n{\n Dosomething(sender.id, sender.x, sender.y);\n}\nRaiseSpecialEvent2(this); //in ClassA\n\n\nLets say this events are raised continuously @50/sec. Which one is more efficient? Does it depend on size of ClassA? I am assuming that Option3 is the best way in terms of performance. Please give your insights." ]
[ "c#", "events" ]
[ "Reading a base64 image string with VBA?", "QUESTION\n\nHow to read or convert a base64 image string with Microsoft Access vba?\n\nREQUIREMENTS\n\nA base64 image string is stored in a ms sqlserver database as below:\n\nBASE64\n\ndata:image/png;base64,iVBORw0KGgoAAAA...\n\n\nUsing vba I am attempting to read the string from the database using microsoft vba.\n\n\n\nI know vba is capable of reading a string from the database to output the image on screen as I currently achieve this result by reading the image as a hex sting as below:\n\nHEX \n\n89504E470D0A1A0A0000000D49484...\n\n\nSo how can vba read a base64 image string to display the image on screen within Microsoft Access?" ]
[ "sql-server", "vba", "ms-access", "base64" ]
[ "Why my selection sort is slower than insertion sort", "I'm trying to write the implementations for selection sort and insertion sort. And tested them with an auto generated array and evaluates the time consuming with Posix gettimeofday in u-second accuracy, under MAC OS.\n\nBut in most case, with an total 65525 and range from -65525 and +65525 input array, the insertion sort is far faster than selection sort, says about half of time.\n\nimplementation see below:\n\nvoid selectionSort (vector<int>& ns) {\nuint_t j, minInd; \nfor (uint_t i = 0; i< ns.size() - 1; i++) {\n j = i + 1; \n minInd = i;\n while (j < ns.size()) {\n if(ns[j] < ns[minInd])\n minInd = j; \n j++;\n }\n if (minInd != i) {\n int tmp = ns[minInd];\n ns[minInd] = ns[i];\n ns[i] = tmp;\n }\n }\n} \n\ninsertSort (vector<int>& ns){\n for(int i = 1; i < (int)ns.size(); i++) {\n int key = ns[i]; \n int j = i - 1;\n for( ; j >= 0; j--) {\n if (ns[j] > key ) {\n ns[j+1] = ns[j]; \n } else {\n break;\n }\n }\n ns[j+1] = key;\n }\n}\n\n\nSome Test results:\n\nInsert Sort:\n\n\n Min=(-65524), index=(89660); Max=(62235), index=(23486) \n ShowSysTime millisecond: 1447749079447950, diff time to last record:20092583\n Min=(-65524), index=(0); Max=(62235), index=(131050)\n\n\nSelection Sort:\n\n\n Min=(-65524), index=(89660); Max=(62235), index=(23486) \n ShowSysTime millisecond: 1447749114384115, diff time to last record:34934768\n Min=(-65524), index=(0); Max=(62235), index=(131050)\n\n\nThe insertion sort is from book ITA, so I suspect my selection sort has something not correct." ]
[ "algorithm", "sorting", "insertion-sort", "selection-sort" ]
[ "Angular Pass Interpolated Data within an *ngFor back to component", "I am currently iterating over collection of Documents that belong to a parent (Policy). I need to get a specific property from the element to send to my back end for processing.\n\nWhen I use the bound data in my HTML elements things work fine:\n\n <tbody>\n <tr *ngFor=\"let el of policy.documents\">\n\n <td>{{el.year}}</td>\n <td>\n <a href=\"{{ el.url }}\" target=\"_blank\">{{ el.docType }}</a>\n </td>\n </tr>\n </tbody>\n\n\nHowever when I try to pass one of the bound elements to a function (via button click) the data does not make it to my component.ts.\n\n<tbody>\n <tr *ngFor=\"let el of policy.documents\">\n\n <td>{{el.year}}</td>\n <td>\n <a href=\"{{ el.url }}\" target=\"_blank\">{{ el.docType }}</a>\n </td>\n <td>\n <button class=\"button btn btn-sm btn-primary\" style=\"min-width: 150px;\" \n (click)=\"getDocuments(el.url)\">View Document</button>\n </td>\n </tr>\n</tbody>\n\n\ncomponent.ts\n\ngetDocuments(url){\n this.policyService.getAuthorizedHeader(url).subscribe((res) => {\n this.authHeader = res.toString();\n window.open(this.authUrl, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes')\n }, error => {\n this.alertify.error(\"Problem with your search: \" + error.errors);\n });;\n }\n\n\nAny Ideas?" ]
[ "angular", "ngfor", "string-interpolation" ]
[ "Calculate number of list items for each list separate and append", "I'm trying something simple(?), to calculate the number of list items and append it to the list in the parent div. The problem is it is always taking the value of the last, as you can see the first list has 4 items and says 4/2 where this should be 4/4.. How to solve this?\n\nThanks\n\nDemo: http://jsfiddle.net/tZLG9/\n\nCode:\n\n$(\".list_slides_pagination li a\").each(function() {\n list_slides_count = $(\".list_slides\").find(\".list_slides_pagination\").length;\n $(this).append(\"/\" + list_slides_count);\n console.log(list_slides_count)\n});" ]
[ "javascript", "jquery", "tags" ]
[ "Prove running time of optimized mergesort is theta(NK + Nlog(N/K))?", "Okay, I know Mergesort has a worst case time of theta(NlogN) but its overhead is high and manifests near the bottom of the recursion tree where the merges are made. Someone proposed that we stop the recursion once the size reaches K and switch to insertion sort at that point. I need to prove that the running time of this modified recurrence relation is theta(NK + Nlog(N/k))? I am blanking as to how to approach this problem.." ]
[ "java", "performance", "mergesort", "recurrence" ]
[ "How to export ONLY selected records in django admin?", "I am using the https://github.com/bendavis78/django-admin-csv to export records to csv. But it will download all records even though I select only a few.\n\nfrom admin_csv import CSVMixin\n\nclass MyModelAdmin(CSVMixin, admin.ModelAdmin):\nlist_display = ['foo', 'bar', 'baz']\ncsv_fields = list_display + ['qux']\n\n\nHere is the admin.py file\n\nfrom functools import update_wrapper\n\nfrom django.contrib.admin.utils import label_for_field\n\n\nclass CSVMixin(object):\n \"\"\"\n Adds a CSV export action to an admin view.\n \"\"\"\n\n change_list_template = \"admin/change_list_csv.html\"\n\n # This is the maximum number of records that will be written.\n # Exporting massive numbers of records should be done asynchronously.\n csv_record_limit = None\n csv_fields = []\n csv_headers = {}\n\n def get_csv_fields(self, request):\n return self.csv_fields or self.list_display\n\n def get_urls(self):\n from django.conf.urls import url\n\n def wrap(view):\n def wrapper(*args, **kwargs):\n return self.admin_site.admin_view(view)(*args, **kwargs)\n return update_wrapper(wrapper, view)\n\n opts = self.model._meta\n urlname = '{0.app_label}_{0.model_name}_csvdownload'.format(opts)\n urlpatterns = [\n url('^csv/$', wrap(self.csv_export), name=urlname)\n ]\n return urlpatterns + super(CSVMixin, self).get_urls()\n\n def get_csv_filename(self, request):\n return unicode(self.model._meta.verbose_name_plural)\n\n def changelist_view(self, request, extra_context=None):\n context = {\n 'querystring': request.GET.urlencode()\n }\n context.update(extra_context or {})\n return super(CSVMixin, self).changelist_view(request, context)\n\n def csv_header_for_field(self, field_name):\n if self.headers.get(field_name):\n return self.headers[field_name]\n return label_for_field(field_name, self.model, self)\n\n def csv_export(self, request, *args, **kwargs):\n import csv\n from django.http import HttpResponse\n\n response = HttpResponse(content_type='text/csv')\n response['Content-Disposition'] = (\n 'attachment; filename={0}.csv'.format(\n self.get_csv_filename(request)))\n fields = list(self.get_csv_fields(request))\n writer = csv.DictWriter(response, fields)\n\n # Write header row.\n headers = dict((f, self.csv_header_for_field(f)) for f in fields)\n writer.writerow(headers)\n\n # Get the queryset using the changelist\n cl_response = self.changelist_view(request)\n cl = cl_response.context_data.get('cl')\n queryset = cl.get_queryset(request)\n\n # Write records.\n if self.csv_record_limit:\n queryset = queryset[:self.csv_record_limit]\n for r in queryset:\n data = {}\n for name in fields:\n if hasattr(r, name):\n data[name] = getattr(r, name)\n elif hasattr(self, name):\n data[name] = getattr(self, name)(r)\n else:\n raise ValueError('Unknown field: {}'.format(name))\n\n if callable(data[name]):\n data[name] = data[name]()\n writer.writerow(data)\n return response\n\n csv_export.short_description = \\\n 'Exported selected %(verbose_name_plural)s as CSV'\n\n\nHere is the change_list_csv.html.\n\n{% extends \"admin/change_list.html\" %}\n{% load admin_urls %}\n\n{% block object-tools-items %}\n {{ block.super }}\n <li>\n {% url cl.opts|admin_urlname:'csvdownload' as download_url %}\n <a href=\"{{ download_url }}{% if querystring %}?{{ querystring }}{% endif %}\" class=\"link\">Download CSV</a>\n </li>\n{% endblock %}\n\n\nThe file looks simple but can't figure out what to change to only export the selected rows." ]
[ "django", "csv", "export" ]
[ "Query about Linq to Sql ordering", "I am trying to figure out a better way of ordering the results of my sql query.\n\nSo far I have\n\nList<ArticlePost> articlePosts = new List<ArticlePost>();\n IQueryable<ArticlePost> query = from ArticlePost in ArticlePostTable select ArticlePost;\n foreach (ArticlePost ArticlePost in query)\n articlePosts.Add(ArticlePost);\n articlePosts = articlePosts.OrderByDescending(ArticlePost => ArticlePost.atclID).ToList();\n\n\nIs this a good way of sorting my list using linq or is there any way i can improve on it?" ]
[ "c#", "linq" ]
[ "How to prevent new user's registration on JHipster", "I want to create a closed community. So I wold have a lot of users but all of them will be invited by myself or somebody.\nMoreover I want them to have only one option to login - social accounts.\n\nI've implemented this functionality but for me it looks like set of hack:\n1) forbid /api/register endpoint to prevent self registration by the registration form\n2) Do not create new user if it is still has not been created (here SocialService#createUserIfNotExist)\n3) Modify some email templates\n\nMy questions now are:\n1) Is it is right way or you can suggest better solution?\n2) Do you think that it may be a good option for further JHipster generator?" ]
[ "jhipster" ]
[ "Using [DisallowNull] vs non-nullable reference type", "I am learning about the ins-and-outs of nullable reference types in C# 8.0\nWhilst reading this blog about nullable reference types, I was left a bit puzzled by the following example.\npublic static HandleMethods\n{\n public static void DisposeAndClear([DisallowNull] ref MyHandle? handle)\n {\n ...\n }\n}\n\nThe author shows how a [DisallowNull] attribute can be used in this case. However, my query is why would you need the attribute here at all? Is this code not the same?\npublic static HandleMethods\n{\n public static void DisposeAndClear(ref MyHandle handle)\n {\n ...\n }\n}\n\nBy removing the attribute, and the ? at the end of MyHandle, would this be a like-for-like alternative?\nEDIT:\nThanks to UnholySheep, I believe I understand this now.\npublic static void DisposeAndClear([DisallowNull] ref MyHandle? handle)\n{\n handle = null;\n}\n\nWhen calling this version of the function, handle cannot be null going in. However, it could be set to null inside the function, so when the function returns, anything using handle needs to check whether handle is null." ]
[ "c#", "nullable-reference-types" ]
[ ".Htaccess from ?p=activate&id=57A5dz into users/activate/id/57A5dz", "I would like to rewrite my urls from http://www.domain.com/index.php?p=activate&id=57A5dz into http://www.domain.com/users/activate/id/57A5dz.\nI searched a lot around google but nothing worked.\nI always see the 404 page..\n\nMy .htaccess:\n\n\nRewriteEngine On\n\nRewriteCond %{REQUEST_FILENAME} !-d\n\nRewriteCond %{REQUEST_FILENAME} !-f\n\nRewriteRule ^(.*)$ \\?p=$1 [QSA,L]\n\nRewriteRule ^(.*)/(.*)/$ ?page=$1&id=$2\n\nRewriteCond %{REQUEST_URI} ^/web-gallery/images/\n\nRewriteRule ^images/(.+)$ /web-gallery/images/$1\n\n\nAnd i also tried to add this:\n\nRewriteRule ^([^/]+)/(\\d+)/.*$ $1&id=$2 [L]\n\nThank you" ]
[ ".htaccess" ]
[ "Can I change change body element into another body element", "It's very hard to phrase it in the title. Can I change the whole body element of a page into another body element? I want move user into another page but then their socket.id changes, so I figured I could just change all the elements into the elements of the next page. \n\nCreating all elements from scratch and arranging them takes a lot of time. Is there a way to maybe save the whole body into a variable and then change the current body element for that one? Maybe I'd first save it somehow into a database and load it on the actual page after a button click?" ]
[ "javascript", "html", "dom", "socket.io" ]
[ "Distributing a local Flask app", "I've made a simple Flask app which is essentially a wrapper around sqlite3. It basically runs the dev server locally and you can access the interface from a web browser. At present, it functions exactly as it should.\n\nI need to run it on a computer operated by someone with less-than-advanced computing skills. I could install Python on the computer, and then run my .py file, but I am uncomfortable with the files involved being \"out in the open\". Is there a way I can put this app into an executable file? I've attempted to use both py2exe and cx_freeze, but both of those raised an ImportError on \"image\". I also tried zipping the file (__main__.py and all that) but was greeted with 500 errors attempting to run the file (I am assuming that the file couldn't access the templates for some reason.)\n\nHow can I deploy this Flask app as an executable?" ]
[ "python", "flask", "distribution" ]
[ "How to pass a httprouter.Handle to a Prometheus http.HandleFunc", "Cannot pass Prometheus midware into httprouter endpoint definitions.\n\nI'm trying to add a Prometheus midware into our endpoint implementation. But our endpoint are using a third party mux package called httprouter. Then when I tried to add this midware into existing code base, I cannot find a good way to integrate both together.\n\n\nrouter := httprouter.New()\nrouter.GET(\"/hello\", r.Hello)\n\nfunc (r configuration) Hello(w http.ResponseWriter, req *http.Request, ps httprouter.Params)\n\nfunc InstrumentHandlerFunc(name string, handler http.HandlerFunc) http.HandlerFunc {\n counter := prometheus.NewCounterVec(\n do something...\n )\n\n duration := prometheus.NewHistogramVec(\n do something...\n )\n return promhttp.InstrumentHandlerDuration(duration,\n promhttp.InstrumentHandlerCounter(counter, handler))\n}\n\n\n\nMy problem is I can not pass my prometheus handle to that httprouter endpoint function as parameter \n\nBelow is what I want to do:\n\n\nfunc InstrumentHandlerFunc(name string, handler httprouter.Handle) httprouter.Handel {\n\n}\n\nrouter.Get(\"/hello\", InstrumentHandlerFunc(\"/hello\", r.Hello))" ]
[ "go", "prometheus", "httprouter" ]
[ "Fatal error getId() on a non-object called in an array of objects", "I have a fatal error (call to getId() on a non-object) in this code :\n\n$users[] = $em->getRepository(Tutore::class)->findAll();\n\nforeach ($users as $user) {\n $colle = $em->getRepository(Colle::class)->find($id);\n $passages[] = $em->getRepository(PasserColle::class)->findBy(array('colle' => $colle->getId(),\n 'username' => $user->getId()));\n}\n\nforeach ($passages as $passage){\n $passages['note'] = $passage->getNote();\n}\n\n\nI dumped $users and it's an array of object. I don't understand why it's showing me this error.\nI have the same error with $passage->getNote()." ]
[ "arrays", "object", "foreach", "symfony", "fatal-error" ]
[ "jQuery UI Draggable constrain position under dynamically created parent div", "I have created an input that creates divs to use as menu items. These divs are draggable, constrained to the parent div, and movement limited by a 40px at a time.\n\nI need to ensure that when I drag a div, it can only be dragged to 40px past the div above it so the div above it acts as a parent div. For instance the first div it creates should not be draggable at all because it has no parent above it\n\nThe fiddle is here, http://jsfiddle.net/clintongreen/BMX4J/\n\nThanks" ]
[ "jquery", "jquery-ui", "jquery-ui-draggable" ]
[ "Fill parent div with image element", "I want to fill a parent div with a img, but instead of setting the image as a background property of the div, I want it to be a individual img element inside of the div.\n\nIn other words, I want to do this:\n\ndiv {\n background-image: url('someimg.jpg');\n background-size: cover;\n background-repeat: no-repeat;\n}\n\n\n..but with a img element, like this:\n\n<div>\n <!-- Image element should cover the container on dekstops and small screens as well -->\n <img src=\"someimg.jpg\">\n</div>\n\n\nI managed to do something like this on the img:\n\nimg {\n width: 100%;\n max-height: 100%;\n object-fit: fill;\n}\n\n\n..but on resize, it doesn't fill the parent. Here's a fiddle: https://jsfiddle.net/dy5ub0f5/5/" ]
[ "html", "css" ]
[ "Avoid Method invocation getLatitude may produce java.Lang.NullPointerException", "I have a method to show on the map the current position of the device. I am using FusedLocationProviderClient because it seems to be the most accurate.\n\nOn currentLocation.getLatitude() I get the warning: \n\n\n Method invocation may produce java.Lang.NullPointerException\n\n\nHow can I avoid this risk? And why it is related only to currentLocation.getLatitude() and not to currentLocation.getLongitude()?\n\nprivate void getDeviceLocation(){\n Log.d(TAG, \"getDeviceLocation: getting the devices current location\");\n\n FusedLocationProviderClient mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);\n\n try{\n if(mLocationPermissionsGranted){\n\n final Task location = mFusedLocationProviderClient.getLastLocation();\n\n location.addOnCompleteListener(task -> {\n if(task.isSuccessful()){\n Log.d(TAG, \"onComplete: found location!\");\n\n Location currentLocation = (Location) task.getResult();\n LatLng latLng = new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());\n\n mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, DEFAULT_ZOOM));\n\n }else{\n Log.d(TAG, \"onComplete: current location is null\");\n }\n });\n }\n }catch (SecurityException e){\n Log.e(TAG, \"getDeviceLocation: SecurityException: \" + e.getMessage() );\n }\n}" ]
[ "java", "android", "fusedlocationproviderclient" ]
[ "Numpy 2d array, obtain indexes of rows where specified column indexes equal 1", "I have a 2d numpy array like so, which will only ever have 0, 1 values.\n\na = np.array([[1, 0, 1, 0], # Indexes 0 and 2 == 1\n [0, 1, 1, 0], # Indexes 1 and 2 == 1\n [0, 1, 0, 1], # Indexes 1 and 3 == 1\n [0, 1, 1, 1]]) # Indexes 1, 2, and 3 == 1\n\n\nWhat I'd like to do is to get the indices of every row where a pair of column indexes passed are all equal to 1. \n\nFor example, if the function doing this is get_rows, get_rows(a, [1, 3]), should return [2, 3], because the rows at indexes 2 and 3 have column indexes 1 and 3 equal to 1. Similarly, get_rows(a, [1, 2]) should return [1, 3]. \n\nI know how to do this in a Pandas dataframe, but I'd like to stick to using pure numpy for this one. I tried using np.where in some form like \n\nnp.where( ((a[i1 - 1] == 1) & (a[i2 - 1] == 1) ))\n\n\nbut this doesn't seem to give me what I want, and wouldn't work for varying number of passed indices." ]
[ "python", "arrays", "numpy" ]
[ "How to boost a SOLR document when indexing with /solr/update", "To index my website, I have a Ruby script that in turn generates a shell script that uploads every file in my document root to Solr. The shell script has many lines that look like this:\n\n curl -s \\\n \"http://localhost:8983/solr/update/extract?literal.id=/about/core-team/&commit=false\" \\\n -F \"myfile=@/extra/www/docroot/about/core-team/index.html\"\n\n\n...and ends with:\n\ncurl -s http://localhost:8983/solr/update --data-binary \\\n'<commit/>' -H 'Content-type:text/xml; charset=utf-8'\n\n\nThis uploads all documents in my document root to Solr. I use tika and ExtractingRequestHandler to upload documents in various formats (primarily PDF and HTML) to Solr.\n\nIn the script that generates this shell script, I would like to boost certain documents based on whether their id field (a/k/a url) matches certain regular expressions. \n\nLet's say that these are the boosting rules (pseudocode):\n\nboost = 2 if url =~ /cool/\nboost = 3 if url =~ /verycool/\n# otherwise we do not specify a boost\n\n\nWhat's the simplest way to add that index-time boost to my http request?\n\nI tried:\n\ncurl -s \\\n \"http://localhost:8983/solr/update/extract?literal.id=/verycool/core-team/&commit=false\" \\\n -F \"myfile=@/extra/www/docroot/verycool/core-team/index.html\" \\\n -F boost=3\n\n\nand:\n\ncurl -s \\\n \"http://localhost:8983/solr/update/extract?literal.id=/verycool/core-team/&commit=false\" \\\n -F \"myfile=@/extra/www/docroot/verycool/core-team/index.html\" \\\n -F boost.id=3\n\n\nNeither made a difference in the ordering of search results. What I want is for the boosted results to come first in search results, regardless of what the user searched for (provided of course that the document contains their query). \n\nI understand that if I POST in XML format I can specify the boost value for either the entire document or a specific field. But If I do that, it isn't clear how to specify a file as the document contents. Actually, the tika page provides a partial example:\n\ncurl \"http://localhost:8983/solr/update/extract?literal.id=doc5&defaultField=text\" \\\n--data-binary @tutorial.html -H 'Content-type:text/html'\n\n\nBut again it isn't clear where/how to specify my boost. I tried:\n\ncurl \\ \n\"http://localhost:8983/solr/update/extract?literal.id=mydocid&defaultField=text&boost=3\"\\\n--data-binary @mydoc.html -H 'Content-type:text/html'\n\n\nand\n\ncurl \\ \n\"http://localhost:8983/solr/update/extract?literal.id=mydocid&defaultField=text&boost.id=3\"\\\n--data-binary @mydoc.html -H 'Content-type:text/html'\n\n\nNeither of which altered search results.\n\nIs there a way to update just the boost attribute of a document (not a specific field) without altering the document contents? If so, I could accomplish my goal in two steps:\n1) Upload/index document as I have been doing\n2) Specify boost for certain documents" ]
[ "solr", "apache-tika", "solr-cell" ]
[ "Using a class library assembly that internally uses a link to a global assembly info file", "I am struggling with the current scenario below. I'm using vs 2010 and C# with .NET 4:\n\n\nI have a separate solution (call it solution A) that has 2 class library projects in it (call them B and C).\nProject B has a link to a \"GlobalAssemblyInfo.cs\" file in Project C, BUT Project B does not depend on Project C, it merely just has a link to the .cs file in Project C.\nThis is all well and good as everything compiles and B.dll + C.dll is produced.\nNow I have a totally different solution (call it D) that has only 1 console application project in it (call it E).\nNow in Project E, I add a reference to B.dll. When I compile all is well.\n\n\nThe problem is when I debug Project E, when I get to a line of code that uses any object from Project B (or B.dll), I get an error that says \"FileNotFoundException unhandled exception. Could not load file or assembly B\", where B is the fully qualified name of assembly B.\n\nHow do I resolve this problem? I know the problem is caused by the linking to the \"GlobalAssemblyInfo.cs\" file in Project C because when I remove / delete this link everything works fine and I can use object in assembly B.\n\nHere is a url that explains how to link to files within a solution / project if you need to understand what linking is http://bloggingabout.net/blogs/jschreuder/archive/2006/11/02/Centralizing-AssemblyInfo-settings_2C00_-or-simplify-versioning-of-solutions.aspx" ]
[ "assemblyinfo" ]
[ "Spark org.apache.jena.shared.NoReaderForLangException: Reader not found: JSON-LD", "I am using Jena in Spark. I am facing a weird issue when I am deploying on the cluster (Does not happen on local Dev, for which i do not need to build an uber jar)\n\nWhen I deploy on the cluster i get the following exceptions: \n\nCaused by: org.apache.jena.shared.NoReaderForLangException: Reader not found: JSON-LD\n at org.apache.jena.rdf.model.impl.RDFReaderFImpl.getReader(RDFReaderFImpl.java:61)\nat org.apache.jena.rdf.model.impl.ModelCom.read(ModelCom.java:305)\n\n\n1 - I wonder, generally speaking where does an error like org.apache.jena.shared.NoReaderForLangException: Reader not found: JSON-LD may come/originate from ? Again this code works perfect in local mode.\n\n2 - My Build.sbt Assembly strategy: \n\nlazy val entellectextractorsmappers = project\n .settings(\n commonSettings,\n mainClass in assembly := Some(\"entellect.extractors.mappers.NormalizedDataMapper\"),\n assemblyMergeStrategy in assembly := {\n case \"application.conf\" => MergeStrategy.concat\n case \"reference.conf\" => MergeStrategy.concat\n case PathList(\"META-INF\", \"services\", \"org.apache.jena.system.JenaSubsystemLifecycle\") => MergeStrategy.concat\n case PathList(\"META-INF\", \"services\", \"org.apache.spark.sql.sources.DataSourceRegister\") => MergeStrategy.concat\n case PathList(\"META-INF\", xs @ _*) => MergeStrategy.discard\n case x => MergeStrategy.first},\n dependencyOverrides += \"com.fasterxml.jackson.core\" % \"jackson-core\" % \"2.9.5\",\n dependencyOverrides += \"com.fasterxml.jackson.core\" % \"jackson-databind\" % \"2.9.5\",\n dependencyOverrides += \"com.fasterxml.jackson.module\" % \"jackson-module-scala_2.11\" % \"2.9.5\",\n dependencyOverrides += \"org.apache.jena\" % \"apache-jena\" % \"3.8.0\",\n libraryDependencies ++= Seq(\n \"org.apache.jena\" % \"apache-jena\" % \"3.8.0\",\n \"edu.isi\" % \"karma-offline\" % \"0.0.1-SNAPSHOT\",\n \"org.apache.spark\" % \"spark-core_2.11\" % \"2.3.1\" % \"provided\",\n \"org.apache.spark\" % \"spark-sql_2.11\" % \"2.3.1\" % \"provided\",\n \"org.apache.spark\" %% \"spark-sql-kafka-0-10\" % \"2.3.1\"\n //\"com.datastax.cassandra\" % \"cassandra-driver-core\" % \"3.5.1\"\n ))\n .dependsOn(entellectextractorscommon)\n\n\nIf anyone has a hint about using Jena and Spark, awesome, else any hints about what could cause the Reader not found: JSON-LD, as in when can that happens, or what does it means from the library standpoint. This way I can trace back, what in my packaging is causing it to happen." ]
[ "apache-spark", "sbt", "jena", "spark-structured-streaming", "sbt-assembly" ]
[ "set the default value of the new column to a value of an existing column after altering table", "I have a table called "users".\n\nid name \n1 jack\n2 lisa\n\nI want to add a new column and set the default value of it to the value of the "id" column.\nALTER TABLE users ADD COLUMN user_index INTEGER NOT NULL DEFAULT id;\n\nsince, the DEFAULT keyword, only accepts constant values the above code doesn't work.so, how can I set the default value of the new column to the value of "id" column?" ]
[ "android", "sqlite", "android-studio", "android-sqlite", "alter-table" ]
[ "Make Espresso wait for WebView to finish loading", "Is there a reliable way to make Espresso wait for WebViews to finish loading?\n\nI've tried the approach outlined here but found it unreliable. It also has other drawbacks:\n\n\nIt relies on replacing the WebView's WebChromeClient. Any existing WebChromeClient can't be wrapped either, since WebViewrt doesn't have a getWebChromeClient() method for some reason.\nIt requires a specific WebView instance, so every time I start an Activity with a WebView I have to get the WebView instance and register a new WebviewIdlingResource for it.\n\n\nI'm hoping someone has a solution without any of these drawbacks. I had hopes that the espresso-web package might provide a solution, but it doesn't appear to offer anything relating to loading." ]
[ "android", "testing", "webview", "android-espresso" ]
[ "Retrieving PHP Cookie", "I am trying to use a cookie in stored using PHP to determine if a user is logged in.\n\nI am setting the cookie using the following:\n\nelse $keep_alive = time()+(86400 * 14);\nsetcookie(\"id\",mysql_result($result, 0, \"id\"),$keep_alive, \"/\", \"mydomain.com\");\n\n\nWhen I attempt to get the value of 'id' I am able to retrieve it using the following, so long as I do so before the headers are sent.\n\n$id = $_COOKIE['id'];\n\n\nHowever, if the page headers have already been sent the value of 'id' isn't retrieved. Is it not possible to get the value of a cookie after the headers are sent, or am I missing something?" ]
[ "php", "html" ]
[ "Write a C# program to append additional text to an existing file with contents", "I am new to C#. I did the following question given below with code and I got the following error described below\n\nquestion: Write a C# program to append additional text to an existing file with contents. You are given a file named \"sentences.txt\" with a few lines already stored in it.\nCreate a program to ask the user for several sentences (until they just press Enter) and append them in \"sentences.txt\". Enter the below contents:\n\"C# supports abstraction and encapsulation.\nC# supports inheritance and polymorphism.\"\nThe new content must be appended to its end. \nDisplay the entire contents of the text file on the screen.\n\nmy code : \n\nusing System;\nusing System.IO;\n\npublic class Program //DO NOT change the class name\n{\n //implement code here\n static void Main()\n {\n try\n {\n StreamWriter file = File.AppendText(\"sentences.txt\");\n string line;\n Console.Write(\"Enter a sentence: \");\n\n do\n { \n line = Console.ReadLine();\n if (line != \"\")\n file.WriteLine(line);\n }\n while (line != \"\");\n file.Close();\n }\n catch (Exception)\n {\n Console.WriteLine(\"Error!!!\");\n }\n }\n}\n\n\nthis code is not able to read the file elements and not taking the input from the user also . How should I rectify it." ]
[ "c#" ]