texts
sequence | tags
sequence |
---|---|
[
"Updating a value in app.config at runtime",
"I've got two projects under the same solution. I use one project to update the app.config file of the second project. I manage to read the values I need, by using the GetSection method and the ClientSettingsSection class, but I can't find how to update those values."
] | [
"c#",
"configuration"
] |
[
"Material design drawer under the status bar: how to achieve it using a DrawerLayout with two FrameLayouts as children?",
"I'm currently setting up the navigation drawer to follow the material design specs. I've already checked Chris Banes post (available in Material design checklist) and made all of the implementations listed there such as custom themes and so on, and this question as well, but none of them seem to meet the requirements of my app structure. \n\nAs you guessed from the title, my DrawerLayout has got two FrameLayouts as children: one for the content and another for the drawer (it is important to point out that I can't change this structure since I need to keep the ability to update the content in the NavigationDrawer dinamically and obviously to keep the ability to swap fragments as the main content).\n\nThe problem is now that I don't know where to put the toolbar declaration in xml in order to achieve the expected design and without messing all up, since the DrawerLayout requires two children.\n\nactivity_main.xml\n\n<android.support.v4.widget.DrawerLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\nxmlns:tools=\"http://schemas.android.com/tools\"\nandroid:id=\"@+id/drawer_layout\"\nandroid:layout_width=\"match_parent\"\nandroid:layout_height=\"match_parent\"\ntools:context=\"com.myapp.MainActivity\" \nandroid:fitsSystemWindows=\"false\"> <!-- Setting this one to true makes the status bar to have a non-transparent shitty background -->\n\n<!--\n As the main content view, the view below consumes the entire\n space available using match_parent in both dimensions.\n-->\n\n<FrameLayout\n android:id=\"@+id/container\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\" >\n\n <android.support.v7.widget.Toolbar\n xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n android:id=\"@+id/toolbar\"\n android:layout_height=\"wrap_content\"\n android:layout_width=\"match_parent\"\n android:minHeight=\"?attr/actionBarSize\"\n android:background=\"?attr/colorPrimary\" \n app:theme=\"@style/ThemeOverlay.AppCompat.ActionBar\" />\n\n </FrameLayout>\n\n<com.myapp.widget.ScrimInsetsFrameLayout\n android:id=\"@+id/navigation_drawer\"\n android:layout_width=\"@dimen/navdrawer_width\"\n android:layout_height=\"match_parent\"\n android:layout_gravity=\"start\"\n android:fitsSystemWindows=\"true\"/>\n</android.support.v4.widget.DrawerLayout>\n\n\nGives this result:\nAs you can see, the status bar seems to be completely absent (maybe it's correct?) since the content is drawn full screen. When the app starts I can see the toolbar is drawn (rendered without the staus bar padding, thus messing up with the system icons) and then suddenly gets overlayed by the map content. I'm currently running Android 4.4.4 but it's the same on the emulator with Android 5.0.\n\n\n\nIn another stackoverflow question it was suggested to put a root LinearLayout with the Toolbar and the DrawerLayout, but would result in strange results, such as correctly rendering the toolbar but with the status bar (with solid non-transparent background) under it. I've tried also to use a FrameLayout as root, with poor results.\n\nAny advice on how to handle this problem?"
] | [
"android",
"android-layout",
"android-fragments",
"navigation-drawer",
"material-design"
] |
[
"how to get a value out of a cell into a userform vba excel",
"I want to use a value of my active worksheet to put in a userform. This has to be dynamic because in my worksheet i have multiple values.\nThe userform open hisself if you click on a button using a macro.\n\nHere are the pictures of the values that i want to put automatically in my userfrom and also my userform.\n\nThanx\n\n\n\n[enter image description here][2]\nenter image description here"
] | [
"vba",
"excel"
] |
[
"Spring Boot: Renaming the Main class",
"I'm new to Spring and Spring Boot, but I'm using it as a template. \n\nThe Main.java file contains in part the following:\n\npackage com.example;\n\n@Controller\n@SpringBootApplication\npublic class Main {\n\n}\n\n\nUnfortunately I need to import another class that is called Main, and use it in this class. The other class is in a Jar and I don't really want to recompile it, so I was thinking the best way would be to rename this Main.\n\nHowever when I do that (renaming it to JavaGettingStarted), the Maven plugin for Spring Boot will fail: \n\n[ERROR] Failed to execute goal\norg.springframework.boot:spring-boot-maven-plugin:2.0.0.RELEASE:repackage\n(default) on project java-getting-started: Execution default of goal\norg.springframework.boot:spring-boot-maven-plugin:2.0.0.RELEASE:repackage\nfailed: Unable to find a single main class from the following\ncandidates [com.example.JavaGettingStarted, com.example.Main] -> [Help\n1]\n\n\nIs Main some sort of default? Can I change it?"
] | [
"java",
"spring",
"maven",
"spring-boot"
] |
[
"Windows 7 x64 issue with PyVisa after making exe-file",
"I create a little GUI interface to work with Keysight stuff. \n\nI use Python 3.6.4, PyVisa 1.8 (both x64), setuptools 19.2\n\nWhen i create exe-file by PyInstaller it's all builded whithout any errors. \n\nAnd when a run application it's all good.\n\nBut when i run it into another machine (win7x64, without python, pyvisa, etc... stuff) it's doesn't work by OSError: Could not open VISA library\n\n\n\n\n\nHow can i packed up my application and pyvisa stuff into one piece?\n\n\"\"\" Main body \"\"\"\nimport sys, time, visa, interface\nfrom PyQt5 import QtCore, QtWidgets, QtGui\n\nRM = visa.ResourceManager(\"C:/Windows/System32/visa32.dll\")\n#RM = visa.ResourceManager()\nKEYSIGHT = RM.open_resource('TCPIP0::10.11.0.200::inst0::INSTR')\n..."
] | [
"python-3.x",
"pyqt5",
"pyinstaller",
"pyvisa"
] |
[
"Is it possible to create a file with binary data without writing to file?",
"I tried binding binary data to an array in a post request, but it doesn't work.\n$ch = curl_init(); \ncurl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); \n\n$data = curl_exec($ch); \n\ncurl_close($ch); \n\nThe API endpoints expect me to upload a file.\nIs there a way to do the following with the binary data instead?\nif (function_exists('curl_file_create')) { // php 5.5+\n $cFile = curl_file_create($file_name_with_full_path);\n} else { // \n $cFile = '@' . realpath($file_name_with_full_path);\n}\n$post = array('extra_info' => '123456','file_contents'=> $cFile);\n$ch = curl_init();\ncurl_setopt($ch, CURLOPT_URL,$target_url);\ncurl_setopt($ch, CURLOPT_POST,1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $post);\n$result=curl_exec ($ch);\ncurl_close ($ch);\n\nI don't want to upload the file to my directory before uploading it. I was trying to find a way to create a file in-memory and then put it inside of $post before doing a post to an API endpoint, but it seems that there's no way to do that, or is there?"
] | [
"php",
"curl"
] |
[
"Checking string to categorize items in Python",
"I'm new to Python and I'm trying to categorize string variable based on the value from other variable.\n\nFor example:\n\nline ='Centrino Advanced-N 6205 [Taylor Peak]'\nkey = 'Centrino Advanced'\nkey2 ='Centrino'\n\n\nwhen I execute \n\nprint(all(word in line.lower() for word in key.lower().split()))\nprint(all(word in line.lower() for word in key2.lower().split()))\n\n\nthey both return true, of course, but I want it to just match the key instead both key and key2\n\nI want it to be outputted like below, which consider key2 is not valid.\nWhat would be the best approach to perform such task?\n\nline ='Centrino Advanced-N 6205 [Taylor Peak]'\nkey = 'Centrino Advanced' # True\nkey2 ='Centrino' # False\n\n\nThank you all in advanced."
] | [
"python"
] |
[
"Python decode jwt token USING JOSE module",
"Please help me to decode this jwt USING python jose module.\nI don't know what key I should use. because any online jwt decoder can decode it without any key.\ntoken = eyJhbGciOiJSUzI1NiIsImtpZCI6ImVlYTFiMWY0MjgwN2E4Y2MxMzZhMDNhM2MxNmQyOWRiODI5NmRhZjAiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiIxNjcwMzExMDQ1NjYtYmZpMmgyODdzMWYxdTFzaWFicGI1ZWo4OHExa25nMnMuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiIxNjcwMzExMDQ1NjYtYmZpMmgyODdzMWYxdTFzaWFicGI1ZWo4OHExa25nMnMuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMDEyODA4NDEwNzU2MjUwMzQwMjAiLCJlbWFpbCI6ImRzYjMyMW1wQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJhdF9oYXNoIjoiWmpVY1Eyd3JkLUdzY3F2Y2dqci1BQSIsIm5vbmNlIjoiUFp2SGhsX2tUTGR1Sktmem80LW9qdyIsImlhdCI6MTYxMTY5MjA2NywiZXhwIjoxNjExNjk1NjY3fQ.kNFbqjtJO2HKsSX-jt967MLi2xjeRH4W9JsA4yPQDQEgrHqa3BX6PVFJCBjq-Fn7vmlTT1lUcElVPwtvcBUV8Z4I7dCuWKcTxTt6R8501f1I2X0tQeEu_zfg-ianzOlQkg3KvLT_D-oaIfNkoU7jAt4Mywe6xHiDKszlA6KE8T6PLV_VeiCJGvciLbPW7DhKiuL-kfTjhHoZ6_XHeruR6rb_psZNvH5t-D3Yjc27EwH0_Wumcl1GjN20eF2xO-UDhO4BMRHGIM5876QUYB58dxblLG1flEaeXi9z4R-XnrLPYpAYZDYQDcPMni9fUm9d8pNZDeTGh6WyGkTqkXuHvg\n\nI tryied:\njwt.decode(token=token, key=???, algorithms='RS256')"
] | [
"python",
"python-jose"
] |
[
"How to pick(choose) multiple images using camera API at the same time in phonegap?",
"How to choose or pick multiple images at the same time in phonegap camera API when using Camera.DestinationType.FILE_URI. I am able to pick only one images at a time. I am able to pick multiple files(including txt,pdf..) in sdcard using this. So i want same like for images. \n\nnavigator.camera.getPicture(function(imageData) {\nwindow.resolveLocalFileSystemURI(imageData, function(fileEntry) {\n fileEntry.file(function(fileObj) {\n }, onFail, {\n quality : 50,\n destinationType : Camera.DestinationType.FILE_URI\n});\n\n\nMy cordova version 3.3, Jquery Mobile 1.3.2.\n\nPlease suggest any plugins are available to do this."
] | [
"javascript",
"android",
"jquery-mobile",
"cordova"
] |
[
"Unity 2019.2.0f1. Game doesn't restart after back button pressed during splash screen display in android?",
"Game doesn't work after back button pressed during splash screen or loading in android. I am using unity v 2019.2.0f1 personal. I made my project in v 2019.1.12f1 and then i upgraded rebuild it in v 2019.2.0f1. I know about that issue \"unity not re-initializing after quitting in android\", i some how fixed that but that solution works only if when game has fully loaded the scene (after splash screen).\n\nI came to know about this when i accidentally pressed back button while game was showing splash screen then i went to the resent app or stack and tried to launch it but it was the same black screen of death. Please help."
] | [
"android",
"unity3d",
"initialization",
"splash-screen"
] |
[
"Vertical tabbed content with position sticky",
"I am not sure why position sticky is not working here:\n\nJsFiddle\n\n#tabs ul {\n position: sticky;\n}\n\n\nSince it's too much content to be scrolled, I need help in making the menu sticky, but just when you are in vertical tabs, then I don't need it to be sticky anymore."
] | [
"jquery",
"css",
"jquery-ui"
] |
[
"\"backup and restore operations for static class attributes\" in PHP",
"I saw this phrase in the PHPUnit Documentation:\n\n\n The implementation of the backup and\n restore operations for static\n attributes of classes requires PHP 5.3\n (or greater). The implementation of\n the backup and restore operations for\n global variables and static attributes\n of classes uses serialize() and\n unserialize()\n\n\nWhat is the idea behind this? I mean, I haven't used serialize and unserialize for this purpose. How exactly are these so-called \"backup and restore\" operations related to static attributes?"
] | [
"php",
"oop",
"phpunit"
] |
[
"Object variable not set (Error 91)",
"I have a problem ADODB.RECORDSET, i have MSFlexGrid called flgFact what is filled with data and i want to add that data related on a recordset called rsDetal but when i compile the code it drop me (error 91 : Object variable or With block variable rate is not) in the if\n\nPrivate Sub cmdeport_Click()\n Dim rsDetal As ADODB.Recordset\n Set rsDetal = flgFact.DataSource\n If Not (rsDetal.EOF And rsDetal.BOF) Then\n rsDetal.MoveFirst\n Do While Not rsDetal.EOF\n Numdocu = rsDetal(4)\n Fec_Emision = rsDetal(5)\n Totl = rsDetal(16)\n Igve = rsDetal(17)\n Totv = rsDetal(18)\n Mont_Pade = rsDetal(14)\n Mont_Paco = rsDetal(15)\n Call TEMPTRAMA(Numdocu, Fec_Em, Totl, Igve, Totv, Mont_Pade, Mont_Paco)\n rsDetal.MoveNext\n Loop\n End If\nEnd Sub\n\n\ni checked my value rsDetal and the value taken from the MSFlexGrid is Nothing"
] | [
"vb6",
"adodb",
"msflexgrid"
] |
[
"How do Maven Plugins like the Jetty-Maven-Plugin manage to keep their goals running until manually stopped?",
"I'm currently developing a Maven Plugin and wonder how some Plugins like the Jetty-Maven-Plugin manage to execute goals which require the user to stop them?\n\nE.g. running\n\n$ mvn jetty:run\n\n\nstarts an embedded Jetty but doesn't go through all of Maven's lifecycle and then stops.\n\nI've tried creating a Thread to keep the goal running but this doesn't seem to be enough."
] | [
"maven-3",
"maven-plugin"
] |
[
"make bash abort when proces does not abort and vice versa",
"I'm trying to make by bash script do a \"not\" on an abort so that when a called script returns ok it aborts, and vice versa when it does not abort. \n\nI'm trying this like\n\n#!/bin/bash\nset -e\nmy_process || echo \"Program failed as expected. Good!\" \nmy_process ; echo \"Program did not fail as expected. Bad!\" ; exit -1\n\n\nbut i don't see how to combine the two."
] | [
"bash"
] |
[
"Getting the position of an (real) object",
"The story: Lets say I have a robot with a distance (ultrasound?) sensor. The robot can calculate the distance from any object in front of it but it cannot know the coordinates of the object. So the robot moves a little bit to get a diffrent view angle and calculates the distance from that view knowing how far it is from the first view.\n\nHow do I get the coordinates or some kind of position of a real life object in Python 3.4 with the following input.\n\nDistance from object at view A.\nDistance from object at view B.\nDistance between view A and B.\n\nA and B are always on the same X coordinate.\n\nInput example:\n\na = 3.5 #Distance from object at point A (in cm)\n\nb = 7 # Disatance from object at point B (in cm)\n\nc = 5 # Distance between A and B (in cm)\n\n\nThe output should be some coordinates or something that I can use to find out the position of an object.\n\nHow would I calculate where the object is? I know there is some kind of an algorithm but I don't know what it's called or how it works.\n\nI guess this is more a math question than a programming question but I want to implement this programmatically.\n\nAnyways the input doesn't need to be exactly this. I guess you would also need an angle or something similar so if extre input is needed just use it in the anwser.\n\nThanks!\n\n(I am on Win 10, 64bit, Python 3.4)\n\nIf you know how to do this or some algorithm name but you don't know Python, please point it out or give an example of how to do it with math, and I will try to implement it in Python."
] | [
"python",
"math",
"python-3.4"
] |
[
"How to avoid using shell=True in the python subprocess module when faced with memory constraints",
"As part of a larger python script I am writing that is associated with genome sequence alignment, I would like to be able to record the number of lines in a gzipped file provided by the user. As far as I can tell, the following bash command is the simplest way to accomplish such a task:\nzcat file/path.gz | wc -l\n\nUsing the python subprocess module, (and avoiding shell=True) I use the following code in Python to accomplish the same task:\nzcatInput = subprocess.check_output(("zcat", filePathFromUser), encoding = "utf-8")\nresult = subprocess.check_output(("wc", "-l"), encoding = "utf-8", input = zcatInput)\n\nHowever, some of the files I am trying to do this with are hundreds of millions of lines long once unzipped, so storing the result of the zcat command uses a ridiculous amount of memory (more than my computer has available).\nMy question is this: What is the best way to circumvent this problem without using shell=True? (From what I've read online, shell=True appears to be very dangerous and should be avoided at all costs).\nAdditionally: Is this a scenario where the use of shell=True with properly sanitized inputs is acceptable, or do the dangers of shell=true go even further than I am aware of?\nIn my efforts to answer these questions, I've come up with two possible solutions:\n\nCreate a simple bash script to perform the zcat operation on a given file and pipe it to wc -l. Then, call that script using the subprocess module (and shell=False, hooray!)\nUse the shell=True argument with the subprocess module to just run the bash command with '|', but sanitize the user input using shlex.quote().\n\nI suppose you could also boil down my question to something more concrete by asking: What is the difference (if any) between the two above approaches in terms of security and memory constraints, and is there a preferable "option 3" that I am missing?"
] | [
"python",
"shell",
"ubuntu",
"subprocess",
"out-of-memory"
] |
[
"StandardOutput.ReadLine() hang the application using c#",
"Following is the application code. some time p.StandardOutput.ReadLine(); works fine but some time it hang up i tried all things but still getting this error\n\n ProcessStartInfo startInfo = new ProcessStartInfo(\"c:\\\\windows\\\\system32\\\\test.exe\");\n String s = \" \";\n\n startInfo.WindowStyle = ProcessWindowStyle.Hidden;\n startInfo.CreateNoWindow = true;\n startInfo.RedirectStandardInput = true;\n startInfo.RedirectStandardOutput = true;\n startInfo.UseShellExecute = false;\n Process p = Process.Start(startInfo);\n p.StandardInput.WriteLine(\"list volume\\n\");\n String f = \"\";\n bool ignoredHeader = false;\n\n s = p.StandardOutput.ReadLine();\n p.WaitForExit();\n\n\nPlease help me"
] | [
"c#",
"asp.net"
] |
[
"javascript counter not adding 1 but adding 2 without intending to",
"I am trying to create counter that increase by one each time as follow:\n\nvar imnum=0;\n(function changeImage(){\n ++imnum;\n $( \".slider\" ).fadeOut( 5000, function() {\n // Animation complete.\n $('#home-slider-im').attr(\"src\",images[imnum]);\n $('#home-slider-t').attr(\"src\", imagesText[imnum]);\n\n $( \".slider\" ).fadeIn( 2000, function() {\n // Animation complete\n });\n\n console.log(imnum);\n setTimeout(changeImage,10000)\n\n})})();\n\n\nbut the console log output is 1 3 7 15... not 1 2 3 4... am I doing something wrong? what is it? how to fix it?"
] | [
"javascript",
"jquery"
] |
[
"FOSElastica + JMs serializer malformed data",
"I installed ElasticSearch 6 with their Docker image and everything work well.\n\nThen I installed and configured FOSElastica like the doc said.\n\nThis is the following config of fos_elastica\n\nfos_elastica:\n clients:\n default: { host: '%env(ELASTICSEARCH_HOST)%', port: '%env(ELASTICSEARCH_PORT)%' }\n serializer:\n serializer: jms_serializer\n indexes:\n app:\n client: default\n types:\n user:\n serializer:\n groups: [elastica]\n persistence:\n driver: orm\n model: AppBundle\\Entity\\User\n provider: ~\n listener: ~\n finder: ~\n\n\nAnd the model of my User entity to give the elastica serializer group to some field\n\nAppBundle\\Entity\\User:\n exclusion_policy: ALL\n properties:\n firstname:\n expose: true\n groups: [elastica, list, details]\n lastname:\n expose: true\n groups: [elastica, list, details]\n locale:\n expose: true\n groups: [elastica, details]\n\n\nThe serializer is working well for my API and is well configurated\n\n jms_serializer:\n metadata:\n auto_detection: true\n directories:\n AppBundle:\n namespace_prefix: 'AppBundle'\n path: '%kernel.project_dir%/config/serializer'\n\n\nWhen I'm trying to populate ElasticSearch I get, I think a bad serialization error\n\nIn Http.php line 181:\n\n[Elastica\\Exception\\ResponseException] \nMalformed action/metadata line [3], expected START_OBJECT but found [VALUE_STRING]\n\n\nI tried to set field typing using properties.type config in the fos_elastica configuration without success.\n\nI tried with another entity and I get the same error.\n\nI have already work with FOSElasticaBundle ~1year ago on the same project and population was working... \n\nI didn't success to find where is the problem, if there is a JMSSerializer/FOSElastica bug or a misconfig\n\nDid I miss something in the configuration ? Do you already had this issue ?"
] | [
"php",
"symfony",
"elasticsearch",
"serialization"
] |
[
"Inject NServiceBus with Ninject in WebApi App",
"I´m trying to send a message to the queue from my WebApi application.\nThe first time the server starts everything goes fine and I can send a message to the queue from my controller, but the next time the action is called it throws the folloowing exception:\n\nCannot access a disposed object.\nObject name: 'UnicastBus'.\n\n\nThis is how I´m binding the IBus interface\n\npublic static class NinjectWebCommon\n{\n ...\n private static void RegisterServices(IKernel kernel)\n {\n kernel.Bind<IBus>().ToConstant(CreateBus()).InSingletonScope();\n }\n\n private static IBus CreateBus()\n {\n Configure.Serialization.Xml();\n return Configure.With()\n .DefaultBuilder()\n .UseTransport<Msmq>()\n .UnicastBus()\n .SendOnly();\n }\n}\n\n\nAnd in my controller\n\npublic class CreatedOrderMessageController : ApiController\n{\n private readonly IBus bus;\n\n public CreatedOrderMessageController(IBus bus)\n {\n this.bus = bus;\n }\n\n public string Get(int id)\n {\n bus.Send(new OrderCreatedMessage(id));\n return \"true\";\n }\n}\n\n\nAny thoughts on this error?\n\nThanks"
] | [
"c#",
"ninject",
"nservicebus",
"asp.net-web-api"
] |
[
"Change encoding window console from python",
"I have some trouble with encoding. I have a program that runs a command in windows console and get the results. In this case it returns some lines from a text file which have accent(tilde in spanish). These accents are not properply encoded.\n\nimport os\np= os.popen(' chcp 65001 && findstr /s /i /r /c:\"EVNT\" '+path+'\"\\\\*-LOG')\ntmp = p.read()\n\n\nI have tried the same command directly in console so it's work fine. I can get the words with accent.\n\nchcp 65001 && findstr /s /i /r /c:\"EVNT\" *-LOG"
] | [
"python",
"encoding",
"console"
] |
[
"Variable thickness in Seekbar",
"I want the seekbar thickness variable. Progressed part of the seekbar should be more thick than the rest of the part. Here is what i want: \n\nCan you give me any suggession? Sorry for the image quality :P"
] | [
"android",
"android-layout",
"android-seekbar"
] |
[
"Hook javascript to dropdownlist change",
"¡Hola! \n\nMy current task is to have a page where, with a dropdownlist, a user can select a deck title. Once a title is selected, the page should postback with details on that deck.\n\nHere's what I've got at the moment: \n\n@model IEnumerable<SCATChartsMVC.Models.Charts_DeckList>\n\n@{\n ViewBag.Title = \"Index\";\n\n if (IsPost) { ViewBag.Title = \"We posted back!\"; }\n}\n\n<h2>Index</h2>\n\n@{ var list = ViewData.Model.Select(cl => new SelectListItem\n {\n Value = cl.RecNum.ToString(),\n Text = cl.DeckTitle.ToString()\n });\n}\n\n\n@using (Html.BeginForm(\"Details\", \"Charts_DeckList\", FormMethod.Post)) \n{ \n @Html.DropDownList(\"deckTitles\", list, \"---------select---------\")\n\n <input type=\"submit\" name=\"submit\" value=\"Submit\" />\n @Html.ActionLink(\"Details\", \"Details\", \"Charts_DeckList\", new { id = list.ElementAt(4).Text }, \"\")\n\n}\n\n<script src=\"~/Scripts/jquery-1.10.2.js\"></script>\n<script>\n $(\"deckTitles\").change(function () {\n if ($(\"#deckTitles\").val() != \"\") {\n var test = {};\n test.url = \"/Charts_DeckList/Details\";\n test.type = \"POST\";\n test.data = JSON.stringify($('#deckTitles').val());\n test.datatype = \"json\";\n test.contentType = \"application/json\";\n test.success = true;\n test.error = function () { alert(\"Error!\"); };\n $.ajax(test);\n }\n })\n</script>\n\n\nThe input tag and ActionLink under Html.BeginForm were for my own testing purposes; the ActionLink works correctly if I specify the element. I'm hoping to be able to pass something similar back whenever a user clicks a selection, as opposed to whenever they hit the \"details\" button.\n\nThe submit input tag does not work. It does route properly to Charts_DeckList/Details, but the parameter in the action is always null.\n\nI'm just getting into the whole MVC/Web rigamarole, so there's a lot I don't know that I'm not even aware I don't know. While I've seen a number of different resources on the internet suggesting different things, much of the web development jargon is lost on me at this point in time, and much of the way these things work under the hood is lost on me since VS seems to put together so much of it automagically. \n\nAny pointers would be appreciated. Thank you.\n\n\n\nbarrick's suggestion below is correct!\n\nI also had to move the script tags up into the BeginForm brackets, heads up."
] | [
"c#",
"javascript",
"html",
"razor",
"asp.net-mvc-5"
] |
[
"hapi : include a js custom library",
"In my index.js file I would like to load an external js library where I store functions. In the long run I would make it a module, but right now I need to get things prototyped. It's not part of node so I can't put it into node_modules. What's the command? \n\nI have index.js and I have functions.js in the same folder."
] | [
"javascript",
"node.js",
"hapijs"
] |
[
"What to have in mind when building a AJAX-based webapp",
"We're in the first steps of what will be a AJAX-based webapp where information and generated HTML will be sent backwards and forwards with the help of JSON/POST techniques.\n\nWe're able to get the data out quickly without putting to much load on the database with the help of a cache-layer that features memcached as well as disc-based cache. Besides that - what's essential to have in mind when designing AJAX heavy webapps?\n\nThanks a lot,"
] | [
"php",
"ajax",
"performance",
"json"
] |
[
"Android-NDK how to compile this code? | Beginner",
"A developer has published its code in GitHub for anyone who wants to create their server for SAMP Android (a project in development that allows them to play Android GTA online).\n\nCode Link: https://github.com/4x11/SAMP-Android\n\nI want to know which program to use and the right commands to compile this code. As far as I know, this is an NDK build code .."
] | [
"android-ndk",
"android.mk"
] |
[
"How do you loop through past items in a search in a Zotonic template?",
"I would like to able to loop through past events in a template:\n\n{% for page in m.search[{past cat='event'}] %}\n {% if forloop.first %}<ul>{% endif %}\n <h2>{{ m.rsc[page].date_start|date:\"M j, Y\" }} {{ m.rsc[page].title }}</h2>\n <p>{{ m.rsc[page].body|show_media }}</p>\n <p><a href=\"{{ m.rsc[page].website }}\">Register to attend this event.</a></p>\n {% if forloop.last %}</ul>{% endif %}\n{% endfor %}\n\n\nBasically I am looking for a past search type that acts as the opposite of the upcoming search type.\n\nI already can get upcoming events as follows:\n\n{% for page in m.search[{upcoming cat='event'}] %}\n {% if forloop.first %}<ul>{% endif %}\n <h2>{{ m.rsc[page].date_start|date:\"M j, Y\" }} {{ m.rsc[page].title }}</h2>\n <p>{{ m.rsc[page].body|show_media }}</p>\n <p><a href=\"{{ m.rsc[page].website }}\">Register to attend this event.</a></p>\n {% if forloop.last %}</ul>{% endif %}\n{% endfor %}\n\n\nI have no qualms coding this if I am pointed in the right direction and I will contribute the result back to the master code base.\n\nHow do you loop through past items in a search in a Zotonic template?"
] | [
"templates",
"search",
"zotonic"
] |
[
"PHP exec commands running unintentionally as root",
"I am very confused and concerned about the user ownership of commands run via the PHP \"exec\" statement. I am running PHP 5.5/Apache 2.2/CENTOS 6 in a cPanel/WHM environment with the DSO/mod_ruid handler.\n\nIn a test, I have the following php script:\n\n<?php\n echo 'whoami: ',exec('whoami'),'<br />';\n echo 'user: ',exec('echo ${USER}'),'<br />';\n echo 'home: ',exec('echo ${HOME}'),'<br />';\n?>\n\n\nWhen I run the script through my browser, I see these results:\n\nwhoami: cuser\nuser: root\nhome: /root\n\n\nwhere cuser is my system's cPanel ID and the user ID in the suPHP, mod_ruid, and mpm-itk directives in my domain's virtual host httpd.conf configuration.\n\nFurthermore, my httpd.conf file assigns \"nobody\" as the User and Group and, indeed, my httpd processes (as returned from the \"ps -ef | grep httpd\") are owned by \"nobody\".\n\nMy question is why the exec commands return different results for the \"whoami\" and \"echo ${USER}\" commands and whether there is a security risk because of an error in my Apache configuration. Optimally, I'd like my exec commands to run as the cuser user. Can I make that happen?\n\nThank you very much for any information you can provide."
] | [
"php",
"linux",
"apache"
] |
[
"Parsing ASMX response with PHP and SimpleXML",
"I'm querying an ASMX service for a value. The service returns the following XML object:\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <soap:Body>\n <PerformSupportRequestResponse xmlns=\"http://www.example.com/API\">\n <PerformSupportRequestResult>\n <Table>\n <xs:schema id=\"NewDataSet\" xmlns=\"\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n <xs:element name=\"NewDataSet\" msdata:IsDataSet=\"true\" msdata:MainDataTable=\"Results\" msdata:UseCurrentLocale=\"true\">\n <xs:complexType>\n <xs:choice minOccurs=\"0\" maxOccurs=\"unbounded\">\n <xs:element name=\"Results\">\n <xs:complexType>\n <xs:sequence>\n <xs:element name=\"TotalUsers\" type=\"xs:long\" minOccurs=\"0\" />\n </xs:sequence>\n </xs:complexType>\n </xs:element>\n </xs:choice>\n </xs:complexType>\n </xs:element>\n </xs:schema>\n <diffgr:diffgram xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\" xmlns:diffgr=\"urn:schemas-microsoft-com:xml-diffgram-v1\">\n <DocumentElement xmlns=\"\">\n <Results diffgr:id=\"Results1\" msdata:rowOrder=\"0\">\n <TotalUsers>2494</TotalUsers>\n </Results>\n </DocumentElement>\n </diffgr:diffgram>\n </Table>\n </PerformSupportRequestResult>\n </PerformSupportRequestResponse>\n </soap:Body>\n</soap:Envelope>\n\n\nI've tried working with this using SimpleXML and even flirted with DOMDocument. I have to believe that there is an easy way to load the values that will be returned between <Results> and </Results> into an array, but so far the only reliable method has been to remove any line that contains a namespace or doesn't contain a result I want. I don't think this is practical because I have to make several calls to this service with differing queries, and the responses aren't always going to be the same, but they will always be in the Results node of the response.\n\nI've also tried to breadcrumb my way to the answers, using something like:\n\n$media = $xml->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->PerformSupportRequestResponse->PerformSupportRequestResult->Table->children('urn:schemas-microsoft-com:xml-diffgram-v1')->diffgr->DocumentElement->Results\n\n\nand have come up empty-handed. Is there an easy way to retrieve the members of the Results node without resorting to re-writing the entire XML object?"
] | [
"php",
"xml",
"web-services"
] |
[
"How to convert linq entitySet AND CHILDREN to lists?",
"I ran into an error when trying to serialize a linq entitySet. To get around this i converted the entitySet to a list. The problem I have run into now is that it's child entity sets are not converting to a list and when I try to serialize the parent those are now throwing an error. Does anyone know of a way to convert a linq entitySet AND it's children to lists?\n\np.s. I'm new to linq so if any of this dosn't make sense let me know"
] | [
"asp.net",
"linq"
] |
[
"How to determine orientation of Windows Phone 7?",
"How can you tell whether the device is oriented vertically (portrait) or horizontally (landscape)?\n\nIs there an API that simplifies this or do you have to make the determination \"by hand\" using the accelerometer?"
] | [
"windows-phone-7"
] |
[
"PhpStorm Find all Instances in current remote file",
"I am trying to get a list of search results for a string in the current file which is opened from a remote host. CTRL F only highlights the instances in the doc but does not give me an easy overview. If I have a file downloaded to my project folder I can press CTRL SHIFT F for \"find in path\" and then CTRL ENTER to open the find window. complicated but better than nothing. \n\nIs there a simple \"find all in current file\" command, disregarding whether its a project file or a remote file?"
] | [
"phpstorm"
] |
[
"Is there a way to setup a timed or polling route in Apache Camel only using the Spring DSL?",
"I have a nice simple route that uses Camel's ftpcomponent:\n\n<camelContext id=\"myroute\" xmlns=\"http://camel.apache.org/schema/spring\">\n <route>\n <from uri=\"file:///outgoing\"/>\n <to uri=\"ftp://user@randomftpsite/test/?password=password\"/>\n </route>\n</camelContext>\n\n\nIs there a way to have this route triggered, say once an hour, right in the Spring DSL?"
] | [
"spring",
"apache-camel"
] |
[
"How to get the last parent page slug or id in wordpress theme development?",
"Given a sceanrio, for example:\n\n\nPage 1\nPage 2\n\n\nPage 3\n\n\nPage 4\n\n\nPage 5\nPage 6\n\n\nPage 7\n\n\n\nPage 8\n\n\n\nHow to get the last parent page slug or id in wordpress theme development, using only the ID of the top most parent page?\n\nThe top most parent page in the scenario given is \"Page 2\"\nFollowing the sceanario given the last parent page in the hierarchy is \"Page 6\"."
] | [
"php",
"wordpress"
] |
[
"Memory Leak on DeleteOnExitHook",
"I have a Java application running 24/7, it has a connection to a MySQL server and a TimerTask (is running Akka). I'm running into OutOfMemoryError after a week or less of operation and the heap dump reveals a LinkedHashMap with over 4 millions of Strings, they have a GC root of java.io.DeleteOnExitHook using 800 MB of heap.\n\nAll the Strings are something like /tmp/jar_cachexxxx.tmp\n\nThis problem is consistent in two machines running OpenJDK Runtime Environment (build 1.8.0_101-b13). The JDBC driver is the one provided on maven \"mysql-connector-java\" version 5.1.38 and I'm using the connection pool BoneCP, version 0.8.0.\n\nAnyone has an idea about this leak?\n\nUpdate -- 5/12/16\n\nThe problem has been solved after we've changed the compiler for the project. We noticed that eclipse jar creator was the only thing that has any relation with jar cache, so after we compiled the project with maven, the memory leak was gone."
] | [
"java",
"memory-leaks",
"out-of-memory",
"akka"
] |
[
"Replacing tables with unordered lists",
"I have a requirement to remove the use of tables and replace the code with HTML lists (<ul> and <li>). The HTML code to be replaced is as below\n\n<table> \n <tr> \n <td> \n <img width=\"40\" height=\"40\" src=\"../images/johnsmith2.jpg\" alt=\"johnsmith2\" /> \n </td> \n <td> \n <table> \n <tr><td>John Smith</td></tr> \n <tr><td>24 years</td></tr> \n <tr><td>Chicago</td></tr> \n </table> \n </td> \n </tr> \n</table> \n\n\nTried multiple options using lists but could not achieve this display. The text on the right always went below the image using lists, I wanted the vertical text list (name, then age, then city) to be adjacent to the image i.e. the list should produce the same shape as produced by the above table.\n\nPlease let me know how this can be done via CSS with HTML lists."
] | [
"html",
"css",
"html-lists"
] |
[
"Array with a \"graphical wrong\" space",
"I've started jQuery, html and css recently and I do not really understand everything. As the work deals with all of these things, I don't know where my problem comes from.\n\nI want to generate a html array with js (data will come (later) from a server). This array might be \"dynamic\" (automatic filling, updating, etc.) and nice to see (hence css).\n\nI do have something \"good\" right now. The only thing is I do have a \"hidden\" column and I can't get rid of it.\n\n\r\n\r\nvar data = [\"City 1\", \"City 2\", \"City 3\"]; //headers\r\n\r\nvar data1= [[\"New York\", 123, \"Seattle\"],\r\n [\"Paris\", \"Milan\", \"Rome\"],\r\n [\"Pittsburg\", \"Wichita\", \"Boise\"]];\r\n\r\nvar cityTable;\r\n\r\n\r\n//Init and creation of the header\r\n$(document).ready(function() {\r\n cityTable = makeTable($(\"#test\"), data);\r\n appendTableColumn(cityTable, [\"Calgary\", \"Ottawa\", \"Yellowknife\"]);\r\n});\r\n\r\n\r\n\r\n// Add a line thanks to the button\r\n$(function(){\r\n $('#button').click(\r\n function(e){\r\n appendTableColumn(cityTable, [\"Calgary\", \"Ottawa\", \"Yellowknife\"]);\r\n }\r\n )\r\n }\r\n )\r\n\r\n//Add a line method\r\nfunction appendTableColumn(table, rowData) {\r\n var lastRow = $(\"<tr class=\\'row\\'/>\").appendTo(table.find('thead:last'));\r\n $.each(rowData, function(colIndex, c) {\r\n console.log(c);\r\n lastRow.append($('<td id=\"cell\" class=\\'cell\\'/>').text(c));\r\n });\r\n return lastRow;\r\n}\r\n\r\n//Creation of the table\r\nfunction makeTable(container, data) {\r\n\r\n var table = $(\"<table/>\");\r\n var row = $(\"<thead>\");\r\n\r\n row.append($(\"<tr class=\\'row\\'/>\"));\r\n $.each(data, function(rowIndex, r) {\r\n row.append($(\"<th>\").text(r));\r\n row.append($(\"</th>\"));\r\n });\r\n\r\n table.append(row);\r\n\r\n return container.append(table);\r\n}\r\ntbody{\r\n display: : block;\r\n padding:20px;\r\n max-width:800px;\r\n margin:auto auto;\r\n font-family:sans;\r\n overflow-y: scroll;\r\n}\r\n\r\ntable{\r\n\r\n}\r\n\r\n\r\nth {\r\n background:#666;\r\n color:#fff;\r\n padding-left: 5px;\r\n}\r\ntd {\r\n padding:5px;\r\n}\r\n\r\ninput {\r\n height: 24px;\r\n font-size: 18px;\r\n padding:2px;\r\n border:0;\r\n}\r\nbody {\r\n font: normal medium/1.4 sans-serif;\r\n}\r\n\r\n\r\n\r\n.cell:hover{\r\nbackground-color:#FF7368;\r\n}\r\n.row:hover{\r\n background-color:#E8CAB2;\r\n}\r\n.row:hover{\r\n background-color:#E8CAB2;\r\n}\r\n<!DOCTYPE html>\r\n<html >\r\n<head>\r\n <meta charset=\"UTF-8\">\r\n <title>Editable Table</title>\r\n <link rel='stylesheet prefetch' href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css'>\r\n <link rel='stylesheet prefetch' href='http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css'>\r\n <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>\r\n <script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js'></script>\r\n <script src='http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js'></script>\r\n <script src='http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore.js'></script>\r\n <link rel=\"stylesheet\" href=\"in0.css\">\r\n <link href=\"metro-icons.css\" rel=\"stylesheet\">\r\n <script src=\"in0.js\"></script>\r\n</head>\r\n<body>\r\n <button id='button' type=\"button\" >Click Me!</button>\r\n <input type=\"search\" id=\"search\" placeholder=\"Filter by Title\">\r\n <table id=\"test\"></table>\r\n</body>\r\n</html>"
] | [
"javascript",
"jquery",
"html",
"css"
] |
[
"How to filter a message in Kibana?",
"I am trying to create a Dashboard in which the message field has the following entry \n\necho <version>\n\n\nThe version keeps on changing per execution. I want the Dashboard to display all version and corresponding count. How do I configure the dashboard to visualize the same?"
] | [
"elasticsearch",
"logstash",
"kibana"
] |
[
"TitleAreaDilaog - Title Area / SWT",
"Is there ways to modify the appearance of the title area. Can you add some like a horizontal line to the bottom, to better separate the title area from the rest of the dialog. If I wanted to add a image or place text other than the standard \n\npublic void create() {\n super.create();\n setTitle(\"The Base Dialog Class\");\n setMessage(\"Hello World\");\n} \n\n\nIs it possible the make the title area look they you like and not the standard way?"
] | [
"java",
"jface"
] |
[
"remove() removing from all items in list",
".remove() has some behavior I don't understand.\n\nx = [[1,2,3]]*3\nx[0].remove(1)\n\n\nthen x becomes [[2, 3], [2, 3], [2, 3]]. \n\nWhy does this happen, and how can I fix this? I want 1 removed from the first list only."
] | [
"python",
"list"
] |
[
"Making all images' sources https:// using *.user.js",
"EDIT: Why doesn't this work?\n\n@match http://tumblr.com/*\n$(document).ready(function() {\n $(img).each(function() {\n var i = $(this).attr(\"src\");\n var n = i.replace(\"http://\", \"https://\");\n $(this).attr(\"src\", function() {\n return n;\n });\n });\n});\n\n\nEDIT: To be clear, I DO NOT OWN THE WEBSITE. I want to have images on sites like https://facebook.com/ and https://tumblr.com/ be on https."
] | [
"javascript",
"jquery",
"html",
"ssl",
"userjs"
] |
[
"Add a checkout hidden field with a random unique string value in woocommerce",
"In Woocommerce, I would like to add a hidden field to in checkout page, which attribute value will be a custom generated unique random string of character.\n\nIs that possible?"
] | [
"php",
"wordpress",
"woocommerce",
"checkout",
"hidden-field"
] |
[
"Post Updated Value Using Eloquent",
"I am learning AngularJS on Laravel, and I am making a simple app. So far the app displays rows from the DB in either a completed area, or a not completed area. If a user clicks the item, it moves to the opposite area.\n\n$scope.move = function(item) {\n item.has_item = !item.has_item;\n};\n\n\nThe above moves the item on click, however for persistence I add:\n\n$scope.move = function(item) {\n var newState = !item.completed;\n $http.post('/items', item).success(function() {\n item.completed = newState;\n });\n};\n\n\nNow, I just need a route to accept this post and insert the updated value of completed to the DB.\n\nI've tried:\n\nRoute::post('items', function()\n{\n $completed = Input::get('completed');\n return $completed->push();\n});\n\n\nHowever, I have had no luck. What do I need to do to insert the value into the DB?"
] | [
"php",
"ajax",
"angularjs",
"laravel",
"eloquent"
] |
[
"Deleting Invalid Duplicate Rows in SQL",
"I have a table which stores the check-in times of employees through Time Machine on the basis of a username. If an employee punches multiple times then there would be multiple records of his check-ins which would only have a time difference of few seconds in between. Obviously only the first record is valid. All the other entries are invalid and must be deleted from the Table. How can i do it if i can select all the checkin records of an employee for the current date? \n\nThe Data in the db is as follows.\n\nUsername Checktime CheckType\n HRA001 7/29/2012 8:16:44 AM Check-In\n HRA001 7/29/2012 8:16:46 AM Check-In\n HRA001 7/29/2012 8:16:50 AM Check-In \n HRA001 7/29/2012 8:16:53 AM Check-In"
] | [
"asp.net",
"sql",
"sql-server-2005"
] |
[
"Custom Variable for Paypal Installment Plan",
"I have decided to use Paypal's Payment Gateway method that allows my customer to have the option to pay the amount fully or have an installment plan for them to pay for the things they ordered. \n\nI'm aware that you can define variables before the creation of the Installment Plan button. However, the problem with this is that the variables are predefined.\n\n\nWhat I'm looking for is if there's a way to change the value of these variables, how do I do so?\n\nHere's my code for my cartbookout the page so far.\n\n<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_top\">\n<input type=\"hidden\" name=\"cmd\" value=\"_s-xclick\">\n<input type=\"hidden\" name=\"hosted_button_id\" value=\"YQUKWHZVR23K8\">\n<table> \n<tr><td><input type=\"hidden\" name=\"on0\" value=\"plan\"></td></tr>\n\n<tr><td><input type=\"hidden\" name=\"os0\" value =\"option_0\"></td><td>\n\n<strong>Installment for Programme</strong></td></tr>\n\n<tr><td></td><td>Number of payments 4</td></tr><tr><td></td><td>Start \npayments At checkout</td></tr>\n<tr><td></td><td>\n\n<table>\n<tr><th align=\"left\">Due*</th><th align=\"right\">Amount</th></tr>\n<tr><td>At checkout</td><td align=\"right\"><?php echo ($totalAmount/4) + \n\"SGD\" ; ?></td></tr><tr><td>Every 1 month (x 3)</td><td align=\"right\"><?php \necho ($totalAmount/4);?></td></tr><tr><td COLSPAN=\"2\" ALIGN=\"right\"><?php \necho $totalAmount ?></td></tr></table></td></tr>\n<tr><td colspan=\"3\"><i>* We calculate payments from the date of checkout.\n</i></td></tr></table>\n<table><tr><td align=center><i></i></td></tr><tr><td><input type=\"image\" \nsrc=\"https://www.paypalobjects.com/en_US/i/btn/btn_installment_plan_LG.gif\" \nborder=\"0\" name=\"submit\" alt=\"PayPal - The safer, easier way to pay \nonline!\"></td></tr></table>\n<img alt=\"\" border=\"0\" \nsrc=\"https://www.paypalobjects.com/en_US/i/scr/pixel.gif\" width=\"1\" \nheight=\"1\">\n</form>\n\n\nI've tried to look up this issue on StackOverflow, but they were asking mostly on Payment in Full but not an Installment Plan method. Also, I've tried their solutions but to no avail.\n\nAny help would be appreciated."
] | [
"php",
"html",
"paypal"
] |
[
"Dynamic length of SQL args",
"I have the following:\n\nsql = 'INSERT INTO home_title VALUES (%s, %s, %s, %s, %s)'\n\n\nHowever, the length of arguments is 57. How would I dynamically create the (%s, %s, ...) based on multiplying by 57?"
] | [
"python",
"mysql",
"sql"
] |
[
"How to whitelist IP addresses for AWS ElasticBeanStalk Application Health Check?",
"I use an IP whitelist in the application CORS configuration.\n\nUnfortunately, this means that Application Health Check pings to the ElasticBeanStalk application fail with:\n\nError: Bad Request: Invalid origin\n\n\nThe IP addresses appear to be dynamic.\n\nHow do I dynamically query for the HealthCheck ping IP addresses, so I can include them in the whitelist?\n\nAWS seems to have multiple health checkers, and the IP ranges seem to differ for each. Found the Route53 health checker IPs in the aws cli route53:get-checker-ip-ranges, but cannot find an equivalent end-point for ElasticBeanStalk (or ElasticLoadBalancer; which the ElasticBeanStalk application health check appears to use).\n\nDeployment environment: AWS Elastic BeanStalk with 64bit Amazon Linux 2017.03 v4.2.0 running Node.js"
] | [
"amazon-web-services",
"amazon-elastic-beanstalk",
"amazon-route53",
"health-monitoring",
"elastic-load-balancer"
] |
[
"Rails form - Iterating over collection in form",
"In my form I want to iterate over a specific collection and collect the same information about each. For simplicity's sake something like:\n\n<%= form_tag :update_dog do %>\n <% @dogs.each do |dog| %>\n <%= text_field_tag :name, :class=>dog.id %>\n <% end %>\n <%= submit_tag \"Add\", :class => 'btn btn-success'%>\n<%= end %>\n\n\nWhere I would want to collect each dog's name to manipulate in the controller (in which I'd like to be able to iterate over each submitted dog name and access its id). The potential number of dogs in my collection is variable. What is the best way to do this? The code above is what I have so far but I have no idea if it's right and if so, how to use it in the controller. \n\nThanks so much!"
] | [
"ruby-on-rails",
"ruby-on-rails-3"
] |
[
"Click on each item in Navigation Drawer with Multiple Fragments in Flutter reloads the screen",
"I have implemented a Navigation Drawer with Multiple Fragments in Flutter as below tutorial but when I click on each navigation drawer item, it rebuilds each screen again. How can I keep it alive? I don't want each screen to rebuild. Thanks in advance for your help :)\n\nhttps://medium.com/@kashifmin/flutter-setting-up-a-navigation-drawer-with-multiple-fragments-widgets-1914fda3c8a8?fbclid=IwAR2uur5NsehbJkh9FK8O6ZigmbQBx0V50i-DzyGlaJSpN7IkvijqhWL9GGw\n\nclass DrawerItem {\n String title;\n IconData icon;\n\n DrawerItem(this.title, this.icon);\n}\n\nclass HomePage extends StatefulWidget {\n final drawerItems = [\n new DrawerItem(\"Sales\", Icons.shopping_basket),\n new DrawerItem(\"Items\", Icons.category),\n new DrawerItem(\"Setting\", Icons.settings)\n ];\n\n @override\n State<StatefulWidget> createState() {\n return new _HomepageState();\n }\n}\n\nclass _HomepageState extends State<HomePage> with TickerProviderStateMixin {\n int _selectedDrawerIndex = 0;\n\n _getDrawerItemWidget(int pos) {\n switch (pos) {\n case 0:\n return new SaleGrid();\n case 1:\n return new ItemsList();\n\n default:\n return new Text(\"Error\");\n }\n }\n\n _onSelectItem(int index) {\n setState(() => _selectedDrawerIndex = index);\n Navigator.of(context).pop(); // close the drawer\n }\n\n @override\n Widget build(BuildContext context) {\n var drawerOptions = <Widget>[];\n for (var i = 0; i < widget.drawerItems.length; i++) {\n var d = widget.drawerItems[i];\n drawerOptions.add(new ListTile(\n leading: new Icon(d.icon),\n title: new Text(d.title),\n selected: i == _selectedDrawerIndex,\n onTap: () => _onSelectItem(i),\n ));\n }\n\n return new Scaffold(\n appBar: new AppBar(\n // here we display the title corresponding to the fragment\n // you can instead choose to have a static title\n title: new Text(widget.drawerItems[_selectedDrawerIndex].title),\n ),\n drawer: new Drawer(\n child: new Column(\n children: <Widget>[\n UserAccountsDrawerHeader(\n accountName: Text('Kimsung'),\n accountEmail: Text('[email protected]'),\n currentAccountPicture: ClipOval(\n child: Image.asset(\n 'assets/profile.jpg',\n fit: BoxFit.cover,\n ),\n ),\n ),\n new Column(children: drawerOptions)\n ],\n ),\n ),\n body: _getDrawerItemWidget(_selectedDrawerIndex),\n );\n }\n}"
] | [
"flutter",
"navigation-drawer"
] |
[
"What does means by rh- in php packages in CentOS?",
"Following is the result of yum search php-pdo \n\n\n\n1st one has no php version.\nNext two has php version 5.4 and 5.5 respectively.\nAnd next 3 has php version with rh at starting.\nWhat is the significance/meaning of rh?"
] | [
"php",
"yum"
] |
[
"Receive information from a specific Node",
"The problem is that I have one and the same page constantly parsed. How can I fix this, what am I doing wrong? how to get information from a specific site.\n//General url ("https://www.zieglers.com/church-goods/church-furnishings/altar-sets/?sort=featured&page=1")\npublic static void GetProductsLinks(string url) \n {\n var html = HtmlRetriever(url);\n\n if (string.IsNullOrEmpty(html))\n return;\n var doc = new HtmlDocument();\n doc.LoadHtml(html);\n\n //Get All products from this page\n var tag = doc.DocumentNode.SelectNodes("//figure[@class='card-figure']/a");\n\n if (tag == null)\n return;\n // Check if there is a button next\n var nextButtonIsExist = doc.DocumentNode.SelectSingleNode(\n "//link[@rel = 'next']");\n\n\n //if exist form a new link ("https://www.zieglers.com/church-goods/church-furnishings/altar-sets/?sort=featured&page=2")\n if (nextButtonIsExist != null)\n {\n url = nextButtonIsExist.Attributes["href"].Value;\n }\n\n // I fill the List <string> with links to all items from this page\n foreach (var item in tag)\n {\n var tok = item.InnerText;\n linksProductsList.Add(item.Attributes["href"].Value);\n }\n\n // If there is a button next, then we pass our newly generated url\n if (nextButtonIsExist != null)\n {\n GetProductsLinks(url);\n }\n }\n\nThe problem is that the site has pagination, and each link has 2-6 pages, can you tell me how you can parse?"
] | [
".net",
"html-agility-pack"
] |
[
"Falcon cannot read request body",
"I am trying to read a simple request body with JSON data.\n\nThe request body:\n\n[\n{\n ...data\n},\n{\n ...data\n}\n]\n\n\nWhen I try (In EventResource)\n\ndef on_post(self, req, resp):\n\n print(req.stream.read())\n\n\nThe following is logged into the console: b''\n\nI have no clue what I am doing wrong or why it is not displaying my body data. Every example I see when doing this it actually logs the data instead of what I am getting.\n\nRequirements.txt (might be some out of context, but I've added the full list just to be sure.)\n\nastroid==1.5.3\nbson==0.5.0\ncffi==1.11.2\nclick==6.7\nfalcon==1.4.1\nfalcon-auth==1.1.0\nfalcon-jsonify==0.1.1\nFlask==0.12.2\ngreenlet==0.4.12\ngunicorn==19.7.1\nisort==4.2.15\nitsdangerous==0.24\nJinja2==2.10\nlazy-object-proxy==1.3.1\nMarkupSafe==1.0\nmccabe==0.6.1\nmimeparse==0.1.3\nmongoengine==0.15.0\npycparser==2.18\nPyJWT==1.5.3\npylint==1.7.4\npymongo==3.5.1\npython-mimeparse==1.6.0\npytz==2017.3\nreadline==6.2.4.1\nsix==1.11.0\nWerkzeug==0.12.2\nwrapt==1.10.11\n\n\napp.py\n\napi = falcon.API(middleware=[\nfalcon_jsonify.Middleware(help_messages=settings.DEBUG)\n])\n\n\nroutes.py\n\nfrom app import api\nfrom resources.event import EventResource\nfrom resources.venue import VenueResource\n\n# EventResources\napi.add_route('/api/event', EventResource())\napi.add_route('/api/event/{event_id}', EventResource())\napi.add_route('/api/venue/{venue_id}/events', EventResource())\n\n# VenueResources\napi.add_route('/api/venue', VenueResource())\napi.add_route('/api/venue/{venue_id}', VenueResource())\napi.add_route('/api/event/{event_id}/venue', VenueResource())\n\n\nI run my project with gunicorn routes:api --reload\n\nExample POST request (that logs the b''):\n\ncurl -d '{\"key1\":\"value1\", \"key2\":\"value2\"}' -H \"Content-Type: application/json\" -X POST http://localhost:8000/api/event\n\n\nThe only thing I added as a header is Content-Type/application/json\n\nI've read through this but it didn't help me."
] | [
"python-3.x",
"rest",
"gunicorn"
] |
[
"what is wrong with this code? adding node after a given value in list",
"i am using a while to add a node to my linked list after a value provided.\nbut it is not working accordingly. \n\nI have done print command inside while loop it's showing that it works fine as I want, but when I am printing list it's not.\n\nclass Node:\n def __init__(self, data):\n self.data = data\n self.next = None\n\n\nclass LInkedList:\n def __init__(self):\n self.head = None\n\n def print_list(self):\n\n cur_node = self.head\n while cur_node:\n print(cur_node.data)\n cur_node = cur_node.next\n\ndef apppend(self, data):\n new_node = Node(data)\n if self.head is None:\n new_node = self.head\n return\n last_node = self.head\n while last_node.next is not None:\n last_node = last_node.next\n last_node.next = new_node\n\ndef prepend(self, data):\n new_node = Node(data)\n\n new_node.next = self.head\n self.head = new_node\n\ndef add_after_node(self, after, data):\n new_node = Node(data)\n this_node = self.head\n while this_node:\n\n if this_node.data == after:\n new_node.next = this_node.next\n this_node.next = new_node\n\n\n # print(this_node.data) this shows that is updating properly \n this_node = this_node.next\n\n\n\n\n\n\nnew_list = LInkedList()\nnew_list.prepend(10)\nnew_list.prepend(20)\nnew_list.prepend(30)\nnew_list.prepend(20)\n\n\n\nnew_list.add_after_node(20, 50)\nnew_list.print_list()\n\n\nI want that 50 should be added after each 20 in the list.\nfor example:\ninput :- 20 30 20 10\noutput :- 20 50 30 20 50 10\n\nright now it is printing 20 50 10 with print_list function I don't know why?"
] | [
"python",
"python-3.x",
"linked-list"
] |
[
"ConnectionString loses password after connection.Open",
"i'm using ADO.NET to get some information from the database on a server,\nso this is what i do:\n\nstring conStr = \"Data Source=myServer\\SQLEXPRESS;Initial Catalog=DBName;User ID=myUser;Password=myPassword\";\n\nSqlConnection conn = new SqlConnection(conStr);\n\nconn.Open();\n// do stuff\nconn.Close();\n\n\nbut after calling Open method i noticed that conn.ConnectionString is losing the password so it becomes:\n\n\"Data Source=myServer\\SQLEXPRESS;Initial Catalog=DBName;User ID=myUser;\"\n\n\nwhich causes exception with any SqlCommand afterwords\nhow to fix this?\nNote:The strange thing is that does not happen always\nEdit: i don't think it has anything to do with the command it self but anyway \n\nSqlCommand command = new SqlCommand(\"select GetDate()\", conn);\nSqlDataReader reader = command.ExecuteReader();"
] | [
"c#",
"ado.net"
] |
[
"How to display python list values in form using table in odoo 9",
"I have set of values in python list, And I want to display the values in forms using table \n\nPython code:\n\[email protected]\ndef get_models(self):\n models_list =[]\n model_obj = ''\n models_list1 = []\n gs_configuration_obj = self.env['ir.model']\n for sco_search in gs_configuration_obj.search([]):\n for sco_obj in gs_configuration_obj.browse(sco_search.name):\n models_list += sco_obj\n user_models_list = [x[0] for x in models_list]\n models_list = sorted(list(set(user_models_list)))\n for m in models_list:\n print m\n return models_list\n\n\nNow I have to display the list values in form as a table.\n\nThanks"
] | [
"jquery",
"xml",
"python-2.7",
"odoo-9"
] |
[
"Modern UI Design with Background animate and transition xml",
"Please how can I achieve this login background transition and EditText animation in android studio\n\nI want to expand the edittext when onFocusChange is true and shrink back is is false\nand drawable for background design with transition"
] | [
"java",
"android",
"xml",
"material-design"
] |
[
"Connection to Azure Automation using own Service Principal with KEY",
"I'm creating a runbook with Azure Automation and using the cmdlets \n\n$connection = Get-AutomationConnection -Name $Name\n\n\nThe connection is linked to a certificate that has a key. How do I provide a key with this connection cmdlet \n\n Add-AzureRmAccount -ServicePrincipal `\n -EnvironmentName \"AzureUSGovernment\" `\n -Tenant $connection.TenantID `\n -ApplicationId $connection.ApplicationID `\n -CertificateThumbprint $connection.CertificateThumbprint `\n -ErrorAction Stop `\n |Out-Null\n\n\nError:\n\nAADSTS70002: Error validating credentials. AADSTS50012: Client assertion contains an invalid signature. [Reason - The key was not found., Thumbprint of key used by client: 'xxx', Please visit 'https://developer.microsoft.com/en-us/graph/graph-explorer' and query for 'https://graph.microsoft.com/beta/applications/8a09f2d7-8415-4296-92b2-80bb4666c5fc' to see configured keys] Trace ID: adfa5f5d-aaf2-4657-9e5f-1966ad540600 Correlation ID: 68f34f9b-b773-46ed-993e-e06ead5dd6b4 Timestamp: 2018-08-10 02:58:01Z"
] | [
"azure",
"azure-automation",
"azure-connect",
"azure-runbook"
] |
[
"Chrome and selenium headless on and off?",
"How can i turn on headless mode using java and selenium, and after doing some code turn it off and show the current page?\nI already tried using options.setHeadless(false) but it did not work."
] | [
"java",
"selenium",
"google-chrome",
"selenium-webdriver"
] |
[
"How can I manually read N messages off the queue or if Y time has passed in the onmessage() method?",
"I am looking to implement the following logic in my Message driven beans onmessage method\n\nRead N messages or wait for Y time, whichever happens first and then commit the transaction.\n\nI would really appreciate if I can get a example of the code to implement this logic?\n\nT"
] | [
"transactions",
"jms",
"mq"
] |
[
"How can I store resource available by date (year/month/day/our) in database?",
"I have a program which manage resources (agents). In the program there is a feature to select a date from a calendar (e.g.: 08/11/2013 5 a.m.) and get back the number of available resources at selected time. How can I store the status of the resources for every hour of all day in the year effectively in a relational database?\n\nResource status just a string: \"accessible\" or \"busy\".\n\nHave you any idea or strategy for this?\n\nThanks for help!"
] | [
"database",
"date",
"relational-database",
"store"
] |
[
"SELECT multiple rows from single column into single row",
"I want to write an SQL Server query that will retrieve data from the following example tables:\n\nTable: Person\nID Name\n-- ----\n1 Bill\n2 Bob\n3 Jim\n\nTable: Skill\nID SkillName\n-- -----\n1 Carpentry\n2 Telepathy\n3 Navigation\n4 Opera\n5 Karate\n\nTable: SkillLink\nID PersonID SkillID\n-- -------- -------\n1 1 2\n2 3 1\n3 1 5\n\n\nAs you can see, the SkillLink table's purpose is to match various (possibly multiple or none) Skills to individual Persons. The result I'd like to achieve with my query is:\n\nName Skills\n---- ------\nBill Telepathy,Karate\nBob \nJim Carpentry\n\n\nSo for each individual Person, I want a comma-joined list of all SkillNames pointing to him. This may be multiple Skills or none at all.\n\nThis is obviously not the actual data with which I'm working, but the structure is the same.\n\nPlease also feel free to suggest a better title for this question as a comment since phrasing it succinctly is part of my problem."
] | [
"sql",
"sql-server"
] |
[
"dokuwiki authentication from java",
"Here is the scenario:\n\nI want to use docuwiki to show help and other content to users. The users are grouped by to organization. Each organization gets their own content that should be private to them. Enter ACL. I get how I can create a user and limit him to a certain subsection of the wiki. \n\nNow the fun part begins. How can I authenticate these users from my server? I'm running a Tomcat/Java/MSSQL stack. I have full control of both servers.\n\nI'd imagine if it is possible, I would imagine I can post the username/password to the wiki from the servlet, and get some kinda token back that the user can access the site with. But I don't see anything in the documentation about this. If anyone has any ideas, pointers or alternatives, I'd appreciate it."
] | [
"java",
"sql-server",
"authentication",
"dokuwiki"
] |
[
"Read a matrix from a file",
"This is my function to read a matrix from a file. In the text file I have on the first line 2 is n and 3 is m and on the next two lines is the matrix. \nI don't have erros, but my program \"stop working\" and I don't know why. Thank you!\nIn main I have: readmatrix(n,m,a, \"text.txt\");\n\nint readmatrix(int* n,int *m, int a[*n][*m], char* filename){\n FILE *pf;\n int i,j;\n pf = fopen (filename, \"rt\");\n if (pf == NULL)\n return 0;\n fscanf (pf, \"%d\",n); \n for (i=0;i<*n;i++) \n {\n for(j=0;j<*m;j++)\n fscanf (pf, \"%d\", &a[i][j]);\n }\n fclose (pf); \n return 1; \n }"
] | [
"c"
] |
[
"Titanium For Iphone app",
"I am very new to Titanium. I created one project just by clicking new project and then launched the same. It did not launch. Displayed Info was application exited from Simulator and warning was SDK not Supported. My Titanium version is 1.2.0. Can anyone help me to sort out this problem."
] | [
"iphone",
"titanium"
] |
[
"is there a way to search for deeply nested json in activerecord with postgres?",
"Suppose I have a foos table that has a json column called \"json_col\"...\n\nIs there a way with ActiveRecord to do:\n\nFoo.create!(:json_col => { :foo => { :bar => 'baz' } }.to_json)\n\nFoo.where_with_magical_json_finder(:bar => 'baz')"
] | [
"postgresql",
"activerecord"
] |
[
"Disable too-many-ifs heuristic",
"How do I disable the too-many-ifs heuristic? Sometimes the prover goes out to lunch, and when I interrupt it, I can see that the prover is busy with a call of too-many-ifs0 and count-ifs-lst."
] | [
"acl2"
] |
[
"Selenium script doesn't print the XPath value",
"I made this Selenium script as a practice to scrape JS heavy pages.\n\nThe programs, start up a WebDriver enters a website, then press a button so they all show up then I want just pull some data, the names of the clubs, but there is a problem.\n\nIt just prints [], can someone tell me what I'm doing wrong here?\n\nAnd my goal is to get the names of the clubs like Acadiana Kennel Club, Inc. \n\nfrom selenium import webdriver\nfrom selenium.webdriver.support.ui import WebDriverWait\nfrom selenium.webdriver.support import expected_conditions as EC\nfrom selenium.common.exceptions import TimeoutException\n\noption = webdriver.ChromeOptions()\noption.add_argument(\" - incognito\")\n\nbrowser = webdriver.Chrome('/home/djurovic/Desktop/Linux ChromeDriver/chromedriver', chrome_options=option)\nbrowser.get('https://webapps.akc.org/club-search/?fbclid=IwAR1X9TkSI49bHgH3w4VmgrMS05sxLbbazaMO17Q1rEfVq7Pj4Ze66B4hdLM#/agility')\n\ntimeout = 20\n\nbuttonXpath = '//a[@class=\"button\"]'\nnamesXpath = '//*[@class=\"ng-binding\"]/text()'\n\ntry:\n buttonElement = WebDriverWait(browser, timeout).until(lambda browser: browser.find_element_by_xpath(buttonXpath))\n buttonElement.click()\n clubNames = WebDriverWait(browser, timeout).until(lambda browser: browser.find_elements_by_xpath(namesXpath))\n print(clubNames)\nexcept TimeoutException:\n print('Timed out waiting for page to load')\n browser.quit()"
] | [
"python",
"selenium"
] |
[
"Ajax call only working on first page of webgrid",
"Hi all,\n\nI have a webgrid that has pagination. One of the column displays an icon that can be clicked and will trigger an ajax call. The ajax call works fine on the first page of the webgrid but it doesn't seem to be working on the next pages. I don't think it's even hitting the ajax call, the display would also jump on the top of the page. Can someone tell me what I'm doing wrong or how I can make it work on the other pages of the webgrid as well?\n\nvar Grid = new WebGrid(canPage: true, canSort: false, rowsPerPage: 25, ajaxUpdateContainerId: \"gridContent\");\nGrid.Bind(Model.DataList);\nGrid.Pager(WebGridPagerModes.NextPrevious);\n\nvar gridColumns = new List<WebGridColumn>();\n\ngridColumns.Add(PaymentGrid.Column(columnName: \"WavFile\", header: \" \", format:@<text>\n@if (item.WavFile != null && item.WavFile != \"\")\n{ <a href=\"#\" id=\"audiobtn\" class=\"audiobtn\"><img src=\"~/Content/audio.png\" \ntitle=\"Download\" alt=\"@item.WavFile\" /></a> }\nelse\n{ @Html.Raw(\"<img src=\\\"/Content/audiooff.png\\\" />\") }</text>));\ngridColumns.Add(Grid.Column(columnName: \"EmployeeID\", header: \"EmpID\"));\ngridColumns.Add(Grid.Column(columnName: \"LastName\", header: \"Last\", canSort: \ntrue));\ngridColumns.Add(Grid.Column(columnName: \"FirstName\", header: \"First\", canSort: true));\n\n<div id=\"gridContent\">\[email protected](\ntableStyle: \"table table-striped table-hover\",\nheaderStyle: \"\",\nfooterStyle: \"\",\nalternatingRowStyle: \"\",\nrowStyle: \"\",\nmode: WebGridPagerModes.All,\ncolumns: Grid.Columns(gridColumns.ToArray())\n) \n</div>\n\n<script type=\"text/javascript\">\n$(document).ready(function () {\n\n$(\".audiobtn\").click(function (e) {\n\n$.ajax({\ntype: \"POST\",\nurl: \"/EmployeeInfo/VoiceAuthorization\",\ndata: { audio: $(this).find('img').attr('alt') },\nasync: false,\ncache: false,\nsuccess: function (response) {\n\nif (e.button == 0) {\n$(\"#ContextMenu\").css('left', e.pageX + 5);\n$(\"#ContextMenu\").css('top', e.pageY + 5);\n$(\"#ContextMenu\").fadeIn(100); \n} \n},\nerror: function (error) {\nalert('Invalid wav file');\nconsole.log(error);\n}\n});\n\nreturn false;\n});\n\n$(\"#ContextMenu\").click(function () {\n$(\"#ContextMenu\").fadeOut(80); \n});\n\n$(document).click(function (e) {\nif (e.target.id != 'audiobtn' && !$('#audiobtn').find(e.target).length) {\n$(\"#ContextMenu\").hide(); \n} \n });\n\n return false;\n });\n});\n\n\nThank you"
] | [
"jquery",
"ajax",
"asp.net-mvc",
"pagination",
"webgrid"
] |
[
"How do i find the smallest value in prolog",
"I have the following code\n\noption(2):-\n write('Enter place of origin: '), read(Origin),\n write('Enter place of destination: '), read(Destination),\n path(Origin, Destination, Path, Length),nl,nl,\n printPath(Path), write(' '),\n writef(' TOTAL DISTANCE = %d', [Length]),nl,fail;true.\n\n\nAnd I wanted to find the smallest value among the lengths. I get an output similar to this\n\nbahirdar-->mota TOTAL DISTANCE = 100\nbahirdar-->markos-->mota TOTAL DISTANCE = 70"
] | [
"prolog",
"shortest-path"
] |
[
"Is there a way to make a button's color random using the code below?",
"I am currently working on a react native project, where at a click of a button, the button's color will change. I was asked to copy code from an image that was 144px. The image quality wasn't the greatest.\nHere's the code:\nimport React, { Component } from 'react';\nimport { Text, View, StyleSheet, Button } from 'react-native';\n\nexport default class App extends Component {\n constructor() {\n super();\n this.state = {\n counter: 0,\n buttonColor: 'blue',\n };\n }\n componentDidMount() {\n setInterval(this.incrimentCounter, 100000000000);\n }\n incrimentCounter = () => {\n this.setState({ counter: this.state.counter + 1 });\n };\n componentDidUpdate() {\n console.log('Counter value has changed');\n }\n changeColor = () => {\n var letters = '0123456789ABCDE';\n var color = '#';\n for (var i = 0; i < 6; i++) {\n color += letters[Math.floor(Math.random() * 16)];\n }\n this.setState({button: color})\n };\n render() {\n return (\n <View style={{ flex: 1 }}>\n <Text style={{ marginTop: 50, marginLeft: 170 }}>\n {this.state.counter}\n </Text>\n <Button\n title="By clicking on this button, the color of this button will change. Try it!"\n style={{ color: this.state.buttonColor }}\n onPress={this.incrimentCounter}></Button>\n </View>\n );\n }\n}\n\n\nI made a function called changeColor and in that I have made different variables such as letters, and color. I have to randomly generate a hexadecimal number such as #191970. When the button is clicked, the button's color will change with the random color that is generated.\nHowever, the code is not working.\nCode for reference:\nhttps://snack.expo.io/@therealsneh/random-color-button\nThanks!"
] | [
"javascript",
"react-native",
"button",
"expo"
] |
[
"Ngrams with a dataset java eclipse",
"hi i am trying to use ngrams on this data set ( number of attacks) but i am confused to how to merge the 2 methods together so that the n-grams can spot the frequency on how many times they appear. i am just trying to data process but i am confused. any help would be appreciated thank you.\nThis is what i have done so far. as you can see the main method holds the dataset but how can i merge all methods together so that the Ngrams runs on the data. thank you\n\n public class MainProcess {\n\n\n public static void main(String args[]) throws IOException\n {\n FileReader readhandle = new \n FileReader(\"/Users/muhammad/Desktop/ADFA- \n LD/Attack_Data_Master/Adduser_1/UAD-Adduser-1-=1.txt\");\n BufferedReader br = new BufferedReader(readhandle);\n String line = null;\n while((line = br.readLine()) != null)\n {\n System.out.println(line);\n }\n br.close();\n readhandle.close();\n }\n\n public class Ngrams {\n\n\n ArrayList<String> nGrams = new ArrayList<String>();\n\n public void generateNGrams(String str, int n) {\n\n if (str.length() == n ) {\n int counter = 0;\n while (counter < n) {\n nGrams.add(str.substring(counter));\n counter++;\n }\n return;\n }\n\n int counter = 0;\n String gram = \"\";\n while (counter < n) {\n gram += str.charAt(counter);\n counter++;\n }\n nGrams.add(gram);\n generateNGrams(str.substring(1), n);\n }\n\n public void printNGrams() {\n\n\n\n for (String str : nGrams) {\n System.out.println(str);\n }\n }}\n\n\n\n\n\n\n\n\n}"
] | [
"java",
"eclipse"
] |
[
"Why are my non-active variables picking up prices?",
"A simple program to help me calculate costs for some new flooring, but my final outputs are not what i expect. \nIn particular, when underlay is \"No\", the variable for underlayarea is still picking up a value and being printed at the end.\nIf it isn't painfully obvious, this is my first crack at it. Ever. \n\nI was expecting that while the variables for 'edging' and 'underlay' remained \"No\" that no values would be stored in that while loop.\n\nunderlay='No'\nedging=input('Are you ordering Edging?').title()\nunderlay=input('Are you ordering underlay?').title()\nroomsize=input('How many square meters is the room?')\nroomflt=float(roomsize)\nwhile edging =='Yes':\n #ask for user inputs\n edgeprice=input(\"How much is the edging per meter?\")\n edgeperim=input('What is the perimeter of the room?')\n #convert to float for calculation\n one=float(edgeperim)\n two=float(edgeprice)\n #calculate\n edgearea=one*two\n #reset flag\n edging='No'\nwhile underlay=='Yes':\n #ask for user input\n underlayprice=input('How much per square meter for the Underlay?')\n #convert to float for calculation\n three=float(underlayprice)\n four=float(roomflt)\n #calculate\n underlayarea=three*four\n #reset flag\n underlay='No'\n#set the floor price\nfloorprice=input(\"How much is the floor per square meter?\")\n#convert to float for calculation\nfive=float(floorprice)\nsix=float(roomflt)\n#calculate\narea=five*six\n#get the cost\naddemup=(edgearea+underlayarea+area)\nprint(\"\\n----------------------------------------------\\nThe total is £{0:.2f} to purchase the flooring.\".format(addemup))\nprint(\"This is made up of £{0:.2f} for the floor itself,\".format(area))\nprint(\"This is made up of £{0:.2f} for the edging,\".format(edgearea))\nprint(\"and £{0:.2f} for the underlay\".format(underlayarea))"
] | [
"python",
"python-3.x"
] |
[
"mysql subquery in select join",
"I have a problem with the following statement:\n\nSELECT SUM(foreseen_charges.commonCharge) as required, foreseen_charges.flatsId \nLEFT JOIN (SELECT deposits.flatsId FROM deposits GROUP BY flatsId) deps\nON foreseen_charges.flatsId = deps.flatsId\nFROM foreseen_charges GROUP BY foreseen_charges.flatsId\n\n\nAnd I always getting this error:\n\n\n You have an error in your SQL syntax; check the manual that corresponds\n to your MySQL server version for the right syntax to use near 'LEFT\n JOIN (SELECT deposits.flatsId FROM deposits GROUP BY flatsId) deps\n ON f' at line 2\n\n\nCould anyone help me?\n\nBest Regards,\nCs"
] | [
"mysql",
"join",
"subquery"
] |
[
"Performing calculations on every pair of fields",
"For genetic analyses I'm trying to convert a 2-probability file (10gb) to 3-probabilities file . basically i have to insert a third column after every 2 other instances, this third column can be calculated as 1-(first instance + second instance). How would you do this? \n\nFrom:\n\n0.800 0.200 0.000 0.200 0.800 0.200\n0.000 0.900 0.000 0.900 0.000 0.900\n0.900 0.010 0.900 0.010 0.770 0.010\n\n\n(the file contains many columns and rows)\n\nto \n\n0.800 0.200 0.000 0.000 0.200 0.800 0.800 0.200 0.000\n0.000 0.900 0.100 0.000 0.900 0.100 0.000 0.900 0.100\n0.900 0.010 0.090 0.900 0.010 0.090 0.770 0.010 0.220"
] | [
"python",
"perl",
"bash",
"awk",
"calculated-columns"
] |
[
"using variables from variable group in release tasks",
"I have created a variable group and set a variable there CustomArtifactName and have given the scope as Release\nThe value of this variable is set in build pipeline so it generates a unique name for artifacts\nWrite-Host "##vso[task.setvariable variable=CustomArtifactName]$(Get-Date -Format yyyyMMddhhmmss)"\nI can use this fine in build pipelline in yaml in PublishPipelineArtifact@1 tasks like this\n'drop-pom-''$(CustomArtifactName)'\nBut when I use the below in release pipeline maven tasks in Maven POM File field\n$(System.DefaultWorkingDirectory)/cucumber-java-junit5-webapp/drop-pom-$(CustomArtifactName)/s/target/pom.xml\nI get\n##[error]Unhandled: Not found mavenPOMFile: \nI also tried to use this variable in Download Pipeline Artifact task but got similar result\nHow do I use variables from variable group in release tasks fields/properties? According to this msdoc we simply have to use $(variableName) but thats not working ."
] | [
"azure",
"azure-devops",
"azure-pipelines"
] |
[
"How to debug Java memory errors?",
"There is a Java Struts application running on Tomcat, that have some memory errors. Sometimes it becomes slowly and hoard all of the memory of Tomcat, until it crashes.\n\nI know how to find and repair \"normal code errors\", using tests, debugging, etc, but I don't know how to deal with memory errors (How can I reproduce? How can I test? What are the places of code where is more common create a memory error? ). \n\nIn one question: Where can I start? Thanks\n\nEDIT:\n\nA snapshot sended by the IT Department (I haven't direct access to the production application)"
] | [
"java",
"performance",
"memory-leaks",
"profiling"
] |
[
"Huge binary number Conversion",
"I have the following question, \n\nworking on Matlab I have a very large vector containing lets say ones and zeros, and I want to convert it into decimal, the thing is that the number is way to big so a variable can not hold it, so I thought braking it into small pieces that are within the acceptable boundaries and converting those pieces into decimal numbers that will be stored in a matrix or vector. I was wondering if you have any suggestions on how to implement that or a better way all together. \n\nThanks in advance."
] | [
"matlab",
"math",
"vector",
"decimal"
] |
[
"Running phpdbg to analyse \"live\" code coverage",
"I want to allow my testers to use the development website \"as usual\" and collect code coverages of every \"run\", combined everything and be able to say \"after 4 hours of tests, here are the 75% of the code that were executed\".\n\nI use the php-code-coverage library (https://github.com/sebastianbergmann/php-code-coverage) and everything is working fine except that with xdebug as the tool used for code coverage it's way too slow (10 times slower that without activating php-code-coverage).\n\nI've compiled my own version of php 7.2 with \"--enable-phpdbg\" and with the help of the command \"update-alternatives\" I'm able to run in cli : \n\n\n$ php index.php\n\n\nand get the code coverage I need, and it's only two times slower (every call to \"php\" is calling \"phpdbg\").\n\nBut I can't find a way to make it work with apache so that when I'm loading my website it's the executable \"phpdbg\" and not \"php\" that is used.\n\nEven if I'm compiling my own \".so\" it will still be \"php\" that will be executed."
] | [
"php",
"code-coverage",
"phpdbg"
] |
[
"How to specify left join in EF?",
"My model:\n\npublic partial class history_builds\n{\n public int ID { get; set; }\n public int build { get; set; }\n public int br { get; set; }\n public int tag { get; set; }\n public string line { get; set; }\n public int rev { get; set; }\n public int user_ID { get; set; }\n public string distrib_path { get; set; }\n public string setup_path { get; set; }\n public System.DateTime build_date { get; set; }\n public string product { get; set; }\n}\n\npublic partial class history_uploads\n{\n public int ID { get; set; }\n public int ID_user { get; set; }\n public string Line { get; set; }\n public int Build { get; set; }\n public string Distrib { get; set; }\n public System.DateTime Time_upload { get; set; }\n public int Status { get; set; }\n}\n\npublic partial class user\n{\n public int ID { get; set; }\n public string Name { get; set; }\n public int ID_group { get; set; }\n}\n\n\nContext:\n\npublic DbSet<history_builds> history_builds { get; set; }\npublic DbSet<history_uploads> history_uploads { get; set; }\npublic DbSet<user> users { get; set; }\n\n\nI try to do left join like this Entity framework left join \n\nvar items = entities.history_builds\n .Join(\n entities.users.DefaultIfEmpty(),\n hb => hb.user_ID,\n u => u.ID,\n (hb, u) =>\n new {\n hb.distrib_path,\n hb.setup_path,\n hb.build_date,\n hb.build,\n User = (u == null ? String.Empty : u.Name),\n hb.rev\n }\n )\n .Join(entities.history_uploads.DefaultIfEmpty(),\n hb => hb.build,\n hu => hu.Build,\n (hb, hu) =>\n new HistoryBuidItem {\n Revision = hb.rev,\n Build = hb.build,\n DistribPath = hb.distrib_path,\n SetupPath = hb.setup_path,\n BuildDate = hb.build_date,\n User = hb.User,\n IsUpload = (hu == null ? true : false)\n }\n )\n .Where(x => ids.Contains(x.Revision))\n .ToList();\n\n\nBut it doesn't work, EF still emit inner join sql code, what is wrong?"
] | [
"c#",
"entity-framework",
"orm"
] |
[
"Unable to access DOM elements in Firefox Add-on content script",
"Using Firefox 34 and addon SDK 1.17.\n\nI am using the SDK's page-mod to attach a content script. Inside the content script I am seeing very weird behaviour when trying to access DOM elements.\n\nmain.js\n\npageMod.PageMod({\n include: \"somewebsite\",\n contentScriptWhen: 'end',\n contentScriptFile: [data.url(\"stuff.js\")]\n});\n\n\nstuff.js\n\nlog(document.getElementsByTagName(\"body\")); // empty object\nlog(document.getElementById(\"SomeIdThatShouldBeThere\")); // empty object\nlog(document.getElementsByTagName(\"li\")); // x amount of empty objects...\n\n\nThis will however work as expected:\n\ndocument.body.style.border = \"5px solid red\";\n\n\nAlso for the empty objects that I get I can do\n\nobj.style.border = ...\n\n\nand it will work, the html element is seen to change border colour etc. But I am not able to read the properties of the elements, so I am working blind.\n\nI have read people say there are some restrictions to modifying DOM from content scripts, but I am not able to do even the most basic thing apparently. Is this supposed to be supported or not then?\n\nedit: Eventually I noticed that the elements are in their correct places and I can read their properties, but logging an element will still only ever print an empty object... Meaning every desired property of an element has to be printed separately. At least it works, but could be better."
] | [
"firefox",
"firefox-addon-sdk",
"content-script"
] |
[
"Having problems with implementing the center slider using the slick slider from Ken Wheeler",
"I am having a lot of problems with being able to use the center mode slider to implement within my website. It seems that the arrow next and previous do not seem to appear. Has anyone successfully been able to use this slider ?\n\nIt is from this website: \n\nhttp://kenwheeler.github.io/slick/"
] | [
"javascript",
"html",
"css",
"slider",
"carousel"
] |
[
"How to rollback specific Databases with Active Record",
"Rails 6 has Multiple Databases with Active Record.\n\nMy question is what if I want to rollback a migration in one specific database? \n\nsomething like this is not working:\n\nrails db:rollback:primary\n\n\nLink to \"Multiple Databases with Active Record\" documentation:\nhttps://edgeguides.rubyonrails.org/active_record_multiple_databases.html"
] | [
"ruby-on-rails",
"ruby-on-rails-6"
] |
[
"Special characters display as ? marks",
"I have some special characters here:\nhttp://209.141.56.244/test/char.php\n\nbut when I grab this file via ajax here, they show up as back ? marks:\nhttp://209.141.56.244/test/char.html\n\nThese characters should be \"ISO-8859-1 Western\" but switching my browser encoding to any of the options don't help.\n\nWhy is this and how can I fix it?"
] | [
"php",
"html",
"ajax",
"unicode",
"encoding"
] |
[
"Azure Data Factory Copy Task OnPremises DB to Azure Database",
"Am trying to copy data tables from On-Premises MSSQL to Azure SQL Tables.\n\nMy setting for Table Option on Sink Tab of Copy Activity is to set to 'Auto Create Table' (This will automatically create sink table if doesn't exists and this doesn't support using blob storage as staging.)\n\nWhen executed with above setting it never finishes and it just shows status in progress.\n\nBut when source is other than MSSQL it works fine. Tested with CSV files and Oracle db.\n\n\n\nIf I set Table Option to None, i can enable staging, but now it expects to have target table defined before it loads.\n\n\n\nAny clues why it's not working for MSSQL ??"
] | [
"azure-sql-database",
"azure-data-factory",
"copy-activity"
] |
[
"How to empty the back-history in firefox tab?",
"After a day of SO my back history of the firefox tab is pretty long. \n\nHow can I empty it, without closing the tab and opening it again? Can I run a GreaseMonkey script to do that?\n\nEdit:\nAfter following the ideas of Noitidart, I now have in the scratchpad the history (window.history) with window.history.length elements. I can go back and forth. But how do I empty it?"
] | [
"firefox",
"firefox-addon"
] |
[
"Javascript return only parent object that contain a special property",
"Suppose I have an object like following:\n\nvar Obj = {\n a: {\n name: 'X',\n age: 'Y',\n other: {\n job: 'P',\n location: {\n lat: XX.XXXX,\n lng: YY.YYYYY,\n .........\n }\n }\n }\n };\n\n\nMy objective: I need a method that will check existence of a key and return its immediate parent object for any level of nesting.\n\nExample If I search for lat that method will return location object, if I search for job it will return other and so on.\n\nPlease help.\nThanks...."
] | [
"javascript",
"jquery",
"javascript-objects"
] |
[
"Use selenium WebDriver to select radio button from text",
"We've got some poorly written radio buttons on a legacy page as follows:\n\n<input id=\"button1\" name=\"button\" value=\"32\" onchange=\"assignProduct(this.value);\" type=\"radio\"></input>\nRADIO TEXT 1\n<input id=\"button2\" name=\"button\" value=\"33\" onchange=\"assignProduct(this.value);\" type=\"radio\"></input>\nRADIO TEXT 2\n\n\nfor information, this displays the same as would:\n\n<input id=\"button\" name=\"button\" value=\"32\" onchange=\"assignProduct(this.value);\" type=\"radio\">RADIO TEXT 1</input>\n<input id=\"button\" name=\"button\" value=\"33\" onchange=\"assignProduct(this.value);\" type=\"radio\">RADIO TEXT 2</input>\n\n\nThe latter code is more correct and allows selection of input button by text \"RADIO TEXT 2\" by:\n\ndriver.findElement(By.xpath(\"(//input[contains(@text, 'RADIO TEXT 2')])\")).click();\n\n\nWhat code can I use to find the radio button in the first code sample, which is what I actually have to deal with? \n\nThe text is no longer contained within the element so .xpath() doesn't match it.\n\nI need to find the text, then click the input immediately prior? Can I do this without consuming and traversing the entire page?"
] | [
"html",
"selenium",
"radio-button",
"webdriver"
] |
[
"JMeter POST/Send files after redirect",
"I have a problem with JMeter testing for File Uploads. \nI want to upload a certain XML-file. \n\nWhen I create the request to \"exampleurl.de/upload\"\nthe POST date will be only for this URL, but I want to Upload the File to the redirected Page \"exampleurl.de/upload?execution=e3s1\"\n\nBut I can't create a Request for the redirected URL.\n\nIs it possible to wait for a redirection and then send the POST request?"
] | [
"jmeter",
"spring-webflow"
] |
[
"Response for preflight has invalid HTTP status code: 401 angular",
"Using angular and Spring Boot we're trying to add authentication to our service but for some reason we can't 'open' and fetch data from an url we know works\n\nAngular: \n\nthis.getMismatches = function () {\n return $http({\n \"async\": true,\n \"crossDomain\": true,\n \"url\": GLOBALS.mismatchUrl,\n \"method\": \"GET\",\n \"headers\": {\n \"authorization\": \"Basic YWRtaW46USNROawdNmY3UWhxQDlQA1VoKzU=\"\n }\n });\n}\n\n\n(currently the login token is hard coded for testing purposes)\n\nRest service: \n\n@CrossOrigin(origins = \"*\")\n@RequestMapping(\"/api/mismatch\")\npublic List<Mismatch> home() {\n return service.getAll();\n}\n\n\nCrossOrigin = * should take care of the CORS issue but this failed URL call is really weird.\n\nExtra things we've tried:\n\n'Access-Control-Allow-Methods', 'GET, POST, OPTIONS'\n'Access-Control-Allow-Origin', '*'\n'Content-Type', json plaintext jsonp etc\n\nApp.js:\n $httpProvider.defaults.headers.common = {};\n $httpProvider.defaults.headers.post = {};\n $httpProvider.defaults.headers.put = {};\n $httpProvider.defaults.headers.patch = {};"
] | [
"javascript",
"java",
"angularjs",
"spring-boot"
] |
[
"Copying elements from one character array to another",
"I wanted to transfer elements from a string to another string, and hence wrote the following program. Initially, I thought that the for loop should execute till the NULL character (including it i.e) has been copied. But in this code, the for loop terminates if a NULL character has been found (i.e, not yet copied), but its still able to display the string in which the elements have been copied. How is this possible, if there is no NULL character in the first place?\n\n#include<stdio.h>\n#include<stdlib.h>\n\nint main()\n{\n char temp[100], str[100];\n fgets(str, 100, stdin);\n int i;\n for(i = 0; str[i]!='\\0'; i++)\n {\n temp[i] = str[i];\n }\n puts(temp);\n return 0;\n}"
] | [
"c",
"arrays",
"string",
"null",
"copying"
] |
[
"Direct reply notifications on older android versions",
"Is is possible to make notifications with direct reply on older Android versions? If it is possible can someone explain it to me. Thank you in advance."
] | [
"android",
"notifications"
] |
[
"Digitally sign multiple PDF files with an E-ID in a specified folder",
"Note: I have heavily edited most of my post as I have advanced a bit further now\n\nI am currently working on a small project: the general idea is that the user selects a folder, inserts his E-ID and all PDF files in that folder are modified with his digital signature and an image to represent this when printed.\nI am currently using the iTextSharp framework to accomplish this. But because I have to convert the source to VB.NET, I have hit a full stop.\n\nThe following code accomplishes its task of adding a digital signature to a PDF document, however. It only does so with the test-certificate I have created with Visual Studio. Anything else and the PDF just isn't created, I have checked with breakpoints and myPkcs12Store does not get filled with anything: I cannot retrieve the personal key from the eID.\n\n Private Sub Test()\n Dim myKeyStore As New X509Store(StoreName.My, StoreLocation.CurrentUser)\n myKeyStore.Open(OpenFlags.[ReadOnly])\n Dim myCertificateCollection As X509Certificate2Collection = myKeyStore.Certificates\n Dim myCertificate As X509Certificate2 = Nothing\n Dim selectedCertificates As X509Certificate2Collection = X509Certificate2UI.SelectFromCollection(myCertificateCollection, \"Certificaten\", \"Select een certificaat om te tekenen\", X509SelectionFlag.SingleSelection)\n\n If selectedCertificates.Count > 0 Then\n Dim certificatesEnumerator As X509Certificate2Enumerator = selectedCertificates.GetEnumerator()\n certificatesEnumerator.MoveNext()\n myCertificate = certificatesEnumerator.Current\n End If\n myKeyStore.Close()\n\n 'Settings'\n Dim source = \"source.pdf\"\n Dim result = \"result.pdf\"\n Dim reason = \"test\"\n Dim Location = \"locatie\"\n\n\n Dim myPkcs12Store As New Pkcs12Store()\n Using memorystreamPfx As New System.IO.MemoryStream(myCertificate.Export(X509ContentType.Pkcs12))\n myPkcs12Store.Load(memorystreamPfx, \"\")\n End Using\n\n\n For Each strAlias As String In myPkcs12Store.Aliases\n If myPkcs12Store.IsKeyEntry(strAlias) Then\n Dim pk = myPkcs12Store.GetKey(strAlias).Key\n\n Using myPdfReader As New PdfReader(source)\n Using myFileStream As New FileStream(result, FileMode.Create, FileAccess.Write)\n Using myPdfStamper As PdfStamper = PdfStamper.CreateSignature(myPdfReader, myFileStream, \"0\")\n Dim myPdfDocument As New Document(myPdfReader.GetPageSizeWithRotation(1))\n\n 'Define the digital signature appearance'\n Dim myPdfSignatureAppearance As PdfSignatureAppearance = myPdfStamper.SignatureAppearance\n myPdfSignatureAppearance.CertificationLevel = PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED\n myPdfSignatureAppearance.Image = Image.GetInstance(\"Images/poro1_by_justduet-d63wx6c.png\")\n myPdfSignatureAppearance.Reason = reason\n myPdfSignatureAppearance.Location = Location\n myPdfSignatureAppearance.SetVisibleSignature(New iTextSharp.text.Rectangle(myPdfDocument.PageSize.Width - 120, 36, myPdfDocument.PageSize.Width - 36, 96), myPdfReader.NumberOfPages, \"Digital Signature\")\n\n 'Attach digital signature to PDF document'\n Dim myExternalSignature As IExternalSignature = New PrivateKeySignature(pk, \"SHA-256\")\n MakeSignature.SignDetached(myPdfSignatureAppearance, myExternalSignature, {(myPkcs12Store.GetCertificate(strAlias).Certificate)}, Nothing, Nothing, Nothing, 0, CryptoStandard.CMS)\n End Using\n End Using\n End Using\n End If\n Next\n\n\nAny help would be appreciated! Further questions please ask\n\nbdebaere"
] | [
"vb.net",
"pdf",
"itextsharp",
"bouncycastle"
] |
[
"How to write to stdout AND to log file simultaneously with Popen?",
"I am using Popen to call a shell script that is continuously writing its stdout and stderr to a log file. Is there any way to simultaneously output the log file continuously (to the screen), or alternatively, make the shell script write to both the log file and stdout at the same time?\nI basically want to do something like this in Python:\ncat file 2>&1 | tee -a logfile #"cat file" will be replaced with some script\n\nAgain, this pipes stderr/stdout together to tee, which writes it both to stdout and my logfile.\nI know how to write stdout and stderr to a logfile in Python. Where I'm stuck is how to duplicate these back to the screen:\nsubprocess.Popen("cat file", shell=True, stdout=logfile, stderr=logfile)\n\nOf course, I could just do something like this, but is there any way to do this without tee and shell file descriptor redirection?:\nsubprocess.Popen("cat file 2>&1 | tee -a logfile", shell=True)"
] | [
"python",
"subprocess",
"popen"
] |
[
"Associative Array, Array and Tree",
"I have two questions:\nHow can the Array Abstract data type be modified to implement an Associative Array?\nHow can the tree abstract data type be modified to implement an Associative Array?"
] | [
"c++",
"arrays",
"tree",
"associative-array"
] |
[
"Problems creating Yeoman generator",
"I've tried two different approaches to creating a Yeoman generator, and both are failing. Here's where I'm currently at, but first with a couple of notes:\n\n\nyo doctor passes all tests\nI have fixed npm's permissions by changing the default install path, as detailed here.\n\n\nAttempt 1:\nI installed the generator-generator module with no errors, but executing yo generator results in the following error:\n\nmodule.js:328\nthrow err;\n^\n\nError: Cannot find module 'download'\n at Function.Module._resolveFilename (module.js:326:15)\n at Function.Module._load (module.js:277:25)\n at Module.require (module.js:354:17)\n at require (internal/module.js:12:17)\n at Object.<anonymous> (/usr/local/lib/node_modules/generator-generator/node_modules/yeoman-generator/lib/actions/fetch.js:3:16)\n at Module._compile (module.js:398:26)\n at Object.Module._extensions..js (module.js:405:10)\n at Module.load (module.js:344:32)\n at Function.Module._load (module.js:301:12)\n at Module.require (module.js:354:17)\n\n\nI took a guess and ran npm install -g download, but that didn't fix anything.\n\nAttempt 2\nI followed the steps outlined on Yeoman's Authoring page, but even after npm link resulted in a valid path to my new generator, yo boilerplate just resulted in a generator not installed error. The generator file structure is as follows:\n\ngenerator-boilerplate\n app\n index.js\n .yo-rc.json\n package.json\n\n\nThe contents of package.json are:\n\n{\n \"name\": \"generator-boilerplate\",\n \"version\": \"0.1.0\",\n \"description\": \"A Yeoman generator for a standard front-end project\",\n \"files\": [\n \"app\"\n ],\n \"main\": \"index.js\",\n \"scripts\": {\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"keywords\": [\n \"yeoman-generator\",\n \"boilerplate\"\n ],\n \"author\": \"<my name>\",\n \"license\": \"UNLICENSED\",\n \"private\": true,\n \"dependencies\": {\n \"yeoman-generator\": \"^0.22.3\"\n }\n}\n\n\nThe contents of app/index.js are (just to get something to work):\n\n'use strict';\n\nvar util = require('util');\nvar path = require('path');\nvar generators = require('yeoman-generator');\nvar chalk = require('chalk');\n\nvar Boilerplate = generators.Base.extend({\n // The name `constructor` is important here\n constructor: function () {\n // Calling the super constructor is important so our generator is correctly set up\n generators.Base.apply(this, arguments);\n\n // Next, add your custom code\n this.option('coffee'); // This method adds support for a `--coffee` flag\n },\n\n promptUser: function() {\n var done = this.async();\n\n // have Yeoman greet the user\n console.log(this.yeoman);\n\n var prompts = [{\n name: 'appName',\n message: 'What is your app\\'s name ?'\n },{\n type: 'confirm',\n name: 'addDemoSection',\n message: 'Would you like to generate a demo section ?',\n default: true\n }];\n\n this.prompt(prompts, function (props) {\n this.appName = props.appName;\n this.addDemoSection = props.addDemoSection;\n\n done();\n }.bind(this));\n }\n});\n\nmodule.exports = Boilerplate;\n\n\nAny help would be greatly appreciated. Thanks!"
] | [
"node.js",
"yeoman",
"yeoman-generator"
] |
[
"Postgres issue - Ruby on Rails (Postgres) on Google Container Engine",
"Run into a little problem and I'm hoping someone can point me in the right direction. Im running a Rails+Postgres multi-container and they start up fine, except rails shows this in the logs when I try access the IP of the LoadBalancer: \n\nPG::ConnectionBad (could not connect to server: No such file or directory\nIs the server running locally and accepting connections on\nUnix domain socket \"/var/run/postgresql/.s.PGSQL.5432\"?):\n\n\nMy two container pod files and my database.yml are as follows:\n\nRAILS POD\n\napiVersion: v1\nkind: Pod\nmetadata:\n name: cartelhouse\n labels:\n name: cartelhouse\nspec:\n containers:\n - image: gcr.io/xyz/cartelhouse:v6\n name: cartelhouse\n env:\n - name: POSTGRES_PASSWORD\n # Change this - must match postgres.yaml password.\n value: mypassword\n - name: POSTGRES_USER\n value: rails\n ports:\n - containerPort: 80\n name: cartelhouse\n volumeMounts:\n # Name must match the volume name below.\n - name: cartelhouse-persistent-storage\n # Mount path within the container.\n mountPath: /var/www/html\n volumes:\n - name: cartelhouse-persistent-storage\n gcePersistentDisk:\n # This GCE persistent disk must already exist.\n pdName: rails-disk\n fsType: ext4\n\n\n\n\nPOSTGRES POD\n\napiVersion: v1\nkind: Pod\nmetadata:\n name: postgres\n labels:\n name: postgres\nspec:\n containers:\n - name: postgres\n image: postgres\n env:\n - name: POSTGRES_PASSWORD\n value: mypassword\n - name: POSTGRES_USER\n value: rails\n - name: PGDATA\n value: /var/lib/postgresql/data/pgdata\n ports:\n - containerPort: 5432\n name: postgres \n volumeMounts:\n - name: postgres-persistent-storage\n mountPath: /var/lib/postgresql/data\n volumes:\n - name: postgres-persistent-storage\n gcePersistentDisk:\n # This disk must already exist.\n pdName: postgres-disk\n fsType: ext4\n\n\n\nDATABASE.YML FILE\n\n\nproduction:\n <<: *default\n adapter: postgresql\n encoding: unicode\n database: app_production\n username: <%= ENV['PG_ENV_POSTGRES_USER'] %>\n password: <%= ENV['PG_ENV_POSTGRES_PASSWORD'] %>\n host: <%= ENV['PG_PORT_5432_TCP_ADDR'] %>\n\n\nI assume its a linking issue, or something to do with PGDATA paths I specified?"
] | [
"ruby-on-rails",
"postgresql",
"docker",
"google-kubernetes-engine"
] |
[
"How to create ref inside react hoc using typescript without forwardedRef",
"This is my code:\nimport React, {\n InputHTMLAttributes,\n Component,\n ComponentClass,\n TextareaHTMLAttributes\n} from 'react';\n\n\n// type TElementType = HTMLInputElement | HTMLTextAreaElement;\n// type TAttributesType =\n// | InputHTMLAttributes<HTMLInputElement>\n// | TextareaHTMLAttributes<HTMLTextAreaElement>;\n\ninterface IClassType {\n somevalue: string;\n}\n\ntype TElementType = HTMLInputElement;\ntype TAttributesType = InputHTMLAttributes<HTMLInputElement>;\n\nconst withInput = (Comp: ComponentClass<TAttributesType>): ComponentClass<IClassType> => {\n class MyInput extends Component<IClassType> {\n private refValue = React.createRef<TElementType>();\n\n componentDidMount() {\n console.log('do something');\n }\n\n render() {\n return (\n <>\n <Comp\n name="someinput"\n value="somevalue"\n type="text"\n ref={ref => {\n this.refValue = ref;\n }}\n />\n </>\n );\n }\n }\n\n return MyInput;\n};\n\nexport default withInput;\n\nThis is the error on this.refValue = ref:\n\nType 'Component<TAttributesType, any, any> | null' is not assignable to type 'RefObject'.\nType 'null' is not assignable to type 'RefObject'.\n\nI have looked online and can only find examples of forwardedRefs. I do not need to forward a ref from my passed component, since the ref is only necessary within my hoc."
] | [
"reactjs",
"typescript",
"react-ref",
"react-hoc"
] |
[
"Django TypeError at /polls/1/vote/ _reverse_with_prefix() argument after * must be an iterable, not int",
"This is the polls app tutorial from the Django Docs. \n\nWhen I go to the first question http://127.0.0.1:8000/polls/1/, select an option and click 'Vote', I get the error message.\n\nerror message\n\nviews.py:\n\nfrom django.http import HttpResponseRedirect\nfrom django.shortcuts import get_object_or_404, render\nfrom django.urls import reverse\nfrom django.views import generic\n\nfrom .models import Choice, Question\n\n\nclass IndexView(generic.ListView):\n template_name = 'polls/index.html'\n context_object_name = 'latest_question_list'\n\n def get_queryset(self):\n \"\"\"Return the last five published questions.\"\"\"\n return Question.objects.order_by('-pub_date')[:5]\n\n\nclass DetailView(generic.DetailView):\n model = Question\n template_name = 'polls/detail.html'\n\n\nclass ResultsView(generic.DetailView):\n model = Question\n template_name = 'polls/results.html'\n\n\ndef vote(request, question_id):\n question = get_object_or_404(Question, pk=question_id)\n try:\n # request.POST['choice'] returns ID of the selected choice as a string\n selected_choice = question.choice_set.get(pk=request.POST['choice'])\n except (KeyError, Choice.DoesNotExist):\n # Redisplay the question voting form.\n return render(request, 'polls/detail.html', {\n 'question': question,\n 'error_message': \"You didn't select a choice.\",\n })\n else:\n selected_choice.votes += 1\n selected_choice.save()\n # Always return a HttpResponseRedirect after successfully dealing with POST data.\n # This prevents the data from being posted twice if a user hits the Back button.\n return HttpResponseRedirect(reverse('polls:results', args=question_id, ))\n\n\npolls/urls.py:\n\nfrom django.urls import path\n\nfrom . import views\n\napp_name = 'polls'\nurlpatterns = [\n path('', views.IndexView.as_view(), name='index'),\n path('<int:pk>/', views.DetailView.as_view(), name='detail'),\n path('<int:pk>/results/', views.ResultsView.as_view(), name='results'),\n path('<int:question_id>/vote/', views.vote, name='vote'),\n]\n\n\npolls/templates/polls/index.html:\n\n{% if latest_question_list %}\n <ul>\n {% for question in latest_question_list %}\n <li><a href=\"{% url 'polls:detail' question.id %}\">{{ question.question_text }}</a></li>\n {% endfor %}\n </ul>\n{% else %}\n <p>No polls are available.</p>\n{% endif %}\n\n\npolls/templates/polls/detail.html:\n\n<h1>{{ question.question_text }}</h1>\n\n{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}\n\n<form action=\"{% url 'polls:vote' question.id %}\" method=\"post\">\n {% csrf_token %}\n {% for choice in question.choice_set.all %}\n <input type=\"radio\" name=\"choice\" id=\"choice{{ forloop.counter }}\" value=\"{{ choice.id }}\"/>\n <label for=\"choice{{ forloop.counter }}\">{{ choice.choice_text }}</label><br>\n {% endfor %}\n <input type=\"submit\" value=\"Vote\"/>\n</form>\n\n\npolls/templates/polls/results.html:\n\n<h1>{{ question.question_text }}</h1>\n\n<ul>\n {% for choice in question.choice_set.all %}\n <li>{{ choice.choice_text }} -- {{ choice.votes }} vote{{ choice.votes|pluralize }}</li>\n {% endfor %}\n</ul>\n\n<a href=\"{% url 'polls:detail' question.id %}\">Vote again?</a>\n\n\nCan anyone please help?"
] | [
"python",
"django",
"django-forms",
"django-templates",
"django-views"
] |
[
"Google Fit API - International users sync issue",
"I'm using the Google Fit API Rest\nHere is the data I'm retrieving from Google Fit using the API:\n2021-03-21 29989 Steps\n2021-03-20 12 Steps\n\nHere is the data the user exported from Google:\n3/22/2021 16,480 Steps\n3/21/2021 13,521 Steps\n\nIn both circumstances, the steps equal 30,001\nThe dates are clearly off by one day because of the time zone. The daily count is also off for the same reason, however, it added up to the same steps.\nWhat general approach/strategy can I take to get the steps obtained from the API match those on Google Fit when I don't have a timezone?\nMy API currently loops through the database and syncs all user data, not distinguishing domestic vs international users.\nHere is the code snippet used to get steps:\n//***** Get steps \n case DATATYPE_STEP_COUNT_DELTA:\n if ($dataStreamId == 'derived:com.google.step_count.delta:com.google.android.gms:estimated_steps') {\n $listDatasets = $dataSets->get("me", $dataStreamId, $startTime . '000000000' . '-' . $endTime . '000000000');\n if ($debug == 1) PrintR($listDatasets,"DATATYPE_STEP_COUNT_DELTA");\n $step_count = 0;\n foreach ($listDatasets as $dataSet) {\n if ($dataSet['startTimeNanos']) {\n $sec = $dataSet['startTimeNanos'] / 1000000000;\n $activity_date = date('Y-m-d', $sec); \n $dataSetValues = $dataSet['value']; \n if ($dataSetValues && is_array($dataSetValues)) {\n foreach ($dataSetValues as $dataSetValue) {\n if(!isset($stepsArr[$studentencodedid][$activity_date])) $stepsArr[$studentencodedid][$activity_date] = 0;\n $stepsArr[$studentencodedid][$activity_date] += $dataSetValue['intVal'];\n $step_count += $dataSetValue['intVal'];\n }\n }\n }\n }\n }\n break;\n //***** End get steps"
] | [
"google-api",
"google-fit",
"google-fit-sdk"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.