Id
int64
34.6M
60.5M
Title
stringlengths
15
150
Body
stringlengths
33
36.7k
Tags
stringlengths
3
112
CreationDate
stringdate
2016-01-01 00:21:59
2020-02-29 17:55:56
Y
stringclasses
3 values
37,280,082
How close the connection PDO PHP?
<p>I'm trying to close the connection in my class and I wonder if it is correct.</p> <p>My public function disconnect(); close connection.</p> <p>Class Connection:</p> <pre><code>&lt;?php class Connection{ private static $instance; public static function getInstance(){ if (!isset(self::$instance)) { try { self::$instance = new PDO(DB_DRIVE . ':host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS); self::$instance-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); self::$instance-&gt;setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); } catch (PDOException $exception) { echo $exception-&gt;getMessage(); } } return self::$instance; } public static function prepare($sql){ return self::getInstance()-&gt;prepare($sql); } public static function lastInsertId($sql){ return self::getInstance()-&gt;lastInsertId($sql); } public function disconnect(){ return self::$instance = null; } } </code></pre> <p>I use so in my script after execution:</p> <pre><code>&lt;?php $connectionDb = new Connection(); $connectionDb-&gt;disconnect(); </code></pre> <p>Is correct?</p>
<php><mysql><pdo>
2016-05-17 15:14:12
LQ_CLOSE
37,280,166
Why Closing a File Stream in Java is so Important
<p>With huge advancements in CUPs able to process mass amounts of information in fractions of seconds, why is it important that I close a file stream? </p>
<java><file>
2016-05-17 15:17:23
LQ_CLOSE
37,280,285
Is this (auto && elem : v) syntax simple C++? or should I add more options to the compiler
I tried to compile the solution proposed here http://stackoverflow.com/a/29422628/6019417 , but ran into an error. I did not knew it was possible to avoid iterators like that in `C++` with the use of this `(auto && elem : v)` Or is it a little more than `C++`? b.cpp ---- #include <iostream> #include <vector> #include <utility> #include <algorithm> #include <string> #include <set> int main() { std::vector<std::pair<std::string, std::string>> v { {"handgun", "bullets"}, {"turret", "bullets"}}; std::cout << "Initially: " << std::endl << std::endl; for (auto && elem : v) std::cout << elem.first << " " << elem.second << std::endl; return 0; } Compilation ---- $ cc b.cpp -std=c++0x -o myprog Errors ---- > b.cpp: In function ‘int main()’: <br> > b.cpp:15: error: expected initializer before ‘:’ token <br> > ... Appreciate your help.
<c++><compilation><iterator><set>
2016-05-17 15:22:07
LQ_EDIT
37,280,856
PHP code not able to run in Android App
- I have created an app in which there is a login page (login.php).This consists of the form - The other script i have created is loginScript.php - When i try to run the code, login.php,it does runs in the webview of app but when hit "sign in" button, the action calls the loginScript.php but it does not runs instead whole scripts displayed. > Kindly suggest what should i do to run the php script in the app (Internet is active)
<php><android>
2016-05-17 15:45:25
LQ_EDIT
37,280,937
Android how to turn Location services on programatically?
I am building an android app to track my device, is it possible to turn location services on via code? I have searched for code to do so i have found some and on execution of code it gives some sort of security exceptions, and some threads here on stack over flow were saying that it is impossible to do so, If possible please provide code, if impossible why so?
<android>
2016-05-17 15:49:03
LQ_EDIT
37,281,456
Read txt with delimeter and multiple spaces
<p>I have a text file where the delimiter is '&amp;'. However, the first column is text and may contain spaces as well - How can I properly read it ? The text looks like</p> <pre><code>selection according to criteria A &amp; 2312 </code></pre> <p>some other selection according to criteria B &amp; 345</p> <p>Please note that the text in first column can contain more than one word (ie more spaces from one to another line). I ve tried something</p> <pre><code>char ch; ch="&amp;"; ifstream filein; filein.open("selection.txt"); while (1) { data &gt;&gt; c1 &gt;&gt; char &gt;&gt;c2 ; cut1.push_back(c1); cut2.push_back(c2); if (!data.good()) break; } </code></pre> <p>but this does not work... </p> <p>thanks in advance</p>
<c++><ifstream>
2016-05-17 16:14:01
LQ_CLOSE
37,281,742
How can I remove a property from an object?
<p>I have this object:</p> <pre><code> {"wordFormId":"abandon", "wordFormIdentity":1, "ascii":97, "wordId":"abandon", "primary":true, "posId":2} </code></pre> <p>How can I remove the ascii property? I know I could set it to null but I assume it would then still be there. What I would like to do is to completely remove it.</p>
<javascript>
2016-05-17 16:28:16
LQ_CLOSE
37,282,845
using map to check for true or false doesn't work
<p>I am trying no to use a loop as Im practicing map, filter etc. and wonder why my code doesn't work? </p> <pre><code>function checking(array,item){ var temporary=true; array.map(function(x){ if (x!=item){ temporary=false; } }); return temporary; } checking([1, 2, 3], 2); </code></pre>
<javascript><loops><dictionary><filter>
2016-05-17 17:31:45
LQ_CLOSE
37,283,781
Should I learn Angularjs first or Laravel?
<p>I'm a beginner web developer, I decided to learn my first framework so it's my first time to use a framework and I decided to learn Angularjs &amp; Laravel. which one should I start with ?</p> <p>PS: I code in PHP and I know PHP OOP, also I'm kinda good at JS </p>
<javascript><php><angularjs><laravel><typescript>
2016-05-17 18:30:28
LQ_CLOSE
37,283,974
Can we install .exe file generated by a C# console app? if yes, how?
<p>Can we install .exe release file generated by a C# console app? if yes, how?</p>
<c#><installation><exe>
2016-05-17 18:42:39
LQ_CLOSE
37,284,260
Where Should I Start to make my own Swift Library?
<p>Iv been developing Swift for 1 Year now and I feel like I have fairly good knowledge of the language.</p> <p>Now I am wondering where do people start when creating a large open source project like AlamoFire or a small custom button/animation library for others to use?</p> <p>Iv tried looking for some kind of "build a small swift library tutorial" but noone are around.</p> <p>I realize this may be a broad question and I am not looking for a A-Z list. IF you can give me the main points I need to dig into and what I need to think about before attempting to create it that would be amazing!</p> <p>Thank you!</p>
<swift>
2016-05-17 19:00:26
LQ_CLOSE
37,284,382
C++ rewrite file
<p>I have a C++ class where many of the assignments involve copying and pasting code from the book. Problem is that the format of the book makes this a very tedious task. When I copy and paste, there are extraneous numbers and spaces on the left of the code, and parts of the code are misaligned. I'm looking to write a C++ program to read a file (probably a .txt) to reformat the code and delete the numbers on the side. </p> <p>However, I've been searching cplusplus.com, and can't figure out what library to import, so that I can open and edit the file. I'd appreciate a point in the right direction, and any tips for text editing any of you might have. Thank you.</p>
<c++>
2016-05-17 19:07:47
LQ_CLOSE
37,285,057
Php shows wrong time
<p>I'm making a website and the php time is incorrect, it is 40 seconds behinde. How do I fix it? (I have time events on my site). I have one javascript clock which is fine btw.</p>
<php>
2016-05-17 19:48:49
LQ_CLOSE
37,285,466
How to configure exim4 to send & receive email on a VPS using my own domain name?
<p>I just bought a new "public cloud" to put my new website on it.</p> <p>This public cloud is in "advanced zone", which means that every instance I deploy is in a NAT network with private IP (10.1.1.x), and there is a firewall in front of the global network to control IN and OUT ports.</p> <p>I have deployed two instances with Debian 8, one for webserver &amp; the other one for the database. I have my own domain name (let's say "mydomain.com"), and I want my website to be able to send email using this domain name (FROM would be "no-reply@mydomain.com") and I would like to receive emails sent by users of the website (TO contact@mydomain.com) using a Thunderbird or Outlook for example.</p> <p>Exim4 was already installed on the webserver (installed by default in Debian 8), I used <code>dpkg-reconfigure exim4-config</code> to reconfigure it. Here is the content of my different files.</p> <p>/etc/exim4/update-exim4.conf.conf</p> <pre><code>dc_eximconfig_configtype='internet' dc_other_hostnames='contact.mydomain.com' dc_local_interfaces='127.0.0.1' dc_readhost='' dc_relay_domains='' dc_minimaldns='false' dc_relay_nets='' dc_smarthost='' CFILEMODE='644' dc_use_split_config='false' dc_hide_mailname='' dc_mailname_in_oh='true' dc_localdelivery='mail_spool' </code></pre> <p>/etc/hosts :</p> <pre><code>ROUTER_IP mydomain.com contact </code></pre> <p>/etc/hostname :</p> <pre><code>contact </code></pre> <p>/etc/email-addresses :</p> <pre><code>contact@mydomain.com </code></pre> <p>When I type <code>hostname</code> : contact<br> When I type <code>hostname -d</code> : com<br> When I type <code>hostname -f</code> : mydomain.com</p> <p>In my DNS I created a zone with SPF type to avoid spam. Here it is :</p> <pre><code>TTL = 600 / Target = "v=spf1 a mx ptr ~all" </code></pre> <p>I tried to send an email using this command :</p> <pre><code>echo "This is a test." | mail -s Testing myownaddress@gmail.com </code></pre> <p>When I'm sending an email to gmail, I receive an email from <code>root (root@mydomain.com)</code> and not <code>contact@mydomain.com</code></p> <p>When I'm sending an email to my own personnal address, I have an error in exim4 mainlog <code>/var/log/exim4/mainlog</code> :</p> <pre><code>SMTP error from remote mail server after RCPT TO:&lt;johnny@myserver.com&gt;: host mail.myserver.com [37.xx.xx.Xx]: 504 5.5.2 &lt;contact&gt;: Helo command rejected: need fully-qualified hostname </code></pre> <p>I don't understand what I'm doing wrong. Do you have any idea on this please ?</p> <p>Thanks in advance !<br> Regards,<br> Julien Q.</p>
<email><vps><exim><exim4><public-cloud>
2016-05-17 20:15:27
LQ_CLOSE
37,285,730
Simple password-prompr in C
I'm trying to make a simple user and password autentication in C. I was told to never use gets() when getting input and I should use fgets() instead. But I'm not sure of how the fgets() works or why is giving me this input. Here is the code. #include <stdio.h> #include <string.h> int login(char *user, char *passwd){ int enter = 0; char p[6]; char u[6]; printf("User: "); fgets(u, sizeof u, stdin); printf("Pass: "); fgets(p, sizeof p, stdin); printf("%s\n", p); if (strcmp(user, u) == 0 && strcmp(passwd, p) == 0){ enter = 1; } return entrar; } int main(){ char user[] = "admin"; char passwd[] = "12345"; if (login(user, passwd)){ puts("--ACCESS GRANTED--"); } else{ puts("--Wrong pass or user--"); } return 0; } Ouput >User: admin >Pass: >--Wrong pass or user-- It doesn't even let me enter the password after I press enter.
<c><pointers><fgets><password-prompt>
2016-05-17 20:29:54
LQ_EDIT
37,286,211
What code does Facebook, Skype, etc. look for to make their thumbnails?
<p>When I post a link in Facebook or Skype, they display some of the content as a thumbnail, but it's not the whole page, usually it's the most representative image. I would like my own pages to have nice thumbnails in Facebook, Skype, etc. too. What code do they look for to do this?</p>
<html><facebook><thumbnails><preview><skype>
2016-05-17 21:04:29
LQ_CLOSE
37,286,431
converting string of datetime to datetime C#
I want to converting string of date-time to date-time format like this **5/10/2016 12:00:00 AM** format . i tried more than way but not working please any advice. DateTime myDate = DateTime.ParseExact(txtManufacturerDate.Text, "MM-dd-yyyy",null);
<c#><datetime>
2016-05-17 21:20:54
LQ_EDIT
37,286,601
operator< error in priority queue
<p>I am facing "binary '&lt;': no operator found which takes a left-hand operand of type 'const Baloons' (or there is no acceptable conversion)" error and I cannot find any solution?</p> <p>I would also like to ask how can I order the priority queue by baloon.end?</p> <pre><code>#include &lt;iostream&gt; #include &lt;queue&gt; #include &lt;vector&gt; using namespace std; class Baloons { public: float start; float end; public: Baloons() {} Baloons(float start, float end) : start{ start }, end{ end } {} }; int main() { Baloons baloon1(1, 5); Baloons baloon2(4, 7); Baloons baloon3(6, 9); Baloons baloon4(11, 12); std::priority_queue&lt;Baloons&gt; myBaloons; myBaloons.push(baloon1); myBaloons.push(baloon2); myBaloons.push(baloon3); myBaloons.push(baloon4); while (!myBaloons.empty()) { Baloons b = myBaloons.top(); cout &lt;&lt; b.start &lt;&lt; " -&gt; " &lt;&lt; b.end &lt;&lt; " "; myBaloons.pop(); } system("pause"); return 0; </code></pre> <p>}</p>
<c++><stl><priority-queue>
2016-05-17 21:34:11
LQ_CLOSE
37,287,866
Obtaining encoder data
<p>Hello and in advance thank you for reading my post, </p> <p>I am working on a project which is controlled by a stepper motor which also includes an encoder. I have made the motor running and now I want to proceed to the next step and include the functions of the encoder. I know that the encoder tells me the actual position travelled by the motor, however, as I am still quite a newbie, I have unfortunately no idea how to include the information of my encoder into my code (which library? which variables). Both motor and encoder are connected to my Arduino Uno and I have also attached a photo with the corresponding pins for the encoder. </p> <p>Thank you for any much required help</p>
<arduino><encoder>
2016-05-17 23:36:20
LQ_CLOSE
37,289,588
A java program that generates 100 random numbers
<p>Can someone help me with this exercise? Write a program that generates 100 random numbers and stores each number into an integer array. For this program, you must meet the following technical requirements: 1) In main, generate the 100 random numbers and store each in an array 2) In main, ask the user to enter a number to see if it exists in the array 3) Write a function that takes the array and user number as input parameters and returns either true or false if the number does or does not exist in the array respectively 4) In main, call this function appropriately and use the result to print out to the user if the number they provided is in the array</p>
<java>
2016-05-18 03:10:11
LQ_CLOSE
37,289,991
replace the value with small value for example
I have column in table of customer contains very tall number like this 7351267613862 I want replace the value with small value for example. > 7351267613862 = 1 > 7371867613863 = 2 > 7351267993855 = 3 How can do this by using SQL script. Note: this value cloud appear in the table many times.
<sql-server><sql-server-2008><sql-server-2008-r2>
2016-05-18 03:53:17
LQ_EDIT
37,290,098
Want to Implement Chat Feature in my android app is there any library or sdk i can use ? or i have to code it all myself?
<p>i just don't know where to get started.<br> i am making a college project in which students can discuss problems with other students or with teacher may be its like a post in Facebook and commenting below that post .</p>
<android><chat>
2016-05-18 04:04:32
LQ_CLOSE
37,291,513
Where to get poi final jar for xssf?
<p>I have downloaded poi -3.14 jar from Maven repository but it was having all packages for hssf where I need xssf for xlsx format. Where should I download xssf jar.</p>
<java><apache><apache-poi>
2016-05-18 06:06:17
LQ_CLOSE
37,292,556
Why is my code crashing?
<p>I've got a pretty basic question, why is my code crashing? I'm learning to use pointers and I really don't know why the code crashes after I enter the values of x1,x2,y1 and y2 (this happens in case 3 of the second switch). I've looked everywhere and I can't find a reason. I need to send the values entered in function menuLR, case 3 to the function DistDosPuntos, an then return the values to menuLR,case 3. </p> <p>Here's my code.</p> <p>Some of the code is in spanish, however it's not relevant to know how the code is working. In advance thanks for your help and patience, I know this is quite dumb, but I've tried several methods and haven't been able to either solve or understand the problem</p> <pre><code>#include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; #include &lt;math.h&gt; void menu1(); void menuLR(); void DistDosPuntos(); void menu1() { int a; float m,x1,x2,y1,y2,k,v,d; printf("MENU PRINCIPAL\n"); printf("1.- La línea Recta \n"); printf("2.- La circunferencia \n"); printf("3.- Coordenaas Polares \n"); printf("4.- Salir\n"); scanf("%d",&amp;a); switch(a) { case 1: menuLR(&amp;m,&amp;x1,&amp;x2,&amp;y1,&amp;y2,&amp;k,&amp;v,&amp;d); break; case 2 : // ; break; case 3 : //; break; case 4 : break ; } } void menuLR (float *m,float*x1,float *x2,float *y1,float*y2,float*k,float *v,float *d) { int b; printf("LA LINEA RECTA\n"); printf("1.- Ecuación de la recta dada su puendiente y un punto de la misma \n"); printf("2.- Ecuación de la recta que pasa por dos puntos\n"); printf("3.- Distancia entre dos puntos del plano \n"); printf("4.- Punto medio entre dos puntos del plano\n"); printf("5.- Perímetro y área de un triángulo en un plano\n"); printf("6.- Regresar al menú principal\n"); scanf("%d",&amp;b); switch (b) { case 1 : printf("Introduzca la pendiente de la recta m y el punto P1(x1,y1)\n"); printf("Introduzca m\n"); scanf("%f",m); printf("Introduzca x1\n"); scanf("%f",x1); printf("Introduzca y1\n"); scanf("%f",y1); printf("La ecuación de la recta es:\n"); printf("y-y1 = m(x-x1)\n"); printf("Sustituyendo valores:\n"); printf("y-%f = %f (x-%f) \n" ,*y1,*m,*x1); printf("Desarrollando y despejando:\n"); *k = ((*m)*(*x1)); printf("y-%f = %fx-%f)\n",*y1,*m,*k); *v= -*k+*y1; printf("y=%fx+(%f)\n",*m,*v); printf("La ecuación de la recta en la forma general 'y=mx+b' es:\n"); printf("y=%fx+(%f)\n",*m,*v); break; case 2 : break; case 3 : printf("Introduzca el punto en el plano P1(X1,Y1)\n"); printf("x1:"); scanf("%f",x1); printf("y1:"); scanf("%f",y1); printf("Introduzca el punto en el plano P2(X2,Y2)\n"); printf("X2:\n"); scanf("%f",x2); printf("Y2:\n"); scanf("%f",y2); DistDosPuntos(&amp;x1,&amp;x2,&amp;y1,&amp;y2,&amp;d); printf("La distancia entre los puntos P1 y P2 es:\n %f",*d); break; case 4 : // exit ; break ; } } void DistDosPuntos(float *x1,float *x2, float *y1, float *y2,float *d) { *d = sqrt(pow((*x2-*x1),2) + pow((*y2-*y1),2)); } int main() { int a,b; float m,x1,y1,k,v,d,y2,x2; menu1(&amp;b,&amp;x1,&amp;y1,&amp;x2,&amp;y2,&amp;m,&amp;k,&amp;v,&amp;d); DistDosPuntos(&amp;x1,&amp;x2,&amp;y1,&amp;y2,&amp;d); return 0; } </code></pre>
<c><pointers>
2016-05-18 07:10:26
LQ_CLOSE
37,292,676
what is the last parameter in getInt() method in SharedPerference Android
<p>What is meant by "-1" in last line of this SharedPreference program ?</p> <pre><code>SharedPreferences sp = getSharedPreferences("your_prefs", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); editor.putInt("your_int_key", yourIntValue); editor.commit(); SharedPreferences sp = getSharedPreferences("your_prefs", Activity.MODE_PRIVATE); int myIntValue = sp.getInt("your_int_key", -1); </code></pre>
<java><android><sharedpreferences><android-sharedpreferences>
2016-05-18 07:16:40
LQ_CLOSE
37,296,286
why else if not working here ?
> When i will getIntent name for particular place my map will focus on that place but its working for only one place why is it so ? here is my code if(restaurant_name != null ) { if (restaurant_name.equals("Fun N Food")) { mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(26.89209, 75.82759), 15.0f)); mMap.addMarker(new MarkerOptions() .position(new LatLng(26.89209, 75.82759)) .title("FUN N FOOD")) .showInfoWindow(); } else if (restaurant_name.equals("Hoagies")) { mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(26.89515, 75.83052), 15.0f)); mMap.addMarker(new MarkerOptions() .position(new LatLng(26.89515, 75.83052)) .title("HOAGIES")) .showInfoWindow(); } else if (restaurant_name.equals("Ping Pang")) { mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(26.89568, 75.83060), 15.0f)); mMap.addMarker(new MarkerOptions() .position(new LatLng(26.89568, 75.83060)) .title("PING PANG")) .showInfoWindow(); } > Here only Fun n Food is working .. why all other two is not working what am doing wrong ? i try switch case also but in that non of one is working plz help me
<java><android><if-statement>
2016-05-18 10:01:29
LQ_EDIT
37,297,525
Read parameters from file both to C and Python scripts
<p>I am new to C programming, and I am trying to have one parameters file that will be accessed by Python script and C script, so I would have to define the parameters in both scripts every run. For example, in C I have:</p> <pre><code>doublereal N,DB,DW,PP; N = 15; DB = 1.2; DW = 150; PP = 90; </code></pre> <p>In Python I save the parameters in a dictionary</p> <pre><code>pars = {'N':15.0,'DB':1.2,'DW':150.0,'PP':90.0} </code></pre> <p>What is the best way to structure a file from which I will read those values both into Python and C scripts?</p>
<python><c><dictionary>
2016-05-18 10:56:03
LQ_CLOSE
37,297,775
preq_replace href value only if there string x is not found in it
i have a problem with the following situation i want to replace the href value with preg_replace and dont know how i got 3 types of links 1:<a href="http://www.something.com"></a> 2:<a href="smartlink:webview-something"></a> 3:<a href="link/to/something"></a> i want to add the domain on link 3 (http://www.something.com/link/to/something) but 1 and 2 should stay untouched. how can i do that? kind regards martin
<php><regex>
2016-05-18 11:06:53
LQ_EDIT
37,298,980
missing logout page in view/users in cakephp
i am working on cakephp and while clicking on logout button url goes to some other address http://demo4sbc.com.Because there is no logout.ctp present in view/users, so can any one can tell me the coding for logout.ctp page.
<cakephp><model-view-controller>
2016-05-18 12:00:54
LQ_EDIT
37,302,618
How do I insert one value into one column?
<p>I need to get a value from a field on front end application that is connected to the DB. The thing is I would like to insert the single value entered into One column in a table that has multiple columns.</p>
<sql><sql-server><tsql>
2016-05-18 14:30:43
LQ_CLOSE
37,303,003
How to add a string to array in a simple way - C++
<p>So I have this problem my teacher gave me which is: Enter the names and salaries of 5 employees into two arrays and print the name of the employee who has the highest salary.</p> <p>Im not sure how to input a string to an array and link it to the other array, this is what I wrote:</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; using namespace std; int main() { int salary, x, y; string name; int Arr1[5]; int Arr2[5]; x = 0; y = 0; for (int i = 0; i &lt;= 5; i++) { cin &gt;&gt; Arr1[name]; cin &gt;&gt; Arr2[x]; if (x &gt; y) { x = y; } } cout &lt;&lt; "Employee" &lt;&lt; Arr1[name]&lt;&lt; "has the biggest salary of:" &lt;&lt; y &lt;&lt; endl; return 0; } </code></pre>
<c++><arrays>
2016-05-18 14:44:51
LQ_CLOSE
37,303,280
how to compare dictionary values in python
Can someone tell me how can i compare all values to each other on the same dictionary please? Ex: dictionary whitch contains lot of sequences (sequence=key) whitch correspond to a lot of amino acide seuquences (dna translation, trans = value) dic_trans[sequence]=trans Thanks
<python>
2016-05-18 14:56:08
LQ_EDIT
37,305,784
Shell script to compare file names(without extension) in a directory
<p>My requirement is I will have xml and pdf files like pairs.(e.g.,file1.xml, file1.pdf and file2.xml,file2.pdf) in same folder.</p> <p>I need to check for xml files which are not having pdf pair and move them to different folder.(e.g., if file3.xml doesn't have file3.pdf, I need to move it to different folder).</p> <p>Please answer me the shell script to do get this functionality done.</p>
<linux><shell>
2016-05-18 16:53:35
LQ_CLOSE
37,310,151
How to subtract multiple string values from another string
<p>With:</p> <pre><code>abc = 'abc' xyz = 'xyz' word = 'begin abc- middle_xyz_ end' </code></pre> <p>I need to extract the values of <code>abc</code> and <code>xyz</code> from <code>word</code>. The result should be </p> <pre><code>result = 'begin - middle__ end' </code></pre> <p>How to achieve this with a minimum amount of code?</p>
<python>
2016-05-18 21:09:51
LQ_CLOSE
37,310,280
Force Matlab to run a deep learning code on CPU instead of GPU
I don't have CUDA-enabled NVIDIA GPU and I want to force matlab to run the code on CPU instead of GPU (yes I know, it will be very very slow). How can I do it? As an example, lets try to run [this code][1]. Here is the error given by Matlab: There is a problem with the CUDA driver or with this GPU device. Be sure that you have a supported GPU and that the latest driver is installed. Error in nnet.internal.cnn.SeriesNetwork/activations (line 48) output = gpuArray(data); Error in SeriesNetwork/activations (line 269) YChannelFormat = predictNetwork.activations(X, layerID); Error in DeepLearningImageClassificationExample (line 262) trainingFeatures = activations(convnet, trainingSet, featureLayer, ... Caused by: The CUDA driver could not be loaded. The library name used was 'nvcuda.dll'. The error was: The specified module could not be found. [1]: http://it.mathworks.com/help/vision/examples/image-category-classification-using-deep-learning.html
<matlab><compilation><deep-learning>
2016-05-18 21:19:10
LQ_EDIT
37,310,361
How to add a URL to download a file in java
<p>I want to add a URL into my java program: <a href="http://www.markit.com/news/InterestRates_JPY_20160426.zip" rel="nofollow">http://www.markit.com/news/InterestRates_JPY_20160426.zip</a>; so basically when you open this link a zip file is downloaded. How do I do that?</p> <p>And then, I want to unzip the downloaded file in the java program as well.</p> <p>How do I do these in java?</p>
<java><url><zip>
2016-05-18 21:26:00
LQ_CLOSE
37,310,978
Is there a better hands-on, concrete way to learn Javascript?
<p>I have started several Javascript books and read about variables, loops, arrays, all of the intro material. I still find it difficult to grasp. I am doing a course on FreeCodeCamp which is very confusing and unclear, and I think the reason why it's so unclear to me is because of the way it's being presented: the same way I've seen on CodeAcademy and in textbooks.</p> <p>For example, I learned HTML and CSS by building websites. Does anyone know of a way I can learn Javascript by building stuff, and learning how each piece of code can function in a real-life setting?</p> <p>I see examples where we create arrays of lists of names and correspond them with ages and maybe genders. But how would I be using arrays in order to build something? What would be the type of thing I could build with that kind of information?</p> <p>Sorry if this question is confusing, but I am a beginner and hoping that there is a way I'll be able to learn. I just keep hitting walls where it's like Greek to me.</p>
<javascript>
2016-05-18 22:15:23
LQ_CLOSE
37,311,147
compiler throws error "is_enum not declared in this scope" among others wxwidgets
the g++ compiler throws the error when i compile. I am using code::blocks for this. the exact error is: C:\wx\include\wx\strvararg.h|350|error: 'is_enum' in namespace 'std' does not name a template type| C:\wx\include\wx\strvararg.h|354|error: 'is_enum' was not declared in this scope| C:\wx\include\wx\strvararg.h|354|error: template argument 1 is invalid| the build is a non-monolithic dll build. thanks for any help!
<c++><compiler-errors><codeblocks><wxwidgets>
2016-05-18 22:31:02
LQ_EDIT
37,312,056
Visual studio code comment in HTML files
<p>I am trying Visual Studio Code lately and i've noticed that when i try to add a line comment in an HTML file (using Ctrl+/ or Ctrl+K Ctrl+C) instead of this: <code>&lt;!-- --&gt;</code>, i get this <code>{# #}</code>.</p> <p>In JS or CSS files the key bindings work just fine and produce the expected result.</p> <p>So how can i get the proper type of comments in HTML files?</p>
<html><comments><visual-studio-code><key-bindings><code-editor>
2016-05-19 00:21:52
HQ
37,312,334
Error on Vagrant Up on Linux
<p>I try to run vagrant on my Ubuntu 14.04. So for, I did these steps:</p> <p>-Install vagrant -Install virtualbox -added box for provider</p> <p>then I run the </p> <blockquote> <p>vagrant up</p> </blockquote> <p>command.</p> <p>After running the command, I take these output and at the and there is an error message which I cannot figure out how can I solve and run it correctly.</p> <blockquote> <p>Bringing machine 'default' up with 'virtualbox' provider...</p> <p>==> default: Checking if box 'udacity/ud381' is up to date...</p> <p>==> default: Clearing any previously set forwarded ports...</p> <p>==> default: Clearing any previously set network interfaces...</p> <p>==> default: Preparing network interfaces based on configuration...</p> <pre><code>default: Adapter 1: nat </code></pre> <p>==> default: Forwarding ports...</p> <pre><code>default: 5000 (guest) =&gt; 5000 (host) (adapter 1) default: 22 (guest) =&gt; 2222 (host) (adapter 1) </code></pre> <p>==> default: Booting VM... There was an error while executing <code>VBoxManage</code>, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.</p> <p>Command: ["startvm", "0399f946-6a87-4310-a22d-c1a4525ae2f0", "--type", "headless"]</p> <p>Stderr: VBoxManage: error: The virtual machine 'ud381_default_1463617458900_49294' has terminated unexpectedly during startup with exit code 1 (0x1) VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine</p> </blockquote> <p>What should I do to fix these error ? </p>
<linux><vagrant><virtualbox>
2016-05-19 01:05:13
HQ
37,312,501
How do I detect and connect to a hidden SSID on my Raspiberry Pi 3 (Raspbian)?
<p>How do I configure my Raspberry Pi 3 (running Raspbian) to connect to a hidden network? I know it involves editing the /etc/network/interfaces file and the wpa_supplicant.conf file. I've followed a few other guides, but when I make these file changes and reboot, I can't even detect visible networks, as they disappear from my wifi menu. I think I'm just editing these files with incorrect configurations. </p>
<raspberry-pi><wifi><hidden><ssid><raspberry-pi3>
2016-05-19 01:26:31
HQ
37,312,678
How to make an .exe generated by Visual Studio 2013 run in other computers?
<p>Greetings to everyone in this forum.</p> <p>I just finished my mid-term project in Visual Studio 2013 for collegue and my professor want us to give him the .exe of the project. The problem is that it only works in my computer. When I try to open the .exe in other computers, this error shows up:</p> <ul> <li>The program can't start because MSVCP120.dll is missing from your computer. Try reinstalling the program to fix this problem. </li> </ul> <p>I was wondering if there is any way to fix this problem, so that the .exe can work in any computer that run Windows.</p> <p>I really appreciate any help you can provide.</p>
<c++><visual-studio-2013>
2016-05-19 01:50:57
LQ_CLOSE
37,312,957
How can I delete multiple files from a directory specified by a multi-selected listbox in C# WPF?
<p>I have a directory that contains multiple text files. The name of each text file is also the same as the first line in the text file, which is the same name that it used to populate the text content of each listbox item. ex. I have files "a", "b", and "c". My list box will contain the items "a", "b", and "c". I have my list box set to an extended selection so the user can select multiple files. I want the user the be able to delete selected files. This is my current broken code:</p> <pre><code>private void btnDeleteSelection_Click(object sender, RoutedEventArgs e) { var selectedFiles = lstSavedSites.SelectedItems; string selectedFile; try { foreach (var file in selectedFiles) { selectedFile = lstSavedSites.SelectedItem.ToString(); File.Delete("@C:/myFolderName/anotherFolderName/" + selectedFile); } PopulateListBox(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } </code></pre> <p>The ex.Message says "The given path's format is not supported."</p>
<c#><wpf>
2016-05-19 02:26:39
LQ_CLOSE
37,313,735
Unable to list target platforms. Please make sure the android sdk path is correct
<p>I am trying to build old unity version(v_4.6.3) project. but i have got a error. already i have got successful result, but current my sdk is updated with latest version.</p> <p><a href="http://screencast.com/t/u7lNiyoc" rel="noreferrer">http://screencast.com/t/u7lNiyoc</a></p> <p>Here is my unity error log.</p> <blockquote> <pre><code>Error building Player: CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct. See the Console for more details. C:\Program Files\Java\jdk1.8.0_66\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="E:/Temp/sdk\tools" -Dfile.encoding=UTF8 -jar "C:/Program Files (x86)/Unity/Editor/Data/BuildTargetTools/AndroidPlayer\sdktools.jar" - stderr[ Exception in thread "main" java.lang.NoClassDefFoundError: com/android/utils/ILogger at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at SDKMain.main(SDKMain.java:128) Caused by: java.lang.ClassNotFoundException: com.android.utils.ILogger at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 3 more ] stdout[ ] </code></pre> </blockquote> <p>How can i fix this issues. Thank you for advances. Kind Regards.</p>
<java><android><unity3d>
2016-05-19 03:58:54
HQ
37,314,598
In Express.js why does code after res.json() still execute?
<p>In Node with Express, I have a piece of code like this. </p> <pre><code> if (req.body.var1 &gt;= req.body.var2){ res.json({success: false, message: "End time must be AFTER start time"}); console.log('Hi') } console.log('Hi2') //other codes </code></pre> <p>I expected that if var1 is >= var2, the response would be sent and the execution would end. Like return statements in Java/C#</p> <p>But appearantly that's not the case. After the response is sent, both 'Hi' and 'Hi2' and all the other code after that continues to get executed.</p> <p>I was wondering how I would stop this from happening? </p> <p>Also, I was wondering under what circumstances would you actually want code to keep on executing after a response has already been sent.</p> <p>Cheers</p>
<javascript><json><node.js><express><httpresponse>
2016-05-19 05:31:37
HQ
37,314,738
How to resize image in angular 2 before uploading it to server?
<p>I want to resize image with size of 74 x 74, I am using ng2-uploader directive to upload image. If there is any other directive I can use to achieve my requirement please suggest me. Thanks</p>
<angular>
2016-05-19 05:42:51
HQ
37,315,180
Change log level in unittest
<p>I have the impression (but do not find the documentation for it) that unittest sets the logging level to <code>WARNING</code> <em>for all loggers</em>. I would like to:</p> <ul> <li>be able to specify the logging level for all loggers, from the command line (when running the tests) or from the test module itself</li> <li>avoid unittest messing around with the application logging level: when running the tests I want to have the same logging output (same levels) as when running the application</li> </ul> <p>How can I achieve this?</p>
<python><logging><python-unittest>
2016-05-19 06:13:29
HQ
37,315,317
What is the difference between @Inject and @Injectable in Angular 2 typescript
<p>I don't understand When to use @Inject and when to use @Injectable ?</p> <pre><code> import {Component, Inject, provide} from '@angular/core'; import {Hamburger} from '../services/hamburger'; export class App { bunType: string; constructor(@Inject(Hamburger) h) { this.bunType = h.bun.type; } } </code></pre> <p>And..</p> <pre><code> import {Injectable} from '@angular/core'; import {Bun} from './bun'; @Injectable() export class Hamburger { constructor(public bun: Bun) { } } </code></pre>
<dependency-injection><typescript><angular><injectable>
2016-05-19 06:22:11
HQ
37,316,156
How to debounce user input in reactjs using rxjs
<p>My problem may be a trivial one but I wasn't able to find the answer so far. </p> <p>How can I defer (debounce) updating state in React while user is typing, to avoid unnecessary updates?</p> <p>Having <code>&lt;input onChange={this.onChange} .../&gt;</code>, how can I bind onChange event with rxjs? Should I try to make this input observable or should I use FromEventPattern?</p> <p>In both cases I have no idea how to bind React events with rxjs. The second question is whether the user will see any input changes during debounce?</p>
<reactjs><rxjs>
2016-05-19 07:05:42
HQ
37,316,177
Distribute a Python package with a compiled dynamic shared library
<p>How do I package a Python module together with a precompiled <code>.so</code> library? Specifically, how do I write <code>setup.py</code> so that when I do this in Python</p> <pre><code>&gt;&gt;&gt; import top_secret_wrapper </code></pre> <p>It can easily find <code>top_secret.so</code> without having to set <code>LD_LIBRARY_PATH</code>?</p> <p>In my module development environment, I have the following file structure:</p> <pre><code>. ├── top_secret_wrapper │   ├── top_secret.so │   └── __init__.py └── setup.py </code></pre> <p>Inside <code>__init__.py</code>, I have something like:</p> <pre><code>import top_secret </code></pre> <p>Here's my <code>setup.py</code></p> <pre><code>from setuptools import setup, Extension setup( name = 'top_secret_wrapper', version = '0.1', description = 'A Python wrapper for a top secret algorithm', url = None, author = 'James Bond', author_email = 'James.Bond.007@mi6.org', license = 'Spy Game License', zip_safe = True, ) </code></pre> <p>I'm sure my <code>setup.py</code> is lacking a setting where I specify the location of <code>top_secret.so</code>, though I'm not sure how to do that.</p>
<python><package><setuptools><distutils>
2016-05-19 07:06:39
HQ
37,316,181
javascript - lodash - create a unique list based on multiple attributes
<p>My collection looks like this. </p> <pre><code> var list = [{id:'12345', sequence:null}, {id:'12346', sequence:null}, {id:'12347', sequence:null}, {id:'12348', sequence:1}, {id:'12348', sequence:2}, {id:'12349', sequence:1}, {id:'12349', sequence:1}]; </code></pre> <p>I am trying to get a unique list so that object with same id AND sequence will only return one of the objects (we have 2 here- {id:'12349', sequence:1})</p> <p>my code</p> <pre><code> var uniqueList = _.uniq(list, function(obj) { return obj.id &amp;&amp; obj.sequence; }); </code></pre> <p>can we use lodash uniq like this? what is the approach to fix this issue?</p>
<javascript><underscore.js><unique><lodash>
2016-05-19 07:06:44
HQ
37,317,498
Changing Azure Resource Group location
<p>I have a setup in azure with a bunch of resources combined in a resource group. I want my services to be located in west-europe, so all my resources are there (where possible)</p> <p>I just noticed that when creating the resource group, i accidentally used West US.</p> <p>So the current setup is:</p> <p>Resource Group 1 (West US)</p> <ul> <li>App Service 1 (West Europe)</li> <li>App Service 2 (West Europe)</li> <li>SQL Server (West Europe)</li> <li>Storage account (West Europe)</li> <li>... (West Europe)</li> </ul> <p>Can I change the location of the resource group without having to create a new one and migrate everyting?</p> <p>And maybe more importantly: Should i change the location or does it not impact anything?</p> <p>Thanks!</p>
<azure><azure-sql-database><azure-storage><azure-web-sites><azure-resource-manager>
2016-05-19 08:12:55
HQ
37,317,594
What is the equivalent of 'head :ok' from Rails in Phoenix?
<p>I want to return a response that has no content (merely headers) like <a href="http://apidock.com/rails/ActionController/Head/head" rel="noreferrer">this one</a></p> <pre><code>def show head :ok end </code></pre>
<ruby-on-rails><elixir><phoenix-framework>
2016-05-19 08:16:36
HQ
37,317,705
What is the difference between annotation and decorator?
<p>I am confused when to use term annotation and when to use decorator ? </p> <pre><code> @Component({ selector: 'tabs', template: ` ` }) export class Tabs { } </code></pre>
<typescript><angular>
2016-05-19 08:21:32
HQ
37,317,727
Deprecated rolling window option in OLS from Pandas to Statsmodels
<p>as the title suggests, where has the rolling function option in the ols command in Pandas migrated to in statsmodels? I can't seem to find it. Pandas tells me doom is in the works:</p> <pre><code>FutureWarning: The pandas.stats.ols module is deprecated and will be removed in a future version. We refer to external packages like statsmodels, see some examples here: http://statsmodels.sourceforge.net/stable/regression.html model = pd.ols(y=series_1, x=mmmm, window=50) </code></pre> <p>in fact, if you do something like:</p> <pre><code>import statsmodels.api as sm model = sm.OLS(series_1, mmmm, window=50).fit() print(model.summary()) </code></pre> <p>you get results (window does not impair the running of the code) but you get only the parameters of the regression run on the entire period, not the series of parameters for each of the rolling period it should be supposed to work on.</p>
<python><pandas><deprecated><statsmodels>
2016-05-19 08:22:53
HQ
37,317,779
Making a unique extension id and key for Chrome extension?
<p>I have a Chrome extension I made, but based it on some example found online. Its not in a crx file. The extension ID is the one used in the example. I would like to change it before I upload my extension to the chrome store. My question is how do I change this? Do I just manually change the letters in my manifest.json file? Or does the extension id have to be generated from something because its in a fixed format? Same for the key, can I just randomly change these two before I do anything else now that I'm ready?</p> <pre><code>{ // Extension ID: rnldjzfmornpzlahmmmgbagdohdnhdic "key": "MIGfMA3GCSqGSIb3DFEBAQUAA4GNADCBiQKBgQDcBHwzDvyBQ6bDppkIs9MP4ksKqCMyXQ/A52JivHZKh4YO/9vJsT3oaZhSpDCE9RCocOEQvwsHsFReW2nUEc6OLLyoCFFxIb7KkLGsmfakkut/fFdNJYh0xOTbSN8YvLWcqph09XAY2Y/f0AL7vfO1cuCqtkMt8hFrBGWxDdf9CQIDAQAB", "name": "Name of extension", ... </code></pre>
<google-chrome-extension>
2016-05-19 08:25:28
HQ
37,318,351
Combine first and last name into full name c#
<p>So here is what I have </p> <pre><code> txtFull.Text = txtFirst.Text + “\n” + txtSecond.Text; </code></pre> <p>not sure why its not working</p>
<c#>
2016-05-19 08:53:07
LQ_CLOSE
37,318,707
Why do most frameworks use margin and not padding on p, h1, h2 etc.?
<p>Would there be any downside to use padding? Or why everyone seems to go with margin?</p>
<css><twitter-bootstrap><frameworks>
2016-05-19 09:08:43
LQ_CLOSE
37,319,236
Use new firebase sdk in android eclipse project
<p>new firebase with awesome features was just announced, but according to documentation (<a href="https://firebase.google.com/docs/android/setup#prerequisites" rel="noreferrer">https://firebase.google.com/docs/android/setup#prerequisites</a>) android studio (as well as gradle) is required now. For now in my cocos2d-x apps I have to use ADT/Eclipse to build apps, because gradle isn't supported yet (however cocos2d-x team is working on it). I'm now using an older version of the sdk, which is just a jar file. Is there a way to use new firebase in eclipse? What worries me the most is that plugin:</p> <pre><code>apply plugin: 'com.google.gms.google-services' </code></pre>
<android><eclipse><firebase><cocos2d-x><adt>
2016-05-19 09:32:39
HQ
37,319,367
Subtract Three dimention array from 2D
I have two data set,the first one is 3D and the second is 2D. how can we implement the subtract of the two array. the code bellow generate error : double[][] diff = new double[1][a.length]; for (int i = 0; i < a.length - 1; i++) { for ( int j=0; j<a[0].length; j++){ for ( int k=0; k<a[0][0].length; k++) { diff[0][i] = a[i][j][k]- b[i][j]; } } }
<java><arrays>
2016-05-19 09:38:48
LQ_EDIT
37,319,676
Using a Progress Bar while Seeding a database in Laravel
<p>I have to seed quite a lot of data into a database and I want to be able to show the user a progress bar while this happens. I know this is documented:</p> <ul> <li><a href="https://laravel.com/docs/master/artisan#registering-commands" rel="noreferrer">https://laravel.com/docs/master/artisan#registering-commands</a> (just above)</li> <li><a href="http://symfony.com/doc/2.7/components/console/helpers/progressbar.html" rel="noreferrer">http://symfony.com/doc/2.7/components/console/helpers/progressbar.html</a></li> </ul> <p>but I'm having problems including it in my seeder.</p> <pre><code>&lt;?php use Illuminate\Database\Seeder; class SubDivisionRangeSeeder extends Seeder { public function run() { $this-&gt;output-&gt;createProgressBar(10); for ($i = 0; $i &lt; 10; $i++) { sleep(1); $this-&gt;output-&gt;advance(); } $this-&gt;output-&gt;finish(); } } </code></pre> <p>or</p> <pre><code>&lt;?php use Illuminate\Database\Seeder; class SubDivisionRangeSeeder extends Seeder { public function run() { $this-&gt;output-&gt;progressStart(10); for ($i = 0; $i &lt; 10; $i++) { sleep(1); $this-&gt;output-&gt;progressAdvance(); } $this-&gt;output-&gt;progressFinish(); } } </code></pre> <p>from <a href="https://mattstauffer.co/blog/advanced-input-output-with-artisan-commands-tables-and-progress-bars-in-laravel-5.1" rel="noreferrer">https://mattstauffer.co/blog/advanced-input-output-with-artisan-commands-tables-and-progress-bars-in-laravel-5.1</a></p> <p>Any ideas?</p>
<php><symfony><laravel>
2016-05-19 09:51:28
HQ
37,319,734
Gradle build fail with Cannot run program No such file or directory
<p>I have a gradle build file with the following task which need to run <code>sphinx-build</code>, I'm running it on Mac OS X with the gradle information bellow.</p> <pre><code>task makeDocs(type:Exec) { workingDir 'sphinx' commandLine 'sphinx-build' args = ["-b", "html", "-d", "build/doctrees", "-t", "$platformDir", "build/ppsource", "build/html"] } </code></pre> <p>When I run this task I get the following exception:</p> <pre><code>Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'sphinx-build' at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27) at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36) at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:65) ... 1 more Caused by: java.io.IOException: Cannot run program "sphinx-build" (in directory "/Users/idoran/Documents/Seebo/dev/SDK/seebosdk_docs/sphinx"): error=2, No such file or directory at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25) ... 3 more Caused by: java.io.IOException: error=2, No such file or directory </code></pre> <p>When I run sphinx-build from the same terminal everything works fine.</p> <hr> <pre><code>$ gradle --version ------------------------------------------------------------ Gradle 2.2.1 ------------------------------------------------------------ Build time: 2014-11-24 09:45:35 UTC Build number: none Revision: 6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a Groovy: 2.3.6 Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013 JVM: 1.8.0_65 (Oracle Corporation 25.65-b01) OS: Mac OS X 10.10.5 x86_64 </code></pre>
<gradle>
2016-05-19 09:53:37
HQ
37,321,047
Wrap long template literal line to multiline without creating a new line in the string
<p>In es6 template literals, how can one wrap a long template literal to multiline without creating a new line in the string?</p> <p>For example, if you do this:</p> <pre><code>const text = `a very long string that just continues and continues and continues` </code></pre> <p>Then it will create a new line symbol to the string, as interpreting it to have a new line. How can one wrap the long template literal to multiple lines without creating the newline?</p>
<javascript><ecmascript-6><template-literals>
2016-05-19 10:51:27
HQ
37,321,159
i need to get 2 decimal points in gb
i need to get decimal points in gband if any tb size there how can I retrive below is my code :: Example batch file to show free disk space on C: @echo off cls echo. echo Free Space on C: echo ======================================== for /f "tokens=1-3" %%n in ('"WMIC LOGICALDISK GET Name,Size,FreeSpace | find /i "C:""') do set free=%%n& set total=%%p echo. rem echo %free% bytes free set free=%free:~0,-3% set /a free=%free%/1049 echo. rem echo %free% MB free (approx and underestimated) set /a free=%free%/1024 echo. echo %free% GB free pause > NUL
<batch-file>
2016-05-19 10:56:35
LQ_EDIT
37,321,860
Regex: take string between <tag> and \n or </tag>
<p>I can't figure out where I'm wrong.</p> <p>I have a pile of pages from where I need to get the content of the tags and make it a file name.</p> <p>My regex</p> <pre><code>title2 = re.search(r'(&lt;title&gt;)(.+)(&lt;/title&gt;)', content) filename_test = str(title2.group(2)+'.txt') </code></pre> <p>It works fine until it comes to a title like this:</p> <pre><code>&lt;title&gt;Klaatu - barada nikto &lt;/title&gt; </code></pre> <p>I've tried a lot of variants, none of them works.</p> <p>Main idea is that something like this should have worked:</p> <pre><code>title2 = re.search(r'(&lt;title&gt;)(.+)(\n|(&lt;/title&gt;))', content) </code></pre> <p>i.e. "stop when you come to new line <strong>or</strong> this tag" But it doesn't.</p>
<python><regex>
2016-05-19 11:29:17
LQ_CLOSE
37,322,238
Loop between two large numbers in few minutes
<p>I want to loop from <code>0.900000000000000000000000000000</code> to <code>0.999999999999999999999999999999</code> (<strong>30 digit after decimal</strong>) with step of <code>0.000000000000000000000000000001</code> . I used for loop and it takes hours of time. Can it be done in few minutes ? </p>
<java>
2016-05-19 11:45:49
LQ_CLOSE
37,322,451
Difference between Admob Ads and Firebase Ads
<p>I'm trying to migrate from Google analytics to the new Firebase analytics but I noticed there are libraries for ads too. Are firebase ads going to replace admob ads as well? Should I keep using admob via google play services? Or make a switch to the Firebase SDK? What's the difference anyways?</p>
<android><firebase><admob>
2016-05-19 11:54:48
HQ
37,322,550
Private messages in Symfony2
<p>I use Symfony 2.8 There are website on it where users can register. I need to add the possibility of private messages between users. Is there a plugin that will do this?</p>
<php><symfony><plugins>
2016-05-19 11:58:36
LQ_CLOSE
37,323,003
sas loigc operators not evaluating correctly
I have a condition which follows this logic Av(B^C) which is equivalent to (AvB) ^ (BvC). Where: A = NAF> 2 B= (COUNT_INT + COUNT_NOINT < 25) C= (NAF> 1) This is the condition given in the specs: NAF> 2 OR (( COUNT_INT + COUNT_NOINT < 25) AND (NAF> 1)) This is how I coded it in sas, but its not producing the correct results. I appreciate any suggestions. Thanks. if (((naf gt 2 or sum(count_int,count_nonint) lt 25)) and (naf gt 2 or naf gt 1)) then check_naf = "bad";
<sas><conditional><logical-operators>
2016-05-19 12:18:47
LQ_EDIT
37,324,332
How to find the nearest neighbors for latitude and longitude point on python?
<p><strong>Input:</strong></p> <pre><code>point = (lat, long) places = [(lat1, long1), (lat2, long2), ..., (latN, longN)] count = L </code></pre> <p><strong>Output:</strong> <code>neighbors</code> = subset of <code>places</code> close to the <code>point</code>. (<code>len(neighbors)=L</code>)</p> <p><strong>Question:</strong> Can I use kd-tree for quick nearest-neighbor<strong>s</strong> lookup for points with latitude and longitude? (For example, implementation in <em>scipy</em>)</p> <p>Is it necessary to transform the geographical coordinates (latitude and longitude) of the point in the coordinates x,y?</p> <p>Is it the best way to solve this?</p>
<python><geolocation><scipy><nearest-neighbor><kdtree>
2016-05-19 13:14:18
HQ
37,324,429
$_POST open in new edited tab
<pre><code> &lt;form method="post" target="_blank" action="battle.php" onsubmit="window.open('battle.php','','width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=0,resizable=0,left=30,top=0');" &gt; &lt;input type="hidden" name="username" value="&lt;?php echo $username; ?&gt;"/&gt; &lt;input type="hidden" name="password" value="&lt;?php echo $password; ?&gt;"/&gt; &lt;input type="submit" value="OPEN TO BATTLE.php"/&gt; &lt;/form&gt; </code></pre> <p>^^Working but not the way I want it.</p> <p>I am trying to make this form open a new window at the size <code>'width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=0,resizable=0,left=30,top=0'</code>when the Submit button is clicked.</p> <p>I want it so that the $_POST data is transfered through to the new webpage</p>
<javascript><php><html><css>
2016-05-19 13:19:07
LQ_CLOSE
37,324,917
New warning when building android app with gradle
<p>Yesterday it was fine, today it shows this warning when I clean or build the project:</p> <blockquote> <p>WARNING: Ignoring Android API artifact com.google.android:android:2.1_r1 for appDebug WARNING: Ignoring Android API artifact com.google.android:android:2.1_r1 for appRelease</p> </blockquote> <p>I think it was caused by an update of the gradle plugin for android.</p> <p>Anyone knows what it means ?</p>
<android><android-gradle-plugin>
2016-05-19 13:37:13
HQ
37,325,871
Firebase Analytics for web apps (after Firebase expansion)
<p>I am building a web application with Firebase and yesterday they released their expansion with all great new features. However, the Analytics section is now only available for Android and IOS apps, but I need to check the general performances and data usage of my web app as before. Is there a way to see those statistics, to prevent my app of being turned off if I exceed my limits? </p>
<javascript><angularjs><firebase><firebase-realtime-database>
2016-05-19 14:12:10
HQ
37,326,068
ASP.NET Core RC2 Area not published
<p>So I just updated my app to use ASP.NET Core RC2. I published it using Visual Studio and noticed that my Area is not published:</p> <p>This snapshot is from <code>src\MyProject\bin\Release\PublishOutput</code>:</p> <p><a href="https://i.stack.imgur.com/FjpgY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FjpgY.png" alt="enter image description here"></a></p> <p>And here is my Area, named <code>Admin</code> in Visual Studio:</p> <p><a href="https://i.stack.imgur.com/VGvdF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VGvdF.png" alt="enter image description here"></a></p> <p>Am I missing an step or what?</p>
<c#><asp.net-core><asp.net-mvc-areas><.net-core-rc2>
2016-05-19 14:20:04
HQ
37,326,843
How to get PHP variable from another php file
I have functions.php while ($row_posts = mysqli_fetch_array($run_news)) { $news_id = $row_posts['news_id']; $user_id = $row_posts['user_id']; $topic_id = $row_posts['topic_id']; $news_title = $row_posts['news_title']; $news_date = $row_posts['news_date']; // getting the user who has posted the thread $user = "select * from users where user_id ='$user_id' AND posts = 'yes'"; $run_user = mysqli_query($con, $user); $row_user = mysqli_fetch_array($run_user); $user_name = $row_user['user_name']; $user_image = $row_user['user_image']; And another file showmap.php where I want $string to be dynamically come from user $string = 'Massive fire underneath Metro-North tracks in MODEL TOWN disrupts train service.'; $lower_string= strtolower($string);
<php>
2016-05-19 14:50:11
LQ_EDIT
37,327,137
Is it possible to have a popup when clicing on the menu with angularJs?
I actually have this menu and i want to add a popup authentification when clicing on the "Dashboard" word... is it possible? Here is the code of the index page and i don't know what to change...`<div ng-include="'views/templates/custom-styles.html'"></div> <ng-include src="'views/layout/header.html'"></ng-include> <nav id="headernav" class="navbar ng-hide" role="navigation" ng-show="getLayoutOption('layoutHorizontal') && !layoutLoading"> <div class="nav"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"> <i class="fa fa-reorder"></i> </button> </div> <div class="collapse navbar-collapse navbar-ex1-collapse" ng-class="{'large-icons-nav': getLayoutOption('layoutHorizontalLargeIcons')}" id="horizontal-navbar"> <ul ng-controller="NavigationController" id="top-nav" class="nav navbar-nav"> <li ng-repeat="item in menu" ng-if="!item.hideOnHorizontal" ng-class="{ hasChild: (item.children!==undefined), active: item.selected, open: (item.children!==undefined) && item.open, 'nav-separator': item.separator==true }" ng-include="'templates/nav_renderer_horizontal.html'" ></li> </ul> </div> </nav> <div id="wrapper"> <div id="layout-static"> <div class="static-sidebar-wrapper" ng-show="!layoutLoading"> <nav class="static-sidebar" role="navigation"> <ul ng-controller="NavigationController" id="sidebar" sticky-scroll="50"> <li id="search" ng-cloak> <a href=""> <i class="fa fa-binoculars opacity-control"></i> </a> <form ng-click="$event.stopPropagation()" ng-submit="goToSearch()"> <input type="text" ng-model="searchQuery" class="search-query" placeholder="Type to filter..." /> <button type="submit" ng-click="goToSearch()"><i class="fa fa-binoculars"></i></button> </form> </li> <li ng-repeat="item in menu" ng-class="{ hasChild: (item.children!==undefined), active: item.selected, open: (item.children!==undefined) && item.open, 'nav-separator': item.separator==true, 'search-focus': (searchQuery.length>0 && item.selected) }" ng-show="!(searchQuery.length && !item.selected)" ng-include="'templates/nav_renderer.html'" ></li> </ul> </nav> <!-- #sidebar--> </div> <div class="static-content-wrapper"> <div class="static-content"> <div id="wrap" ng-view="" class="mainview-animation animated"> </div> <!--wrap --> </div> <footer role="contentinfo" ng-show="!layoutLoading" ng-cloak> <div class="clearfix"> <ul class="list-unstyled list-inline pull-left"> <li></li> </ul> <button class="pull-right btn btn-default btn-sm hidden-print" back-to-top style="padding: 1px 10px;"><i class="fa fa-angle-up"></i></button> </div> </footer> </div> </div> </div> ` [HERE IS A PICTURE] [HERE IS A PICTURE]: http://i.stack.imgur.com/aQelz.png
<javascript><html><css><angularjs><angular-ui-bootstrap>
2016-05-19 15:02:03
LQ_EDIT
37,327,389
Python For loop repeats second loop
<p>I have 2 files (a.txt and shell.txt)</p> <p>in a.txt there are 59 lines and I've extracted their domains with the regex</p> <p>in shell.txt there are 5881 lines.</p> <p>The domains from a.txt exists in shell.txt and I want to extract the entire line of shell.txt if the domain of a.txt exists in shell.txt</p> <p>Unfortunately my loops are not working right so I would like to get some help from you guys.</p> <p>Thanks.</p> <pre><code>import re s1 = open('a.txt', 'r').read().splitlines() s2 = open('shell.txt', 'r').read().splitlines() for x in s1: c1 = re.findall("\/\/(.*)\/",x.split("|")[0])[0] for x2 in s2: c2 = re.findall("\/\/(.*)\/",x2.split("|")[2]) if c1 == c2: print x2 </code></pre>
<python><regex><loops><for-loop>
2016-05-19 15:12:07
LQ_CLOSE
37,327,652
Add column to DataFrame in sparkR
<p>I would like to add a column filled with a character <code>N</code> in a DataFrame in SparkR. I would do it like that with non-SparkR code :</p> <pre><code>df$new_column &lt;- "N" </code></pre> <p>But with SparkR, I get the following error : </p> <pre><code>Error: class(value) == "Column" || is.null(value) is not TRUE </code></pre> <p>I've tried insane things to manage it, I was able to create a column using another (existing) one with <code>df &lt;- withColumn(df, "new_column", df$existing_column)</code>, but this simple thing, nope...</p> <p>Any help ?</p> <p>Thanks.</p>
<r><sparkr>
2016-05-19 15:22:39
HQ
37,328,023
List comprehensions in Jinja
<p>I have two lists:</p> <ol> <li>strainInfo, which contains a dictionary element called 'replicateID'</li> <li>selectedStrainInfo, which contains a dictionary element called 'replicateID'</li> </ol> <p>I'm looking to check if the replicateID of each of my strains is in a list of selected strains, in python it would be something like this:</p> <pre><code>for strain in strainInfo: if strain.replicateID in [selectedStrain.replicateID for selectedStrain in selectedStrainInfo] print('This strain is selected') </code></pre> <p>I'm getting the correct functionality in django, but I'm wondering if there's a way to simplify using a list comprehension:</p> <pre><code>{% for row in strainInfo %} {% for selectedStrain in selectedStrainsInfo %} {% if row.replicateID == selectedStrain.replicateID %} checked {% endif %} {% endfor %} {% endfor %} </code></pre>
<python><jinja2>
2016-05-19 15:38:33
HQ
37,328,810
php mail() function doesn't return anything
<p>I want to send mail with php mail() function from php code, this function return true but i don't receive any message I've sent is it some problem with my hMailServer in data folder it shows data like the mail was sent but I don't get nothing</p>
<php><email>
2016-05-19 16:14:51
LQ_CLOSE
37,329,561
How to list indexes created for table in postgres
<p>Could you tell me how to check what indexes are created for some table in postgresql ? </p>
<postgresql>
2016-05-19 16:53:10
HQ
37,329,708
can frontend-maven-plugin use node, npm already installed?
<p>I am new using maven and frontend-maven-plugin. I understand that we can add this code to pom.xml to run grunt for example:</p> <pre><code> &lt;plugin&gt; &lt;groupId&gt;com.github.eirslett&lt;/groupId&gt; &lt;artifactId&gt;frontend-maven-plugin&lt;/artifactId&gt; &lt;!-- NB! Set &lt;version&gt; to the latest released version of frontend-maven-plugin, like in README.md --&gt; &lt;version&gt;@project.version@&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;install node and npm&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;install-node-and-npm&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;nodeVersion&gt;v5.3.0&lt;/nodeVersion&gt; &lt;npmVersion&gt;3.3.12&lt;/npmVersion&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;npm install&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;npm&lt;/goal&gt; &lt;/goals&gt; &lt;!-- Optional configuration which provides for running any npm command --&gt; &lt;configuration&gt; &lt;arguments&gt;install&lt;/arguments&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;npm run build&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;npm&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;arguments&gt;run build&lt;/arguments&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;grunt build&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;grunt&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;arguments&gt;--no-color&lt;/arguments&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre> <p>I actually installed node and npm on my server for example: node is installed under /opt/app/trss/nodejs, npm under /opt/app/trss/nodejs/npm how can this pom.xml use the node,npm installed on my server? Thanks</p>
<javascript><node.js><maven><npm><gruntjs>
2016-05-19 17:00:37
HQ
37,330,574
[c#]Find dublicates in array
int[] array = { 10, 5, 10, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 11, 12, 12 }; for (int i = 0; i < array.Length; i++) { int count = 0; for (int j = 0; j < array.Length; j++) { if (array[i] == array[j]) { count = count + 1; } } Console.WriteLine(array[i] + " repeats " + count + " times"); } Console.ReadKey(); [Output][1] [1]: http://i.stack.imgur.com/vH1wi.jpg I don't want to use LINQ! My question is, how to print results only once. For example: 10 repeats 2 times 5 repeats 3 times 2 repeats 2 times ... Thanks.
<c#><arrays><find>
2016-05-19 17:47:57
LQ_EDIT
37,330,718
How install font-awesome via bower
<p>I have just installed font-awesome via bower:</p> <pre><code>bower install font-awesome --save </code></pre> <p>And it appears to not add the CSS at the bower build. How can I install it?</p>
<bower><font-awesome>
2016-05-19 17:54:42
HQ
37,331,059
I cannot find my mistake. It should bounce off the paddles and it should restart once it is gameover. Can someone find my mistakes?
So this is my entire code and what it does not do, but should definitely do is first bounce off when colliding with the paddles and second if it does not do so then once the game enters in gameover mode once a key is pressed it should restart the game. Now I've tried several things and nothing seems to work. Can someone please find a solution and try to explain what I did wrong? // variables for the ball int ball_width = 15, ball_height = 15; int ballX = width/2, ballY = height/2; // // variables for the paddles int paddle_width = 20, paddle_height = 150; int paddle1 = 60, paddle2; // // direction variables int directionX = 15, directionY = 15; // // variables for the score int scorecounter = 0; // //game states boolean playing = false, gameover = false, finalscore = false, score = true; void setup () { size (1900, 1300); // the field game is going to be 1900x1300 px big rectMode (CENTER); paddle2 = width - 60; } void draw () { background (0); // black background playing (); gameover (); finalscore(); } // void playing () { if (keyPressed) { playing = true; } if (!playing) { // playing = false fill(255); textSize(80); textAlign(CENTER); text("Press Space to Play", width/2, height/4); fill (255); ellipse (width/2, height/2, ball_width, ball_height); // this is the starting point of the ball fill (255, 10, 20); rect(paddle1, (height/2), paddle_width, paddle_height); // red pong fill (60, 255, 0); rect(paddle2, (height/2), paddle_width, paddle_height); // green pong } if (playing) { // playing = true score(); ballX = ballX + directionX; ballY = ballY + directionY; fill (255); ellipse (ballX, ballY, ball_width, ball_height); fill ( 255, 10, 20 ); rect(paddle1, mouseY, paddle_width, paddle_height); // red pong fill ( 60, 255, 0 ); rect(paddle2, mouseY, paddle_width, paddle_height); // green pong if ( ballY > height ) { directionY = -directionY; } // if the ball reaches the lower wall it will bounce off if ( ballY < 0 ) { directionY = -directionY; } // if the ball reaches the upper wall it will bounce off if ( ballX > width || ballX < 0 ) { gameover = true; } } if (ballX == paddle1 && ballY <= paddle_height) { directionX = -directionX; directionY = -directionY; } if (ballX == paddle2 && ballY <= paddle_height) { directionX = -directionX; directionY = -directionY; } } void gameover () { if (gameover) { background (0); } finalscore (); score = false; if (keyPressed) { playing = true; } } void score () { if (playing) { fill(255); textSize(45); textAlign(CENTER); text ( scorecounter, width/2, height/4); if (ballX == paddle1 && ballY <= paddle_height) { scorecounter = scorecounter + 10; } if (ballX == paddle2 && ballX <= paddle_height) { scorecounter = scorecounter + 10; } } if (!playing) { score = false; } } void finalscore () { if (gameover) { score = false; fill(255); textSize(45); textAlign(CENTER); text("Game Over. Press a key to play again.", width/2, height/4); fill(255); textSize(80); textAlign(CENTER); text("You scored " + scorecounter + " points", width/2, (height/4) * 3); if (keyPressed) { playing = playing; } } }
<processing>
2016-05-19 18:10:52
LQ_EDIT
37,331,332
How to integrate "Google Firebase Analytics" in ionic apps?
<p>In the official <a href="https://firebase.google.com/docs/android/setup">Firebase Integration Guide (Android)</a> and <a href="https://firebase.google.com/docs/ios/setup">Firebase Integration Guide (iOS)</a>, they have provided individual integration guidelines.</p> <p>Could you please tell me an ionic way I can integrate <code>Firebase Analytics</code> into ionic apps?</p> <p>I need to do this as AdMob made the <code>Firebase Analytics</code> as its recommendation analytics solution for mobile apps.</p> <p>Thank you in advance.</p>
<ionic-framework><firebase-analytics>
2016-05-19 18:26:53
HQ
37,331,756
Google Sheets API v4 - How to get the last row with value?
<p>How to get the last row with value in the new Google Sheets API v4 ?</p> <p>i use this to get a range from a sheet:</p> <pre><code>mService.spreadsheets().values().get("ID_SHEET", "Sheet1!A2:B50").execute(); </code></pre> <p>how to detect the last row with value in the sheet ?</p>
<android><google-sheets><google-drive-api><google-spreadsheet-api>
2016-05-19 18:49:47
HQ
37,332,152
MATLAB Error! In an assignment A(I) = B, the number of elements in B and I must be the same
I'm new to MATLAB but after some studies and practice I was able to get going and there is this particular model I'm trying to analyze and plot using MATLAB. Unfortunatley I got stuck on K2 as it brought up this error "***??? In an assignment A(I) = B, the number of elements in B and I must be the same.***" I ran the debugger and I found out that J4 alone was a vector while other variables were all scalar. Please guys how can I resolve this error to have my plot? Here is the code that I ran. h1 = 1*10^-6; h2 = (10:10:1500)*10^-6; a = 62.5*10^-6; b = a+h1; c = b+h2; alpha_1 = 0.55*10^-6; alpha_2 = 17.2*10^-6; alpha_3 = 14.2*10^-6; zeta = 6.3*10^-6; P11 = 0.121; P12 = 0.27; neff = 1.456; U1 = 0.17; U2 = 0.32; U3 = 0.31; E1 = 0.74*10^11; E2 = 1.08*10^11; E3 = 1.96*10^11; n = 1; while(n<=150) J1(n) = E2*(b^2-a^2)*(1-U1)-E1*a^2*(1-U2)-E1*b^2*(1+U2); J2(n) = 2*E1*b^2; J3(n) = E1*E2*(b^2-a^2)*(alpha_2 - alpha_1); J4(n) = 2*E3*(c(n)^2-b^2)*a^2; J5(n) = E2*(b^2-a^2)*(1-U3)*b^2+E2*(b^2-a^2)*(1+U3)*c(n)^2-E3*(c(n)^2-b^2)*(1+U2)*a^2-E3*(c(n)^2-b^2)*(1-U2)*b^2; J6(n) = E2*E3*(c(n)^2 - b^2)*(b^2-a^2)*(alpha_2-alpha_3); K1(n) = ((alpha_3-alpha_1)*E3*(c(n)^2-b^2)+(alpha_2-alpha_1)*E2*(b^2-a^2))/(E1*a^2+E2*(b^2-a^2)+E3*(c(n)^2-b^2)); K2(n) = (J2*J6-J3*J5)/(J2*J4-J1*J5); Sr(n) = (neff^2/2)*(P11+P12)*(((1-U1)*K2/E1)-U1*K1); Sz(n) = (1+P12)*(K1-(2*U2*K2/E1)); St(n) = alpha_1+zeta; Km(n) = St+Sz+Sr; n=n+1; end plot(h2,Km)
<matlab>
2016-05-19 19:12:09
LQ_EDIT
37,333,305
Ansible: create a user with sudo privileges
<p>I have taken over a Ubuntu 14.04 server. It has a user called "deployer" (used with capistrano), and as such, it needs sudo privileges. With this setup, I can log into the server and do stuff like:</p> <pre><code>workstation&gt; ssh deployer@myserver myserver&gt; sudo apt-get install git myserver&gt; exit workstation&gt; </code></pre> <p>I am trying to figure out how to use Ansible (version 2.0.2.0 and python 2.7.3) to create a user called "deployer" and be able to log into the server with that id and then so sudo-ish things like "apt-get install". My playbook looks like this:</p> <pre><code>--- - hosts: example become: yes tasks: - name: Update apt cache apt: update_cache: yes cache_valid_time: 3600 - group: name=sudo state=present - name: Add deployer user and add it to sudo user: name=deployer state=present createhome=yes become: yes become_method: "sudo" - name: Set up authorized keys for the deployer user authorized_key: user=deployer key="{{item}}" with_file: - /home/jaygodse/.ssh/id_rsa.pub </code></pre> <p>After running this playbook, I am able to ssh into the machine as "deployer", (e.g. ssh deployer@myserver) but if I run a sudo command, it always asks me for my sudo password. </p> <p>I understand that the "deployer" user ultimately has to find its way into the visudo users file, but I cannot figure out which magical Ansible incantations to invoke so that I can ssh into the machine as deployer and then run a sudo command (e.g. sudo apt-get install git") without being prompted for a sudo password. </p> <p>I have searched high and low, and I can't seem to find an Ansible playbook fragment which puts the user "deployer" into the sudo group without requiring a password. How is this done?</p>
<ansible-playbook><sudoers>
2016-05-19 20:22:46
HQ
37,333,586
Which is better Theano?
**I want to install Theano on my windows 8.1 x64 machine. I already have anaconda (latest 64 bit) with python 2.7.x version.** **I have two options of installing:** # Option 1 : from pip pip install Theano **And** # Option 2 : Bleeding edge from git pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git **Can someone let me know the major differences between two and which one is suggested to install?**
<python><theano>
2016-05-19 20:38:40
LQ_EDIT
37,333,876
What are ES6 arrow functions, how do they work?
<p>I am curious about ES6 arrow functions (fat arrow functions). Are they simply syntactic sugar derived from CoffeeScript, or is there more to them than meets the eye?</p>
<javascript><ecmascript-6><arrow-functions>
2016-05-19 20:57:59
LQ_CLOSE
37,334,156
jQuery & Javascript Differences
<p>I understand the difference between jQuery &amp; JavaScript but I don't know which to learn and why to learn it.</p> <p>For example I know jQuery makes a lot of functions &amp; activities much easier than the JavaScript equivalent but that's really all I know in for jQuery's Advantages. But what if I come across something that can only be done in plain JavaScript? But by the time I'm advanced with jQuery, attempting to do the JavaScript equivalent might be overly complexed and maybe hinder completion for whatever reason.</p> <p>And if jQuery makes everything much easier why should I bother learning plain JavaScript? is there an advantage to not using jQuery to complete projects, do more developers use JavaScript, does it hold a job better than a jQuery developer, is there more resources out there for JavaScript over jQuery, is JavaScript more compatible with other languages further down the line, will I be able to do more complex functions and build more complex applications using plain JavaScript?</p> <p>I basically want to become a full stack developer and I've hit the JavaScript section of my personal development and want to make the right decision and in a way to me jQuery feels like you have less control because its easier if that makes sense.</p> <p>All these questions spring to mind but the main question I want answering is why should I learn which and why not the other. I would really appreciate an answer from another developers point of view.</p> <p>Thank you all!</p>
<javascript><jquery>
2016-05-19 21:18:01
LQ_CLOSE
37,334,668
Is there a python equivalent for RSpec to do TDD?
<p>I'm looking for a test framework like Ruby's RSpec to do test driven development in Python. The advantage of a framework like RSpec is that it offers a DSL that lends itself well to TDD. First you describe the test in english, and then you write the test, and when it fails you get a message saying what test failed with your nice description of what the test is trying to do.</p> <p>So far I've looked at PyTest and Nose. PyTest seems closer to ruby's MiniTest than RSpec. Instead of offering a DSL with language to make it read like specifications, it focuses on assertions. Nose seems like a wrapper on PyTest that doesn't add its own DSL.</p> <p>Is there another option I'm missing? Or am I just misusing PyTest and Nose? Has the Python community settled on some totally different way of doing this and I should stop trying to make it like Ruby? It doesn't seem, based on the number of stars on GitHub, that the community has really anointed either of these options as the preferred testing framework.</p>
<python><ruby><testing><rspec><tdd>
2016-05-19 21:52:26
HQ
37,335,307
Get list of data types from schema in Apache Spark
<p>I have the following code in Spark-Python to get the list of names from the schema of a DataFrame, which works fine, but how can I get the list of the data types?</p> <pre><code>columnNames = df.schema.names </code></pre> <p>For example, something like: </p> <pre><code>columnTypes = df.schema.types </code></pre> <p>Is there any way to get a separate list of the data types contained in a DataFrame schema?</p>
<python><apache-spark><types><schema><spark-dataframe>
2016-05-19 22:53:38
HQ
37,335,712
Android firebase 9.0.0 setValue to serialize enums
<p>I have this class making use of enums. Parsing to Firebase json used to work just fine - using Jackson. While migrating to firebase-database:9.0.0 I get the following:</p> <blockquote> <p>com.google.firebase.database.DatabaseException: No properties to serialize found on class .... MyClass$Kind</p> </blockquote> <p>where Kind is the enum declared type. The class:</p> <pre><code>public class MyClass { public enum Kind {W,V,U}; private Double value; private Kind kind; /* Dummy Constructor */ public MyClass() {} public Double getValue() { return value; } public void setValue(Double value) { this.value = value; } public Kind getKind() { return kind; } public void setKind(Kind kind) { this.kind = kind; } } </code></pre> <p>I suspect Firebase no longer uses Jackson when serializing setValue(new MyClass()).</p> <p>Is there a way to get enum types serialized? Or some means to be explicit with respect to the serializer method?</p>
<android><firebase><firebase-realtime-database>
2016-05-19 23:35:05
HQ
37,335,722
SQL - Multiple Counts that are grouped, from multiple tables, with a join thrown in.
Hoping for some help on this topic. I've found related things but nothing that encompassed my whole problem. I have two tables that hold image paths. The counts of approved images should equal the count of published images but I have evidence that they do not. One table has to have a join to group by the same criteria as the other table. I only want to return rows where the two counts don't match up. I've included the two queries I have that would return the data individually. Even if I tried to use Excel as a crutch, the amount of rows this query would return is in the millions. Query 1 select product_id, count(*) from published p join published_set ps on ps.id = p.media_set_id group by ps.product_id Query 2 select product_id, count(*) from media where status in 'APPROVED' group by pro_sku I did use Excel to pull one category of products that I suspected was the worst and got 8,000 mismatches out of 12,000 products. I want to compare this to other areas of the website, which I believe have little to no mismatches. My suspicion is a system is inserting data into the table incorrectly in a specific category.
<sql><oracle><join><group-by>
2016-05-19 23:36:28
LQ_EDIT
37,335,925
How do open programs programatically using registery
ok I have been building voice applications for awhile, and I want to try something different. I want to open programs without manually putting in the programs into code. Process.Start("notepad.exe"); I am wandering how you would execute a program using the registry, for example: string appPath = Path.GetDirectoryName(Application.ExecutablePath); now the reason why I want to do this, is, I don't know what programs the client will have on the computer system.. I have tried researching and everything I find is like how I have been programming. So is there a way to pull the program executable and execute the program. Full Example: if (speech == " ") { Start.Process(Application.ExecutablePath); } or is there anyway to accomplish this.. Please only people who know how to code should respond.. Please don't tell me exactly what I have posted.. Read the question, before answering.
<c#><registry>
2016-05-19 23:59:15
LQ_EDIT
37,336,050
Pipe a stream to s3.upload()
<p>I'm currently making use of a node.js plugin called <a href="https://github.com/nathanpeck/s3-upload-stream">s3-upload-stream</a> to stream very large files to Amazon S3. It uses the multipart API and for the most part it works very well.</p> <p>However, this module is showing its age and I've already had to make modifications to it (the author has deprecated it as well). Today I ran into another issue with Amazon, and I would really like to take the author's recommendation and start using the official aws-sdk to accomplish my uploads.</p> <p>BUT.</p> <p>The official SDK does not seem to support piping to <code>s3.upload()</code>. The nature of s3.upload is that you have to pass the readable stream as an argument to the S3 constructor.</p> <p>I have roughly 120+ user code modules that do various file processing, and they are agnostic to the final destination of their output. The engine hands them a pipeable writeable output stream, and they pipe to it. I cannot hand them an <code>AWS.S3</code> object and ask them to call <code>upload()</code> on it without adding code to all the modules. The reason I used <code>s3-upload-stream</code> was because it supported piping.</p> <p>Is there a way to make aws-sdk <code>s3.upload()</code> something I can pipe the stream to?</p>
<node.js><amazon-web-services><amazon-s3><node-streams>
2016-05-20 00:15:01
HQ
37,336,119
opening image file on c++ , PNG , JPEG
<p>I have tried to open bg.png file , but didn't work. There is no error , but nothing appears. Help Me!</p> <pre><code>int main() { initwindow(600,600,"GAME"); ifstream image("bg.png"); getimage(50, 50 , 450 , 450 , image); putimage(50,50,image,COPY_PUT); system("pause"); } </code></pre>
<c++>
2016-05-20 00:25:44
LQ_CLOSE
37,336,332
Calculate an MD5 checksum for a file in C without opening the file?
<p>I have a list of files in a directory and I want to calculate the MD5 checksum for each of the files. Is there a way to do this without opening the files? If not, what library do I use? Is it the md5 library? </p> <p>Thanks</p>
<c><linux><md5>
2016-05-20 01:00:16
LQ_CLOSE