texts
sequence | tags
sequence |
---|---|
[
"check value of checkboxes inside listview",
"I have a ListView with a checkbox field inside that gets the id set dynamically.\n\nI also have a button that when pressed needs to check if any of the checboxes have been checked but I'm not sure how to get this done.\n\nAny idea on how I can get this done?\n\nThanks\n\nThis is my code:\n\n<asp:ListView ID=\"ListView1\" runat=\"server\" DataKeyNames=\"Id\" \n DataSourceID=\"EntityDataSource1\" EnableModelValidation=\"True\"> \n\n <ItemTemplate>\n <tr>\n <td class=\"firstcol\">\n <input id='Checkbox<%# Eval(\"Id\") %>' type=\"checkbox\" />\n </td>\n </tr>\n </ItemTemplate>\n\n <LayoutTemplate>\n <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n <tr>\n <th width=\"50\" scope=\"col\" class=\"firstcol\">\n\n </th>\n </tr>\n <tr ID=\"itemPlaceholder\" runat=\"server\"></tr>\n </table>\n <asp:Button ID=\"btnDownload\" runat=\"server\" Text=\"Download\" Height=\"26px\" \n onclick=\"btnDownload_Click\" />\n </LayoutTemplate>\n</asp:ListView>\n\n\n\nprotected void btnDownload_Click(object sender, EventArgs e)\n{\n ???????\n}"
] | [
"c#",
".net",
"asp.net",
"listview"
] |
[
"Get status from trainer in ML Engine job (Google Cloud Platform)",
"we have the following architecture to connect with GCP (Google Cloud Platform):\n\n\nModule A: Launches ML Engine jobs remotely (ex: from AWS, our local machine...)\nModule B: GCP (ML Engine). Accepts external requests and runs a specific trainer that we configured.\nModule C: Trainer. It is ran by ML Engine. It runs a learn process and creates a model under /export/Servo/<timestamp>.\n\n\nSo, from what we have seen in the GCP documentation, to override this path we would need to re-implement estimator.export_savedmodel which we totally want to avoid.\n\nThe other solution that we thought about was to send the output folder from the trainer to the ML Engine job, so that when our Module A asks for the status of that ML Engine Job, it gets the output folder.\n\nIs there a way to do this? Is there any easier way?"
] | [
"python",
"tensorflow",
"google-cloud-platform"
] |
[
"Print full filenames with spaces in shell with find command",
"I have a find command that will print size and filename(along with full path) of the 20 largest files on the given directory and write it into a file:\n\nfind ${DIR} -type f -size +1M -exec du -h '{}' + | sort -hr|awk '{print $1\",\"$2}'|head -20 >>files.csv\n\n\nThe problem is, there exist some files with spaces in their file names. These file names are only printed till the first space.\n\nEx: A file named 'hello there.txt' is printed as 'hello'\n\nI tried setting the IFS to '\\n',\n\ni.e. IFS=$'\\n',\n\n\nbut the problem still persists.\n\nAny help will be much appreciated.\n\nThanks!"
] | [
"shell",
"scripting",
"find",
"filenames",
"spaces"
] |
[
"Garbage Collection and Callbacks",
"If I have object A, which calls DAO object B to perform some database update - Once B's function completes it calls a call back function in A (A.finishProcess()) does this create memory issues? I mean does B then remain in memory until A completes? or is B still removed with GC?\n\nI ask this as I'm considering using call backs instead of returning a \"result\" object or code from B.\n\nIn short, is it better design (and memory usage) wise to \"return\" an object of results rather than using a callback to a calling object?\n\nPS: Please ignore specific's ie, it doesn't mention AsycnTask, its a contrived situation to get my question across :)\n\nCheers for any help"
] | [
"java",
"android",
"callback",
"garbage-collection"
] |
[
"Axis Labels in Pyplot Heatmap",
"I can make a heatmap using:\nIndex= [np.arange(0, 1, 1/5)]\nCols = ['A', 'B', 'C', 'D']\ndf = DataFrame(abs(np.random.randn(5, 4)), index=Index, columns=Cols)\n\nplt.pcolor(df)\nplt.yticks(np.arange(0.5, len(df.index), 1), df.index)\nplt.xticks(np.arange(0.5, len(df.columns), 1), df.columns)\nplt.show()\n\nwhich gives:\n\nHow can I change the y axis labels to '0.0 0.5 1.0' please?"
] | [
"python",
"pandas",
"matplotlib",
"heatmap",
"axis-labels"
] |
[
"Weird Behavior of Google ReCaptcha V2",
"I am using PHP Mailer to mail the details of a form to a particular Email Address. But before that the code checks the server side validation of Google Recaptcha Version 2. I am facing this weird behavior where the server validation is always returning me false. I am not able to figure out why? I have double-checked the site and secret keys and both are as defined my google account. Following is the code:\n\n <?php \n require 'PHPMailer-master/src/PHPMailer.php';\n require 'PHPMailer-master/src/SMTP.php';\n require 'PHPMailer-master/src/Exception.php';\n if(isset($_POST['submit'])) \n {\n $captcha;\n $target_dir = \"Upload_Attachment/\";\n $name = htmlentities($_POST['name']);\n $email = htmlentities($_POST['email']);\n $mobile = htmlentities($_POST['mobile']);\n $edu_qual = htmlentities($_POST['edu_qual']);\n $years_exp = htmlentities($_POST['years_exp']);\n $comments = htmlentities($_POST['frmrequirements']);\n if(isset($_POST['g-recaptcha-response']))\n {\n $captcha=$_POST['g-recaptcha-response'];\n }\n if(!$captcha)\n {\n echo '<script>alert(\"Something Went Wrong!\");</script>';\n exit;\n }\n $secretKey = \"MY_SECRET_KEY\";\n $ip = $_SERVER['REMOTE_ADDR'];\n\n $response=file_get_contents(\"https://www.google.com/recaptcha/api/siteverify?secret=\".$secretKey.\"&response=\".$captcha.\"&remoteip=\".$ip);\n $responseKeys = json_decode($response,true);\n if(intval($responseKeys[\"success\"]) !== 1) {\n echo '<script>alert(\"Something Went Wrong!\");</script>';\n exit;\n } \n else \n {\n $ds= DIRECTORY_SEPARATOR;\n $target_dir = \"resume_files\".$ds;\n $target_file = $target_dir . basename($_FILES[\"my_File\"][\"name\"]);\n if (move_uploaded_file($_FILES[\"my_File\"][\"tmp_name\"], $target_file)) \n {\n //echo \"The file \". basename($file). \" has been uploaded.\";\n } \n else \n {\n echo '<script>alert(\"Something Went Wrong!\");</script>';\n }\n $mail = new PHPMailer\\PHPMailer\\PHPMailer();\n $mail->isSMTP(); // enable SMTP\n $mail->SMTPAuth = true; // authentication enabled\n $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail\n $mail->Host = \"smtp.gmail.com\";\n $mail->Port = 465; // or 587\n $mail->isHTML();\n $mail->Username = \"MY_USER_NAME\";\n $mail->Password = \"MY_PASSWORD\";\n $mail->SetFrom(\"MY_EMAIL\");\n $mail->Subject = \"Job Enquiry from \".$_POST['name'];\n $mail->Body = \"\n <html>\n <body>\n <table cellspacing = '5' cellpadding = '5' border='2'>\n <tr>\n <td>Name:</td> \n <td>\".$name.\"</td>\n </tr>\n <tr>\n <td>Email ID:</td>\n <td>\".$email.\"</td>\n </tr>\n <tr>\n <td>Mobile No:</td> \n <td>\".$mobile.\"</td>\n </tr>\n <tr>\n <td>Years of Experience:</td>\n <td>\".$years_exp.\"</td>\n </tr>\n <tr>\n <td>Educational Qualification:</td>\n <td>\".$edu_qual.\"</td>\n </tr>\n <tr>\n <td>Comments:</td>\n <td>\".$comments.\"</td>\n </tr>\n </table>\n </body>\n </html>\n \";\n $mail->addAttachment($target_file);\n $mail->AddAddress(\"TARGET_EMAIL_ID\");\n if(!$mail->Send()) \n {\n echo '<script>alert(\"Something Went Wrong!\");</script>';\n }\n else \n {\n unlink($target_file);\n }\n echo \"<script>location='careers?success=1'</script>\";\n }\n}\n?>\n\n\nPlease help me."
] | [
"php",
"recaptcha"
] |
[
"Sum Function not working in SQL",
"Possible Duplicate:\n Sum a column of a table based on another sum of a table \n\n\n\n\nI sum up a column from an already summed column in a sub-select in sql but it gives me the same value as the already summed column. The TotalAmount is supposed to add up to the InvoiceTotal but it just copies the same value. Can anyone see what I am doing wrong or if there is a better way to go about this?\n\ndeclare @ReportLines table \n (RebateInvoiceID int, \n RebateSetupID int ,\n ShortItemNo float primary key(RebateInvoiceID,RebateSetupID,ShortItemNo),\n TotalAmount float,\n InvoiceTotal float,\n TotalQuantity int )\ninsert @ReportLines\nselect\n Total.RebateInvoiceID\n, Total.ID\n, Total.ShortItemNo\n, Total.TotalAmount\n, sum(Total.TotalAmount) as InvoiceTotal\n, Total.TotalQuantity\nfrom\n(\nselect \ni.RebateInvoiceID\n,coalesce(rs.WholesalerRebateSetupID,r.RebateSetupID) as ID\n,bl.ShortItemNo\n, sum(round(r.Amount,2)) as TotalAmount\n, sum(r.Quantity) TotalQuantity\nfrom\n @Invoices i\n join RebateInvoices ri (nolock) on \n ri.RebateInvoiceID=i.RebateInvoiceID\n inner loop join Rebates r (nolock) on\n r.RebateInvoiceID=i.RebateInvoiceID \n join RebateSetup rs (nolock) on\n rs.RebateSetupID=r.RebateSetupID\n join BidLines bl (nolock) on \n r.BidLineGuid=bl.BidLineGuid\n join @Products p on\n p.ShortItemNo=bl.ShortItemNo\n left join ChargebackDetailHistory cd (nolock) on \n r.DocumentBranchPlant = cd.DocumentBranchPlant\n and r.DocumentNumber = cd.DocumentNumber\n and r.DocumentType = cd.DocumentType\n and r.LineNumber = cd.LineNumber\n left join EDI.dbo.JDE_SaleDetail sd (nolock) on \n r.DocumentBranchPlant = sd.BranchPlant\n and r.DocumentNumber = sd.OrderNumber\n and r.DocumentType = sd.OrderType\n and r.LineNumber = sd.LineNumber\nwhere \n cd.InvoiceDate between @BeginDate and @EndDate\n or sd.InvoiceDate between @BeginDate and @EndDate\ngroup by\n i.RebateInvoiceID\n, coalesce(rs.WholesalerRebateSetupID,r.RebateSetupID)\n, bl.ShortItemNo\n) Total\n\ngroup by \ntotal.rebateinvoiceid,\ntotal.ID,\ntotal.shortitemno,\ntotal.totalamount,\ntotal.totalquantity"
] | [
"sql",
"sum"
] |
[
"How to access a property of an object stdClass Object?",
"Doing print_r() on my array I get the following:\n\n stdClass Object\n (\n[Products] => Array\n (\n [0] => stdClass Object\n (\n [Id] => 265531\n [ProductTitle] => test0\n [ZarfiyatSalane] => 600.000\n [MizanJazbMavad] => 660.000\n )\n [1] => stdClass Object\n (\n [Id] => 265532\n [ProductTitle] => test1\n [ZarfiyatSalane] => 500.000\n [MizanJazbMavad] => 500.000\n )\n\n )\n\n)\n\n\nHow can I access a specific value in the array?\n The following code does not work because of the stdClass Object\n\necho $array['ProductTitle'];"
] | [
"object",
"stdclass"
] |
[
"Understanding Promises in Javascript",
"I was trying to comprehend the use of Promise in Javascript for which Google search lead me to this article \n\nThe author of post points out this \n\n\n Promises (like callbacks) allow us to wait on certain code to finish\n execution prior to running the next bit of code.\n\n\nWhich for some reason sounded like this to me (and it porbably might be)\n\n axios.get(url).then((response) => ).catch((err) => \n\n\nThereafter he showed this example \n\nfunction delay(t){\n return new Promise(function(resolve){\n return setTimeout(resolve, t)\n });\n}\nfunction logHi(){\n console.log('hi');\n}\ndelay(2000).then(logHi);\n\n\nHere, I am unable to comprehend what/how are we passing something in resolve here function(resolve) and when do we use something like \n\n return new Promise(function(resolve){\n\n\nand when do we do something like \n\n axios.get(url).then((response) => ).catch((err) =>"
] | [
"javascript"
] |
[
"Iterate over arguments in a bash script and make use of their numbers",
"If I want to iterate over all arguments it is as easy as for i in \"$@\"; do .... However, let's say I want to start with the second argument and also make use of the arguments' positions for some basic calculation.\n\nAs an example I want to shorten these commands into one loop:\n\ngrep -v 'foobar' \"$2\" | grep -f $file > output1.txt\ngrep -v 'foobar' \"$3\" | grep -f $file > output2.txt\ngrep -v 'foobar' \"$4\" | grep -f $file > output3.txt\ngrep -v 'foobar' \"$5\" | grep -f $file > output4.txt\n\n\nI tried many variations like for i in {2..5}; do grep -v 'foobar' \"$$i\" | grep -f $file > output$(($i-1)).txt; done; however, it seems bash expansion doesn't work like this.\n\nEDIT:\n\nSeems I made a mistake not emphasizing that I need to make use of the argument's position/number (i.e., 2 from $2). It's important because the output files get used separately later in the script. All of the provided answers so far seem correct but I don't know how to use them to make use of the argument's \"number\"."
] | [
"bash",
"loops",
"command-line"
] |
[
"Colab OSError: [Errno 36] File name too long when reading a docx2text file",
"I am studying NLP techniques and while I have some experience with .txt files, using .docx has been troublesome. I am trying to use regex on strings, and since I am using a word document, this is my approach:\nI will use textract to get a docx to txt and get the bytes to strings:\nimport textract\nmy_text = textract.process("1337.docx")\nmy_text = text.decode("utf-8")\n\nI read the file:\ndef load_doc(filename):\n\n # open the file as read only\n file = open(filename, 'r')\n\n # read all text\n text = file.read()\n\n # close the file\n file.close()\n\n return text\n\nI then try and do some regexs such as remove all numbers and etc, and when executing it in the main:\ndef regextest(doc):\n\n...\n\n...\ntext = load_doc(my_text)\ntokens = regextest(text)\nprint(tokens)\n\nI get the exception:\nOSError: [Errno 36] File name too long: Are you buying a Tesla?\\n\\n\\n\\n - I believe the pricing is...(and more text from te file)\n\nI know I am transforming my docx file to a text file and then, when I read the "filename", it is actually the whole text. How can I preserve the file and make it work? How would you guys approach this?"
] | [
"python-3.x",
"nlp",
"nltk",
"re"
] |
[
"Drawing text over/in a Process/Game",
"I'm currently working on a C++ DLL project.\nThis DLL will be injected into a game.\n\nAll I'm looking to do for now is draw some text like \"Active\" or \"Working\" in the bottom right or left hand corner of the screen when in game.\n\nJust to give me something visual to show that the DLL is working and active/injected."
] | [
"c++",
"text",
"drawing"
] |
[
"Unexpected Keras predictions",
"I tried the keras tutorial that I found here...\n\nhttps://github.com/eijaz1/Building-a-CNN-in-Keras-Tutorial/blob/master/cnn_tutorial.ipynb\n\nEverything worked fine till line 10. \nBut I am not able to predict correctly. I get the results like this...\n\nmodel.predict(X_test[:4])\n\narray([[0., 0., 1., 0., 0., 0., 0., 0., 0., 0.],\n [0., 0., 1., 0., 0., 0., 0., 0., 0., 0.],\n [0., 0., 1., 0., 0., 0., 0., 0., 0., 0.],\n [0., 0., 1., 0., 0., 0., 0., 0., 0., 0.]], dtype=float32)\n\n\nThe expected results as per the tutorial are:\n\narray([[1.6117248e-09, 8.6684462e-16, 6.8095707e-10, 1.5486043e-08,\n 6.2878847e-14, 1.2934288e-15, 1.1453808e-16, 9.9999928e-01,\n 1.0626109e-08, 6.9729606e-07],\n [1.3555871e-07, 2.6465393e-06, 9.9999511e-01, 2.0351818e-08,\n 1.9796262e-11, 1.6996018e-12, 2.1163373e-06, 1.2008194e-17,\n 4.8792381e-10, 2.6086671e-13],\n [6.7238901e-08, 9.9785548e-01, 1.9031411e-04, 3.9194603e-08,\n 1.2894072e-04, 1.5791730e-06, 1.2754040e-06, 4.1349044e-09,\n 1.8221687e-03, 5.5910935e-08],\n [9.9999356e-01, 1.6909821e-12, 8.2496926e-10, 1.7359107e-11,\n 1.7359230e-12, 1.8865266e-13, 6.4659162e-06, 2.3738855e-11,\n 1.1319052e-08, 2.6948474e-08]], dtype=float32)\n\n\nI am using keras version 2.2.2 if that matters. \n\n\n\nUpdate:\n\nWhile training the model, I am getting pretty low accuracy compared to that tutorial. \n\nmodel.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=3)\n\nTrain on 60000 samples, validate on 10000 samples\nEpoch 1/3\n60000/60000 [==============================] - 75s 1ms/step - loss: 14.3141 - acc: 0.1118 - val_loss: 14.2677 - val_acc: 0.1148\nEpoch 2/3\n60000/60000 [==============================] - 74s 1ms/step - loss: 14.3741 - acc: 0.1082 - val_loss: 14.4692 - val_acc: 0.1023\nEpoch 3/3\n60000/60000 [==============================] - 134s 2ms/step - loss: 14.3691 - acc: 0.1085 - val_loss: 14.3483 - val_acc: 0.1098\n\n\nHow do I improve the accuracy? I am using exactly same code as shown in the tutorial.\n\nHere is the output that I get even if I use the exactly same code:\n\nhttps://github.com/shantanuo/Building-a-CNN-in-Keras-Tutorial/blob/master/cnn_tutorial_mismatch.ipynb"
] | [
"python",
"machine-learning",
"keras",
"keras-2"
] |
[
"How to insert text into specific line in textarea with jQuery?",
"If I have this HTML code:\n\n<textarea>\nline 1 text\nline 2 text\nline 3 text\nline 4 text\nline 5 text\n</textarea>\n\n\nHow can I insert text after the third line, so my result is this:\n\n<textarea>\nline 1 text\nline 2 text\nline 3 text\nthis is my new text here!!!!!!!!!\nline 4 text\nline 5 text\n</textarea>"
] | [
"javascript",
"jquery"
] |
[
"Word Object Model to Open Xml - get StyleId from Style WOM object",
"I am trying to interop between the Word Object Model and Open XML SDK. Given the Style WOM object, how do I map it to the corresponding Style.StyleId in OpenXML?\nWord Object Model Style object exposes the NameLocal property, but its value is localized and I cannot convert it to the (locale-invariant) style id. There is nothing that returns the corresponding styleId attribute stored in the DOCX file.\nI could create a DOCX file using the Word Object Model and open it using Open XML SDK to enumerate all available style, but that seems like a kludge..."
] | [
"ms-word",
"openxml",
"openxml-sdk"
] |
[
"How to get only the Time from DateTime datatype",
"I have a table called TimeSpan. It contains a column StartTime. StartTime is of type DateTime. In my view I pass a time. Therefore, I need to convert StartTime to time(\"HH:mm\"). How can I accomplish that?\n\npublic ActionResult planview(Double budget, DateTime startTime, DateTime endTime)\n{\n var model = from Ts in db.TimeSpans \n where Ts.StartTime < startTime \n select Ts;\n return View(model);\n}\n\n\nThe above query needs to be changed to Ts.StartTime(convert to time) < startTime."
] | [
"c#",
"asp.net-mvc",
"datetime"
] |
[
"PHP empty TMP_NAME on iOS Upload Image",
"I am currently developing an iOS project that requests the user to upload an image to the server.\n\nI currently have this code in my class in Objective-C:\n\n NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];\n [request setHTTPShouldHandleCookies:NO];\n [request setTimeoutInterval:60];\n [request setHTTPMethod:@\"POST\"];\n NSString *boundary = @\"------VohpleBoundary4QuqLuM1cE5lMwCy\";\n NSString *contentType = [NSString stringWithFormat:@\"multipart/form-data; boundary=%@\", boundary];\n [request setValue:contentType forHTTPHeaderField: @\"Content-Type\"];\n\n NSMutableData *body = [NSMutableData data];\n NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];\n [parameters setValue:[SSKeychain passwordForService:@\"ID\" account:@\"SpotterBike\"] forKey:@\"ID\"];\n\n for (NSString *param in parameters) {\n [body appendData:[[NSString stringWithFormat:@\"--%@\\r\\n\", boundary] dataUsingEncoding:NSUTF8StringEncoding]];\n [body appendData:[[NSString stringWithFormat:@\"Content-Disposition: form-data; name=\\\"%@\\\"\\r\\n\\r\\n\", param] dataUsingEncoding:NSUTF8StringEncoding]];\n [body appendData:[[NSString stringWithFormat:@\"%@\\r\\n\", [parameters objectForKey:param]] dataUsingEncoding:NSUTF8StringEncoding]];\n }\n\n NSString *FileParamConstant = @\"uploadedfile\";\n NSData *imageData = UIImageJPEGRepresentation(image, 1);\n\n if (imageData){\n [body appendData:[[NSString stringWithFormat:@\"--%@\\r\\n\", boundary] dataUsingEncoding:NSUTF8StringEncoding]];\n [body appendData:[[NSString stringWithFormat:@\"Content-Disposition: form-data; name=\\\"%@\\\"; filename=\\\"image.jpg\\\"\\r\\n\", FileParamConstant] dataUsingEncoding:NSUTF8StringEncoding]];\n [body appendData:[@\"Content-Type:image/jpeg\\r\\n\\r\\n\" dataUsingEncoding:NSUTF8StringEncoding]];\n [body appendData:imageData];\n [body appendData:[[NSString stringWithFormat:@\"\\r\\n\"] dataUsingEncoding:NSUTF8StringEncoding]];\n }\n\n [body appendData:[[NSString stringWithFormat:@\"--%@--\\r\\n\", boundary] dataUsingEncoding:NSUTF8StringEncoding]];\n [request setHTTPBody:body];\n [request setURL:[NSURL URLWithString:@\"http://212.92.57.155/App/UploadImage.php\"]];\n\n\nHowever, although the server recieves the image, I am not able to process it for further usage in it. As you see, tmp_name is empty, so I am not able to move the image to the directory.\n\nprint_r($_FILES['uploadedfile']);\n\n(\n [name] => image.jpg\n [type] => \n [tmp_name] => \n [error] => 1\n [size] => 0\n)\n\n\nAny idea of why this is happening?"
] | [
"php",
"objective-c",
"image-uploading"
] |
[
"Python app import error in Django with WSGI gunicorn",
"I'm trying to deploy a Django app with gunicorn on Heroku and I've run into a few hitches.\n\nWhen I began my project my Django version was 1.3 and didn't contain the standard wsgi.py module, so I added the standard wsgi module as top/wsgi.py (top being my project name, turk being my app name, topturk being the containing directory - preserved so error logs make sense below).\n\nNow when I run\n\ngunicorn top.wsgi:application -b 0.0.0.0:$PORT\n\n\nThe server successfully starts up,\n\n19:00:42 web.1 | started with pid 7869\n19:00:42 web.1 | 2012-07-25 19:00:42 [7869] [INFO] Starting gunicorn 0.14.5\n19:00:42 web.1 | 2012-07-25 19:00:42 [7869] [INFO] Listening at: http://0.0.0.0:5000 (7869)\n19:00:42 web.1 | 2012-07-25 19:00:42 [7869] [INFO] Using worker: sync\n19:00:42 web.1 | 2012-07-25 19:00:42 [7870] [INFO] Booting worker with pid: 7870\n\n\nbut then when I navigate to 0.0.0.0:5000 I get returned an Internal Server Error:\n\n19:00:45 web.1 | 2012-07-25 17:00:45 [7870] [ERROR] Error handling request\n19:00:45 web.1 | Traceback (most recent call last):\n19:00:45 web.1 | File \"/Users/intenex/Dropbox/code/django/topturk/venv/lib/python2.7/site-packages/gunicorn/workers/sync.py\", line 102, in handle_request\n19:00:45 web.1 | respiter = self.wsgi(environ, resp.start_response)\n19:00:45 web.1 | File \"/Users/intenex/Dropbox/code/django/topturk/venv/lib/python2.7/site-packages/django/core/handlers/wsgi.py\", line 219, in __call__\n19:00:45 web.1 | self.load_middleware()\n19:00:45 web.1 | File \"/Users/intenex/Dropbox/code/django/topturk/venv/lib/python2.7/site-packages/django/core/handlers/base.py\", line 47, in load_middleware\n19:00:45 web.1 | raise exceptions.ImproperlyConfigured('Error importing middleware %s: \"%s\"' % (mw_module, e))\n19:00:45 web.1 | ImproperlyConfigured: Error importing middleware turk.middleware.subdomain: \"No module named turk.middleware.subdomain\"\n19:00:47 web.1 | 2012-07-25 17:00:47 [7870] [ERROR] Error handling request\n19:00:47 web.1 | Traceback (most recent call last):\n19:00:47 web.1 | File \"/Users/intenex/Dropbox/code/django/topturk/venv/lib/python2.7/site-packages/gunicorn/workers/sync.py\", line 102, in handle_request\n19:00:47 web.1 | respiter = self.wsgi(environ, resp.start_response)\n19:00:47 web.1 | File \"/Users/intenex/Dropbox/code/django/topturk/venv/lib/python2.7/site-packages/django/core/handlers/wsgi.py\", line 219, in __call__\n19:00:47 web.1 | self.load_middleware()\n19:00:47 web.1 | File \"/Users/intenex/Dropbox/code/django/topturk/venv/lib/python2.7/site-packages/django/core/handlers/base.py\", line 47, in load_middleware\n19:00:47 web.1 | raise exceptions.ImproperlyConfigured('Error importing middleware %s: \"%s\"' % (mw_module, e))\n19:00:47 web.1 | ImproperlyConfigured: Error importing middleware turk.middleware.subdomain: \"No module named turk.middleware.subdomain\"\n\n\nI'm assuming this is a python path error, where the server doesn't know how to import from my app directory\n\nThe relevant import code is here in settings:\n\nMIDDLEWARE_CLASSES = (\n 'turk.middleware.subdomain.SubdomainMiddleware',\n 'turk.middleware.removewww.RemoveWWWMiddleware',\n)\n\n\nI attempted to fix this problem by inserting my app directory into sys.path like so at the top of my settings.py file like so:\n\nPROJECT_ROOT = os.path.dirname(os.path.realpath(__file__))\nsys.path.insert(1, PROJECT_ROOT+'/turk/')\n\n\nWhich I've verified adds the app directory to the path, but still no dice. Any ideas? Also\n\nsys.path.insert(1, PROJECT_ROOT+'/turk/')\n\n\nseems hackish and adds at least two copies of the directory to the path, what's the correct way to append to PYTHON_PATH in Django? Thanks!"
] | [
"python",
"django",
"import",
"wsgi",
"gunicorn"
] |
[
"How to get attribute label in Yii2 ActiveRecord",
"How to get attribute label in Yii2?\n\nI found this function getAttributeLabel() here in Yii2 doc, I am using it in a controller. But it's throwing an error:\n\nCall to undefined function app\\controllers\\getAttributeLabel()"
] | [
"activerecord",
"yii2"
] |
[
"Interface segregation principle - Java",
"I have an interface\n\ninterface XXXCommandHandler(){\n void parse(String something);\n String response();\n String additionalResponse();\n}\n\n\n\nSome of the classes that implement XXXCommandHandler do not implement additionalResponse(). \nI am using ApplicationContextManager.getInstance().getBeansOfType(XXXCommandHandler.class) to get the classes that implement XXXCommandHandler\nThen call parse, response and additionalResponse\nSince some do not implement additionalResponse I am forced to return null.\n\n\nI can think of the following\n\n\nInstead of returning null on classes that do not implement additionalResponse, declaire additionalResponse as default method and return null / or make it return Optional etc and override it on the classes that implement additionalResponse method.\nUgly way :- return null in all the classes that do not implement additionalResponse \nCreate two different interfaces XXXCommandHandlerParser() with parse and response method and XXXCommandHandlerAddtionalresponse() with additionalResponse method extending XXXCommandHandlerParser i.e\n\ninterface XXXCommandHandlerParser(){\n\n void parse(String something);\n String response();\n\n}\n\n\ninterface XXXCommandHandlerAddtionalresponse() \nextends XXXCommandHandlerParser {\n\n String additionalResponse();\n}\n\nBut if I do #3 I had to change \nApplicationContextManager.getInstance().getBeansOfType(XXXCommandHandlerAddtionalresponse.class).\nIf I do #4 then classes that do not implement additionalResponse or that do not implement XXXCommandHandlerAddtionalresponse will not be picked up.\n\n\nCan you think of any elegant way?"
] | [
"java",
"design-patterns",
"coding-style"
] |
[
"Regex get text between tags",
"I try to get the text between a tag in JAVA.\n\n`\n\n<td colspan=\"2\" style=\"font-weight:bold;\">HELLO TOTO</td>\n <td>Function :</td>\n\n\n`\n\nI would like to use a regex to extract \"HELLO TOTO\" but not \"Function :\" \n\nI already tried something like this \n\n`\n\nString btwTags = \"<td colspan=\\\"2\\\" style=\\\"font-weight:bold;\\\">HELLO TOTO</td>\\n\" + \"<td>Function :</td>\";\n Pattern pattern = Pattern.compile(\"<td(.*?)>(.*?)</td>\");\n Matcher matcher = pattern.matcher(btwTags);\n while (matcher.find()) {\n String group = matcher.group();\n System.out.println(group);\n }\n\n\n`\n\nbut the result is the same as the input.\nAny ideas ?\n\nI tried this regex (?<=<td>)(.*?)(?=</td>) too but it only catch \"Function:\" \nI don't know of to set that he could be something after the open <td ...>\n\nAlready thanks in advance"
] | [
"java"
] |
[
"How to expand all nodes that has a children on page load by default in wix angular tree control",
"Has anybody tried to expand all nodes that has a children on page load by default in tree created by angular tree control. It is packed with lots of features but lacks this one. It is having an expanded nodes property. So do we need to find the array of nodes that has children by some other logic and has to pass the same to expanded nodes? Is that the correct logic or am i missing any inbuilt functionality in the directive? Please help\n\nhttp://wix.github.io/angular-tree-control/"
] | [
"javascript",
"angularjs",
"tree"
] |
[
"What protocol and port does npm use?",
"When I run \n\nnpm install\n\n\nWhat protocol and port does it use for fetching the node_modules folder files?\n\nI didn't find an answer by searching here or on Google"
] | [
"npm",
"npm-install",
"node-modules"
] |
[
"SendGrid API | Get Campaign Stats",
"I've been looking for a way to get SendGrid reports but only for specific campaigns. I can see the stats on the Campaigns page of the SendGrid dashboard, but I can't find an API endpoint to get that data.\n\nI was able to retrieve the Global and Overview stats with no problem, but in this case, is not helpful for me. I need per-campaign stats. Is there a way to get those reports through the API?"
] | [
"php",
"sendgrid-api-v3"
] |
[
"Rails 4 has_many :through with collection_check_boxes and additional join table text_field",
"I've already searched about the whole internet but I can't get this forms working. Here's the thing:\n\nI have two models connected by a has_many :through join model:\n\nestoque.rb\n\nclass Estoque < ActiveRecord::Base\n has_many :mpm_ests\n has_many :ordem_de_servicos, :through => :mpm_ests, dependent: :destroy\nend\n\n\nordem_de_servico.rb\n\nclass OrdemDeServico < ActiveRecord::Base\n has_many :mpm_ests, dependent: :destroy\n has_many :estoques, :through => :mpm_ests\n accepts_nested_attributes_for :mpm_ests\nend\n\n\nAnd the join model mpm_est.rb\n\nclass MpmEst < ActiveRecord::Base\n belongs_to :ordem_de_servico\n belongs_to :estoque\nend\n\n\nWhat I want to do is make a collection_check_boxes with a nested extra text_field called quantidade (quantity), as I've setup the join table:\n\nmigration file of the join table (mpm_est):\n\nclass CreateMpmEsts < ActiveRecord::Migration\n def change\n create_table :mpm_ests do |t|\n t.integer :ordem_de_servico_id\n t.integer :estoque_id\n t.string :quantidade\n end\n add_index :mpm_ests, :ordem_de_servico_id\n add_index :mpm_ests, :estoque_id\n add_index :mpm_ests, [:ordem_de_servico_id, :estoque_id], unique: true\n end\nend\n\n\nBut the problem is I have no idea how to do this in my controller and view. I've tried something like this, but it didn't work.\n\nordem_de_servicos_controller.rb\n\ndef new\n @ordem_de_servico = OrdemDeServico.new\n @ordem_de_servico.mpm_ests.build\nend\n\ndef edit\n @ordem_de_servico.mpm_servs.build\n @ordem_de_servico.mpm_ests.build\nend\n\n[...]\n\n def ordem_de_servico_params\n params.require(:ordem_de_servico).permit(:cliente_id, :veiculo, :placa, :mecanico_id, {:estoque_ids => []}, :quantidade, :prazo, :pago, :valor_pago, :historico_pgto, :status)\n end\n\n\nand in my ordem_de_servico _form view:\n\n<%= f.fields_for :mpm_ests do |ff| %>\n <%= ff.collection_check_boxes(:ordem_de_servico, :estoque_ids, Estoque.all, :id, :nome) %>\n <%= ff.text_field :quantidade %><br>\n<% end %>\n\n\nEdit 1\n\nThe basic idea what I want to do is something like this:\n\n\r\n\r\n<!DOCTYPE html>\r\n<html>\r\n<body>\r\n\r\n<h1>Ordem De Servico (Service)</h1>\r\n\r\n<label>Number<label>\r\n<input type=\"text\">\r\n\r\n<label>Service<label>\r\n<input type=\"text\">\r\n\r\n<label>Person<label>\r\n<input type=\"text\">\r\n\r\n<h5>Inventory (estoque)</h5>\r\n<form action=\"\">\r\n<input type=\"checkbox\" name=\"vehicle\" value=\"Bike\">Iron <label>Quantity<label><input type=\"text\"><br>\r\n<input type=\"checkbox\" name=\"vehicle\" value=\"Car\">copper <label>Quantity<label><input type=\"text\"><br>\r\n<br><button>Save Ordem de Servico (service)</button>\r\n</form>\r\n\r\n</body>\r\n</html>"
] | [
"ruby-on-rails",
"forms",
"activerecord",
"rails-4-2-1"
] |
[
"Readjust text inside an EditText (android)",
"Is possible to change dynamically the size of the text of an EditText when the text is too long and readjust it to fit within the bounds?"
] | [
"java",
"android",
"text",
"android-edittext",
"bounds"
] |
[
"Javascript slide effect onclick",
"I'd like to add a slide & fade effect to a DIV, with purely Javascript, using \"onclick\".\n\nThe code is here: http://jsfiddle.net/TCUd5/\n\nThe DIV that has to slide has id=\"pulldown_contents_wrapper\".\nThis DIV is contained in a SPAN, that also triggers it:\n\n<span onclick=\"toggleUpdatesPulldown(event, this, '4');\" style=\"display: inline-block;\" class=\"updates_pulldown\" >\n <div class=\"pulldown_contents_wrapper\" id=\"pulldown_contents_wrapper\">\n\n\nAnd I think the JS code that controls the SPAN onclick is:\n\nvar toggleUpdatesPulldown = function(event, element, user_id) {\n if( element.className=='updates_pulldown' ) {\n element.className= 'updates_pulldown_active';\n showNotifications();\n } else {\n element.className='updates_pulldown';\n } \n}\n\n\nIf it is not possible to make it with pure JS, do you have an idea how could I do it with Mootools? (*I'd like to use only pure JS or the Mootols framework).\n\nI have tried to implement the code from: why javascript onclick div slide not working? but with no results.\n\nThanks a lot.\n\nI have managed to make it with Mootools, but I can't figure it out how to add a slide & fade effect, and a delay on mouseout\n\n window.addEvent('domready', function() {\n $('updates_pulldown').addEvents({\n mouseenter: function(){\n $('updates_pulldown').removeClass('updates_pulldown').addClass('updates_pulldown_active')\n $('pulldown_contents_wrapper').set('tween', {\n duration: 1000,\n physics: 'pow:in:out',\n transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'\n }).show();\n },\n mouseleave: function(){\n $('pulldown_contents_wrapper').set('tween', {\n duration: 1000,\n delay: 1000,\n }).hide();\n $('updates_pulldown').removeClass('updates_pulldown_active').addClass('updates_pulldown')\n },\n });\n });\n\n var toggleUpdatesPulldown = function(event, element, user_id) {\n showNotifications();\n }\n\n\nAny idea?"
] | [
"javascript",
"onclick",
"mootools",
"slide",
"effect"
] |
[
"ClearCase Copying an entire element",
"Is there any way I can copy an entire element from one VOB to another VOB in clearcase?\ni.e including labels and other metadata.\n\nThanks\nNush"
] | [
"clearcase"
] |
[
"TypeError: csv.fromPath is not a function",
"I'm using fast-csv to read my csv file but it gives me error like this\n\n\n UnhandledPromiseRejectionWarning: TypeError: csv.fromPath is not a\n function\n\n\nHere is my code:\n\nconst fileRows = [];\nconsole.log(\"req.file.path\",req.file.path)\n// open uploaded file\ncsv.fromPath(req.file.path)\n .on(\"data\", function (data) {\n fileRows.push(data); // push each row\n })\n .on(\"end\", function () {\n console.log(fileRows);\n //fs.unlinkSync(req.file.path); // remove temp file\n\n const validationError = validateCsvData(fileRows);\n if (validationError) {\n return res.status(403).json({ error: validationError });\n }\n //else process \"fileRows\" and respond\n return res.json({ message: \"valid csv\" })\n })"
] | [
"node.js",
"csv",
"express",
"fast-csv"
] |
[
"Does Rust implicitly create map entries when indexing, like C++?",
"In C++ the indexing operator is defined for std::map and std::unordered_map so that if your reference to the container is non-const just the act of indexing without assigning is enough to have implicitly created a value inside the container. This sometimes creates subtle bugs, where you expect to be referencing a value inside a container but instead actually create one, e.g. config[\"stting\"] instead of config[\"setting\"].\n\nI know Python addresses this by having __setitem__ and __getitem__ be separate methods but this requires cooperation with the parser.\n\nDoes Rust do anything to address this frequent source of bugs?"
] | [
"c++",
"rust",
"hashmap"
] |
[
"Multiple deltaQueries in one entity",
"I do have dataimport configuration like this\n<dataConfig>\n <dataSource name="datasourceA" ... />\n <document>\n <entity name="A" dataSource="datasourceA" transformer="HTMLStripTransformer,RegexTransformer" \n query="SELECT a.id, a.time from tableA a"\n deltaImportQuery="SELECT a.id, a.update_time from tableA a WHERE a.id = '${dataimporter.delta.id}'"\n deltaQuery="SELECT id FROM tableA a WHERE a.update_time &gt; '${dataimporter.last_index_time}">\n <field column="id" name="id" />\n ...\n\n\nand crontab\n*/2 * * * * curl "http://solr:8983/solr/A_index/dataimport?command=delta-import&commit=true"\n\nBut there are some cases when this is not enough. I want to be able to update Solr immediately after modifying record in DB, for example by making a request such as\ncurl "http://solr:8983/solr/A_index/dataimport?command=delta-import&commit=true&record_id=5\n\ndeltaQuery="SELECT id FROM tableA a WHERE a.id = '${dataimporter.request.record_id}"\n\n\nThe problem is I want to be able to do it both ways, keeping old one with crontab and last_index_time and adding the new one with record_id. I know I'm able to run current delta-import every couple of seconds, but the example above is simplified and running this query every couple of seconds seems like an overkill."
] | [
"solr"
] |
[
"jquery checkbox inside table tag not able to access",
"i m trying to access all checkbox inside table tag....\ninitially all checkbox were inside div tag at that time below code was working fine and i was able to access the each checkbox\n\n $('#div_id').children('input').each(function()\n{\n if(this.type == 'checkbox')\n {\n if($(this).attr('id') == 1)\n {\n this.checked = true;\n }\n }\n});\n\n\nnow when i places checkbox inside table it stop working. i tried to change 'div_id' to 'table_id' still no success. any suggestions ?\n\nAll checkboxes and table is dynamically created."
] | [
"javascript",
"jquery",
"html",
"checkbox"
] |
[
"JavaScript .call understanding",
"That is a code that is used as an addition to a URL for a XMLHttpRequest.What comes out in the url is: \n\nhttp://something/something.aspx?QueryString_from_below\n\nArray.prototype.slice.call(document.getElementsByName(\"radio\"), 0)\n .find(function (el, pos, arr) {\n if (el.checked == true) {\n return el\n }\n }).id.replace(\"option\", \"\") + \"=\" + document.getElementById(\"searchField\").value;\n\n\nSo it puts the radios in an array,searches for the checked box,assembles the queryString but I cant figure out the part: Array.prototype.slice.call(document.getElementsByName(\"radio\"), 0).Why call an argument 0 on an array?The output of that and this:\ndocument.getElementsByName(\"radio\")\nis identical."
] | [
"javascript"
] |
[
"How can I run Genymotion with Lollipop and higher version on Ubuntu of 32-bit system?",
"I am using Genymotion on Ubuntu 32-bit system and I am able to start virtual device with version lower than Kitkat i.e. 4.4.4.\n\nBut I want to run virtual device with Lollipop and higher version.\n\nPlease help.\n\nThanks in advance."
] | [
"ubuntu-14.04",
"virtualbox",
"genymotion"
] |
[
"Scripting OpenOffice Forms with VB or python",
"I'm trying to script my OpenOffice document (Writer in my case) to do some simple things with widgets. Namely I'd like to copy text from widget to widget. For this I want to get one component and than get text from it.\n\nI've been trying to do sth like this:\n\ndocument = ThisComponent.CurrentController.Frame\n\noDocument = ThisComponent\noTextBoxFrom = document.getByName(\"Text Box 1\") # 1\noTextBoxFrom = oDocument.getByName(\"Text Box 1\") # 2\n\n\nNeither version #1 nor #2 work. VB compiler spits out that \"Text Box 1\" is not accessible, however I have that component in my form. My guess is that I'm trying to get this component from a wrong place, eg. not it's frame. I just can't figure out what is the structure of the document.\n\nThis seems like a pretty easy task, however I'm unable to find any OpenOffice specification as for accessing OO UNO objects from VB, or python."
] | [
"python",
"scripting",
"vbscript",
"openoffice-writer"
] |
[
"How to keep track of online users in GraphQL using GraphQL-Java-Kickstart",
"Currently I am using ApolloSubscriptionConnectionListener.\n\nIt contains 4 methods: onConnect, onTerminate, onStart and onStop.\n\nHowever onTerminate did not fire when I close my client. onStop seems to fire every time the client canceled the subscription. How can I check that a user is online?"
] | [
"kotlin",
"graphql",
"apollo",
"graphql-java",
"graphql-subscriptions"
] |
[
"reordering a factor A by the numeric values of a factor B",
"Hi there: I have a data set that looks like this. I my data set, alpha, omega and zeta are the names of issues. Respondents were asked rate a party leader ('Z', 'B' or 'C') as the leader that would best manage that issue. \n\nI would like to show the distribution of responses for each issue, but I would like to see the facets ordered such that the first facet shows the highest percent for a particular party leader (e.g. Z) and then moving down.\n\nIn the code below, I specifically chosen variable names that span the length of the alphabet (e.g. alpha to zeta) and not set a seed, because I want to get some code back that always orders the levels of the variable Issue such that the first level is the issue that party leader Z scored highest on, and that the second level is the issue that party leader Z scored second-highest on.\n\n#load libraries\nlibrary(dplyr)\nlibrary(forcats)\nlibrary(tidyr)\nlibrary(ggplot2)\n\n#In my data set these are issues, like taxes, health, etc. \nalpha<-sample(c('Z', 'B', 'C'), replace=T,size=300)\nomega<-sample(c('Z', 'B', 'C'), replace=T,size=300)\nzeta<-sample(c('Z', 'B', 'C'), replace=T, size=300)\n\n#make data frame\ndf<-data.frame(alpha, omega, zeta)\n\ndf %>% \n #gather into an issue variable and a leader variable\n gather(Issue, Leader) %>% \n #count\n count(Issue, Leader) %>% \n #form groups for counting percent\n group_by(Issue) %>% \n #calculate percent\n mutate(pct=n/sum(n)) %>%\n #ungroup\n group_by(Leader)%>% \n #try reordering based on\n mutate(Issue=fct_reorder(Issue, pct, .desc=F)) %>% \n ggplot(., aes(x=Leader, y=pct))+geom_col()+facet_wrap(~Issue)"
] | [
"r",
"forcats"
] |
[
"How do browsers preview the first N frames of a gif before it is fully downloaded?",
"I'm interested in developing a gallery on a mobile device. I noticed, for example, that the Android browser will keep repeating all the frames it currently has. How is this done?"
] | [
"gif"
] |
[
"How to match words with random characters in between using Regex?",
"Kinda hard to explain what I'm trying to do, so here's an example.\n\nI'm looking for the word \"bar\" in the following string.\n\nbarristabrarbvvvaar\n\n\nIt should return bar, brar and bvvvaar since all of them have bar even with random characters in the middle. \n\nHow do I do that?\n\nI tried\n\nb.*a.*r"
] | [
"regex"
] |
[
"Apple association file fetched in development but not in TestFlight and App Store",
"Universal links work perfectly fine in development, but once I sign the applications and deploy them to TestFlight and App Store, it looks like the apple-app-site-association is not fetched and therefore the app isn't registered for oppening the universal links.\n\n1. /.well-known/apple-app-site-association file:\n\n\r\n\r\n{ \r\n \"applinks\": { \r\n \"apps\": [], \r\n \"details\": [{ \r\n \"appID\": \"myteamid.com.mycompany.appName\", \r\n \"paths\": [\"*\"] \r\n }] \r\n } \r\n} \r\n\r\n\r\n\n\nThe server part looks OK, since it is successfuly fetched whenever I run the app via the cable on my phone.\n\nApp Search API Validation tool returns this for Link to application:\n\nAction required\n\n\nCould not extract required information for Universal Links. Learn how\nto implement the recommended Universal Links. \nError no apps with domain entitlements \nThe entitlement data used to verify deep link dual authentication is from the current released version of your app. This data may take 48 hours to update.\n\n\n2) Capabilities:\n\nAssociated domains - ON with Domain list of:\napplinks: link.mycompany.com\n\nOther things I have turned on are: Push Notifications and Background Modes.\n\n3) Provisioning profile:\nI created a new one after adding the Universal links and Push notifications and it includes:\n\nCapabilities: \n\n\nAssociated Domains,\nList item\nGame Center,\nIn-App Purchase,\nKeychain Sharing,\nPush Notifications.\n\n\nEntitlements:\n\n\nget-task-allow,\napp-enviroment,\ncom.apple.developer.associated-domains,\ncom.apple.developer.team-identifier,\napplication-identifier,\nbeta-reports-active,\nkeychain-access-groups\n\n\n4) While installing the app, it behaves different in test flight then it does when loading via cable:\n\n\nVia cable I can see the successfull http request for the apple-app-site-association file and finally form the process swcd: \"Added service 'applinks', appID 'myteamid.com.mycompany.appName', domain 'link.mycompany.com' \"\nTest flight - when installing there is no sign of http request and the following line is shown if I previously had the app installed via cable: \"Removed service 'applinks', app ID 'myteamid.com.mycompany.appName', domain 'link.mycompany.com' (removed domain) \"\n\n\nThis of course results in the fact that whenever I install the app via TestFlight or Describution, the Universal links do not work.\n\nAny ideas where it goes wrong?"
] | [
"ios",
"provisioning-profile",
"testflight",
"ios-provisioning",
"ios-universal-links"
] |
[
"Fatal error: Call to undefined function imap_open()",
"I am trying to read emails using php,i am using below code but its shoeing an error Fatal error: Call to undefined function imap_open() in /testpage2/testmail.php on line 18 can anyone guide me.thanks\n\n<?php\n$codes = array(\"7bit\",\"8bit\",\"binary\",\"base64\",\"quoted-printable\",\"other\");\n$stt = array(\"Text\",\"Multipart\",\"Message\",\"Application\",\"Audio\",\"Image\",\"Video\",\"Other\");\n\n$pictures = 0;\n$html = \"\";\n\n# Connect to the mail server and grab headers from the mailbox\n\n$mail = imap_open('{mail.xxxxxxxx.com:110/pop3}', '[email protected]', 'xxxxxxxxx');\n$headers = imap_headers($mail);\n\n# loop through each email\n\nfor ($n=1; $n<=count($headers); $n++) {\n $html .= \"<h3>\".$headers[$n-1].\"</h3><br />\";\n\n# Read the email structure and decide if it's multipart or not\n\n $st = imap_fetchstructure($mail, $n);\n $multi = $st->parts;\n $nparts = count($multi);\n if ($nparts == 0) {\n $html .= \"* SINGLE part email<br>\";\n } else{\n $html .= \"* MULTI part email<br>\";\n }\n\n# look at the main part of the email, and subparts if they're present\n\n for ($p=0; $p<=$nparts; $p++) {\n $text =imap_fetchbody($mail,$n,$p);\n if ($p == 0) {\n $it = $stt[$st->type];\n $is = ucfirst(strtolower($st->subtype));\n $ie = $codes[$st->encoding];\n } else {\n $it = $stt[$multi[$p-1]->type];\n $is = ucfirst(strtolower($multi[$p-1]->subtype));\n $ie = $codes[$multi[$p-1]->encoding];\n }\n\n# Report on the mimetype\n\n $mimetype = \"$it/$is\";\n $html .= \"<br /><b>Part $p ... \";\n $html .= \"Encoding: $ie for $mimetype</b><br />\";\n\n# decode content if it's encoded (more types to add later!)\n\n if ($ie == \"base64\") {\n $realdata = imap_base64($text);\n }\n if ($ie == \"quoted-printable\") {\n $realdata = imap_qprint($text);\n }\n\n# If it's a .jpg image, save it (more types to add later)\n\n if ($mimetype == \"Image/Jpeg\") {\n $picture++;\n $fho = fopen(\"imx/mp$picture.jpg\",\"w\");\n fputs($fho,$realdata);\n fclose($fho);\n # And put the image in the report, limited in size\n $html .= \"<img src=/demo/imx/mp$picture.jpg width=150><br />\";\n }\n\n# Add the start of the text to the message\n\n $shorttext = substr($text,0,800);\n if (strlen($text) > 800) $horttext .= \" ...\\n\";\n $html .= nl2br(htmlspecialchars($shorttext)).\"<br>\";\n }\n}\n\n# report results ...\n\n?>\n<html>\n<head>\n<title>Reading a Mailbox including multipart emails from within PHP</title>\n</head>\n<body>\n<h1>Mailbox Summary ....</h1>\n<?= $html ?>\n</body>\n</html>"
] | [
"php",
"email",
"imap",
"pop3"
] |
[
"Sql Query Results to CSV format doesn't include the correct date values",
"Following is my query \n\nFollowing is my table structure \n\nTable Name: Person\n\n ID: (PK,int, not null)\n Name: (Nvarchar(20),null)\n BirthDate : (Datetime,null)\n\n\nFollowing is my query \n\n select Name,BirthDate From Person\n\n\nOutput is as follows\n\n Name BirthDate\n Sam 1986-01-01\n Bob 2001-04-07\n John 2000-02-02\n\n\nOutput in CSV\n\n Name BirthDate\n Sam 00:00.0\n Bob 00:00.0\n John 00:00.0\n\n\nIn order to export this content to csv all i do is select the values and right click on the output window with \"copy with headers\" option.\nit creates the CSV fine but when i open the file i get BirthDate as 00:00.0 for all three values.\nI don't understand what's causing this. Please help."
] | [
"sql",
"sql-server",
"excel",
"tsql",
"csv"
] |
[
"What is the correct way to serve image file from Blob in Spring MVC controller?",
"I wrote a simple SpringMVC app and host on a Paas. I have created a table in Mysql and a column is the Blob. I can upload files through the Mysql admin. Right now, my server can serve html file or javascript files correctly in browser. However, when I serve a jpg file in http://myserver.com/File/ad.jpg, my browser showed a small icon and if I save it, the Windows Image software shows that the image is damaged.\n\nHere are some of the code:\n\n@RequestMapping(value=\"/File/**\", //{name:.+}\", \n method = RequestMethod.GET)\npublic @ResponseBody void getContent(\n// @PathVariable(\"name\") String name,\n HttpServletRequest request, \n HttpServletResponse response) throws IOException {\n String name = request.getPathInfo();\n ....\n IOUtils.copy(blob.getBinaryStream(), out);\n\n\nI found that getServletContext() returns null, so I wasn't able to get contentType, so I saved contentType in Mysql as image/jpeg for the ad.jpg. I set the disposition to be inline. What else should I do to serve a jpg?"
] | [
"java",
"mysql",
"image",
"spring-mvc",
"blob"
] |
[
"java library for high-performance graph/network data structure",
"Well, is there a high-performance graph library for working with primitivies, without those generics/autoboxing overheads? For double lists you may use trove, for linear algebra you may use netlib-java (examples for you to better understand the point of my interest in this question).\n\nAs for Graphs/Networks: all the libs I've found use generics and should be not that performant. I may as well do some tests for that, but I believe that heap-managed network link weights would be inferior to double[] with some bit offsets to get the index for i and j. The usage scenario: there're hundreds of such networks (most of them sparse) of size 4k*4k, there's some genetic optimization running over that set of networks, which do some flow/min route estimations for each specimen.\n\nSo, there're: JGraphT, JUNG, ANNAS, JDSL (the links lead to the APIs/code samples which expose the miserable Java Generics/Object wrappers in all of them). Are there any Trove-ish alternatives? I'd already created some simplistic implementation, but just decided to look around to avoid inventing the proper bicycle...\n\nAny opinions, suggestions?\n\nThanks,\nAnton\n\nPS: Please don't start on performance of generics-laden Java code, at least without linking to some decent benchmark, ok? ;)"
] | [
"java",
"performance",
"graph"
] |
[
"How to dynamically update the attributes of a model in Spring MVC?",
"so I'm pretty new to Spring and used the Spring Initializr to create a new project. I do not have any configuration .XMLs or similiar configuration files. I followed this tutorial to get things going.\n\nMy controller class basically looks like the following:\n\n@Controller\n@Configuration\n@EnableScheduling\npublic class IndexController {\n\n@GetMapping(\"/\")\npublic String index(Model m) {\n m.addAttribute(\"Title\", \"New Website\");\n m.addAttribute(\"MenuOne\", InformationProvider.getMenuOneLink());\n m.addAttribute(\"MenuTwo\", InformationProvider.getMenuTwoLink());\n m.addAttribute(\"StaffNumber\", InformationProvider.getNumberOfStaff());\n m.addAttribute(\"Birthdays\", InformationProvider.getBirthdaysOfToday());\n\n return \"dashboard\";\n}\n\n\n}\n\nThis works fine and everything is doing what it is supposed to be. Unfortunately the attributes which are getting their data by the InformationProvider class need to be updated at run time. The InformationProvider is approaching different APIs on the web and my idea either was to pull data from these APIs every 10 hours for example or to pull the data again on a site refresh. \n\nFrom my understanding my method is supposed to be called each time someone would enter the URL localhost:8080/. My first idea basically was to refresh the site after 10 hours. The method is called when the site is refreshed and it is returning \"dashboard\" each time but the values are not updated. To update my attributes I have to restart my application. I was looking at the @scheduled annotation but this does not really help me since it is only working for methods which have void as return time and do not have object parameters. So scheduling my method index doesn't work and is probably the wrong way to go anyway.\n\nI was googling a lot regarding this topic but I couldn't really find a solution for this specific problem where you only have a model as parameter in your controller method and want to update it afterwards. \n\nWhat is the best approach for this problematic? I was checking the JavaDoc of the model class but it does not contain a remove or update method. Do I need to approach the HashMap behind the model directly and overwrite an attribute by an existing key to update it?\n\nEdit:\n\nTo be more specific about the InformationProvider class, it is basically returning a String received by a cURL method called from Java. Nothing more.\n\nThanks in advance"
] | [
"java",
"spring"
] |
[
"Why is CUDA pinned memory so fast?",
"I observe substantial speedups in data transfer when I use pinned memory for CUDA data transfers. On linux, the underlying system call for achieving this is mlock. From the man page of mlock, it states that locking the page prevents it from being swapped out:\n\n\n mlock() locks pages in the address range starting at addr and continuing for len bytes. All pages that contain a part of the specified address range are guaranteed to be resident in RAM when the call returns successfully; \n\n\nIn my tests, I had a fews gigs of free memory on my system so there was never any risk that the memory pages could've been swapped out yet I still observed the speedup. Can anyone explain what's really going on here?, any insight or info is much appreciated."
] | [
"c++",
"c",
"linux",
"cuda"
] |
[
"Best practice for user login after hashing and storing password in mysql with node bcrypt",
"I just created a handler that stores a username and password in mysql. The handler function performs the standard bcrypt password hash:\n\nbcrypt.hash(myPlaintextPassword, saltRounds, function(err, hash) {\n // Store hash in your password DB. \n});\n\n\nBcrypt also offers the standard code to compare the plaintext with the hash like so:\n\nbcrypt.compare(myPlaintextPassword, hash, function(err, res) {\n // res == true \n});\n\n\nOn an abstract level if I were to do the above compare function I would need to do the following:\n\n\nGet user input username and plain text password\nSend query to database SELECT * FROM users WHERE username = 'SomeName'\nGet back some username and hashed password\nCompare hashed password and authenticate user\n\n\nThe problem with that is that any user specific data cannot be retrieved before authentication so I will need to chain an additional query in order to retrieve any extra user sensitive data and this process would seem janky. And it seems unsafe because the client then has the hashed password at this point when there should be no need to bring back the password.\n\nI would like to:\n\n\nGet user input username and plain text password\nSend query to database \n\nSELECT * FROM users \nWHERE username = 'SomeName' \nAND password = COMPARISON_FUNCTION_THAT_WORKS_WITH_BCRYPT('plaintext')\n\nGet back some username and any user specific data\nand I am done\n\n\nAm I completely missing the boat here, because if I am then what exactly are the 360k downloaders of this software doing for password encryption / user login process?"
] | [
"javascript",
"mysql",
"node.js",
"bcrypt"
] |
[
"Why doesn't \"display: block\" & \"width: auto\" stretch a button to fill the container?",
"When I set display: block; and width: auto; on a button, I'd expect the button to stretch to fill the container as other block elements do. For some reason, it doesn't, at least not in latest Chrome.\n\nWhen Googling around, I found a lot of people asking the same question, who were satisfied with an answer to \"How do I stretch my buttons to fill the container?\" That is not what I'm interested in. (I'm perfectly able to stretch my buttons any way I need.) Inspecting button properties, including the ones imposed by default by the browser didn't help me either.\n\nI'd like to understand, what causes buttons to ignore display: block; width: auto; and stay horizontally sized based on their contents.\n\n\n\nHere's a demonstration of what I mean:\n\n\r\n\r\nbutton {\r\n display: block;\r\n}\r\n<button style=\"width: auto;\">button with `display:block; width:auto;`</button>\r\n<button style=\"width: 100%;\">button with `display:block; width:100%`</button>\r\n\r\n\r\n\n\nI'd expect the button with width:auto; to be stretched as well.\n\n\n\nJust to be absolutely clear, this is not a duplicate to input with display:block is not a block, why not? or any similar question unless that has only answers describing ways to stretch the elements in question.\n\nEdit: It might be a duplicate of What is it in the CSS/DOM that prevents an input box with display: block from expanding to the size of its container. On the other hand, that question doesn't mention buttons at all. You need to read the answer to find out it applies to buttons as well."
] | [
"html",
"css"
] |
[
"what is the use of making a string static",
"If I am not wrong, how many ever same Strings are created, only in only place it is stored by using String interning. If so, what is the use of making a Sting static if it is already being stored in only one place in memory which is nothing but acting as if it was a static variable. Thanks."
] | [
"java",
"string"
] |
[
"mouse movement leaves trails of th image",
"i have made a space invader game. at first the game ran slow whenever i moved the mouse because i had a mouse move event, so someone told me that it was my invalidate method. i changed it accordingly and the game speed is better. but it now does not clear the older image. it leaves a trail of images.\n\nPlease help!\n\nMouse_move event\n\n private void Form1_MouseMove(object sender, MouseEventArgs e)\n {\n Cursor.Dispose();\n objsp.gsPos = new Point(MousePosition.X / 2 - 10, MousePosition.Y / 2 - 15);\n UpdatePosition(objsp.gsPos.X, objsp.gsPos.Y, objsp.gsImage);\n }\n\n\nUpdatePosition method that is being called\n\n private void UpdatePosition(int dx, int dy, Image img)\n { \n Point newPos = new Point(objsp.gsPos.X + dx, objsp.gsPos.Y + dy);\n\n //dont go out of window boundary\n newPos.X = Math.Max(0, Math.Min(ClientSize.Width - img.Width, newPos.X));\n newPos.Y = Math.Max(0, Math.Min(ClientSize.Height - img.Height, newPos.Y));\n\n if (newPos != objsp.gsPos)\n {\n objsp.gsPos = newPos;\n Rectangle rc = new Rectangle(objsp.gsPos, img.Size);\n Invalidate(rc); \n }\n }\n\n\nForm Load output\n\nOnce mouse is moved output"
] | [
"c#",
"winforms"
] |
[
"excel pattern fill depending of that 2 cells are equal",
"I'm trying to make a VBA-code that change the pattern fill when 2 other cells are equal to each. I have the follow code:\n\n Private Sub Workbook_Open()\n' Macro2 Macro\n\n' If (H5)=(J20) Then\n Range(\"H7\").Select\n With Selection.Interior\n .Pattern = xlSolid\n .PatternColorIndex = xlAutomatic\n .ThemeColor = xlThemeColorAccent2\n .TintAndShade = 0.799981688894314\n .PatternTintAndShade = 0\n End With\n If (H5) <> (J20) Then\n Range(\"H7\").Select\n With Selection.Interior\n .Pattern = xlNone\n .TintAndShade = 0\n .PatternTintAndShade = 0\n End With\n Range(\"M20\").Select\n ActiveWorkbook.Save\n End If\n\n End Sub\n\n\nThe first part of the code is working but when you change one of the 2 cells then the pattern is not changed back in no Filling. What is wrong in the code?\n\nNow is the macro only running when you open the workbook. Is it possible that the macro directly is running when you changed a cell?\n\nNow I write the macro for Cell H7 that compares H5 with J20. I want that the macro H5 compares with J20:J29, is this possible one a \"easy\" way?\n\nLast question: Is it also possible to use the macro for more cells in the same sheet, for example E5-E7,F5-F7,G5-G7,.....NK5-NK7 with the same kollom to compare (J20:J29)?\n\nYes, its a kind of conditional formatting. But I can't find the right formula/code for conditional formatting a cell by compare 2 other cells.\nE.g. \"E7 is gray when the date in E5 is equal on the date in J20 or J21 or J22 or ... or J29 otherwise E7 is not filled\" and\n \"F7 is gray when the date in F5 is equal on the date in J20 or J21 or J22 or ... or J29 otherwise f7 is not filled\" and that so on up to \n \"NK7 is gray when the date in NK5 is equal on the date in J20 or J21 or J22 or ... or J29 otherwise NK7 is not filled\"."
] | [
"excel",
"vba"
] |
[
"ArcGIS Development.Java vs .Net(C#)",
"I'm a computer scientist and i've been working with Java mostly to develop applications.\nI just been hired in a company that makes projects with ArcGIS.\nThe company has hired na electrical engineer to develop the arcGIS projects.\nThis engineer used to customize ArcMap with VBA and lately extensions with .NET and C#.\n\nI want to take a new path and start using the ArgGIS Engine with Java.\nI want to know if this choice is right.Has any of you been developing with Engine-Java and how difficult is it(The use of JNI -for which i have little knoledge- is making it more difficult? ).\nAlso I have a little experience with .NET and c++ but not C#.I will have a big learning curve with this path?\n\nAlso which are the advantages and disadvantages and limitations of each method?"
] | [
"c#",
"java",
".net",
"arcgis"
] |
[
"COUNT_DISTINCT(...) WHERE on Google",
"I have a very simple table with two columns on GDS:\nStatus | Consumer ID\nI would like to create a calculated field that would be something like:\nSUM(COUNT_DISTINCT("Consumer ID") WHERE Status = "Active") \n - SUM(COUNT_DISTINCT("Consumer ID") WHERE Status = "Inactive")\n\nBut COUNT_DISTINCT doesn't allow me to work with conditions. Has anyone got any idea on how could I do this?\nThank you!"
] | [
"google-data-studio"
] |
[
"Terraform setup tips: TLS communication across VPCs",
"I'm working for a client that has a simple enough problem:\n\nThey have EC2s in two different Regions/VPCs that are hosting microservices. Up to this point all EC2s only needed to communicate with EC2 instances that were in the same subnet, but now we need to provision our infrastructure so that specific ec2s in VPC A's public subnet can call specific ec2s in VPC B's public subnet (and vice versa). Communications would be calling restful APIs over over HTTPS/TLS 2.0\n\nThis is nothing revolutionary but IT moves slowly and I want to create a Terraform proof of concept that:\n\n\nCreates two VPCs\nCreates a public subnet in each\nCreates an EC2 in each\nInstalls httpd in the EC2 along with a Cert to use SSL/TLS\nCreates the proper security groups so that only IPs associated with the specific instance can call the relevant service\n\n\nThere is no containerization at this client, just individual EC2s for each app with 1 or 2 backups to distribute the load. I'm working with terraform so I can submit different ideas to them for consideration, such as using VPC Peering, Elastic IPs, NAT Gateways, etc.\n\nI can see how to use Terraform to make these infrastructural changes, but I'm not sure how to create EC2s that install a server that can use a temp cert to demonstrate HTTPS traffic. I see a tech called Packer, but was also thinking I should just create a custom AMI that does this.\n\nWhat would the best solution be? This doesn't have to be production-ready so I'm favoring creating a fast stable proof-of-concept."
] | [
"amazon-ec2",
"terraform",
"amazon-ami",
"packer"
] |
[
"Why has the Eclipse Debugger/Emulator disconnected from my app?",
"My app is no longer starting up automatically when I F11 it in Eclipse; the Emulator starts up, but I then have to go and find my app among the applications list/array to invoke it.\n\nThen, when I get to the place in my app where I've set a breakpoint, instead of hitting the breakpoint (Eclipse is not even going into Debug Perspective), my app suddenly \"expires\" and the Emulator pops up the dialog:\n\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\nSorry!\n\nThe application FifeOrTheDinosaur (process.com.aXX3AndSpace.FifeOrTheDinosaur_Package) has stopped unexpectedly. Please try again.\n\nForce close\n\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\nBut then when I click \"Force Close,\" that dialog goes away, and my app starts up again, from its opening Activity...?!?\n\nIt's almost as if my app is not the one being debugged by Eclipse -- Eclipse has lost its connection to it or...???\n\nAnd every time it crashed, I hit the \"Force Close\" button, whereupon my app starts up all over again. What could have disconnected my app from the Debugging system, so that it:\n1) Doesn't run automatically when I run it; rather, I have to \"force\" it to start up, and when it enters a breakpoint, Eclipse's Debug Perspective is not invoked\n2) Continually starts up my app after it has failed...???\nI put a breakpoint on a button click handler prior to that one that is working fine, and it does not drop me into the Eclipse debugger, either...???\n\nUpdate:\nThe console says:\n\n1) ] Failed to install .apk on device 'emulator-5554': timeout\n2) Launch canceled!\n\nUpdated 3/30/2012:\n\nIf I run the app from Eclipse and immediately shut it down just as the Emulator is starting to initialize, it flashes up three \"command window\"-type screens, one right after the other, too fast to read what text they contain. Normally the Emulator window simply goes away, so I don't know if this is a clue for anybody as to what might be happening..."
] | [
"android",
"eclipse",
"debugging",
"android-emulator"
] |
[
"Visual Studio Extension not working if compile with different VS",
"I have installed two version of Visual Studio: 2013 and 2015.\nI want to create VS extension (vsix) which will be work with both versions VS, but Package.Initialize method not fired if I debug different version:\n\nStart debug from VS2013 on VS2015 - extension not working, method not called.\n\nStart debug from VS2015 on VS2013 - extension not working, method not called.\n\nStart debug from VS2015 on VS2015 - extension working.\n\nStart debug from VS2013 on VS2013 - extension working.\n\nPackage definition contants these attributes:\n [PackageRegistration(UseManagedResourcesOnly = true)]\n [InstalledProductRegistration(\"#110\", \"#112\", \"1.0\", IconResourceID = 400)]\n [Guid(GuidList.guidVSPackageTest20132PkgString)]\n [ProvideAutoLoad(UIContextGuids80.SolutionExists)]\n\nIn manifest Install targets sets to [12.0, 14.0]\n\nAny suggestions?"
] | [
"c#",
"visual-studio",
"visual-studio-extensions"
] |
[
"Request builder call not returning when using ssl(https)",
"I am using GWT. Currently using gwt-rpc to for login authentication. For only login purpose i want to use ssl(https) and so instead of using gwt-rpc i am trying Request Builder and calling a servlet with https.\nWhen in Servlet URL i use protocol as http the request builder works perfectly and response returns to client side(onResponseReceived ). but when i use https in the servlet url then the servlet is gettting called but the response is not returning to the onResponseReceived method of request builder.\n\nmy url with http looks like : http://localhost:8888/myproject/myservlet\nand with https it looks like :https://localhost/myproject/myservlet\n\nPlease give any suggestion or is there any other way to do it.and also is it possible to use ssl over gwt-rpc."
] | [
"gwt",
"ssl",
"https",
"gwt-rpc"
] |
[
"Object not being stringfyed and parsed back in Javascript",
"I am making a web app:frontend in Angular and backend in Rails.\nIn my frontend, I am saving a variable to localStorage and trying to retrieve back later.\n\nHere is a variable I'm saving:\n\nvar application = {\n \"id\": 7,\n \"visa_type\": \"string\"\n }\n\n\nThen I save this variable to localStorage,\n\nlocalStorage.setItem(\"key\", application);\n\n\nAfter saving, I return this value, localStorage.application, and I get \"[object Object]\"\n\nso I tried to parse localStorage.application but it says \n\n\n JSON.Parse,'Uncaught SyntaxError: Unexpected token o\n\n\nHow can I successfully return my object??"
] | [
"javascript",
"ruby-on-rails",
"angularjs",
"json"
] |
[
"Redirect keyboard input to child control in .net",
"I have a pretty large .net forms application and I want to be able to capture keyboard input at the form level and redirect it to a textbox, even though it doesn't have focus. I've set the form KeyPreview flag and I can capture the key events with no problem. I can even send characters to the textbox but I don't know how to handle things like the cursor keys, delete, backspace etc.\n\nI tried to send focus to the textbox in the forms OnKeyDown method, in the hope that it would then redirect the key press but that didn't work - it seems like the Focus operation is too slow.\n\nAny bright ideas?\n\nCheers,\n\nChris."
] | [
".net",
"winforms"
] |
[
"Images in Mailchimp email very large in Gmail",
"I have a MailChimp template I am working on for a client. In Gmail only, I get some images that are much larger than the stated dimensions in the template. In this example, the image is shown in Gmail at 600px x 120px but the <td> is:\n\n<td cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse:collapse;vertical-align:top\" height=\"4px\" width=\"600px\">\n <img src=\"http://www.marketingscience.co/boa/hero-header.png\" style=\"display:block;border:0;min-height:4px;width:600px;background-color:#696969;color:white;font-size:18px;line-height:100%;outline:none;text-decoration:none\">\n </td>\n\n\nAny suggestions would be greatly appreciated."
] | [
"email",
"gmail",
"mailchimp"
] |
[
"Modular comparison of characters",
"This seems like a very simple question, but there's surprisingly little written about it on the Internet, and I'm having a hard time implementing it correctly on my own. What is the best way to implement a modular comparison function on ASCII characters in Java, such that the comparison \"wraps around\" the end of the alphabet? I want to use it for a \"between\" function that can partition the entire alphabet at arbitrary locations, and correctly return \"true\" when asked if 'y' is between 'x' and 'b'.\n\nI've already found all the questions and answers that talk about modular arithmetic on characters, so I know how to do modular addition (character shifting) with code like this:\n\nchar shifted = (((original - 'a') + 1) % 26) + 'a';\n\n\nHowever, this is based on Java's built in modular arithmetic functions, which have no equivalent for comparison. Even if I was using plain ints, I have no way of asking Java if a < b < c mod 26 (which should return true if a = 24, b = 25, and c = 1).\n\nSo the general question is, what's the best way to implement modular comparison operations in Java? If that's too hard a problem, is there at least a way to get such comparisons to work for the ASCII alphabet?"
] | [
"java",
"math",
"ascii",
"string-comparison"
] |
[
"HTACCESS Rewrite Rule Results in a Redirect Loop",
"I've set up Apache behind NGINX proxy and my HTTPS redirect (rewrite) rule results in a redirect loop. It looks like HTTPS is returned as false despite I'm setting the environmental variable properly.\n\nMy rewrite rule:\n\nRewriteCond %{HTTPS} off [OR]\nRewriteCond %{HTTP_HOST} !^www\\.example\\.com [NC]\nRewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]\n\n\nMy environmental varaiables:\n\nSetEnvIf X-Forwarded-Proto https HTTPS=on\nSetEnvIf X-Forwarded-SSL on HTTPS=on\n\n\nAnd when I do a var_dump in PHP, I can see that the variables are set properly:\n\n[HTTPS] => on\n\n\nI'm wondering why RewriteCond %{HTTPS} off [OR] always returns true even if the URL is accessed over HTTPS and the environmental variable is set?\n\np.s. As a fix, if I use RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC] in place of RewriteCond %{HTTPS} off [OR], the redirect loop goes away."
] | [
".htaccess",
"nginx",
"mod-rewrite",
"apache2",
"reverse-proxy"
] |
[
"Resolving spring:messages in javascript for i18n internationalization",
"I'm attempting to internationalize some of our code. I have a page in JSPX which is using the <spring:message> tag to resolve strings from a message.properties file. This works fine for the HTML and CSS that is in the JSPX page, however there a javascript file is sourced, and substituting the <spring:message> tag for the string in there just means that it gets printed out verbatim. \n\nMy JSPX sources the javascript like so:\n\n<spring:theme code=\"jsFile\" var=\"js\" />\n<script type=\"text/javascript\" src=\"${js}\" />\n\n\nThe JS where I'm looking the replace the string is below:\n\nbuildList('settings', [{\n name: '<spring:message code=\"proj.settings.toggle\" javaScriptEscape=\"true\" />',\n id:\"setting1\",\n description: '<spring:message code=\"proj.settings.toggle.description\" javaScriptEscape=\"true\" />',\n installed: true\n}]);\n\n\nAnd finally the message.properties is something like:\n\nproj.settings.toggle=Click here to toggle\nproj.settings.toggle.description=This toggles between on and off\n\n\nSo what I'm wondering is, should this work? It seems to me like it should, from what I've gathered on various forums, but I can't figure out where I'm going wrong. Is there a better way to go about this?\n\nI should also note that these files are outside the WEB-INF folder, but by placing the ReloadableResourceBundleMessageSource in the root applicationContext.xml the spring tags are picked up.\n\nThanks for any help!"
] | [
"javascript",
"spring",
"spring-mvc",
"internationalization",
"dojo"
] |
[
"user defined function that looks for a part string then executes another set funtion",
"Hi hoping somebody can help i am struggling to create a user defined function or macro that looks for a particular string in a cell then if found in cell will execute a substitute function.\nexamples of data below located in column AC of my spreadsheet the only constant reference is the end part of the string [CO], [ST] and [MX] as the trailing characters always change i can't use a Find and replace which would be my normal route. i can use the concatenate with nested substitute function but this requires going through 7500- 15000 lines to apply the correct version\nFAUGCB04BCU01CTRL1/BCU_CSWI1.DPCSO1.Oper.ctlVal[CO]\nFAUGCB04BCU01CTRL1/DisconCSWI1.Pos.Oper.ctlVal[CO]\nFAUGCB04BCU01CTRL1/BCU_CSWI1.DPCSO1.stVal[ST]\nFAUGCB04BCU01CTRL1/DisconCSWI2.Pos.stVal[ST]\nFAUGCB04BCU01MEAS/rmsMMXU1.PhV.phsA.cVal.mag.f[MX]\nFAUGCB04BCU01MEAS/rmsMMXU1.PhV.phsB.cVal.mag.f[MX]\nFunction Zen_SYM_ADD(IED As Range, ADDwFC As Range) As String\n\n\n'Function to create zenon symbolic address from the produced helinks full address with functional address (Full 61860 Address Text)\n'Replaces the following formula:\n'=CONCATENATE(K2,"!",SUBSTITUTE(SUBSTITUTE(AC2,".","/",1),".","/",1))for value found[ST]\n'=CONCATENATE(K2,"!",SUBSTITUTE(SUBSTITUTE(AC2,".","/",1),".","/",1))for value found[CO]\n'=CONCATENATE(K2,"!",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(AC2,".","/",1),".","/",1),".","/",1),".","/",1))for value found[MX]\n\nDim strIED, strADDwFC, strTemp As String\nDim intLoopCT, intLastRow As Integer\n\n'take the value of the ied in column k\nstrIED = IED.Value\n'take the 61850 address value in column AC\nstrADDwFC = strADDwFC.Value\n\n\n'If there is no Variable name then output will be blank so exit function here\nIf strADDwFC = "" Then\n Zen_SYM_ADD = ""\n Exit Function\n\nElse\n\n\n 'Insert correct substitute array\n Select Case strADDwFC\n Case "[CO]"\n strADDwFC.Formula = "SUBSTITUTE(SUBSTITUTE(" & strADDwFC & "," & "." & "," & "/" & ",1)," & "." & "," & "/" & ",1) "\n Case "[MX]"\n strADDwFC.Formula = "=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(" & strADDwFC & ",'.','/',1),'.','/',1),'.','/',1),'.','/',1)) "\n Case "[ST]"\n strADDwFC.Formula = "SUBSTITUTE(SUBSTITUTE(" & strADDwFC & ",'.','/',1),'.','/',1) "\n End Select\n \n '"SUBSTITUTE(SUBSTITUTE(" & strADDwFC & "," & "." & "," & "/" & ",1)," & "." & "," & "/" & ",1) "\n '"=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(" & strADDwFC & "," & "." & "," & "/" & ",1)," & "." & "," & "/" & ",1)," & "." & "," & "/" & ",1)," & "." & "," & "/" & ",1)) "\n \n \n 'Build string\n strTemp = (strIED & "!" & strIED & strADDwFC)\n \n \n \n \n 'Set function output\n strADDwFC = strTemp\nEnd If\n \nEnd Function\n\nThis just gives me a 0 or value error in the cell\ni am hoping somebay with more skills than i have can help i have tried different variations of nesting the functions substitute as you can see the [CO] has the funtion and all the arguments ampersanded the [ST] just uses ' rather than ""
] | [
"excel",
"vba"
] |
[
"MySQL Saved Data Are Not Selectable",
"I have 2 TABLES in a MySQL DB ,\nbut My Problem is : In just a single row DATA ARE NOT SELECTABLE for Edit, Delete and etc .\nPlease check the attached image to understand more . \nTell me what is the solution .."
] | [
"mysql",
"sql",
"database",
"phpmyadmin"
] |
[
"How to override an agent in a jenkins pipeline",
"My goal is to create a pipeline, where every stage is having the same agent, except of 1 stage (Stage E in the example below)\n\npipeline {\n agent {\n dockerfile {\n filename 'Dockerfile.tester'\n args '-v $HOME/.docker:/root/.docker'\n }\n }\n stages {\n stage('A') { ... }\n stage('B') { ... }\n stage('C') { ... }\n stage('D') { ... }\n stage('E') {\n agent {\n dockerfile {\n filename 'Dockerfile.deploy'\n args '-v $HOME/.docker:/root/.docker'\n }\n }\n }\n stage('F') { ... }\n }\n}\n\n\nWhat I can do so far is to set globally the agent to none and then set the agent Dockerfile.tester for each stage and for the 1 other stage I set it to Dockerfile.deploy. Any idea how I can set it globally once and then just override it?\n\nHere the new error from if I do it like above:\n\n> git rev-parse --is-inside-work-tree # timeout=10\n\nFetching changes from the remote Git repository\n\n > git config remote.origin.url https://bitbucket.org/*********/*********.git # timeout=10\n\nCleaning workspace\n\n > git rev-parse --verify HEAD # timeout=10\n\nResetting working tree\n\n > git reset --hard # timeout=10\n\n > git clean -fdx # timeout=10\n\nFetching without tags\n\nFetching upstream changes from https://bitbucket.org/*********/*********.git\n\n > git --version # timeout=10\n\nusing GIT_ASKPASS to set credentials BitBucket Login for checkout / pushing\n\n > git fetch --no-tags --progress https://bitbucket.org/*********/********.git +refs/heads/dev:refs/remotes/origin/dev\n\nChecking out Revision ab0d4a522d872a129f53a74f6ecadafb8fd82f11 (dev)\n\n > git config core.sparsecheckout # timeout=10\n\n > git checkout -f ab0d4a522d872a129f53a74f6ecadafb8fd82f11\n\nCommit message: \"chore: test\"\n\nCleaning workspace\n\n > git rev-parse --verify HEAD # timeout=10\n\nResetting working tree\n\n > git reset --hard # timeout=10\n\n > git clean -fdx # timeout=10\n\n[Bitbucket] Notifying commit build result\n\ndocker login failed"
] | [
"jenkins"
] |
[
"Pushing Git non-branch references to a remote",
"Git non-branch references (not branches, tags, remotes and notes) work just fine in a local machine but I have trubles to push them in a remote:\n$ git update-ref refs/exp/ee01 6a534fb5f9aad615ebeeb9d01ebe558a679a3cd1\n\nIt was successfully created:\n$ cat .git/refs/exp/ee01\n6a534fb5f9aad615ebeeb9d01ebe558a679a3cd1\n$ git for-each-ref refs/exp\n6a534fb5f9aad615ebeeb9d01ebe558a679a3cd1 commit refs/exp/ee01\n\nPushing it:\n$ git push origin exp/ee01\nTotal 0 (delta 0), reused 0 (delta 0)\nTo https://github.com/dmpetrov/example-get-started-exp.git\n * [new branch] refs/exp/ee01 -> refs/exp/ee01\n\nHowever, I don't see it when I clone this repo:\n$ git clone https://github.com/dmpetrov/example-get-started-exp.git\n$ cd example-get-started-exp/\n$ git for-each-ref refs/exp # it returns nothing\n\nHow to push non-branch references properly?\nEDIT: I can fetch it by name to FETCH_HEAD. Ideally, I should see\\fetch all the new refs without knowing the names in advance.\n$ git fetch origin exp/ee01\nFrom https://github.com/dmpetrov/example-get-started-exp\n * branch refs/exp/ee01 -> FETCH_HEAD"
] | [
"git",
"git-branch",
"git-remote"
] |
[
"How to Insert Data in multiple tables linked by a foreign key in Java",
"Table Name: \n\n\n CUSTOMER_INFORMATION\n\n\n\nCustomer_ID (PK)\nCustomer_Name \nMobile_Number \n\n\n\n EVENT_INFORMATION\n\n\n\nEvent_ID (PK)\nEvent_Name\n\n\n\n RELATION_TABLE\n\n\n\nEvent_ID (FK)\nCustomer_ID (FK)"
] | [
"java",
"mysql",
"netbeans"
] |
[
"ui-sref and $sce.trustAsHtml",
"I'm using ui-routing to drive requests in my angular webapp. In some case I use URL parameters. Now I've trouble if I use $sce.trustAsHtml(fooModel) beacuse if into fooModel I've something like this 'Hello! Check this value\"'\nui-sref can't generate href into html tag <a>.\nIt's possible to call ui-sref into $sce.trustAsHtml?\n\nthis is working code\n\n<div><a ui-sref=\"secure.foo({val:'value'})\">value</a><div>\n\n\nif I use same string above into model and then\n\n<div ng-bind-html=\"TrustDangerousSnippet(model)\"></div>\n\n\nwhere TrustDangerousSnippet, in my controller, is definded as\n\n$scope.TrustDangerousSnippet = function(p) {\n return $sce.trustAsHtml(p);\n }; \n\n\nin this case ui-sref can't works"
] | [
"angularjs",
"angular-ui-router"
] |
[
"Using subprocess to save image in paint",
"I need to change image compress method from PackBits to LZW, the simplest way is to open it in paint, save and close paint. I know how to open image \n\npath_to_paint = 'C:\\Windows\\system32\\mspaint.exe'\npath_to_file = 'C:\\\\Users\\XXX\\\\Desktop\\\\image.jpg'\n\nsubprocess.call([path_to_paint, path_to_file])\n\n\nis there a way to save it and close paint using subprocess?\nI need to do it on 100+ images."
] | [
"python",
"subprocess",
"paint"
] |
[
"Content type 'text/plain;charset=UTF-8' not supported error in spring boot inside RestController class",
"I got the following @RestController inside a spring boot application :\n\n@Data\n@RestController\npublic class Hello {\n\n @Autowired\n private ResturantExpensesRepo repo;\n\n @RequestMapping(value = \"/expenses/restaurants\",method = RequestMethod.POST,consumes =MediaType.APPLICATION_JSON_VALUE ,\n headers = MediaType.APPLICATION_JSON_VALUE)\n @ResponseBody\n public void hello(@RequestBody ResturantExpenseDto dto)\n {\n Logger logger = LoggerFactory.getLogger(\"a\");\n logger.info(\"got a request\");\n\n ResturantExpenseEntity resturantExpenseEntity = new ResturantExpenseEntity();\n resturantExpenseEntity.setDate(new Date(System.currentTimeMillis()));\n resturantExpenseEntity.setName(dto.getName());\n resturantExpenseEntity.setExpense(dto.getExpense());\n repo.save(resturantExpenseEntity);\n }\n}\n\n\nWhen I try to send request from restClient/RestedClient (both addons of mozila) I get the following error :\n\n\n {\n \"timestamp\": 1512129442019,\n \"status\": 415,\n \"error\": \"Unsupported Media Type\",\n \"message\": \"Content type 'text/plain;charset=UTF-8' not supported\",\n \"path\": \"/expenses/restaurants\"\n }\n\n\nThis eror states that the end point doesnt support Json content,But I did \nput \n\n\n consumes =MediaType.APPLICATION_JSON_VALUE\n\n\ninside @RequestMapping annotation\n\nWhat am I missing?"
] | [
"spring",
"spring-boot",
"utf-8",
"spring-restcontroller",
"spring-web"
] |
[
"How to input an array of random values into a binary search tree algirithm",
"I have an array with randomly generated numbers and I have to input them into a binary search tree algorithm, then to output them and visually represent it.\nHere is the code :\n\n//buttons and input\nrange:<input type=\"text\" id=\"input1\">\nlenght:<input type=\"text\" id=\"input2\">\n<input type=\"submit\" value=\"Submit\" onclick=\"javascript:myJsFunction()\">\n<script>\n//random number generator\nfunction myJsFunction(){\n var x=document.getElementById('input1').value;\n var n=document.getElementById('input2').value;\n var data=[];\n\n for (var i = 0; i < n ; i++){\n data[i]=Math.floor(Math.random()*x);\n }\n}\n\n\n//binary search tree algorithm\nclass Node {\n constructor(data, left = null, right = null) {\n this.data = data;\n this.left = left;\n this.right = right;\n }\n}\n\nclass BinaryTree {\n constructor() {\n this.root = null;\n }\n\n add(data) {\n const node = this.root;\n if (node === null) {\n this.root = new Node(data);\n return;\n } else {\n const searchTree = function(node) {\n if (data < node.data) {\n if (node.left === null) {\n node.left = new Node(data);\n return;\n } else if (node.left !== null) {\n return searchTree(node.left);\n }\n } else if (data > node.data) {\n if (node.right === null) {\n node.right = new Node(data);\n return;\n } else if (node.right !== null) {\n return searchTree(node.right);\n }\n } else {\n return null;\n }\n };\n\n return searchTree(node);\n }\n }\n}\n</script>\n\n\nI need a simple visual representation, something like sticks from the root and nodes (left-right). I couldn't find anything on array to binary tree or proper visualization so i would require some help."
] | [
"javascript",
"arrays",
"input",
"output",
"binary-search-tree"
] |
[
"MS Access: How can i select columns from different tables",
"In MS Access, I need to select a single row with many data from different tables with this query:\n\nselect top 1 a.colname,b.colname,c.colname \nfrom tba a, tbb b, tbc c \nwhere a.colname = 'efg' or\n b.colname ='efg' or\n c.colname ='efg' \n\n\nI will get data perfectly when 'efg' is matched with at least 1 from the 3 tables BUT if it does not match with any of them I will get MS Access frozen with wait cursor. I guessed it is looping for some reason. I only able to stop it with END TASK in Windows's task manager.\n\nHow is my query and can any expert explain or suggest different techniques to avoid this?\n\nThank you."
] | [
"ms-access",
"multiple-tables",
"multiple-select-query"
] |
[
"RangeBarChart plotted over time in aChartEngine",
"What I'd like to do is have a RangeBarChart with it's X-axis as dates. Currently adding new bars to a RangeCategorySeries spaces each bar equally, and there doesn't appear to be a mechanism for manually specifying an X value, such as a Date. TimeSeries exists, but appears only to be for LineCharts.\n\nIdeally what I'd need is a method add(min, max, date) on RangeCategorySeries.\n\nHas anyone implemented this or have some tips for me? Thanks."
] | [
"java",
"android",
"achartengine"
] |
[
"MySQL - grouping data by 2 columns",
"I have the follwoing table:\n\n\nis it possible if i want to select data to be like this ?\n\nso, what i need is to group count by caltype and registrationdate(month, year)\n\nany suggestion would be aprreciated thank you :)"
] | [
"mysql",
"database"
] |
[
"Magento grid filter index for custom column",
"In Magento Grid\n\na) While preparing collection I did some calculations in query and got those values as extra column- \n\nex - select 1 as extracolumn\n\nNow how can I set filter_index and sorting on this column \n\nOR\n\nb) I am using rendering to show custom data in a column, How can I set filter_index and sorting on this column"
] | [
"magento",
"grid",
"renderer"
] |
[
"C++ dynamic_cast runtime-error",
"I have written a small application using dynamic_cast to determine whether it is form the base class or the child class and invokes the function according to it. But when ever child class \nruns, it displays it function twice and no sure why it does that. \n\n#include <iostream>\nusing namespace std;\n\nclass Base{\npublic:\n virtual void setting(){\n cout << \"Hello, I am a function from the base class\" << endl;\n }\n virtual void say(){\n cout << \"Base class says hi\" << endl;\n }\n};\n\nclass Child:public Base{\npublic:\n void setting(){\n cout << \"Hello, I am a function from the child class\" << endl;\n }\n void say(){\n cout << \"Child class says hi\" << endl;\n }\n};\n\nvoid Ready(Base* input){\n Base* bp = dynamic_cast<Base*>(input);\n if(bp){\n bp->setting();\n bp->say();\n }\n Child* cp = dynamic_cast<Child*>(input);\n if(cp){\n cp->say();\n cp->setting();\n }\n}\n\nint main(){\n Base b;\n Child c;\n Ready(&b);\n cout << endl;\n Ready(&c); //runs twice for some reason\n system(\"pause\");\n return 0;\n}"
] | [
"c++",
"class",
"inheritance",
"runtime-error",
"dynamic-cast"
] |
[
"Constraints on calling base constructor",
"Let's say I have the following setup :\n\npublic abstract class A\n{\n B b_ {get; set;} // where B is some abstract class\n\n public A(B b)\n {\n b_ = b;\n }\n}\n\npublic class D : A\n{\n // some new fields\n D(B b) : base(b)\n {\n\n }\n}\n\n\nwhere B is some abstract class from which derives various \"concrete\" types.\n\nIn D's constructor I would like to put constraints on b's runtime type, like allowing only certains type. To do this, I can remove the call to the base's constructor, check in D's constructor for allowed \"concrete\" types and implement a default constructor in base class. Is there another way to do this ? (I find it also ugly to use base constructor and check after.)"
] | [
"c#"
] |
[
"Emscripten - Compile to WASM and keep original callable function names in the glue code",
"Using Emscripten v 1.38.43, I'm compiling a C code. For optimization reasons, I've stripped down the generated JS glue code and minimize the code size.\n\nWhile doing so I've spotted that the JS callables are mapped like so:\n\nvar asmLibraryArg = {\n \"b\": ___setErrNo,\n \"j\": _emscripten_get_heap_size,\n \"i\": _emscripten_memcpy_big,\n \"h\": _emscripten_resize_heap,\n \"g\": myFunctionA,\n \"f\": myFunctionB,\n \"e\": myFunctionC,\n \"d\": myFunctionD,\n \"c\": abortOnCannotGrowMemory,\n \"a\": DYNAMICTOP_PTR\n};\n\n\nMaking my stripped JS harder to maintain. On an older version (1.38.8) it used to output the function names with a prefixed _ i.e \"_myFunctionA\" : myFunctionA\n\n\n\nQ: Can I give the emcc compiler a flag that will force it to keep my original function names in the generated JS?"
] | [
"javascript",
"emscripten",
"webassembly"
] |
[
"input width in form-inline bootstrap 3",
"I don't understand, how I can customize an input (form-control) width in Bootstrap 3? \n\n<header>\n <div class=\"container\">\n <div class=\"row\">\n <form role=\"form\" class=\"form-inline\">\n <div class=\"form-group\">\n <input type=\"text\" class=\"form-control\" placeholder=\"Почтовый идентификатор\" id=\"search\"> \n </div>\n <input type=\"button\" class=\"btn btn-success\" value=\"Найти\" onclick=\"window.location.href = '/result/'+document.getElementById('search').value\">\n </form>\n </div>\n </div>\n</header>\n\n\nCan I do it without some styles (like width in pixels)?"
] | [
"jquery",
"html",
"css",
"twitter-bootstrap",
"twitter-bootstrap-3"
] |
[
"ui-router controller instantiated again on ui-sref",
"I've a state A with a link to a state B.\nState A's controller contains some method declarations and calls on $scope. So something like:\n\ncontroller : function($scope) {\n $scope.myFunc = { ... }\n $scope.myFunc();\n}\n\n\nWhen going to state B, the function $scope.myFunc() is called again. Why is it and how to avoid?\nThanks.\n\nUPDATE\nThe A state contains a inner $state.go with notify and reload set to false to update parameters. If I remove this, the transition is ok...why?\n\nJSFIDDLE\nThis is the fiddle:\nhttps://jsfiddle.net/p2qnrfsm/"
] | [
"angularjs",
"angular-ui-router"
] |
[
"Can I restructure the folder in CodeIgniter app?",
"I have changed my CodeIgniter app folder structure like below:\n\nMyCodeIgniterApp\n - application\n - system\n - newsubfolder\n - public\n - index.php\n - .htaccess\n - composer.json \n\nAs you can see above folder structure, I have kept the public,index.php and .htaccess file inside the subfolder. And I have changed the application and system path inside the index.php file to use right one.\nMy question is can I access my app like http://localhost/MyCodeIgniterApp or what else should I do in order to access like that?"
] | [
"php",
".htaccess",
"codeigniter"
] |
[
"how to check specific word like \"add\" and do specific job in C",
"void repl(){\n while(1){\n while(words[a]!='\\0'){\n if(isNumeric(words[a])){\n push(words[a]);\n }else if(strcmp(words[a],\"add\")==0){\n strcpy(value1, pop());\n strcpy(value2, pop());\n sum2 = (int)atoi(value1) + (int)atoi(value2);\n itoa(sum2,sum);\n printf(\"%d\",sum2);\n }\n a++;\n if(words[a] == '\\0'){\n printStack();\n }\n}\n\n\nwhat I need to care about this code is to receive numbers as char temp[] and check them that they are numeric or not.\n\nhowever I succeed that part of thing, but what I need to solve now is to check if the words[a] is add\n\nthen pop last 2 value to calculate sum of them and push back sum into stack.\n\nwhile I did on this code I received segmentation fault\n\nrepl>1 2 3 4\n4 \n3\n2 \n1\nrepl>add\nSegmentation fault\n\n\nis there any way to solve this?"
] | [
"c"
] |
[
"How to manipulate the current date?",
"Using MediaWiki we can acess current date with:\n\n{{CURRENTYEAR}}-{{CURRENTMONTH}}-{{CURRENTDAY2}}\n\n\nThe output being:\n\n2017-02-02\n\n\nHowever, how could I manipulate the current date so I can insert the previous month?\n\nI've tried {{CURRENTYEAR-1}} but this doesn't seem to work."
] | [
"mediawiki"
] |
[
"Construct new ranked columns out of rank columns in R",
"In the code below I create subsets of df by column and afterwards sorting it by the specific rank variable.\n df <- data.frame(\n id=c("a","b","c","d","e","f"),\n rank1=c(1,3,2,1,5,7),\n rank2=c(4,6,2,1,4,2),\n rank3=c(4,6,2,1,4,2))\n \n for(i in colnames(df)[-1]) {\n assign(i, df %>% \n arrange(desc(across(all_of(i)))) %>%\n select(id))\n}\n\nNow I want to combine these ranked subsets into a new dataframe with one rank variable. This creates the new dataframe:\nrankings <- data.frame(\n rank=1:6\n)\n\nHow do I merge the new dataframe with the ranked subsets of my original dataframe? Preferably the columns should have the name of their ranking (rank1, rank2, rank3), so a rename is probably needed in the loop as well, which I can't get to work, too."
] | [
"r"
] |
[
"JQuery autocomplete custom scroll bar",
"i am not able to define a custom scroll bar to the jquery autocomplete widget , no information is there on the jquery site or any other place either \n\nPlease suggest if any one has an idea\n\nRegards\nSmriti Garg"
] | [
"javascript",
"jquery",
"jquery-autocomplete"
] |
[
"JSON string without keys - how to update MYSQL database related values",
"How can I update MYSQL database values with an JSON string that does not contain keys to identify the data? What I need is to use the first value of the JSAON data (e.g. \"100\", \"200\", \"300\", etc.) to find the correct line in the database, and update the database row with all the other values from the JSON data.\n\nI've thought of parsing the data but I don't know how to do that without the key reference in the JSON data.\n\n[\n[\"100\", \"Salg, avgiftspliktig\", \"\", \"\", \"3000\", \"\"],\n[\"200\", \"Salg, avgiftsfritt\", \"\", \"\", \"3100\", \"I\"],\n[\"280\", \"\", \"\", \"\", \"\", \"\"],\n[\"300\", \"SUM SALG\", \"TOT\", \"100+200\", \"\", \"B\"],\n[\"500\", \"Varekjøp\", \"\", \"\", \"4300\", \"\"],\n[\"600\", \"SUM UTGIFTER\", \"TOT\", \"500\", \"\", \"B\"],\n[\"700\", \"\", \"\", \"\", \"\", \"\"],\n[\"800\", \"Driftsresultat\", \"TOT\", \"300-500\", \"\", \"B\"],\n[\"900\", \"\", \"\", \"\", \"\", \"\"],\n[\"1000\", \"\", \"\", \"\", \"\", \"\"],\n[\"1100\", \"cvzxb\", \"\", \"\", \"\", \"\"],\n[\"1200\", \"\", \"\", \"\", \"\", \"\"]\n]\n\n\nExample update:\n\nDatabase old data (from ID=800):\n800,OldData,TOT,200,,I\n\nDatabase updated value from the JSON data:\n800,Driftsresultat,TOT,300-500,,B"
] | [
"php",
"mysql",
"json",
"string"
] |
[
"splitting paragraphs into spans",
"I have two paragraphs. First I would like to separate each word in first, wrap it with span with id and then move for example 5 first words into second paragraph (with spaces). The problem is that I don't know if append(' ') is a good idea and the second problem is that after injection of the spans to the second paragraph width of it is too large (it should be 100px with text overlaping to next line juz like in first paragraph\n\nhere is my attempt\n\n <body>\n<script type=\"text/javascript\">\n $(function(){\n var obj = $('.p1')\n var text = obj.html().split(' '), len = text.length, result = [];\n for( var i = 0; i < len; i++ ) {\n result[i] = '<span id=\"'+i+'\">' + text[i] + '</span>';\n }\n obj.html(result.join(' '));\n\n var words = $('.p1').find('span');\n for(var i = 0; i < 5; i++){\n $('.p2').append($(words[i]).clone());\n $('.p2').append('&nbsp;');\n }\n });\n</script>\n\n<div class=\"test\" style=\"width:100px\">\n<p class=\"p1\">\ntest1 test2 test3 test4 test5 test6 test7 test8\n</p>\n</div>\n<div class=\"test\" style=\"width:100px\">\n<p class=\"p2\">\n</p>\n</div>\n</body>"
] | [
"javascript",
"jquery",
"html"
] |
[
"WooCommerce my-accounts Page - get the current user for orders query",
"I'm trying to sum specific items for each user, but it seems it doesn't recognize the current user and it sums all the orders for all customers. \n\nHow can I solve this? What I am missing?\n\nHere's the code I am using: \n\n$order_items = apply_filters( 'woocommerce_reports_top_earners_order_items', $wpdb->get_results( \"\n\nSELECT order_item_meta_2.meta_value as product_id, SUM( order_item_meta.meta_value ) as line_total FROM {$wpdb->prefix}woocommerce_order_items as order_items\n\nLEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta as order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id\n\nLEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta as order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id\n\nLEFT JOIN {$wpdb->posts} AS posts ON order_items.order_id = posts.ID\n\nWHERE posts.post_type = 'shop_order'\n\nAND posts.post_status IN ( '\" . implode( \"','\", array( 'wc-completed', 'wc-processing', 'wc-on-hold' ) ) . \"' )\n\nAND order_items.order_item_type = 'line_item'\n\nAND order_item_meta.meta_key = '_line_total'\n\nAND order_item_meta_2.meta_key = '_product_id'\n\nGROUP BY order_item_meta_2.meta_value\n\n\" ));\n$totalPR = 0;\n$Products = array(1507, 1406, 1506);\n\nforeach ($order_items as $item) {\n\n if (in_array($item->product_id, $Products)) {\n\n $totalPR = $item->line_total + $totalPR;\n echo $totalPR;\n\n }\n\n}"
] | [
"php",
"mysql",
"sql",
"wordpress",
"woocommerce"
] |
[
"In a multithreaded process on a system with multiple (physical) CPUs, how is thread scheduling handled?",
"Kind of a broad question, but I'm curious about the details of thread scheduling in a single process application on a machine with multiple physical CPUs.\n\nEDIT - wanted to clarify that below im talking about phyiscal CPUs. I've got a pretty good handle on how a process/threads work with a multicore CPU, but I'm talking multiple physical CPU dyes on the motherboard (like 2 4-core Xeons).\n\nANSWER - thanks to the responses from brokenfoot and nosid, I think I've got it:\n - Linux scheduler has different NUMA policies that affect thread scheduling in regards to their memory mutation/access patterns in regards to core/dye.\n - Cache coherency across dyes is possible, but slower as expected.\n - Best course of action- control mutability of shared memory (try to be immutable)\n - Use an internal (in-process) task scheduler that respects locality of threads\n - Use a NUMA policy that works with your in-process task scheduler\n\nAssumptions:\n\n\nCache coherency is the magic that allows multiple cores to operate on shared memory. (confirmed)\nAs far as I know, cache coherency is possible over multiple CPUs, but at reduced performance (Linux 3+, system has multiple modern multi-core Xeons CPUs). (confirmed)\n\n\nSo the situation: \n\n\nI have a multi-threaded single process service that does... stuff, in parallel. It can effectively utilize multiple cores and divides work up in a way that generally avoids cpu-core cache misses and coherency abuse. Executor has relative thread-affinity for tasks. \nThe service threads can utilize shared data (mostly immutable) in the process.\nThe service architecture is done in a way that running multiple processes on the same box is possible, but is advantageous to have only 1 process per box (shared cache, resources, etc). \n\n\nThe questions:\n\n\nIs cache coherency possible between multiple CPUs? Is it practical? (It is, at reduced performance)\nHow will linux schedule the threads between CPUs? (If possible)\nIs there some way to pin a process to a single CPU? (confirmed)\nAnd ultimately... do I do one process per CPU and pin? Or 1 per box (which would be cool, if i dont screw myself with slow cross-CPU cache misses) (starting to sound like 1 process is good, as long as my parallel tasks have affinity to a certain thread and mostly immutable data)"
] | [
"linux",
"multithreading",
"process",
"parallel-processing",
"linux-kernel"
] |
[
"VSCode: \"No debug adapter, can not send 'evaluate'\"",
"I am trying to run lua 5.4 code in VSCODE but I am getting this error:No debug adapter, can not send 'evaluate'. My debugger is "Local Lua Debugger" and the launch.json is\n{\n "version": "0.2.0",\n "configurations": [\n {\n "type": "lua-local",\n "request": "launch",\n "name": "Launch",\n "program": {\n "lua": "lua54",\n "file": "bot.lua"\n \n }\n }\n ]\n}\n\nAnd the lua file itself is\nprint("Y/N?")\nlocal input = io.input()\nif input == "no" then\n print("yes")\nend\n\nThe error shows up every time I want to input something."
] | [
"json",
"visual-studio-code",
"lua"
] |
[
"implement dc chart in ember",
"i have added dc plugins to my ember app.\nin my hbs i have added\n\n\n\nhere is javascript code:\n\nvar data = [\n\n {date: \"12/27/2012\", http_404: 2, http_200: 190, http_302: 100},\n {date: \"12/28/2012\", http_404: 2, http_200: 10, http_302: 100},\n {date: \"12/29/2012\", http_404: 1, http_200: 300, http_302: 200},\n {date: \"12/30/2012\", http_404: 2, http_200: 90, http_302: 0},\n {date: \"12/31/2012\", http_404: 2, http_200: 90, http_302: 0},\n {date: \"01/01/2013\", http_404: 2, http_200: 90, http_302: 0},\n {date: \"01/02/2013\", http_404: 1, http_200: 10, http_302: 1},\n {date: \"01/03/2013\", http_404: 2, http_200: 90, http_302: 0},\n {date: \"01/04/2013\", http_404: 2, http_200: 90, http_302: 0},\n {date: \"01/05/2013\", http_404: 2, http_200: 90, http_302: 0},\n {date: \"01/06/2013\", http_404: 2, http_200: 200, http_302: 1},\n {date: \"01/07/2013\", http_404: 1, http_200: 200, http_302: 100}\n ];\nvar ndx = crossfilter(data);\nvar parseDate = d3.time.format(\"%m/%d/%Y\").parse;\ndata.forEach(function(d) {\n d.date = Date.parse(d.date);\n d.total= d.http_404+d.http_200+d.http_302;\n});\n\nvar dateDim = ndx.dimension(function(d) {return d.date;});\nvar hits = dateDim.group().reduceSum(function(d) {return d.total;});\nvar minDate = dateDim.bottom(1)[0].date;\nvar maxDate = dateDim.top(1)[0].date;\n\nhitslineChart\n .width(500).height(200)\n .dimension(dateDim)\n .group(hits)\n .x(d3.time.scale().domain([minDate,maxDate]))\n .yAxisLabel(\"Hits per day\");\n\ndc.renderAll();\n\n\nhow to write this javascript code in controller.?"
] | [
"javascript",
"ember.js"
] |
[
"twilio missing attributes c#",
"I'm writing an IVR application using Twilio in C#, and I'm trying to use the gather verb along with it's attributes: input, action, hints, and timeout.\n\nIf I write:\n\nvar gather = new Gather(input: \"speech\", action: Url.Action(\"PostSpeech\"), timeout: 3);\n\n\nThen the \"hints\" attribute is not available. If I try to write it in like:\n\nvar gather = new Gather(input: \"speech\", action: Url.Action(\"PostSpeech\"), timeout: 3, hints: \"stuff, things\");\n\n\nThen it tells me that 'The best overload for Gather does not have a parameter named hints'\n\nAlternatively, if I try:\n\nvar response = new VoiceResponse();\nresponse.Gather(action: Url.Action(\"PostSpeech\"), timeout: 3, hints: \"stuff, things\");\n\n\nThen the \"input\" attribute is not made available to me, similar to the above.\nMy understanding is that all of the attributes listed here:\n\nhttps://www.twilio.com/docs/api/twiml/gather\n\nshould be made available no matter how I use the gather verb. There are a few other attributes (like profanityFilter) that also do not work in either case, but that's irrelevant to me at the moment.\n\nHow can I get the four aforementioned attributes to work here? Am I doing something wrong, or is this just a bug? \n\nP.S. I'm using the Twilio nuget package v5.5.2 as well as the Twilio.AspNet.Mvc package v5.0.2"
] | [
"twilio"
] |
[
"Windows Phone 8.1 webview new tab , file explorer isn't working.",
"I'm writing WindowsPhone 8.1 RT app . My mainpage is a webview of teknoseyir.com . This a social website( like facebook-twitter) and you can upload images. I'm having trouble at uploading images and opening new tab. At the other browsers(Chrome ie11 etc.) when user click this image button , phone appearing file explorer for select images but my webview page it isn't working.\n\n\nWhat should i have to do ?"
] | [
"webview",
"windows-phone-8.1"
] |
[
"VarChar to NVarChar and back",
"The environment is SQL Server 2012. I'm about to change a clr procedure returned result column from varchar to nvarchar, but I'm not sure if the characters which can be found in varchar code page will always convert to the same character in unicode and also the other way. The bad example would be if someone would get the results from procedure with column of nvarchar and put that in database with varchar column. The question is, will they convert correctly always?"
] | [
"clr",
"sql-server-2012",
"varchar",
"nvarchar"
] |
[
"iostream to zlib and files with C++?",
".NET has spoiled me and made me realize how simple certain things can be :(\n\nWith C++ i'd like to use either fopen or ostream/istream to push data to either zlib directly or to some kind of memory buffer (then zlib) then proceed to dump it to a file. I'd like something similar to load it back in.\n\nI looked at zlibs example and while it looks simple it isnt an iostream or file and i need to use buffers. Does anyone know of a existing solution?"
] | [
"c++",
"file",
"iostream",
"zlib"
] |
[
"Cannot set image source in code behind",
"There are numerous questions and answers regarding setting image source in code behind, such as this Setting WPF image source in code.\n\nI have followed all these steps and yet not able to set an image. I code in WPF C# in VS2010. I have all my image files under a folder named \"Images\" and all the image files are set to Copy always. And Build Action is set to Resource, as instructed from documentation.\n\nMy code is as follow. I set a dog.png in XAML and change it to cat.png in code behind.\n\n// my XAML\n<Image x:Name=\"imgAnimal\" Source=\"Images/dog.png\" />\n\n// my C#\nBitmapImage img = new BitmapImage();\nimg.UriSource = new Uri(@\"pack://application:,,,/FooApplication;component/Images/cat.png\");\nimgAnimal.Source = img;\n\n\nThen I get a empty, blank image of emptiness. I do not understand why .NET makes setting an image so complicated..w\n\n[EDIT]\n\nSo the following works\n\nimgAnimal.Source = new BitmapImage(new Uri(@\"pack://application:,,,/FooApplication;component/Images/cat.png\"));\n\n\nIt works, but I do not see any difference between the two code. Why the earlier doesn't work and the latter does? To me they are the same.."
] | [
"c#",
"wpf",
"xaml",
"code-behind"
] |
[
"Beginner ILNumerics: install under VS2012",
"I am very much interested in ILNUmerics and would like to try the free version, but I am having troubles.\n\nI have started with a console application and was trying to run the 'hello ilnumerics'console application but I noticed that VS fails to find MKL libraries.\n\nI am using VS2012 under Windwos 8 (through Bootcamp on a MacBook Pro mid 2010; should it be relevant); I have installed the NuGet Packages extension from the Project solution. Then right-click on references in the solution explorer, 'Manage Nu Get Packages', fron online/search found ilnumerics in various versions. I chose 'ILNumerics' and install. I got 'ILNumerics' and 'ILNumerics.Native' added to my project. Then I can see ILNumerics under 'References' in Solution Explorer and also get two new folders /bin32/ and /bin64/ they both contain two DLLs named: libiomp5md.dll and mkl_custom.dll. I have checked their \n'Copy to Ouput Directory' property and they are all set to 'Copy if newer'.\n\nApparently mkl_custom is not found. I write the following code, taken from the quickstart guide:\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing ILNumerics;\n\nnamespace ConsoleApplication3\n{\n\n class Program : ILMath\n{\n static void Main(string[] args)\n {\n\n ILArray<double> A = array<double>\n (new double[] { 1,1,1,1,1,2,3,4,1,3,6,10,1,4,10,20} ,4, 4);\n ILArray<double> B = counter(4, 2);\n\n ILArray<double> Result = linsolve(A, B);\n Console.Out.WriteLine(\"A: \" + Environment.NewLine +\n A.ToString());\n\n Console.Out.WriteLine(\"B: \" + Environment.NewLine + B.ToString());\n\n Console.ReadKey();\n }\n }\n}\n\n\nand I get this exception:\nAn unhandled exception of type 'System.DllNotFoundException' occurred in ILNumerics.dll\n\nAdditional information: Unable to load DLL 'mkl_custom': The specified module could not be found. (Exception from HRESULT: 0x8007007E)\n\nIf I do not invoke linsolve the ToString method of ILArray does work: if I comment // ILArray Result = linsolve(A, B);\n\nI get the two matrices printed on the screen.\n\nI have also tried to compute the determinant of a matrix and got the same exception: apparently any time I call mkl_custom VS is not capable to find it. \n\nAny help/hint, please?\n\nAlso, is it necessary to install ILNumerics through NuGet on any project added to the solution? Would it be possible to install it locally once for all and then add the reference if necessary?"
] | [
"c#",
"visual-studio-2012",
"ilnumerics"
] |
[
"Relace HWPFDocument paragraph text using java results strange output",
"I require to replace a HWPFDocument paragraph text of .doc file if it contains a particular text using java. It replaces the text. But the process writes the output text in a strange way. Please help me to rectify this issue.\nCode snippet used:\n\npublic static HWPFDocument processChange(HWPFDocument doc)\n{\n try\n {\n Range range = doc.getRange();\n for (int i = 0; i < range.numParagraphs(); i++)\n {\n Paragraph paragraph = range.getParagraph(i);\n if (paragraph.text().contains(\"Place Holder\"))\n {\n String text = paragraph.text();\n paragraph.replaceText(text, \"*******\");\n\n }\n }\n }\n catch (Exception ex)\n {\n ex.printStackTrace();\n }\n return doc;\n}\n\n\nInput:\n\nPlace Holder \nTextvalue1\nTextvalue2\nTextvalue3\n\n\nOutput:\n\n*******Textvalue1\nTextvalue1\nTextvalue2\nTextvalue3"
] | [
"java",
"doc",
"paragraph",
"hwpf"
] |
[
"IEEE_UNDERFLOW_FLAG IEEE_DENORMAL in Fortran 77",
"I am new to Fortran and coding in general so I apologize if my terminology is not correct.\n\nI am using a Linux machine with the gfortran compiler.\n\nI am doing research this summer which involves me getting a program written in about 1980 working again. It is written in Fortran 77. I have all the code as well as some documentation about it. \n\nIn its current form it I am receiving a \"IEEE_UNDERFLOW_FLAG IEEE_DENORMAL\" error. My first thought is that this code was meant to be developed under a different environment/architecture.\n\nThe documentation states “This program was designed to run on the HARRIS computer system. It also can be run on VAX system if the single precision variables are changed into double precision variables both in the main code and the subroutine package.”\n\nI have tried changing the single precision variables to double precision variables, but I may have done that wrong. If this is the correct thing to do any insight would be great.\n\nI have also tried compiling the coding with -std=legacy and -m32. I receive the same error from this as well.\n\nAny advice to get me going in the right direction would be greatly appreciated."
] | [
"fortran",
"gfortran",
"fortran77"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.