texts
sequence | tags
sequence |
---|---|
[
"Turning XML nodes into PHP variables using SimpleXML on a relatively complex XML file",
"I am using simplexml_load_string in order to attempt to turn my XML file into variables I can later enter into a database however am struggling with the output working in some instances and not in others.\n\nThe xml \n\n$response ='<ndxml version=\"2.0\">\n<status code=\"OK\">\n<response function=\"createNewJob\" id=\"1\">\n <status code=\"OK\">\n <job uniqueref=\"5830z858279\" jobref=\"858279\">\n <consignment number=\"8613030\">\n <reference>16755</reference>\n <deadlinedatetime date=\"2014-01-16\" time=\"17:30:00\">\n <jobnumber>\n <labeldata styletag=\"APC\">\n <shippingdate date=\"15/01/2014\">\n <addresses>\n <address type=\"COLLECTION\">\n <company>UK Stuff and Things</company>\n </address>\n <address type=\"DELIVERY\">\n <contact>Person</contact>\n <telephone>02089636985</telephone>\n <addresslines>\n <addressline number=\"1\">Daffy</addressline>\n <addressline number=\"2\">Things</addressline>\n <addressline number=\"3\">Places</addressline>\n <addressline number=\"4\">NORTHAMPTONSHIRE</addressline>\n </addresslines>\n <postzip>NB12 1ER</postzip>\n <country isocode=\"GB\">United Kingdom</country>\n </address>\n </addresses>\n <notes>\n <account code=\"21171\">\n <tariff code=\"MP16\">\n <routing>\n <delivery>\n <route>LOCAL</route>\n <zone>B</zone>\n <driver>31</driver>\n <serviceoptions>\n </serviceoptions></delivery>\n <depots>\n <depot number=\"211\" type=\"Sending\">\n <depot number=\"211\" type=\"Request\">\n <depot number=\"211\" type=\"Delivery\">\n </depot></depot></depot></depots>\n </routing>\n <parcels total=\"1\">\n <dimensions height=\"0\" width=\"0\" length=\"0\">\n <volweight>0.0</volweight>\n <weight>0.14</weight>\n <parcel number=\"1\">\n <barcode>21163148613030001</barcode>\n </parcel>\n </dimensions></parcels>\n </tariff></account></notes></shippingdate></labeldata>\n </jobnumber></deadlinedatetime></consignment></job>\n</status>\n</response>\n\n\n\n \n\nSo I have managed to successfully grab certain elements from this by using the recommended code on the documentation:\n\n$parsed=simplexml_load_string($response);\n$response_statuscode = $parsed->status['code'];\n$response_statuscode2 = $parsed->response->status['code'];\n$response_consignment_num = $parsed->response->job->consignment['number'];\n$response_reference = $parsed->response->job->reference;\n\n\nAll of these have worked exactly as required, however from there it all goes a bit wrong for me. Things with more complicated attributes (more than one!) just don't seem to be working for me.\n\n $response_date = $parsed->response->job->deadlinedatetime['date'];\n\n\nI also tried:\n\n $parsed->response->job->deadlinedatetime->attributes()->date;\n\n\nAnd from there on I can't seem to process anything from label data properly. I am just making a mess of my understanding of the tree?\n\n $response_account_code = $parsed->response->job->labeldata->account['code'];\n\n\nAs always, thanks in advance!"
] | [
"php",
"xml",
"simplexml"
] |
[
"How can I make my wordpress theme installable?",
"I have made a basic wordpress theme and I want to be installable to other blogs. Lets suppose we have this theme:\nwp-content\n|\n|- myTheme\n|--- <theme files>\n\nHow I will export the theme and make it installable to another blogs (if possible via wp-cli too)?\nEdit1\nThe basic philosophy is to have a complete theme with translations etc etc into a zip file (including translations) where in order to upload from the dashboard in order to be able to use it."
] | [
"installation",
"wordpress-theming"
] |
[
"Is the data in a memory-mapped file guaranteed to flush sequentially?",
"I'm trying to implement a file storage mechanism which holds a number of variably-sized records in a single file with the guarantee that the set of records will always be recoverable into a consistent state, even if the system failed at a hardware level.\n\nSo far, every scheme I've come up with pivots on writing data sequentially. Some piece of data would be appended to the end of each record which confirms that the write succeeded. However, if the data is not necessarily written to the disk sequentially when flushed then it would be possible for the confirmation data to be written before the content data.\n\nThere are two obvious ways around this, but both are undesirable:\n\n\nFlush the content, then write the confirmation and flush it. Adding the extra flush may degrade performance.\nInclude a checksum in the confirmation (would require reading the content to confirm that it is valid).\n\n\nI'm using C# on Windows (32 and 64-bit) and .Net 4.0's memory mapped file implementation"
] | [
"paging",
"recovery",
"memory-mapped-files"
] |
[
"Changes in local gem does not show in the application in Rails 5",
"I am developing a gem for my application and want to see if my gem is working on a real application or not, but the problem is if I want to see the changes in the application I have to restart the server.\n\nI have googled the issue but all the solutions were either not working or relatively old (backing to rails 3 or so); is there any way to see the changes without restarting the server in rails 5?"
] | [
"ruby-on-rails",
"rubygems",
"ruby-on-rails-5"
] |
[
"converting date in to same format as it was before in codeigniter",
"I have to convert date format in to 'yyyy-mm-dd' become 'Y-M-d' \n\nthis is code: \n\n$date = '2014-12-17';\n$fleet = date('ymd', strtotime($date));\n\n\nbut output:\n\n700101\n\n\ncan you help me how to solved this problem?\n\nthank you"
] | [
"php",
"codeigniter",
"date",
"time",
"strtotime"
] |
[
"Parsing an array from recursion function C++",
"So I a little new to C++ and discovery what I can and can't do in comparison to python. Basically I have a function and inside that function I want to parse through an array and some integers run it, and return the output number. But it seems to prove a little tricky. Wondering where I am messing up. \n\nSince the function it contains in is dominated by recursion I can't just make it a global variable where the array values are static. \n\nSo here is an outline of the code\n\nvoid sequenceAlignment(int iStart,int jStart,int kStart, int seqLen1Size, int seqLen2Size, int seqLen3Size) {\n\nint lengthi = seqLen1Size - iStart;\nint lengthj = seqLen2Size - jStart;\nint lengthk = seqLen3Size - kStart;\n/* Sets it as a floor */\nint midpoint = (seqLen1Size + iStart) / 2;\n\n/*End the recursion*/\nif (lengthi <= 1)\n return;\n\n/*We set two scoring arrays and intialize the XY Plane in the 3D */\nint forwardScore[2][lengthj + 1][lengthk + 1];\nint backwardsScore[2][lengthj + 1][lengthk + 1];\n\n\n/* Some code */ and then to this \nforwardSubscoringCalculation(multidimensionalarray, int, int, int, int, int, int)\n\n\nThe Function that is being called\n\nvoid forwardSubscoringCalculation(int forwardScore, int scorei, int scorej, int scorek, int scoredArrayi, int scoredArrayj, int scoredArrayk) {\n\n int tempValueHolder = 0;\n int subscore[3] = {-10000, -10000, -10000};\n\n subscore[0] = forwardScore[scorei][scorej][scorek] + scoredArray[scoredArrayi][scoredArrayj][scoredArrayk];\n}\n\n\nI am wondering how can I exactly do this. I thought by setting up the array it also acts like a pointer and be passed through but I might screwing that up. Is it possible in this code or can it be quite tricky?\n\nEDIT Minimal Code \n\nvoid score(int, int, int, int, int, int, int);\nvoid function(int, int ,int, int, int, int)\n\n\nvoid function(int i, int j, int k, int l, int m, int n) {\n\n int forward[Number][Number][Number];\n for (x = 0; x >= l; x++){\n score(forward, i + x, j, k l, m n) \n }\n}\n\nvoid score(int array, value1, value2, value3, value4, value 5, value6){\n /* Do some stuff with the array */\n}"
] | [
"c++",
"arrays"
] |
[
"Mongodb - Query MultiKey Indexed Documents",
"My question is about the way MongoDB operates when querying MultiKey document.\n\nAssuming I have these documents:\n\n{\n a: 1,\n b: 2,\n c: ['x','y','z']\n},\n{\n a:3,\n b: null,\n c: ['x','z']\n}\n\n\nMy query is this:\n\ndb.<collection>.find({ b: null, c: 'x'})\n\n\nAnd my index is:\n\ndb.<collection>.ensureIndex({ c: 1 })\n\n\nMy question is: For the query above (that asks for c AND b), how does MongoDB invokes the query? Does it 'see' that I have an index on c or does it try to only look for an index for both c AND b ?"
] | [
"mongodb",
"indexing",
"multikey"
] |
[
"Error: Two Main Programs in Fortran",
"I'm trying to write a program with a function which returns a matrix with a random number on the diagonal, 1s on the sub-diagonals and 0s everywhere else. So, I wrote this function:\n\n real function am1d\n do i=1,L\n do j=1,L\n if (i.eq.j) then\n am1d(i,j)=rand()*w-w/2.\n elseif ((i-j.eq.1) .or. (j-i.eq.1)) then\n am1d(i,j)=1\n else am1d(i,j)=0\n enddo\n enddo\nend function am1d\n\n\nAnd tried to call it from here (in the same source file, just above the function)\n\n program make3d\n integer, parameter :: L = 20\n real, parameter :: w = 0.5\n real :: x\n\n\n !x=rand(1234) ! seed random manually\n x=rand(itime) ! seed random from current local time\n print *,am1d()(:)\n\n\nend program make3d\n\n\nBut trying to compile this throws the error:\n\n $ f95 make3d.f\nmake3d.f:18.21:\n\n print *,am1d()(:) \n 1\nError: Syntax error in PRINT statement at (1)\nmake3d.f:7.72:\n\n program make3d \n 1\nmake3d.f:24.72:\n\n real function am1d \n 2\nError: Two main PROGRAMs at (1) and (2)\n\n\nWhat does that mean? I didn't think a function could ever be a program? I've had small logical functions underneath the endprogram statement before, without any trouble."
] | [
"fortran"
] |
[
"Loading new images via AJAX don't get same jQuery properies",
"I have a web page that loads pictures in a infinity scroll typ of way. Also I have a javascript that put a animation on the picture. The problem I'm facing is that the new images that are loaded will not get the animation properties. \n\nFirst I have my Javascript code\n\n<script type=\"text/javascript\">\n\njQuery(document).ready(\n function() {\n jQuery('.scroll_container').scrollExtend(\n { \n 'target': 'div#scroll_items', \n 'url': '/popular_data.php',\n 'newElementClass' : 'mosaic-block cover2',\n 'onSuccess' : ''\n }\n );\n }\n);\n\n\n\n jQuery(function($){\n\n $('.cover2').mosaic({\n animation : 'slide', //fade or slide\n anchor_y : 'top', //Vertical anchor position\n hover_y : '40px' //Vertical position on hover\n });\n\n\n });\n\n </script>\n\n\nWhat I would like to do is that the variable OnSuccess should call the cover2 mosaic function. But my Javascript knowledge is not that good. But i think this would solve the problem.\n\nThe plugins I'm using is: \nhttp://buildinternet.com/project/mosaic/ and \nhttp://contextllc.com/tools/jQuery-infinite-scroll-live-scroll\n\nI have notice that if I append the javascript to the popular_data.php file then it will work on the second to last picture but never the last loaded picture."
] | [
"javascript",
"ajax",
"jquery",
"infinite-scroll"
] |
[
"Capybara integration tests with jquery.selectize",
"How can I write a capybara integration test with a form using jquery.selectize?\n\nI'd like to test a user entering a couple of values."
] | [
"ruby-on-rails-3",
"capybara",
"capybara-webkit",
"selectize.js"
] |
[
"How to extract layer rotation (transform) in jsx photoshop script?",
"After I use Free Transform tool to rotate layer by 90 degrees...\n\nHow do I find this value using jsx script?"
] | [
"photoshop",
"photoshop-script",
"jsx"
] |
[
"Pyinstaller 3.1.1 no --exclude-module option",
"I have a little problem with pyinstaller, version 3.1.1. I'm using it with python 3.4 (Anaconda).\nI need to compile a project excluding PyQt5 and matplotlib\n\npyinstaller --onefile --icon=Project.ico --exclude-module=PyQt5 --exclude-module=matplotlib Project.py\n\n\nbut when I try to use \"--exclude-module\" I get the following error message:\n\nUsage: pyinstaller-script.py [opts] <scriptname> [ <scriptname> ...] | <specfile>\npyinstaller-script.py: error: no such option: --exclude-module\n\n\nDid I make a mistake in writing the command?\n\nAny help is welcome.\n\nEDIT:\nThe problem was the version of pyinstaller I was using. I donwloaded the development branche from github. Now I installed the stable version from pyinstaller.org and everything is working fine... At least for the --exclude-module instruction."
] | [
"python",
"matplotlib",
"pyinstaller",
"pyqt5"
] |
[
"How to ensure that rowversion on parent updates when a child entity is modified",
"I'm building an API using Entity Framework against a SQL Server Database. I have 2 Tables/Entities like follows:\nParentTable{\n Id INT Primary Key\n RowVersion BYTE\n}\n\nChildTable{\n ParentKey INT Foreign Key (ParentTable)\n SomeField NVARCHAR\n SomeOtherField NVARCHAR\n}\n\nclass ParentEntity{\n string someOtherField\n ICollection<ChildEntity> childReference\n}\n\nOn saving the Parent object, I want to check the Rowversion to handle any concurrency issues. However I'm finding that when only child entities are modified in the parent object, that the rowversion on the parent does not change. How would I get around this?"
] | [
".net",
"sql-server",
"entity-framework-6"
] |
[
"Laravel API return 401 (Unauthorized) without Laravel Passport",
"I create api token without passport.\nFirst I added column api_token to user table. Next when user logged in I create new api token and save this token in DB.\nNext I added to api.php code:\n\nRoute::group(['middleware' => 'auth:api'], function() {\n Route::post('action', 'APIController@action');\n});\n\n\nNext I using axios to send data:\n\nconst api_token = '<?php echo $api_token ?>';\nlet options = {\n method: 'post',\n url: '/api/action',\n data: data,\n headers: {\n \"X-CSRFToken\": document.querySelector('meta[name=\"csrf-token\"]').getAttribute('content')\n },\n}\nlet params = {\n 'api_token': api_token\n}\n\naxios(options,params)\n.then(function (response) {\n console.log(response);\n})\n.catch(function (error) {\n console.log(error);\n});\n\n\nNext in AuthServiceProvider.php I added:\n\npublic function boot()\n{\n $this->registerPolicies();\n Auth::extend('token', function ($app, $name, array $config) {\n return new TokenGuard(Auth::createUserProvider($config['provider']), $app->request);\n });\n}\n\n\nI using this article.\nStill I have error:\n\n\n 401 (Unauthorized)\n\n\nEDIT:\n\nI change my axios:\n\n const api_token = '<?php echo $api_token ?>';\n let options = {\n method: 'post',\n url: '/api/action',\n data: mergedData,\n headers: {\n \"X-CSRFToken\": document.querySelector('meta[name=\"csrf-token\"]').getAttribute('content'),\n },\n params: {\n 'api_token': api_token\n }\n }\n axios(options)\n .then(function (response) {\n console.log(response);\n })\n .catch(function (error) {\n console.log(error);\n });\n\n\nNow I send token in GET, but I still have error:\n\n\n http://127.0.0.1:8000/api/action?api_token=b005413b-3197-48ac-8747-32bbcf8b858f 401 (Unauthorized)"
] | [
"php",
"laravel",
"api",
"authentication",
"token"
] |
[
"Read account email with batch",
"I am trying to connect every user account at login with our shared storage. \nThis works fine with the command in CMD:\n\nnet use \\\\NAS /USER:[email protected] passwordhere\n\n\nAs we are using AzureActiveDirectory, I will need an email to connect to our shared storage. How can I read the email of the current user to replace it with the example adress? This all should happen in a batch file as there are also plenty of other lines already written. (Also without admin permissions if possible).\n\nThanks,\nMax"
] | [
"azure",
"email",
"batch-file",
"network-drive"
] |
[
"How to set Blur background when dialog create",
"How to set Blur background when dialog create?\n\nI found DialogFragment only and AlertDialog but I want to set in Dialogin activity\n\nHow to create it or What's library recommend?\n\nfinal Dialog dialog = new Dialog(this);\n dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);\n Window window = dialog.getWindow();\n window.setBackgroundDrawableResource(android.R.color.transparent);\n window.setLayout(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);\n dialog.setContentView(R.layout.register_policy_dialog);"
] | [
"java",
"android",
"dialog",
"blur"
] |
[
"SweetAlert, Focusing an input after Confirm",
"Basically I have a form where you can add an User.\n\n<div class=\"container\">\n <div><h1>Formulario para agregar Usuarios</h1></div>\n <form id='addForm' role=\"form\" method=\"POST\">\n <div class=\"form-group col-lg-6\">\n\n <div class=\"form-group \">\n <label for=\"nombre\">Nombre:</label>\n <input class=\"form-control\" type=\"text\" id=\"nombre\" name=\"nombre\" maxlength=\"15\" placeholder=\"Ingrese su Nombre\"/>\n <div id=\"nom\" name=\"nom\"></div>\n </div>\n <div class=\"form-group\">\n <label for=\"apellido\">Apellido:</label> \n <input class=\"form-control\" type=\"text\" id=\"apellido\" name=\"apellido\" maxlength=\"15\" placeholder=\"Ingrese su Apellido\" />\n <div id=\"ape\" name=\"ape\"></div>\n </div>\n <div class=\"form-group\">\n <label for=\"correo\">Correo:</label>\n <input class=\"form-control\" type=\"email\" id=\"correo\" name=\"correo\" maxlength=\"30\" placeholder=\"[email protected]\"/>\n <div id=\"cor\" name=\"cor\"></div>\n </div>\n <div class=\"form-group\">\n <label for=\"password\">Contraseña:</label> \n <input class=\"form-control\" type=\"password\" id=\"password\" name=\"password\" maxlength=\"15\" placeholder=\"Ingrese una Contraseña (mínimo 6 caracteres)\" />\n <div id=\"pas\" name=\"pas\"></div>\n </div> \n <div class=\"form-group\">\n <button class=\"btn btn-default col-sm-2\" id=\"addUser\" name=\"addUser\" type=\"submit\" >\n <span class=\"glyphicon glyphicon-plus-sign\"></span> Agregar</button>\n </div>\n\n <div class=\"form-group col-sm-8\" id=\"userData\" name=\"userData\"></div> \n\n </div>\n\n\nAfter success a sweet alert appears on screen telling you the add worked.\n\nBefore the swal I had a normal alert, and after showing success It would focus on the first input of the form.\n\nBut now when the swal shows up, It gives the focus while swal's on screen and when you click the confirm button the focus is gone.\n\nI tried to set onConfirmButton to false and then add a function\n\n$.post('agregar.php', {nombre: nombre, apellido: apellido, correo: correo, password: password}, function(data) {\n //Se recibe un resultado (data) y se muestra en el div\n //(que en este caso sería una cadena string con algún mensaje)\n if (data=='1') {\n //swal(\"¡Hecho!\", \"¡Has Agregado un Usuario Nuevo!\", \"success\");\n swal({\n title: \"¡Hecho!\",\n text: \"¡Has Agregado un Usuario Nuevo!\",\n closeOnConfirm: false\n },\n function(){\n swal.close();\n $('#nombre').val('')\n $('#apellido').val('');\n $('#correo').val('');\n $('#password').val('');\n $('#nombre').focus();\n\n })\n );\n\n\nBut it just doesn't work."
] | [
"javascript",
"jquery",
"focus",
"confirm",
"sweetalert"
] |
[
"java mysql nested search implementation",
"I need to implement Nested Search (mean to say search records within previously searched records) using mysql/java code.\nFor example, First I searched a table with condition(firstname like '%abc%') and I got 1000 rows for that, Now I want to apply the new search condition (lastname like '%xyz%') on those 1000 rows only not for all rows in that table. \n\nCan anyone let me know how to implement this?\nIs there any feature provided by DB(mysql) itself for this?\n\nAs i mentioned user applies second search on records received from first search result, it's not like user gives both the inputs simultaneously and Second search is not predictable it can be any search on any column.\n\nThanks in advance."
] | [
"java",
"mysql",
"search",
"nested"
] |
[
"vb.NET DLL Registration Free COM with VB6",
"I'm trying to get the simplest Registration Free COM project to work in 64bit Windows7!\nThe COM component is also the simplest vb.NET DLL that works fine from the VB6 EXE when its registered.\n\nCan anyone suggest why the manifests are not working please?\n\nI have already tried to update any VB6 internal Manifest with mt.exe but the general error indicates that there is no internal manifest in Project2.exe\n\nThe VB6 program (Project2.exe) manifest is....\n\n\n \n \n\n <assemblyIdentity name=\"Project2.exe\" version=\"1.0.0.0\" type=\"win32\" processorArchitecture=\"x86\"/>\n\n <dependency>\n <dependentAssembly>\n <assemblyIdentity name=\"ClassLibrary1\" version=\"1.0.0.0\" type=\"win32\"/>\n </dependentAssembly>\n </dependency>\n\n </assembly>\n\n\nAnd the DLL (ClassLibrary1.dll) manifest is.....\n \n \n\n <assemblyIdentity name=\"ClassLibrary1\" version=\"1.0.0.0\" type=\"win32\"/>\n\n <clrClass\n name=\"ClassLibrary1.Class1\"\n clsid=\"{D9531C2A-3822-4222-8D45-BC507FCDF5F3}\"\n progid=\"ClassLibrary1.Class1\"\n threadingModel=\"Both\"/>\n\n <file name=\"ClassLibrary1.tlb\">\n <typelib\n tlbid=\"{DA8A00C1-1E14-4295-AEDE-F8F23DD8E43D}\"\n version=\"1.0\"\n helpdir=\"\"\n flags=\"hasdiskimage\"/>\n </file>\n\n </assembly>"
] | [
"vb6",
"com-interop"
] |
[
"Missing crash logs for iOS unit test runs in test result bundle",
"I am running a large unit test suite on CircleCI using Xcode 10.1, with fastlane executing the test run.\n\nAfter some recent code changes, it seems the tests crash, once, and the test run is restarted, after which it completes. The crashes have happened while running different tests each time, but only one test per run crashes.\n\nThere is little to no useful output in the console about why the crash occurred. Based on WWDC 2016 session 409, I would expect to see crash (diagnostic) logs in the xcresult bundle produced by the tests, but I can't find them.\n\nIs this something specific to Xcode Server, which they use in the WWDC demo? Is there some flag or environment variable that needs to be set to make these get saved in other environments?"
] | [
"ios",
"xcode",
"unit-testing",
"fastlane"
] |
[
"Workers doesn't work in HTML page embedded in WPF project",
"When executing scripts in an HTML page, the page becomes unresponsive until the script is finished.\nThus I want to use workers.\nI have a problem:\n\n<html>\n<head>\n</head>\n<body>\n<button onclick=\"startWorker()\">Start Worker</button> \n<button onclick=\"stopWorker()\">Stop Worker</button>\n<br><br>\n\n<script>\n var w;\n\n function startWorker()\n {\n if (typeof (Worker) !== \"undefined\")\n {\n if (typeof (w) == \"undefined\")\n {\n // Do something\n }\n }\n else\n {\n alert(\"Browser does not support Web Workers.\");\n }\n }\n\n function stopWorker()\n {\n w.terminate();\n w = undefined;\n }\n</script>\n</body>\n</html>\n\n\nI get the \"Browser does not support Web Workers.\" message.\n\nIs there other way to use multithreading so the page becomes responsive before the script is finished?\n\nThanks a lot,\nOrian."
] | [
"javascript",
"html",
"wpf",
"multithreading"
] |
[
"image.style.left is not working javascript",
"Getting an error saying too much recursion. The actually has to move the image. Its giving the same error even if I am trying to clear the timeout. \n\nNote: I found out that the_image.style.left is not moving the image whatsoever.\n\n<!DOCTYPE HTML>\n<html>\n<head>\n<style>\n.image_style{left:x}\n</style>\n<script>\nvar the_timer, x_position = 0, my_image;\nfunction move_image(){\n my_image = document.getElementById(\"imag\");\n x_position = x_position+1;\n my_image.style.left = x_position;\n the_timer = setTimeout(move_image(), 200);\n}\n</script>\n</head>\n<body onclick=\"move_image()\">\n<img src = \"desert.jpg\" id = \"imag\"\n style=\"position:obsolute; width:300px; height:400px; left:0\">\n <script>\n my_image = document.getElementById(\"imag\");\n alert(my_image.style.left);\n </script>\n</body>\n</html>"
] | [
"javascript",
"html",
"css"
] |
[
"Youtube iframe API unclear 'postMessage' on 'DOMWindow' origin issue",
"I have the following functional youtube iframe.\n\n<iframe width=\"100%\" height=\"100%\" \n src=\"//youtube.com/embed/93HWMspjxqI?autoplay=0&origin=http://site.dev&enablejsapi=1\" \n frameborder=\"0\" id=\"video-93HWMspjxqI\">\n</iframe>\n\n\nI want to bind to a video close event. This seems to be determined by onStateChange event from the youtube iframe_api. \n\nReading the docs, I found out how to wrap a player object on top of an existing iframe by doing this:\n\nvar player = new YT.Player(\"video-\"+youtubeParser.getYouTubeIdFromUrl(videoUrl), {\n events : {\n onStateChange : function () {\n console.log(\"state change\");\n }\n }\n});\n\n\nInspecting the console, I see that my video object is created correctly. \n\n\n\nHowever, I am getting insane numbers of errors with the following message:\n\n\n\nI tried adding the following parameters in my player initialization:\n\n var player = new YT.Player(\"video-\"+videoUrl, {\n playerVars : {\n origin : window.location.protocol + \"//\"+window.location.host,\n enablejsapi : 1\n },\n events : {\n onStateChange : function () {\n console.log(\"state change\");\n }\n }\n });\n\n\nThis still doesn't work. The same origin error shows up. Why? It doesn't seem to be a local hosting problem. I isolated the problem in this jsfiddle code : http://jsfiddle.net/srrbqfnm/1/"
] | [
"javascript",
"iframe",
"youtube",
"youtube-javascript-api"
] |
[
"CSS for setting overflow to scroll not working",
"I have a div using the following class:\n\ndiv.textStatement\n{\n height: 70px;\n overflow: hidden;\n}\n\n\nWhen the user clicks a link ('Show More'), the div expands to show more text and the 'overflow' should get set to 'scroll' so that the user can read all the text, in the event there is more text than the height of the div will show. However, the reference to the 'overflow' property of the div is coming back 'undefined' so that I can't set it to 'scroll.' Any idea why the ref to the div's overflow is coming back 'undefined'? I think that would fix the problem (and make the scrollbars show up).\n\nHere's the div:\n\n<asp:Panel ID=\"textStatement\" class=\"textStatement\" runat=\"server\"></asp:Panel>\n<label id=\"candidateStatementShowMoreLess\" class=\"MoreLess\" onclick=\"ShowMoreLess(this)\">Show More</label>\n\n\nHere's the javascript (using jQuery):\n\nvar IsStatementExpanded = false;\nvar IsDescriptionExpanded = false;\n\nfunction ShowMoreLess(moreLessLink)\n{\n var section = $(moreLessLink).prev(\"div\");\n var sectionId = $(section).attr(\"id\");\n var collapsedHeight = 70;\n var expandedHeight = 300;\n\n if (section.height() == collapsedHeight)\n {\n section.animate({ height: expandedHeight }, 500,\n function ()\n {\n $(moreLessLink).html(\"Show Less\");\n\n // ***** This should be setting the overflow to scroll on the div, but isn't, as \"attr\" is coming back undefined. *****\n section.attr(\"overflow\", \"scroll\");\n });\n\n if (sectionId == \"textStatement\")\n {\n IsStatementExpanded = true;\n }\n else if (sectionId == \"textDescription\")\n {\n IsDescriptionExpanded = true;\n }\n }\n else\n {\n section.animate({ height: collapsedHeight }, 500,\n function ()\n {\n $(moreLessLink).html(\"Show More\");\n\n // ***** This could have the same problem as above, but when the user collapses the div. *****\n section.attr(\"overflow\", \"hidden\");\n });\n\n if (sectionId == \"textStatement\")\n {\n IsStatementExpanded = false;\n }\n else if (sectionId == \"textDescription\")\n {\n IsDescriptionExpanded = false;\n }\n }\n}"
] | [
"jquery",
"html",
"css"
] |
[
"rdkafka 0.8.1 ERROR: Failed to build gem native extension",
"I'm runnning bundle install Then I get this error:\nFetching rdkafka 0.8.1\nInstalling rdkafka 0.8.1 with native extensions\nGem::Ext::BuildError: ERROR: Failed to build gem native extension.\n\nExtracting v1.4.0 into tmp//ports/librdkafka/1.4.0... OK\nRunning 'configure' for librdkafka 1.4.0... ERROR, review '/Users/codegeek/.rvm/gems/ruby-2.5.1@ls-member/gems/rdkafka-0.8.1/ext/tmp/ports/librdkafka/1.4.0/configure.log' to see what happened. Last lines are:\n========================================================================\nsource: \n#include <sys/types.h>\n#include <sys/socket.h>\n#include <unistd.h>\nvoid foo (void) {\n int s = socket(0, 0, 0);\n close(s);\n}\n\n libpthread () \n module: self\n action: fail\n reason:\ncompile check failed:\nCC: CC\nflags: -lpthread\n -g -O2 -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wall -Werror _mkltmpVFiBMn.c -o _mkltmpVFiBMn.c.o -lpthread:\nmklove/modules/configure.base: line 1349: -g: command not found\nsource: #include <pthread.h>\n\nBut then it will suggest to do:\nMake sure that `gem install rdkafka -v '0.8.1' --source 'https://rubygems.org/'` succeeds before bundling.\n\nSo I'll run gem install rdkafka -v '0.8.1' --source 'https://rubygems.org/' but then\nit will produce an error too\nBuilding native extensions. This could take a while...\nERROR: Error installing rdkafka:\n ERROR: Failed to build gem native extension.\n\nPlease help. Thanks!"
] | [
"ruby-on-rails",
"ruby"
] |
[
"Codeigniter RESTful API - {\"status\":false,\"error\":\"Unknown method.\"}",
"I've managed to setup the RESTful API in my Codeigniter Application. Now I want to get some data from my MySQL database, so in my Codeigniter models folder I have created a model called category_model.php:\n\n<?php\n Class category_model extends CI_Model {\n var $table_name = 'category';\n\n function get_all_categories()\n {\n $this->db->select('*');\n $this->db->from($this->table_name);\n return $this->db->get();\n }\n }\n?>\n\n\nThen in the Codeigniter controller-folder I created a category.php file:\n\n<?php\n\n include(APPPATH.'libraries/REST_Controller.php');\n\n class Category extends REST_Controller {\n\n function __construct()\n {\n parent::__construct();\n $this->load->model('category_model');\n }\n\n function category_get()\n {\n $data = $this->category_model->get_all_categories();\n $this->response($data);\n }\n\n }\n\n?>\n\n\nNow, when I enter http://localhost/myproejcts/ci/index.php/category/category - I get the error {\"status\":false,\"error\":\"Unknown method.\"} ??\n\nwhat is the issue?\n\n[UPDATE] = I get the same error when setting function index_post()"
] | [
"php",
"mysql",
"codeigniter",
"rest"
] |
[
"Execute SQL Server request in the callback of an HttpWebRequest",
"My understanding is that two HttpWebRequest callback can be executed at the same time because the request are asynchronous. However, I want to work with the database on the callback, and it seems not possible with SQL Server. What is the best practice in this case ? Is there a way to add these requests to a queue, or should I use something like mutexes (which I would prefere to avoid, since deadlocks are difficult to debug) ?\n\nedit: My current code doesn't do anything special to prevent that. I fire multiple (different) requests and sometimes in one of the callbacks I get a exception thrown (\"Invalid Cross Thread Access\") when I try to submit the changes to the database.\n\nI tried to use Dispatcher.BeginInvoke but now I have doubts that it's doing what I want after some googling (I used Dispatcher.BeginInvoke before successfuly when accessing elements in my XAML, so I thought it could fix my problem accessing the db)"
] | [
"windows-phone-7"
] |
[
"REST API and authentication or not?",
"I'm asking questions about developping application from scratch and I have some troubles : \nI'll have a front-end part (Angular) and a backend, they will classically communicate throught REST API on backend.\nAnd for the context : this application (front + back) will be deploy on each equipment which want to use application, so there is no public global server API.\n\nThe question is : do I need in this context to authenticate requests made to backend ? \nOr do I have to consider that being local webservices no authentication is required ? And if I have to, knowing that Rest application must be stateless, should I use OAuth(with a little state part) + JWT excluding HTTP Session authentication ?\n\nThank you so much, there is some concepts I do not understand.\n\nEdit : globally, the question is when to develop a simple REST application and when to develop authentication part for security ?"
] | [
"angular",
"rest",
"oauth-2.0",
"spring-security-oauth2",
"restful-authentication"
] |
[
"DataProc is taking more than 3 hrs to process than expected less than 15 mins",
"I have migrated a portion of C application to process on DataProc using PySpark Jobs (Reading and writing into Big Query - Amount of data - around 10 GB) . The C application that is running in 8 minutes in local data centre taking around 4 Hrs on Data Proc . Could someone advise me the optimal Data Proc configuration ? At present I am using below one :\n--master-machine-type n2-highmem-32 --master-boot-disk-type pd-ssd --master-boot-disk-size 500 --num-workers 2 --worker-machine-type n2-highmem-32 --worker-boot-disk-type pd-ssd --worker-boot-disk-size 500 --image-version 1.4-debian10\nWill really appreciate any help on optimal dataproc configuration .\nThanks,\nRP"
] | [
"performance",
"google-cloud-platform",
"google-cloud-dataproc",
"data-processing",
"dataproc"
] |
[
"using and(&&) operator in for loop in linux",
"01) I am trying to use the && operator in a for loop as shown below in the script. However this does not seem to work. I was not able to see the error generated in the terminal window, since it closes as soon as it runs in to an error. Could someone please tell me what I'm doing wrong?\n\n#!/bin/bash\n\ncd ~/Documents/DTI/\n\n#subj and subj1 contain folders which are located in the DTI directory\nsubj=\"ARN MT\"\nsubj1=\"ARNpre1 ARNpre2\"\n\nfor [[s in $subj] && [s1 in $subj1]]\n\n\n02) And as you can see in my \"subj1\", the first two entries start with the letters ARN which means that they are sub directories of ARN(located in a different place.Not in ARN main directory). So I also want to run a command in which, if subj1 contains subj then it must perform a certain command.For this purpose I wrote the following,\n\nif [[ ${s1} == *\"${s}\"* ]];then\n\n\nwould this be the right way to do such operation?\n\nI would greatly appreciate any help.\n\nThank you in advance."
] | [
"linux",
"for-loop",
"and-operator"
] |
[
"Initialize a private static field outside the class (the meaning of private in this case) and calling to static functions",
"If I will define a private static field in class. Given that it's a private field, can't I initialize it outside the class?\n\nclass X{\n static int private_static_field;\npublic:\n static void setPrivateStaticField(int val);\n};\n\nvoid X::setPrivateStaticField(int val) {\n private_static_field = val;\n}\n\n\nint X::private_static_field(0); // something like that it's ok? if yes, I must write this line? why? can I write it in main?\n\n\nIt's look that it's ok (according to the compiler), but if so, I don't understand the concept of private - How it's ok if it's outside the class?\n\n\n\nIn addition, given the class above, and the next code: \n\nint main() {\n X x1();\n x1.setPrivateStaticField(3);\n return 0;\n}\n\n\nWhat is the meaning of x1.setPrivateStaticField(3); , after all, this function is static and hence it's not related to some object.\nHence, I don't understand how it's ok to call setPrivateStaticField with object (x1) ?\n(I thought that just X::setPrivateStaticField(3); will be ok and that x1.setPrivateStaticField(3); will be error)"
] | [
"c++",
"class",
"static",
"private"
] |
[
"Converting to NotificationCompat breaks SetSmallIcon functionality?",
"I've been having some trouble moving Notification to the Compat library version: In the main library, I used to just convert an icon to a bitmap (api 23 and up) and do SetSmallIcon(icon) to show a dynamic notification icon.\n\nBut the Compat version has only an int argument (I assume it is the resource ID), and I cannot find any information as to how to generate/convert/add my bitmap and/or icon in it.\n\nThe bitmap Is basically generated text converted into a bitmap via a canvas which show the most vital information.\n\nMy question is: Is there a way to make a class variable into a resource, or get its ID that works like a resoource ID, or some other hack that will allow me to actually add my bitmap that I create at runtime?"
] | [
"xamarin",
"notifications"
] |
[
"React can't render array from component",
"I have this component with some menu. In here there is some array iteration of menu items. I want to import this component to other main one but i'm receiving this error - A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.. When i'm remove this array iteration and leave simple link everything is fine. What is wrong?\n\ncomponent:\n\nconst LandingMenu = (props) => {\n return (\n props.data.map((element, _) =>\n <Link class=\"link\" href={ element.target }>{ element.name }</Link>\n )\n )\n};\n\nexport default LandingMenu;\n\n\nimport \n\n<LandingMenu data={LANDING_CONTENT.menu} />"
] | [
"javascript",
"arrays",
"reactjs",
"ecmascript-6",
"redux"
] |
[
"Share axis from one of multiple subplots",
"I have subpolts with a size of 5*4,I am using Loop to write data on them. I'd like to share the x and y-axis for all of them from two specific subplots. If I use sharex or sharey = True, they only share the xy from the last subplot. How could I do it?\nbasedir = Path(r"D:\\Brown research\\Task2 site selection\\All_excel")\nfig, axes = plt.subplots(5, 4, figsize=(10, 10))\nfor xlfile, ax in zip(basedir.glob("*.xlsx"), axes.flat):\n df = pandas.read_excel(xlfile) \n x = newdf['slope'] \n y = newdf['AI']\n nbins = 10\n cm = ax.hist2d(x,y,nbins,cmap=plt.cm.coolwarm, cmin=1,norm=mpl.colors.LogNorm())\n#may add some code here to share y from subplot(5,4,13) and share x from subplot(5,4,20)\nplt.savefig("AI_Slopew_sharexy.png", dpi=300)"
] | [
"python"
] |
[
"Get hex code from x86 Assembly code on Python",
"By CAPSTONE/pydasm library, I can generate assemble code from hex code. but I want to assemble code(x86). not dissemble.\n\nI want to get hex code from assemble code with code base. Is there any library to assemble on Python?"
] | [
"python",
"assembly",
"x86"
] |
[
"Not able to filter Null values before calling a UDF in pyspark",
"I have a data frame and want to call a sample pyspark udf which would subtract integer 1 from each row (this is just to demonstrate the issue which I am facing). \n\n+------+\n|number|\n+------+\n| 1|\n| 2|\n| 3|\n| 4|\n| null|\n+------+\n\n\nI have created below udf :\n\nfrom pyspark.sql import functions as f\n\ndef test1(x):\n return x-1\n\ntest1 = f.udf(test1, IntegerType())\n\n\nI am trying to cal this udf as below :\n\ndf1 = df.withColumn('test', f.when(f.col('number').isNotNull(),test1(f.col('number'))))\n\n\nI was expecting that my udf would only be called when the value is not null, however, I am getting below error:\n\n---------------------------------------------------------------------------\nPy4JJavaError Traceback (most recent call last)\n<command-3906152203954731> in <module>()\n----> 1 df1.show()\n\n/databricks/spark/python/pyspark/sql/dataframe.py in show(self, n, truncate, vertical)\n 377 \"\"\"\n 378 if isinstance(truncate, bool) and truncate:\n--> 379 print(self._jdf.showString(n, 20, vertical))\n 380 else:\n 381 print(self._jdf.showString(n, int(truncate), vertical))\n\n/databricks/spark/python/lib/py4j-0.10.7-src.zip/py4j/java_gateway.py in __call__(self, *args)\n 1255 answer = self.gateway_client.send_command(command)\n 1256 return_value = get_return_value(\n-> 1257 answer, self.gateway_client, self.target_id, self.name)\n 1258 \n 1259 for temp_arg in temp_args:\n\n/databricks/spark/python/pyspark/sql/utils.py in deco(*a, **kw)\n 61 def deco(*a, **kw):\n 62 try:\n---> 63 return f(*a, **kw)\n 64 except py4j.protocol.Py4JJavaError as e:\n 65 s = e.java_exception.toString()\n\n/databricks/spark/python/lib/py4j-0.10.7-src.zip/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)\n 326 raise Py4JJavaError(\n 327 \"An error occurred while calling {0}{1}{2}.\\n\".\n--> 328 format(target_id, \".\", name), value)\n 329 else:\n 330 raise Py4JError(\n\nPy4JJavaError: An error occurred while calling o4509.showString.\n: org.apache.spark.SparkException: Job aborted due to stage failure: Task 2 in stage 123.0 failed 1 times, most recent failure: Lost task 2.0 in stage 123.0 (TID 353, localhost, executor driver): org.apache.spark.api.python.PythonException: Traceback (most recent call last):\n File \"/databricks/spark/python/pyspark/worker.py\", line 480, in main\n process()\n File \"/databricks/spark/python/pyspark/worker.py\", line 472, in process\n serializer.dump_stream(out_iter, outfile)\n File \"/databricks/spark/python/pyspark/serializers.py\", line 456, in dump_stream\n self.serializer.dump_stream(self._batched(iterator), stream)\n File \"/databricks/spark/python/pyspark/serializers.py\", line 149, in dump_stream\n for obj in iterator:\n File \"/databricks/spark/python/pyspark/serializers.py\", line 445, in _batched\n for item in iterator:\n File \"<string>\", line 1, in <lambda>\n File \"/databricks/spark/python/pyspark/worker.py\", line 87, in <lambda>\n return lambda *a: f(*a)\n File \"/databricks/spark/python/pyspark/util.py\", line 99, in wrapper\n return f(*args, **kwargs)\n File \"<command-3906152203954725>\", line 7, in test1\nTypeError: unsupported operand type(s) for -: 'NoneType' and 'int'\n\n\nCan somebody please explain this behavior of Pyspark?\n\nThanks\n\nI have tried rewriting the udf as below and this works\n\ndef test(x):\n if x is None:\n return None\n else: return x -1"
] | [
"python",
"pyspark",
"apache-spark-sql"
] |
[
"pgAdmin - Create Script for db including all schemas and tables?",
"Is there a way to a CREATE Script recursive in pgAdmin where you could right-click on the db and it would give you the CREATE Scripts for the db and all of its schemas and tables in one shot?\nI know I can right-click on a db, schema or table and generate a create script for that one particular thing, but in a db with dozens of tables it becomes a tedious cut and paste chore if you want to save all the necessary scripts."
] | [
"postgresql",
"pgadmin"
] |
[
"Getting two or more images ids from the same column",
"I got a MySQL table with one or more comma separated numbers in it. Those numbers refer to ID's in another MySQL table, witch also includes the name of a image.\n\nI want to select a row where the field \"images\" contains \"1,43\" and display the two images with ID 1 and 43 from the 2nd table.\n\nDo I have to have the two numbers in differents fields? I'd prefer keep them in the same one."
] | [
"php",
"mysql"
] |
[
"Dereferencing a void pointer who points to another pointer",
"I'm attempting to understand C depplier and in one of my nirvanenses meditations got this question \"how to dereferencing a void pointer that points to another kind of pointer\", I guess it could get clearer with the next code:\n\nint a,b,*p1,*p2;\nvoid *p;\na=3;\nb=6\np1=&a;\np2=&b\np=&p1;\n*p=p2 //How I could be able to do this?\n\n\nSo in the above code I want that p1 points at the same value that points p2 using as an intermediate p. I know it could be better just doing p1=p2 but I want to know if what I wrote above it's possible"
] | [
"c",
"pointers"
] |
[
"How does EMV encrypt the contactless transaction?",
"I try to figure out what kind of encryption the EMV standardization recommends for transferring payment information via NFC. I browsed through the specification, but I can't find any hint about this topic. I know though that the card manufacturer provides some encryption technology on their card itself, which has partly been compromised.\nDoes someone know, if its encrypted at all (I hope so) and if so, with which technology?"
] | [
"encryption",
"nfc",
"payment",
"contactless-smartcard",
"emv"
] |
[
"Java Socket: receiving wrong boolean",
"I have a client/server architecture that sends class-instances via sockets.\n\nIn one class I have a boolean:\n\npublic class Survey implements Serializable {\n private static final long serialVersionUID = -1156493488498723461L;\n private boolean isExpired;\n\n public Survey() {\n this.isExpired = false;\n }\n\n public void markAsExpired() {\n this.isExpired = true;\n }\n\n public boolean isExpired() {\n return isExpired;\n }\n}\n\n\nThe part where I send the packet:\n\nsurvey.markAsExpired();\nHashMap<Header, Object> packet = new HashMap<Header, Object>();\npacket.put(header, survey);\n\nSystem.out.println(survey.isExpired()); // prints true\ntry {\n socketOutput.writeObject(packet);\n socketOutput.flush();\n} catch (IOException e) {\n e.printStackTrace();\n}\n\n\nWhen I send that class with the boolean set to true (see above), the client always receives it as false. \n\nWhere does this come from?"
] | [
"java",
"sockets"
] |
[
"jQuery $(document).ready () fires twice",
"I've been sifting around the web trying to find out whats going on here and I have not been able to get a concrete answer.\n\nI have one $(document).ready on my site that seams to run multiple times regardless of the code that is inside it.\n\nI've read up on the bug reports for jQuery about how the .ready event will fire twice if you have an exception that occurs within your statement. However even when I have the following code it still runs twice:\n\n$(document).ready(function() {\n try{ \n console.log('ready');\n }\n catch(e){\n console.log(e);\n }\n});\n\n\nIn the console all I see is \"ready\" logged twice. Is it possible that another .ready with an exception in it would cause an issue? My understanding was that all .ready tags were independent of each other, but I cannot seem to find where this is coming into play?\n\nHere is the head block for the site:\n\n<head>\n<title>${path.title}</title>\n<meta name=\"Description\" content=\"${path.description}\" />\n<link href=\"${cssHost}${path.pathCss}\" rel=\"stylesheet\" type=\"text/css\" />\n<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\" type=\"text/javascript\" charset=\"utf-8\"><!----></script>\n<script src=\"media/js/fancybox/jquery.fancybox.pack.js\" type=\"text/javascript\" ><!-- --></script>\n<script src=\"/media/es/jobsite/js/landing.js\" type=\"text/javascript\" ><!-- --></script>\n<script src=\"/media/es/jobsite/js/functions.js\" type=\"text/javascript\"><!-- --> </script>\n<script src=\"/media/es/jobsite/js/jobParsing.js\" type=\"text/javascript\" charset=\"utf-8\"><!----></script>\n<script src=\"/media/es/jobsite/js/queryNormilization.js\" type=\"text/javascript\" charset=\"utf-8\"><!----></script>\n<script src=\"${jsHost}/js/jquery/jquery.metadata.js\" type=\"text/javascript\" charset=\"utf-8\"><!----></script>\n<script src=\"${jsHost}/js/jquery/jquery.form.js\" type=\"text/javascript\" charset=\"utf-8\"><!----></script>\n<script src=\"http://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/jquery.validate.min.js\" type=\"text/javascript\" charset=\"utf-8\"><!----></script>\n<script src=\"${jsHost}/js/jquery.i18n.properties-min.js\" type=\"text/javascript\" charset=\"utf-8\"><!----></script>\n\n<script type=\"text/javascript\" charset=\"utf-8\">\n\nfunction updateBannerLink() {\n var s4 = location.hash.substring(1);\n $(\"#banner\").attr('href','http://INTELATRACKING.ORG/?a=12240&amp;c=29258&amp;s4='+s4+'&amp;s5=^');\n}\n\n</script>\n</head>\n\n\nPay no attention to the JSP variables, but as you can see i'm only calling the functions.js file once (which is where the .ready function exists)"
] | [
"javascript",
"jquery",
"jquery-events",
"document-ready"
] |
[
"greenscript LESS @imports relative path",
"I have a question about relative paths for '@import' statements for the play! framework's greenscript module. Specifically, I have a 'main.less' file which imports all of my other less files via this syntax:\n\n @import \"variables.less\";\n @import \"mixins.less\";\n @import \"stuff.less\";...\n\n\nIn dev mode, these files all return 404s, and they are being looked for in the greenscript minimized directory ('public/gs' by default). Does anyone know how to have them imported relative to main.less? Thanks for your help!"
] | [
"playframework",
"less",
"greenscript"
] |
[
"Error adding listview items",
"Listview items stopped getting updated on my list automatically. I did not have to use notifydatasetchanged() when adding list items and it was getting updated without refreshing the screen. But after adding a database reference to my code, the listview updates only when I lock and unlock my phone. I tried commenting out the databsereference code, but it still doesn't seem to work. Any suggestions?\n\nUPDATE: I have attached the code below. After using notifydatasetchanged() the list gets automatically updated but all the listview items change to the most recently added item.\n\n ListView=findViewById(R.id.swipemenu);\n HashMap<String,String> item = new HashMap<String,String>();\n ArrayList<HashMap<String,String>> list=new \n ArrayList<HashMap<String,String>>();\n SimpleAdapter adapter=new SimpleAdapter(this, list,\n R.layout.simplelist,\n new String[] { \"line1\",\"line2\" },\n new int[] {R.id.text1, R.id.text2});\n ListView.setAdapter(adapter);\n\n item.put( \"line1\",result.getContents() );\n item.put( \"line2\",\"Qty:1\" );\n list.add( item );\n adapter.notifyDataSetChanged();\n\n\n\n @Override\nprotected void onActivityResult(int requestCode, int resultCode, Intent data) {\n IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);\n if (result != null) {\n if (result.getContents() == null) {\n Toast.makeText(this, \"Result Not Found\", Toast.LENGTH_LONG).show();\n } else {\n try {\n JSONObject obj = new JSONObject(result.getContents());\n\n } catch (JSONException e) {\n e.printStackTrace();\n\n item.put( \"line1\",result.getContents() );\n item.put( \"line2\",\"Qty:1\" );\n list.add( item );\n adapter.notifyDataSetChanged();\n\n\n }\n }\n } else {\n super.onActivityResult(requestCode, resultCode, data);\n }\n}"
] | [
"android",
"listview",
"arraylist"
] |
[
"Rejecting promises with multiple arguments (like $http) in AngularJS",
"Callbacks for $http promises have multiple arguments: body, status, headers, config.\n\nI'd like to create similar promise by hand but don't know how to do this. What I'd like to do is more or less:\n\nmyservice.action().then(function(status, message, config) {\n // ...\n});\n\n\nI know I could pass object with keys to callback but would like to have similar convention as in $http. I look at the angular sources, but either don't understand it fully or just can't do that right.\n\nDo you know how to create promises that are able to pass multiple arguments to callback/errbacks?"
] | [
"javascript",
"angularjs"
] |
[
"JPA Projection: select only some items and an entire entity of @OneToMany relationship",
"I have these two entities:\n\n@Entity\n@Table(name = \"ORGANIZATION\")\npublic class Organization implements Serializable {\n\n private static final long serialVersionUID = 1L;\n\n @Id\n @GeneratedValue(strategy = GenerationType.IDENTITY)\n private Long id;\n\n private String name;\n\n @OneToMany(mappedBy = \"organization\", fetch = FetchType.LAZY)\n private Set<OrganizationMeta> metas;\n\n public Organization() {\n super();\n }\n\n public Organization(Long id, String name, Set<OrganizationMeta> metas) {\n super();\n this.id = id;\n this.name = name;\n this.metas = metas;\n }\n\n // ... others fields ... getters and setters\n}\n\n@Entity\n@Table(name = \"ORGANIZATION_META\")\npublic class OrganizationMeta implements Serializable {\n\n private static final long serialVersionUID = 1L;\n\n @Id\n @GeneratedValue(strategy = GenerationType.IDENTITY)\n private Long id;\n\n @Enumerated(EnumType.STRING)\n @Column(name = \"meta_key\", length = 200, nullable = false)\n private OrganizationMetaKeyEnum metaKey;\n\n private String metaValue;\n\n @ManyToOne(optional = false, fetch = FetchType.LAZY)\n @JoinColumn(nullable = false)\n private Organization organization;\n\n // ... getters and setters ...\n}\n\n\nSo an Organization can have one or more OrganizationMeta, it's a simple situation.\n\nIn the ORGANIZATION_META table there is the foreign key, so it is the owner of the relationship.\n\nIn the Organization entity I have the set of metas loaded by @OneToMany.\n\nI want to write a query using a projection, because I want only some fields of Organization entity, but at the same time I want the entire OrganizationMeta entity.\n\nThis is the JPQL query, but I have always different error\n\n@Query(\"select new net.feed.feedentity.domain.organization.Organization(organization.id, organization.name, organization.metas) from Organization organization left join fetch organization.metas where organization.id = ?1\")\n\n\nIt seem impossible to select in the projection, a set or list of a @OneToMany field.\n\nIs it possible to do this? Anyone encountered this problem ?"
] | [
"hibernate",
"jpa",
"spring-data-jpa",
"hql",
"jpql"
] |
[
"How to define scala compiler plugins in Bazel?",
"Currently I use rules_scala in conjunction with sbt-bazel to try an convert from sbt to bazel.\n\nI'm currently hitting an issue with the 'kind-projector' plugin not being used during the build.\n\nie. compilerPlugin(\"org.spire-math\" % \"kind-projector\" % \"0.9.8\")\n\nDoes anyone have experience working with scalac plugins in Bazel?"
] | [
"scala",
"sbt",
"bazel",
"kind-projector"
] |
[
"About left padding in C programming?",
"I searched through the website already, but I can't seem to find the solution that pertains to my problem:\n\nExample:\n\n printf(\"%s I love puppies\", name);\n\n\nthis is my prinf statement, but how do I left pad in which it will add additional spaces with each for loop?\n\nEdit:\n\n Hello //int i is 0\n Hello //int i is 1\n Hello //int i is 2\n Hello //int i is 3\n\n\nI wanted to do something like this:\n(in for loop)\n\n space += \" \" //where space is first initialized as \"\" \n\n\nIs there a function that is similar to this (in java) in C programming?\n\nEdit: The thing is I have this : printf(\"%s I love puppies\", name); \n\nI was thinking of using int space = i (according to the loop counter) and then do printf(\"%s\", space, \"%s I love puppies\", name); in printf but it says I have too many arguments..."
] | [
"c",
"padding",
"space"
] |
[
"The difference between two sets of tuples",
"I'm trying to write a function that takes a tuple (representing an integer coordinate in the plane) and returns all adjacent coordinates not including the original coordinate.\n\ndef get_adj_coord(coord):\n '''\n coord: tuple of int\n\n should return set of tuples representing coordinates adjacent\n to the original coord (not including the original)\n '''\n\n x,y = coord\n\n range1 = range(x-1, x+2)\n range2 = range(y-1, y+2)\n\n coords = {(x,y) for x in range1 for y in range2} - set(coord)\n\n return coords\n\n\nThe issue is that the return value of this function always includes the original coordinate:\n\nIn [9]: get_adj_coord((0,0))\nOut[9]: {(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1)}\n\n\nI'm probably missing something fundamental to sets and/or tuples, but the following function is definitely not returning what I expect. I also tried also using:\n\ncoords = {(x,y) for x in range1 for y in range2}.remove(coord)\n\n\nBut then function returns nothing. Can anyone point out what I'm very clearly missing here?"
] | [
"python"
] |
[
"Basic connection to sql server",
"I have read many tutorial and examples, but still can't connect to the sql server.\n\nI'm using window authentication and this simple code (stripped down to highlight the connection part)\n\n SqlConnection myConnection = new SqlConnection(@\"Data Source=localhost;Initial Catalog=MyDatabase;Trusted_Connection=True;connection timeout=5\");\n\n try\n {\n myConnection.Open();\n \"connected\"\n }\n catch(SqlException ex)\n {\n \"Send curriculum to mcdonald\" + ex.Message\n }\n\n\nI've tried localhost\\sqlexpress, computername\\sqlexpress and a lot of other settings, the service are on, the database is there and reacheable from sql server management and so on.\nIt's the first time that I try to use sql server so probably I'm forgetting something fundamental, what must I check to be sure to make it work?"
] | [
"c#",
"sql-server"
] |
[
"Matlab: How I can make this transformation on the matrix A?",
"I have a matrix A 4x10000, I want to use it to find another matrix C.\n\nI'll simplify my problem with a simple example:\n\nfrom a matrix A\n\n20 4 4 74 20 20 \n36 1 1 11 36 36 \n77 1 1 15 77 77 \n 3 4 2 6 7 8 \n\n\nI want, first, to find an intermediate entity B:\n\n 2 3 4 6 7 8 \n\n[20 36 77] 0 1 0 0 1 1 3\n\n[4 1 1] 1 0 1 0 0 0 2\n\n[74 11 15] 0 0 0 1 0 0 1\n\n\nwe put 1 if the corresponding value of the first line and the vector on the left, made a column in the matrix A.\n\nthe last column of the entity B is the sum of 1 of each line.\n\nat the end I want a matrix C, consisting of vectors which are left in the entity B, but only if the sum of 1 is greater than or equal to 2.\n\nfor my example:\n\n 20 4\nC = 36 1\n 77 1\n\n\nN.B: for my problem, I use a matrix A 4x10000"
] | [
"matlab",
"matrix"
] |
[
"Sending email to array of recipients on php",
"I am looking to send email to multiple recipients but i am not able to do so.. here is my code. \n\nusing print_r() statement\nArray\n(\n [selectedvalue] => Array\n (\n [0] => [email protected]\n [1] => [email protected]\n [2] => [email protected]\n )\n}\n\n\nand i want to use this emails in mail($mailDO->toEmail)\n\nmail($mailDO->toEmail, $mailDO->subject, $mailDO->message, $headers); \n\n\nkindly help me out...thanks."
] | [
"php",
"mysql",
"email"
] |
[
"Session from iframe to ajax",
"How come when I create a session from an iframe within a domain and then try access the session from another iframe it works fine but when I try access the session through ajax it does not work?\n\n\n\nExample:\n\nWebsite (iframe.php):\n\n<?php \nheader(\"Access-Control-Allow-Origin: *\");\nsession_start();\nif(isset($_POST['session'])){\n $_SESSION['session'] = $_POST['session'];\n echo \"created session\";\n}else if(isset($_GET['want'])){\n //for ajax request\n die($_SESSION['session']);\n}\n?>\n<form action=\"iframe.php\" method=\"post\">\nSESSION VAL:<input name=\"session\" value=\"<?php echo $_SESSION['session']?>\" type=\"text\"/><br>\n<input type=\"submit\"/>\n</form>\n\n\nHTML\n\n<iframe src=\"iframe.php\">\n\n</iframe>\n<br>SESSION FROM AJAX:\n<div id=\"AJAX\"></div>\n\n\nAJAX\n\nwindow.setInterval(function(){\n $.get( \"iframe.php?want\", function( data ) {\n $( \"#AJAX\" ).html( data );\n });\n},1000);\n\n\nSee Fiddle"
] | [
"javascript",
"php",
"ajax",
"session",
"iframe"
] |
[
"FILE_UNRECOGNIZED_PATH for an URI in firefox android extension",
"I'm developing an extention for firefox on android,it's my first attempt and I'm facing hard times, I'm trying to store some data on sqlite file, using the Mozilla storage API to access and store in an sqlite file that exists in the download directory by using the extension. I tried this code\n\nvar f = new FileUtils.File(\"file:///storage/sdcard0/Download/bd.sqlite\");\nfile = FileUtils.getFile(\"ProfD\", [f]); \nmDBConn = Services.storage.openDatabase(file); \nlet stmt = mDBConn.createStatement(\"INSERT INTO try (k,url,track) VALUES(1,'twitter',12)\");\nstmt.executeAsync();\n\n\nand I'm getting this error:\n\n\n E/GeckoConsole( 7345): [JavaScript Error: \"NS_ERROR_FILE_UNRECOGNIZED_PATH: Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsILocalFile.initWithPath]\" {file: \"resource://gre/modules/XPIProvider.jsm -> jar:file:///data/data/org.mozilla.firefox/files/mozilla/sru26yxk.default/extensions/[email protected]!/bootstrap.js\" line: 322}]\n\n\nI'm really lost, I know there is a problem with the path but, it is the right one, I think the problem is how to transform the string path to an URI that can be read."
] | [
"android",
"sqlite",
"firefox-addon",
"storage"
] |
[
"Python Pandas: convert list of objects to a list of integer",
"Hi I have a prboblem to convert list of objects to a list of integers. The objects are within the \"stopsequence\" column of the Pandas data frame \"Kanten\". All of this I receive after so CSV importing and data cleaning in the column. I am using Python 3.X\n\nI am a Python newbie, maybe that's part of the problem here. \n\nimport pandas as pd\nimport numpy as np\nimport os\nimport re\nimport ast\norgn_csv = pd.read_csv(r\"Placeholder path for csv file\")\ndf = orgn_csv.dropna()\nKanten = pd.DataFrame({\"stopsequence\" : df.stopsequence})\n\n# In between is a block in which I use regular expressions for data cleaning purposes.\n# I left the data cleaning block out to make the post shorter\n\n\nKanten.stopsequence = Kanten.stopsequence.str.split (',')\nprint (Kanten.head())\nprint (Kanten.stopsequence.dtype) \n\n\nThis gives the following output:\n\n stopsequence\n2 [67, 945, 123, 122, 996, 995, 80, 81, 184, 990...\n3 [67, 945, 123, 122, 996, 995, 80, 81, 184, 990...\n4 [67, 945, 123, 122, 996, 995, 80, 81, 184, 990...\n5 [67, 945, 123, 122, 996, 995, 80, 81, 184, 990...\n6 [67, 945, 123, 122, 996, 995, 80, 81, 184, 990...\nobject\n\n\nI am looking for a way to transform the list which contains objects. I searched through the StackOverflow Forum intensively and tried a bunch of different approaches. With none of them I was succesfull.\nI tryed to use:\n\nastype(str).astype(int)\n\nKanten.stopsequence = Kanten.stopsequence.astype(str).astype(int)\nThis Returns:\nValueError: invalid literal for int() with base 10:\n\n\nadapted the following post with the use of atoi instead of atof\n\nKanten.stopsequence.applymap(atoi)\nThis Returns:\nAttributeError: 'Series' object has no attribute 'applymap'\n\n\nlist(map())\n\nKanten.stopsequence = list(map(int, Kanten.stopsequence))\nThis returns:\nTypeError: int() argument must be a string, a bytes-like object or a number, not 'list'\n\n\napply(ast.literal_eval)\n\nKanten.stopsequence = Kanten.stopsequence.apply(ast.literal_eval)\nThis returns:\nTypeError: int() argument must be a string, a bytes-like object or a number, not 'list'\n\n\nDoes anybody see a solution for that? I am uncertain if it's a complicated case or I just lacke some further programming experience. If possible a short explanation would be helpful. That I can find a solution myself againg. Thank you in advance."
] | [
"python",
"pandas"
] |
[
"Focusing on next input not working and how to submit the form when user on last input field",
"I have 6 text field and each has maxlength=1. I used the script, the Only user can enter the number. After entering the number cursor will go to next field and the same condition happens with other fields but when cursor on the last filed then, I have to call the AJAX to submit data.\n\nI am facing two issues here \n\n1) How to set autofocus on next input field?\n\n2) How to submit form when user enter the Last field\n\nI tried belwo code\n\n\r\n\r\n/*max filed value is only 1 and it will redirect on next field*/\r\n$(\".child\").keyup(function() {\r\n if (this.value.length == this.maxLength) {\r\n $(this).next('.child').focus();\r\n }\r\n});\r\n\r\n/*Below script is use for stop the letter and can only use number in the field*/\r\n$(function() {\r\n $('.confirm-field').on('keydown', '.child', function(e) {\r\n -1 !== $.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) || /65|67|86|88/.test(e.keyCode) && (!0 === e.ctrlKey || !0 === e.metaKey) || 35 <= e.keyCode && 40 >= e.keyCode || (e.shiftKey || 48 > e.keyCode || 57 < e.keyCode) && (96 > e.keyCode || 105 < e.keyCode) && e.preventDefault()\r\n });\r\n})\r\n\r\n/*ajax calling*/\r\n$(function() {\r\n $('form[name=\"user-confirmation-code\"]').on('submit', function(e) {\r\n e.preventDefault();\r\n $.ajax({\r\n type: 'post',\r\n url: 'demo2.php',\r\n data: $('form[name=\"user-confirmation-code\"]').serialize(),\r\n success: function() {\r\n alert('form was submitted');\r\n }\r\n });\r\n });\r\n});\r\n.confirmation-box {\r\n display: flex;\r\n}\r\n\r\n.confirmation-code {\r\n display: inline-flex;\r\n}\r\n\r\n.confirmation-code input[type=\"text\"] {\r\n width: 30px;\r\n height: 30px;\r\n}\r\n\r\n.confirmation-code-dash {\r\n display: table-cell;\r\n font-weight: 700;\r\n font-size: 2rem;\r\n text-align: center;\r\n padding: 0 .5rem;\r\n width: 2rem;\r\n}\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js\"></script>\r\n\r\n<form action=\"#\" method=\"post\" name=\"user-confirmation-code\">\r\n <div class=\"confirmation-box\">\r\n <div class=\"confirmation-code\">\r\n <div class=\"confirm-field\">\r\n <input type=\"text\" name=\"\" maxlength=\"1\" class=\"child\" autofocus>\r\n </div>\r\n <div class=\"confirm-field\">\r\n <input type=\"text\" name=\"\" maxlength=\"1\" class=\"child\">\r\n </div>\r\n <div class=\"confirm-field\">\r\n <input type=\"text\" name=\"\" maxlength=\"1\" class=\"child\">\r\n </div>\r\n </div>\r\n <div class=\"confirmation-code-dash\">-</div>\r\n <div class=\"confirmation-code\">\r\n <div class=\"confirm-field\">\r\n <input type=\"text\" name=\"\" maxlength=\"1\" class=\"child\">\r\n </div>\r\n <div class=\"confirm-field\">\r\n <input type=\"text\" name=\"\" maxlength=\"1\" class=\"child\">\r\n </div>\r\n <div class=\"confirm-field\">\r\n <input type=\"text\" name=\"\" maxlength=\"1\" class=\"child\">\r\n </div>\r\n </div>\r\n </div>\r\n <!--confirmation-box-->\r\n</form>\r\n\r\n\r\n\n\nWithout parent class is working autofocus\n\n\r\n\r\n$(\".inputs\").keyup(function () {\r\n if (this.value.length == this.maxLength) {\r\n $(this).next('.inputs').focus();\r\n }\r\n});\r\ninput { width: 30px; margin: 5px; }\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js\"></script>\r\n<input class=\"inputs\" type=\"text\" maxlength=\"1\" />\r\n<input class=\"inputs\" type=\"text\" maxlength=\"1\" />\r\n<input class=\"inputs\" type=\"text\" maxlength=\"1\"/>\r\n<input class=\"inputs\" type=\"text\" maxlength=\"1\"/>\r\n<input class=\"inputs\" type=\"text\" maxlength=\"1\"/>"
] | [
"javascript",
"jquery",
"ajax",
"html"
] |
[
"Should we call OnPropertyChanged in UI thread?",
"in this simple example, we can read Property StrTestExample in any thread.\n\nI see in same article, It says the OnPropertyChanged event is automatically marshaled to the UI thread. So we can set StrTestExample in any thread and UI can update. Also Other article says we should take the responsibility to call OnPropertyChaned in UI thread.\n\nwhere is this right? \n\nAny documents from msdn or elsewhere to prove this?\n\npublic class ViewModelBase : INotifyPropertyChanged\n {\n\n private volatile string _strTestExample;\n\n public string StrTestExample\n {\n get { return _strTestExample; }\n set\n {\n if (_strTestExample != value)\n {\n _strTestExample = value;\n OnPropertyChanged(nameof(StrTestExample));\n }\n }\n }\n\n\n public event PropertyChangedEventHandler PropertyChanged;\n\n protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)\n {\n var propertyChanged = PropertyChanged;\n propertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));\n }\n\n\n }"
] | [
"wpf",
"mvvm",
"thread-safety"
] |
[
"How to make an additional http call inside api and process response?",
"I'm trying to create Message Mediation Policies, with which I can make an additional http call, process the response and enrich the current message. How can i do this? I use call Mediator, but I don’t understand how to handle the response.\n\n<?xml version=\"1.0\" encoding=\"UTF-8\"?> <sequence name=\"call_out_handler\" trace=\"disable\" xmlns=\"http://ws.apache.org/ns/synapse\">\n<call blocking=\"true\">\n <endpoint>\n <http method=\"get\" uri-template=\"http://192.168.99.100:8888/stubFORAPIMan/ServletWithTimeout\"/>\n </endpoint>\n</call> </sequence>"
] | [
"wso2",
"wso2-am"
] |
[
"Unit test method does not use the mocked object when running the test. Instead calls the actual class and method",
"I have a class to test named ClassToTest. It calls a CloudService to upload file. \n\npublic class ClassToTest {\n public String moveFilesToCloud(String path, String documentclass, String objStore) {\n log.info(\"Moving files to cloud.\");\n String docId = StringUtils.EMPTY;\n CloudService service = new CloudService();\n try {\n docId = service.uploadDocument(path,documentclass,objStore,\"\");\n } catch (CloudException e) {\n log.info(\"* Error uploading reports to cloud *\" + e.getMessage());\n }\n return docId;\n }\n}\n\n\nBelow is the test class. The test class has a mocked object for CloudService. When I run the test instead of getting the mocked object, the actual CloudService is executed and fails.\n\n@Mock\nCloudService cloudService;\n\n@InjectMocks\nClassToTest classToTest;\n\n@Test\npublic void testMoveFilesToCloud() throws Exception {\n String pass = \"pass\";\n when(cloudService.uploadDocument(\"abc\",\"def\",\"ghi\",\"\")).thenReturn(pass);\n\n String result = classToTest.moveFilesToCloud(\"abc\",\"def\",\"ghi\");\n\n assertEquals(result,pass);\n}\n\n\nI am expecting the mocked object for CloudService to be used when executing this line - \n\nCloudService service = new CloudService(); \n\nInstead, it is actually trying to create a new instance of CloudService.\n\nWhere am I going wrong here?"
] | [
"java",
"unit-testing",
"testing",
"junit",
"mockito"
] |
[
"ITK build Cmake (Gcc compiler) error",
"Trying to compile ITK software using Cmake on a Linux system. Build fails after 39% complete with following error: \n\n\"make[2]: * [Wrapping/Generators/GccXML/llvm-prefix/src/llvm-stamp/llvm-configure] Error 1\nmake[1]: * [Wrapping/Generators/GccXML/CMakeFiles/llvm.dir/all] Error 2\nmake: *** [all] Error 2\"\n\nHelp? \n\nAlso mentions that gcc needs to be version 4.7 or higher, but system has 4.8 installed."
] | [
"gcc",
"cmake",
"itk"
] |
[
"Autowire ViewResolver in Spring MVC",
"For some reason I'm not able to Autowire the ViewResolver:\n\n@Component\npublic class JsonMultipleViewFactory\n{\n @Autowired\n private ViewResolver viewResolver;\n\n // ...\n}\n\n\nviewResolver is null.\n\nThe class JsonMultipleViewFactory is Autowired in a spring controller:\n\n@Controller\npublic class HomeController\n{\n @Autowired\n private JsonMultipleViewFactory jsonMultipleViewFactory;\n\n // ...\n}\n\n\nI've created a github repository containing a very small example reproducing the problem. \n\nCan anyone help me?\n\nThank you."
] | [
"java",
"spring",
"spring-mvc",
"autowired"
] |
[
"Create html links from list of folders in directory",
"I would like to generate a list of hyper-links in my html navigation under one header (+WORKS), so that all I do is add a folder to a location on my server and my website will generate a link to that folder automatically so I do not need to change the code on all my pages in order to see it. \n\nI would like it if someone can help me out with this but even pointing me in the right direction would be helpful as I'm an all around web developer newbie and don't know much of the capabilities of javascript and jquery or any other language besides html and css.\n\nThank you."
] | [
"javascript",
"jquery",
"html",
"list",
"dynamic"
] |
[
"beyondcode\\laravel-websockets it is redirecting to wss instead of ws on localhost",
"I am using laravel version 5.7 and beyondcode\\laravel-websockets package v1.3 the problem I am facing right now is when I am running it on localhost I am getting this error\n\nWebSocket connection to 'wss://localhost/app/somekey?protocol=7&client=js&version=6.0.2&flash=false' failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID\n\nI have changed encrypted to false in bootsrap.js still it connects to wss instead of ws\n\nbootstrap.js\n\nimport Echo from 'laravel-echo'\n\nwindow.Pusher = require('pusher-js');\n\nwindow.Echo = new Echo({\n broadcaster: 'pusher',\n key: process.env.MIX_PUSHER_APP_KEY,\n cluster: process.env.MIX_PUSHER_APP_CLUSTER,\n encrypted: false,\n wsHost: window.location.hostname,\n wsPort: 6001,\n disableStats: true\n});\n\n\nbroadcasting.php config\n\n'connections' => [\n\n 'pusher' => [\n 'driver' => 'pusher',\n 'key' => env('PUSHER_APP_KEY'),\n 'secret' => env('PUSHER_APP_SECRET'),\n 'app_id' => env('PUSHER_APP_ID'),\n 'options' => [\n 'cluster' => env('PUSHER_APP_CLUSTER'),\n 'encrypted' => false,\n 'host' => '127.0.0.1',\n 'port' => 6001,\n 'scheme' => 'http'\n ],\n ],"
] | [
"php",
"laravel",
"websocket",
"laravel-websockets"
] |
[
"Pandas changing data types of multiple columns",
"I'm trying to convert all the values in certain columns into floating point dollar amounts, in the pre-existing columns they have a dollar sign before them, however, they are strings which contain the dollar amount as a whole number. All cells in these columns have values that are not (NaN).\n\nI'm importing this from a read .csv file which is assigned to the variable props and I am looking to convert the values to floats from the following columns: Land Value, Improvement Value',Total Value, and Sale Price\n\nmy code at this point is\n\n col_list = ['Land Value', 'Improvement Value','Total Value','Sale Price']\n for item in col_list:\n props[item] = float(props[item].rstrip('$'))\n\n\nHow exactly can I convert the values in these 4 columns into floating point dollar amounts?"
] | [
"python",
"pandas",
"dataframe"
] |
[
"JQ : Output with static value / variable",
"I want to have an output with static value using jq with static value :4546\n\nnodes.json\n\n{\n \"nodes\": {\n \"node1.local\": {\n \":ip\": \"10.0.0.1\",\n \"ports\": [],\n \":memory\": 1024,\n \":bootstrap\": \"bootstrap.sh\"\n },\n \"node2.local\": {\n \":ip\": \"10.0.0.2\",\n \"ports\": [],\n \":memory\": 1024,\n \":bootstrap\": \"bootstrap.sh\"\n },\n \"node3.local\": {\n \":ip\": \"10.0.0.3\",\n \"ports\": [],\n \":memory\": 1024,\n \":bootstrap\": \"bootstrap.sh\"\n }\n }\n}\n\n\nhere is my command use\n\nips=`jq -c '.nodes | to_entries | map(.value.\":ip\")' nodes.json`\necho $ips\n\n\nwhere the output is \n\n[\"10.0.0.1\", \"10.0.0.2\", \"10.0.0.3\"]\n\n\nand i want it to be like this\n\n[\"10.0.0.1:4546\", \"10.0.0.2:4546\", \"10.0.0.3:4546\"]"
] | [
"bash",
"shell",
"jq"
] |
[
"Delete the Last Character in Every Line of a .txt File",
"I am a beginner to Java. I have successfully exported user data input to a .txt file using a loop, but I would like to remove the last comma per every line of the file. I have tried using a delimiter but cannot get the replaceAll to successfully remove the last comma of every line. \n\nMy current method which exports data is this:\n\npublic void Quit()\n { \n System.out.println(ProjectList.get(0).ProjectName);\n File fileObject = new File(\"results.txt\");\n CorrectInput = true; \n ShowMenu = false; //if ShowMenu is false, the program's menu will terminate\n PrintWriter outputStream = null;\n try\n {\n outputStream =\n new PrintWriter(new FileOutputStream(\"results.txt\"));\n }\n catch(FileNotFoundException e)\n {\n System.out.println(\"Error opening the file\" +\"results.txt\");\n System.exit(0);\n }\n for (int i=0; i<ProjectList.size(); i++){\n outputStream.print(ProjectList.get(i).ProjectName+\",\"+ ProjectList.get(i).NumberOfMember +\",\"); //Project Name and Number of Members exported\n for (int Membercount = 0; Membercount < ProjectList.get(i).NumberOfMember; Membercount ++) //For as long as the member count is less than the total number of members, the program will ask for the user input\n { \n\n outputStream.print(ProjectList.get(i).TeamMember[Membercount]);\n outputStream.print(\",\");\n //END OF LIST OF MEMBERS\n }\n\n for (int CountingIndex = 0; CountingIndex < ProjectList.get(i).NumberOfMember; CountingIndex ++) //For as long as the member count is less than the total number of members, the program will ask for the user input\n { \n outputStream.print(ProjectList.get(i).TeamMember[CountingIndex] + \",\");\n for (int CountedIndex = 0; CountedIndex < ProjectList.get(i).NumberOfMember; CountedIndex++) {\n\n\n if(CountingIndex!=CountedIndex) { //new, adding csv format\n outputStream.print(ProjectList.get(i).TeamMember[CountedIndex] + \",\");\n outputStream.print(ProjectList.get(i).Vote[CountingIndex][CountedIndex] + \",\");\n\n }\n\n\n }\n\n }\n //for (int CountedIndex = 0; CountedIndex < ProjectList.get(i).NumberOfMember && CountingIndex != CountedIndex; CountedIndex++)\n\n\n outputStream.println();\n } \n outputStream.close();\n // read file data into a String\n // read file data into a String\n String data = null;\n try {\n data = new Scanner(new File(\"results.txt\")).useDelimiter(\"\\\\Z\").next();\n data = data.replaceAll(\"(?m)\\\\,$\", \" \");\n } catch (FileNotFoundException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n\n\n System.out.println(\"\\tGoodbye. \"); \n scan.close();\n\n }\n\n\nAn example .txt output looks like this:\n\nPRO1,2,MEM1,MEM2,MEM1,MEM2,100,MEM2,MEM1,100,\nPRO2,2,MEM3,MEM4,MEM3,MEM4,100,MEM4,MEM3,100,\n\n\nBut I would like the .txt/csv output to look like:\n\nPRO1,2,MEM1,MEM2,MEM1,MEM2,100,MEM2,MEM1,100\nPRO2,2,MEM3,MEM4,MEM3,MEM4,100,MEM4,MEM3,100\n\n\nShould I move the try/catch statement for the scanner to a separate method? Thanks so much for your help."
] | [
"java",
"file",
"csv",
"char"
] |
[
"Setting a timeout for DBD::Pg database connection",
"I have tried this in my Perl code, but the timeout doesn't work:\n\n my $dbh = DBI->connect($db, $db_user, $db_pass,{ timeout => 5 });\n\n\nI want to set a timeout on the connection to a postgresql database: how can I do that ?"
] | [
"perl",
"postgresql",
"timeout",
"dbi"
] |
[
"Webpack handlebar Register Helper",
"I am unable to register a Handlebars Helper and have it register in time with Webpack. I do not want to use the handlebar-loader as my HBS code maybe nested in HTML and I cannot keep the files out.\n\nIn helpers.js\n\n\r\n\r\nvar handlebars = require('js/helpers/vendor/handlebars.min')\r\nconsole.warn(handlebars, '<<<<<<< HANDLEBAR')\r\nhandlebars.registerHelper('math', function(lvalue, operator, rvalue) {\r\n lvalue = parseFloat(lvalue)\r\n rvalue = parseFloat(rvalue)\r\n return {\r\n '+': lvalue + rvalue,\r\n '-': lvalue - rvalue,\r\n '*': lvalue * rvalue,\r\n '/': lvalue / rvalue,\r\n '%': lvalue % rvalue,\r\n '>': lvalue > rvalue,\r\n '<': lvalue < rvalue,\r\n '>=': lvalue >= rvalue,\r\n '<=': lvalue <= rvalue,\r\n '!==': lvalue !== rvalue\r\n }[operator]\r\n console.warn(handlebars, '<<<<<<< HANDLEBAR Math Helper shows up in Handlebars.helpers')\r\n\r\n})\r\n\r\n// In Template.js\r\n\r\nvar handlebars = require('js/vendor/handlebars')\r\n ...handlebars.compile(carttemplate)\r\n\r\n\r\n\n\nRunning the code where carttemplate expects the math helper present throws an error math helper not found. \n\nI have tried adding an Alias for the helper itself, moving code around so that the helper executes first to no avail - It just does not work in time."
] | [
"handlebars.js",
"webpack"
] |
[
"unable to login on appcelerator studio (windows pc 64bit)",
"After filling up the details this form keeps popping up."
] | [
"appcelerator",
"appcelerator-studio"
] |
[
"Responsive table with vertical and horizontal headers",
"I have the following table (jsFiddle):\n\n\n\n <table>\n <tr>\n <th></th>\n <th scope=\"col\">BMW</th>\n <th scope=\"col\">Audi</th>\n <th scope=\"col\">Mercedes</th>\n </tr>\n <tr>\n <th scope=\"row\">GPS</th>\n <td>1200</td>\n <td>1000</td>\n <td>1400</td>\n </tr>\n <tr>\n <th scope=\"row\">Bluetooth</th>\n <td>700</td>\n <td>750</td>\n <td>680</td>\n </tr>\n <tr>\n <th scope=\"row\">Sensors</th>\n <td>1230</td>\n <td>1400</td>\n <td>1100</td>\n </tr>\n</table>\n\n\nHow do I make it responsive, so that in mobile devices the table will look like this:\n\n\n\n <table>\n <tr>\n <th></th>\n <th scope=\"col\">BMW</th>\n </tr>\n <tr>\n <th scope=\"row\">GPS</th>\n <td>1200</td>\n </tr>\n <tr>\n <th scope=\"row\">Bluetooth</th>\n <td>700</td>\n </tr>\n <tr>\n <th scope=\"row\">Sensors</th>\n <td>1230</td>\n </tr>\n</table>\n\n\nIs it possible to do this just in CSS? I'm guessing not since I will need to duplicate the vertical headers"
] | [
"javascript",
"html",
"css"
] |
[
"Itemcommand not firing on button click event in a datalist using c#",
"this is my offer.aspx inherits from masterpage\n' />\n\nmy .cs file\n\nprotected void Page_Load(object sender, EventArgs e)\n {\n if (!IsPostBack)\n {\n offerlistbind();\n }\n }\n\npublic void offerlistbind()\n{\n db1.strCommand = \" select Offer.OfferID, Offer.OfferName,Offer.Amount,Offer.FromDate,Offer.ToDate,Offer.Description,bm_package.PackageName,bm_country.Country from Offer inner join bm_package on Offer.PackageID=bm_package.PackageID inner join bm_country on Offer.CountryID=bm_country.CountryID\";\n offerlistnew.DataSource = db1.DataSet();\n offerlistnew.DataBind();\n\n}\n\n\nif i click the button instead of firing item command event item dataBound event is working\n protected void offerlistnew_ItemCommand1(object source, DataListCommandEventArgs e)\n {\n if (e.CommandName == \"subscribe\")\n {\n int ofid = Convert.ToInt32(e.CommandArgument);\n Response.Redirect(\"http://ecom.bom.tv/default.aspx?Offer=\" + ofid + \"\");\n }\n }"
] | [
"c#",
"asp.net"
] |
[
"Using Require.js without data-main",
"Can I use Require.js in development without using the data-main attribute to load in my initial script? ie. <script data-main=\"scripts/main\" src=\"scripts/require.js\"></script> I'm finding it difficult for me to work with this attribute in my development environment."
] | [
"javascript",
"requirejs"
] |
[
"Title bar appears unwanted in windows forms application with .net 5",
"in our applications, we try to give the application an own style and try to hide the windows style. Therefore the main form is set to borderless with no controlbox and so on. This works fine in the last years, actually we are using VS 2019, the actual application was set to .net core 3.1\nThe designer code looks like this\n this.ControlBox = false;\n this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;\n this.IsMdiContainer = true;\n this.MaximizeBox = false;\n this.MinimizeBox = false;\n this.ShowIcon = false;\n\nAs you see, the main form is a MDI Contrainer. In reality the top of the application looks like this, only my title bar with no control box.\n\nSome days ago we change to .net 5.0 and now I noticed, that in that moment, when I add a subform to the mdicontainer, the windows title bar appears.\n_GeneralForm = new FEmpty();\nthis._GeneralForm.MdiParent = this; // A that point the title bar appears in the main form\n.WindowState = FormWindowState.Maximized;\n\nWhat can be the reason? In the debugger I can check that the main form, which is the mdi container is still set to FormBorderstyle.None and all the other settings like done in the designer code.\n\nToday I was trying VS2019 V16.10 but the error is still there.\nGreetings Frank"
] | [
"c#",
"titlebar",
"mdiparent"
] |
[
"how to style based on a variable return value in html",
"#I have a small html script which creates a table. How do I change the the color of ${NodeUP}, ${CPU} based on the value it returns.\nFor example:\nIf ${NodeUP} returns UP, the text UP should be in green and when DOWN the text DOWN should be in Red.\nSimilarly, if ${CPU} is less than 90% then value should be in red and green when greater than 90%\n<tr>\n <td>Node Status </td>\n <td>${NodeUp}</td>\n</tr>\n\n<tr>\n <td>CPU utilization </td>\n <td>${CPU}</td>\n</tr>"
] | [
"html"
] |
[
"Security: implementing a solution against CSRF attacks in struts 1",
"I need to implement a solution to prevent CSRF attacks in an application based on struts 1 framework.\nOn the web, people suggest these kind of solutions:\n\n\nStruts saveToken(request) and isTokenValid(request, true) \nLibraries such as HDIV and OWASP CSRFGuard\n\n\nCurrently I don’t know which one fit best for this problem.\nSo can you give me your opinion on those solutions to direct my choice and if possible with an example\nor suggest other solution. \n\nThanks for help"
] | [
"java",
"security",
"csrf",
"struts-1",
"struts1"
] |
[
"Querying last two days depending on a Workday or not table",
"We use Mysql and we're trying to get averages from last two workdays from a hourly data set like this.\n\n \nDate Price\n2016-12-13 00:00 187,68 \n2016-12-13 01:00 201\n2016-12-13 02:00 211,66 \n2016-12-13 03:00 215,84\n\n\nSo we created a table named (Workdays) that shows if the day is a workday or holiday like this:\n\n \nDate Workday\n2016-12-13 1\n2016-12-14 1\n2016-12-15 0 \n2016-12-16 0\n\n\n1 means workday and 0 means weekend or National Holiday\n\nAt the and, we have to query Average price of the last two workdays seperately considering Workdays table\n\nIs this possible?\n\nThanks a lot."
] | [
"mysql",
"sql",
"average"
] |
[
"PHP Websocket failed: Error during WebSocket handshake: net::ERR_CONNECTION_CLOSED (anonymous)",
"i learning the websocket in PHP but i don't know why have this handshake error.\n\nMy client.html : \n\n<html>\n<body>\n <div id=\"root\"></div>\n <script>\n var host = 'ws://127.0.0.1:8020/';\n var socket = new WebSocket(host);\n socket.onmessage = function(e) {\n console.log(e.data)\n };\n </script>\n</body>\n</html>\n\n\nAnd server.php :\n\n<?php\n\n$address = \"127.0.0.1\";\n$port = 8020;\n\n$socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);\nsocket_bind($socket,$address,$port) or die('bind error');\nsocket_listen($socket) or die('listen error');\n$client = socket_accept($socket) or die('accept error');\n\n$socketread = socket_read($client,5000) or die('Failed to read');\n\npreg_match(\"#Sec-WebSocket-Key: (.*)\\r\\n#\",$socketread,$match);\n$key = base64_encode(sha1($match[1].'258EAFA5-E914-47DA-95CA-C5AB0DC85B11',true));\n\n$header = \"HTTP/1.1 101 Switching Protocols\\r\\n\";\n$header .= \"Upgrade: websocket\\r\\n\";\n$header .= \"Connection: Upgrade\\r\\n\";\n$header .= \"Sec-WebSocket-Accept: $key\\r\\n\";\n$header .= \"Sec-WebSocket-Version: 13\\r\\n\";\n\nvar_dump($header);\nsocket_write($client,$header,strlen($header));\n\n\n$msg = \"connected\";\nsocket_write($client,$msg,strlen($msg));\nsocket_close($socket);\n\n\nHowever, I followed the Mozilla documentation on the handshake :/\n\nThank you for that."
] | [
"php",
"sockets",
"websocket",
"php-socket"
] |
[
"Unity 2D Circle Collider Shaky Movement",
"So, I'm having a problem with shaky movement in a very simple 2D platformer, with a square player, using a circle collider. The player's movement is shaky, not the ground. I think it's a problem with the colliders, because I've been on another post trying to fix the script, and I think I did it. I've been trying to fix this for quite a while. \n\npublic float moveSpeed;\npublic float jumpHeight;\nRigidbody2D rb;\n\nvoid Start()\n{\n rb = GetComponent<Rigidbody2D>();\n}\n\nvoid Update()\n{\n if (Input.GetKeyDown(KeyCode.Space))\n {\n rb.velocity = new Vector2(rb.velocity.x, jumpHeight);\n }\n\n if (Input.GetKey(KeyCode.D))\n {\n rb.velocity = new Vector2(moveSpeed, rb.velocity.y);\n }\n\n if (Input.GetKey(KeyCode.A))\n {\n rb.velocity = new Vector2(-moveSpeed, rb.velocity.y);\n }\n}"
] | [
"c#",
"unity5",
"unity2d",
"collider"
] |
[
"I need a rule that allows me to ban the usages of a form-validator",
"We made our own version of the Validators.required form-validator that is included in base Angular 7. It is mandatory that we use the new CustomValidators.required instead. We are looking into banning the usages of the old required by including it in our already existing TSlint config. We looked into the ban Rule https://palantir.github.io/tslint/rules/ban/ \nBut that doesn't seem to be working, we configured it as follows:\n\n\"ban\": [\n true,\n \"eval\",\n {\"name\": [\"Validators\", \"required\"], \"message\": \"Don't use the Validators.required use the CustomValidators.required instead!\"}\n ]\n\n\nWe are at a loss currently, any help is appreciated :)"
] | [
"angular",
"typescript",
"tslint"
] |
[
"Aldebaran Nao robot simulator without a real robot",
"I want to get the hang of developing on the Nao robot but without having the actual robot yet (I will get it later). So I installed the software at home but I cannot see any robot at the Robot View of Choregraphe.\n\nJust installed Choregraphe Suite 2.1.0.19-vs2010 and also Downloaded and Extracted naoqi sdk 2.1.0.19-vs2010.\n\nI followed the instructions:\n\n\nChoregraphe started\nnaoqi also started via cmd\nnaoqi attached to Choregraphe\n\n\nBut still no virtual robot to be seen at my Robot View tab in Choregraph."
] | [
"visual-studio-2010",
"simulator",
"robot",
"nao-robot"
] |
[
"Rails generate PDF from html",
"I'm facing some problems to generate PDF from html with Rails. I tried to use PDFKit and Wicked_PDF gems, with both I had a problem with page break, they break inside a <tr>.\n\nLet me show you what I'm doing with Wicked_PDF:\n\nIn my controller:\n\nrender pdf: \"report\", \n :template => \"reports/index.html.erb\",\n :layout => \"pdf\",\n :orientation => 'Landscape',\n footer: {\n right: \"Page [page] of [topage]\",\n font_size: 9\n }\n\n\nlayouts/pdf.html.erb:\n\n<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\">\n\n <style>\n .table {\n border-bottom: 1px solid #ddd;\n border-collapse: collapse;\n border-spacing: 0;\n margin-bottom: 20px;\n width: 100%;\n }\n\n td,\n th {\n border-top: 1px solid #ddd;\n padding: 2px;\n text-align: left;\n vertical-align: middle;\n }\n\n .table > thead th {\n background: #f7f7f7;\n }\n </style>\n</head>\n\n<body>\n\n<%= yield %>\n\n</body>\n</html>\n\n\nreports/index.html.erb:\n\n<table class=\"table\">\n <thead>\n <tr>Example of a text that breaks the tr</tr>\n </thead>\n <tbody>\n <% 3.times do %>\n <tr>\n <td><%= \"string \" * 500 %></td>\n </tr>\n <% end %>\n </tbody>\n</table>\n\n\nAlso tried to use this css property: \n\ntr, td, th, tbody, thead, tfoot {\n page-break-inside: avoid !important;\n}\n\n\nNote: I think it would not be relevant to show what I did with PDFKit, since the html and css doesn't change, only the way it is rendered and the problem is exactly the same.\n\nWhat I've missed?\n\nSolutions with other gems are welcome too."
] | [
"html",
"ruby-on-rails",
"pdf-generation",
"wicked-pdf",
"pdfkit"
] |
[
"Want to write formula in cell if x=y, otherwise blank cell, using VBA",
"Let me better explain. If the value of A1 is \"0\" then in A2 I want the formula =vlookup(B1,C1:E3,2,0), If the value of A1 is \"1\", then I simply want a blank cell value for A2. I want this macro to occur upon opening the excel. I thought this would work but it is not\n\nSub test()\n\n Dim indicator As Value\n Dim result As String\n\n indicator = Range(\"A1\").Value\n\n If indicator = 0 Then result = \"=VLOOKUP(A3,C1:D3,2,0)\"\n\n Range(\"a2\").Value = result\n\nEnd Sub"
] | [
"vba",
"excel"
] |
[
"Can \"Windows Error Reporting\" be used for non-fatal Java problems?",
"I was wondering if there was a way to use Windows Error Reporting from \"inside\" a Java program?\n\nIn other words, use the mechanism to report exceptions back to a central location without having the actual JVM crash (which to my understanding is what triggers this in the first place).\n\nThe idea here is to make it easier to collect bug reports from Windows users. \n\n\n\nI'd like to hear too if it can be part of a controlled shutdown. I.e. not a JVM crash but a normal, controlled exit from a Java program.\n\n\n\nAfter thinking it over, I think that it would be sufficient for our purposes to create a set of text files (or perhaps just pipe in a single text stream) to a tiny Windows application located inside our part of the file system. Said Windows application then crashes prominently and cause a report to be sent including the text provided by us. Would that work?"
] | [
"java",
"windows-error-reporting"
] |
[
"Clustered Bar plot in r using ggplot2",
"Snip of my data frame is\n\n\n\nBasically i want to display barplot which is grouped by Country i.e i want to display no of people doing suicides for all of the country in clustered plot and similarly for accidents and Stabbing as well.I am using ggplot2 for this.I have no idea how to do this.\n\nAny helps.\n\nThanks in advance"
] | [
"r",
"ggplot2"
] |
[
"How to convert a column of array values",
"How do I convert a column containing array values into separate columns:\n\nMultiple rows, one column\n\n{100,67,9}\n{100,100} \n{100,100,100}\n{100,9}\n\n\nMultiple rows, multiple columns\n\n100 67 9\n100 100 \n100 100 100\n100 9"
] | [
"sql",
"postgresql",
"pgadmin"
] |
[
"how to add space between two columns in contact form 7",
"I have made form in contact form 7, and i have used Column Shortcodes plugin that form should have two fields in one row, its worked but where do i add some space between two fields in one row \nI have tried this .wpcf7 p {margin-right:10px;} but it does not take effect \n\nhere is the link to site\nhttps://www.childrensdentalclinicjonesboro.com/admission/\n\nI expect that the each fields should have little space between them, but its does not have"
] | [
"wordpress",
"contact-form-7"
] |
[
"Avoid string concatenation to create queries",
"Martin Fowler in his book Patterns of enterprise application architecture says\n\n\n A good rule of thumb is to avoid string concatenation to put together\n SQL queries\n\n\nIt is a practice that I use quite often, to abstract the syntax of my SQL queries from the real data of the query.\n\nCan you explain me why this is considered a bad practice?"
] | [
"sql"
] |
[
"How to fix \"InnoDB: Failed to find tablespace for table X in the cache. Attempting to load the tablespace with space\"",
"Mysql doesn't work, I get the following error:\n\n[ERROR] InnoDB: Failed to find tablespace for table '\"database\".\"table\"' in the cache.\nAttempting to load the tablespace with space id 1290."
] | [
"mysql"
] |
[
"FlushFileBuffers on already written file",
"I have a component that writes his structure to a file.\nThe problem is that the data that he writes needs to be consistent at any system failure.\nSo I need to physical write the data.\nThe problem is that the component doesn't have such an option and to make a filesaver function from component data will take some time and will complicate the program.\n\nThe question is:\nIf I wrote the data with component (ex: ComponentX->WriteToFile(filename) ) can I then use Handle = OpenFile(filename) and then FlushFileBuffers(Handle) to ensure the consistency of the data? Or this trick will not work?\n\nI through that this may work because maybe at OpenFile the system uses the handle already in cache and flushing it will result in saving the cached data from the previous operation (component file save) but I'm not sure.\n\nIf this might not work is there any other method rather than making the data from the component by my self (with CreateFile, ...)"
] | [
"c++",
"file",
"winapi",
"io",
"flush"
] |
[
"Unable to get input regex pattern in type=\"email\" to work correctly",
"I have the following regex pattern that I'm using to validate against email addresses in JavaScript which currently works.\n\n\r\n\r\nconst match = (email) => /^(\"?)(?:[A-Z0-9_%+-]\\.?)+[A-Z0-9_%+-]\\1@(?:(?:(?:[A-Z0-9](?:[A-Z0-9-]*[A-Z0-9])?\\.)+[A-Z]{2,})|(?:(?:[0-9]{3}\\.){3}[0-9]{3})|(?:\\[(?:[0-9]{3}\\.){3}[0-9]{3}\\]))$/i.test(email);\r\n \r\nconsole.log(match('[email protected]'))\r\nconsole.log(match('[email protected]'))\r\nconsole.log(match('@.com'))\r\n\r\n\r\n\n\nI've been attempting to use the HTML pattern prop to validate against this pattern, but I can't seem to get it to work correctly.\n\nI've tried the same pattern but I can't seem to get it to work. I've also tried unescaping the regex pattern too.\n\n\r\n\r\n<form>\r\n <label for=\"email\">Enter your email:</label>\r\n <input type=\"email\" id=\"email\" name=\"email\" pattern='/^(\"?)(?:[A-Z0-9_%+-]\\.?)+[A-Z0-9_%+-]\\1@(?:(?:(?:[A-Z0-9](?:[A-Z0-9-]*[A-Z0-9])?\\.)+[A-Z]{2,})|(?:(?:[0-9]{3}\\.){3}[0-9]{3})|(?:\\[(?:[0-9]{3}\\.){3}[0-9]{3}\\]))$/'>\r\n <input type=\"submit\">\r\n</form>\r\n\r\n\r\n\n\nCurrently any email address results in an incorrect pattern match. Do I need to format the regex pattern differently to support this?"
] | [
"html",
"regex"
] |
[
"Akka Named Resource Serial Execution",
"I'm looking for suggestions on how to accomplish the following. My Akka application, which will be running as a cluster, will be persisting to a backend web service. Each resource I'm persisting is named. For example: A, B, C\n\nThere will be a queue of changes for each resource, and I'm looking for an idea on how I can have a configuration which allows me to control the following:\n\n\nMaximum number of REST calls in progress at any point in time (overall concurrency)\nEnsure that only one REST request for each named resource is in progress\nIt's fine for concurrent requests, as long as they are not for the same resource\nThe named resources are dynamic, based on records in a database\n\n\nThanks"
] | [
"scala",
"akka"
] |
[
"sunspot 1.10 - solr_home",
"I'm using sunspot 1.1.0 , and I tried setting the solr_home in sunspot.yml . when I fire the solr it doesn't take solr_home into account.\nIs there another way to start solr \"rake sunspot:solr:start\" and pass in the solr_home ?"
] | [
"ruby-on-rails",
"solr",
"rake",
"sunspot-rails"
] |
[
"Android AlertDialog - How do I handle extremely large message?",
"I'm popping up an AlertDialog when a ListView item is clicked and the string of the message is very large (nearly 20,000 characters). What winds up happening is that I click the list item and it sits for about 3-4 seconds before displaying the AlertDialog. This is problematic for many reasons, primarily that the user could click the button repeatedly and crash the app.\n\nMy first thought was to try to mimic how the Google Play app handles their open source license display (Play -> Nav Drawer -> Settings -> Open Source License info), where they pop open the AlertDialog and then it looks as though the view/text is loaded after the dialog is shown. I imagined it looking something like this:\n\nAlertDialog.Builder builder = new AlertDialog.Builder(this);\n builder.setTitle(title);\n builder.setMessage(veryLongStringMessage);\n builder.setCancelable(true);\n builder.setNeutralButton(android.R.string.ok, listener);\n\n final AlertDialog alertDialog = builder.create();\n alertDialog.show();\n\n\nPretty basic stuff up until this point. Then I've tried to remove the message set in builder for something like:\n\nbuilder.setMessage(\"\")\n// create/show dialog as above\nalertDialog.setMessage(veryLongStringMessage);\n\n\nBut that seems to just load the whole dialog before showing it. So I thought maybe post a runnable to go at the end of the activity calls, and that wasn't working. I tried doing this in an Async task and could not get it working that way either. I've tried this as a DialogFragment where I call\n\nactivity.getSupportFragmentManager().executePendingTransactions();\n\n\nThen go on to try to set the message after I know the DialogFragment has been shown and I either wind up with an empty dialog (the new message won't show up) or it loads it all at once and I'm sitting with that 3-4 second delay.\n\nAnyone have any good method of implementing and AlertDialog with a very large message?"
] | [
"android",
"android-layout",
"android-fragments"
] |
[
"MVC Control for pdf viewer not consistent",
"<object id='pdfbox' style=\"width:900px; height:800px;\" type=\"application/pdf\" \n data=\"@Url.Action(\"Action\", \"Controller\", new { sID = this.Model.sID })\">\n</object>\n\n\nThis control is used to show the pdf files in the view .\n\nThis control works fine in some systems but in build and some other machines ,it is not working .Is something needs to be installed?"
] | [
"asp.net-mvc",
"asp.net-mvc-4"
] |
[
"Making violin plots for a time series in R",
"I'm trying to make violin plots for my study with repeated measures. Temperature was measured every minute during rest, exercise, and recovery. I want to visualize my data using violin plots every 10 minutes. Connecting the time points with a trace line.\ndat <- structure(list(Rectal = c(37.7471747885623, 37.7456113500327, 37.7424555990783, 37.7387318056167, 37.7346179421912, 37.7299800892173, 37.7230333767273, 37.7170454766354, 37.7097134366366, 37.7031506231242, 37.6977658019971, 37.6640745122859, 37.6699817796991, 37.6796325244397, 37.6906170952057, 37.7023743423906, 37.7146427686485, 37.7313029547686, 37.7502699566081, 37.7701378827216), Time = structure(1:20, .Label = c("00:00:00", "00:01:00", "00:02:00", "00:03:00", "00:04:00", "00:05:00", "00:06:00", "00:07:00", "00:08:00", "00:09:00", "00:10:00", "00:11:00", "00:12:00", "00:13:00", "00:14:00", "00:15:00", "00:16:00", "00:17:00", "00:18:00", "00:19:00", "00:20:00", "00:21:00", "00:22:00", "00:23:00", "00:24:00", "00:25:00", "00:26:00", "00:27:00", "00:28:00", "00:29:00", "00:30:00", "00:31:00", "00:32:00", "00:33:00", "00:34:00", "00:35:00", "00:36:00", "00:37:00", "00:38:00", "00:39:00", "00:40:00", "00:41:00", "00:42:00", "00:43:00", "00:44:00", "00:45:00", "00:46:00", "00:47:00", "00:48:00", "00:49:00", "00:50:00", "00:51:00", "00:52:00", "00:53:00", "00:54:00", "00:55:00", "00:56:00", "00:57:00", "00:58:00", "00:59:00", "01:00:00", "01:01:00", "01:02:00", "01:03:00", "01:04:00", "01:05:00", "01:06:00", "01:07:00", "01:08:00", "01:09:00", "01:10:00", "01:11:00", "01:12:00", "01:13:00", "01:14:00", "01:15:00", "01:16:00", "01:17:00", "01:18:00", "01:19:00", "01:20:00", "01:21:00", "01:22:00", "01:23:00", "01:24:00", "01:25:00", "01:26:00", "01:27:00", "01:28:00", "01:29:00"), class = "factor")), row.names = c(NA, 20L), class = "data.frame")\n\n\nWho knows how to do this? :)\nThanks in advance!"
] | [
"r",
"ggplot2",
"violin-plot"
] |
[
"Grails - html-cleaner plugin",
"I am using this plugin:\n\ncompile \":html-cleaner:0.2\" \n\nI want to keep \\n characters in my strings\n\n def s = \"a\\nb\\nc\\n\"\n println s \n\n\nPrints:\n\na \nb \nc \n\n\nWhen I use:\n\nprintln cleanHtml(s, 'none')\n\n\nIt prints:\n\na b c\n\nYou can create a whitelist using:\n\nhtmlcleaner {\n whitelists = {\n whitelist(\"sample\") {\n startwith \"none\"\n allow \"b\", \"p\", \"i\", \"span\"\n }\n }\n}\n\n\nHow can I keep the \\n characters from being stripped?"
] | [
"grails",
"jsoup"
] |
[
"Use one or multiple random number generators for genetic algorithms?",
"I'm implementing a genetic algorithm using Java programming language. As you know, there are some random events in the algorithm like roullete selection, crossover, mutation, etc. In order to generate a better probability distribution among these events, which approach should be better, to use a unique Random object or create a separate Random object for each event?"
] | [
"java",
"random",
"genetic-algorithm"
] |
[
"for loop help and storing expression results",
"completely new to java and struggling with my assignments, I don't just want to ask for answers but the tutors are not even giving me the methods to use to write my code so I am struggling.\nthe advice given to me is to tidy up the formatting of the code so all the lines are either at the same level or cascade in one direction. needless to say this did no help.\nI feel I am close, but might benefit from a push in the right direction.\nthe question is: In this part you will write a public method calculateCheckNumber() to find S and then use the expression given in part (d) to find C. The method should first create a string omitting the last digit of the longNumber and then find S by iterating through this string. (You may choose to do a separate iteration for the odd and even indexes, or you could do both in a single loop.)\nFinally, your method should calculate and return the value of C using the expression given in (d). Choose meaningful identifiers for your variables.\nExpression:\nCheck that the long number has exactly 16 digits. If not, the long number is not valid.\nIf the long number has 16 digits, drop the last digit from the long number, as this is the "check digit" that we want to check against.\nMultiply by 2 the value of each digit starting from index 0 and then at each even index. In each case, if the resulting value is greater than 9, subtract 9 from it. Leave the values of the digits at the odd indexes unchanged.\nAdd all the new values derived from the even indexes to the values at the odd indexes and call this S.\nFind the number that you would have to add to S to round it up to the next highest multiple of 10. Call this C. If C equals the check digit, then the long number could be valid.\n public class CreditCardChecker\n {\n // Variable for long numbers to be checked\n public String longNumber;\n public int checkDigit;\n public int checkSum;\n public int evenNumber;\n\n /**\n * Constructor for objects of class CreditCardChecker\n * including long number\n */\n public CreditCardChecker(String longNumber)\n {\n // initialise long number variable\n this.longNumber=longNumber;\n this.checkDigit=checkDigit;\n this.checkSum=checkSum;\n }\n /**\n * Sets the value of long number\n */\n public void setLongNumber(String aLongNumber)\n {\n this.longNumber=aLongNumber;\n }\n /**\n * method to get the long number\n */\n public String getLongNumber()\n {\n return this.longNumber;\n } \n /**\n * method to check that long number has exactly 16 digits\n */ \n public boolean isCorrectLength()\n {\n if (longNumber.length() == 16)\n {\n return (true);\n }\n else\n {\n return (false);\n }\n }\n /**\n * Method to get the first 15 characters of long number\n */\n public String firstFifteen()\n {\n return longNumber.substring(0, 15);\n }\n /**\n * Method to calculate the check number from the long number\n */\n public int calculateCheckNumber()\n\n { \n int checkSum=longNumber.charAt(15);\n evenNumber = Integer.parseInt(longNumber);\n for(int longNumber=0; longNumber<= 15; longNumber++){\n System.out.println(evenNumber);\n if (evenNumber %2==0)\n return (evenNumber *2);\n \n if (evenNumber>=9)\n return (evenNumber-9);\n checkSum = evenNumber + evenNumber++;\n }\n return this.evenNumber;\n }\n\n }"
] | [
"java"
] |
[
"How to automate tests for iOS app shortcuts?",
"I have built 4 application shortcuts for the iOS app I'm developing these days. The shortcut menu is triggered by the 3D touch gesture made on the app icon. My question is whether there is a way to automate tests for this? (may be using UIAutomation)"
] | [
"ios",
"objective-c",
"swift",
"ios-ui-automation",
"3dtouch"
] |
[
"Error while importing new projects into eclipse",
"My eclipse is showing errors on the project folder when I am importing a new project into my eclipse. I am not able to find the reason. Please see the attached image of the error. \n\n\n\n[2012-11-12 12:11:32 - ProfilePictureSample] Unable to resolve target 'android-8'\n[2012-11-12 12:11:32 - BooleanOGSample] Unable to resolve target 'android-8'\n[2012-11-12 12:11:32 - Hackbook] Unable to resolve target 'android-8'\n[2012-11-12 12:11:32 - Scrumptious] Unable to resolve target 'android-8'\n[2012-11-12 12:11:32 - PlacePickerSample] Unable to resolve target 'android-8'\n[2012-11-12 12:11:32 - SessionLoginSample] Unable to resolve target 'android-8'\n[2012-11-12 12:11:32 - FriendPickerSample] Unable to resolve target 'android-8'\n[2012-11-12 12:11:32 - HelloFacebookSample] Unable to resolve target 'android-8'\n\n\nThese are the error messages are shown in the console. I have sdk version's 4.1 (API level 16) and 4.0.3 (API level 15) in my eclipse."
] | [
"android",
"eclipse",
"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.