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,210,198
How to route CodeIgniter with Angular.js?
<p>I'm trying to use Angular.js and CodeIgniter together. </p> <p>With <code>ngRoute</code> in my app, I'm setting in my <code>main.js</code>:</p> <pre><code>$locationProvider.html5Mode(true); $routeProvider.when('/test', { templateUrl: 'partials/test.html' }); $routeProvider.otherwise({ templateUrl: 'partials/home.html' }); </code></pre> <p>In my <code>routes.php</code>, I'm setting:</p> <pre><code>$route['default_controller'] = 'home'; $route['(:any)'] = "home"; </code></pre> <p>And in my <code>home/index.php</code>, I have the <code>&lt;ng-view&gt;&lt;/ng-view&gt;</code>.</p> <p>The thing is, <strong>without</strong> the <code>html5Mode(true)</code> (with /#/ on the URL) everything works fine. But otherwise, the partials file works, but the page reloads anyway.</p> <p>In Inspector Elements, things look like this:</p> <p><a href="https://i.stack.imgur.com/lSwQ3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lSwQ3.png" alt="partials/test.html loaded, but the page realoded, and the error &quot;ngView: undefined&quot; showed up"></a></p> <p>partials/test.html loaded, but the page realoded, and the error "ngView: undefined" showed up.</p> <p>I'm still learning Angularjs. Anyone can help?</p>
<javascript><php><angularjs><ajax><codeigniter>
2016-05-13 12:34:09
HQ
37,210,331
Stop ReSharper from putting JavaScript function parameter onto new line
<p>How can I stop ReSharper formatting from turning this:</p> <pre><code>define(['Spec'], function (Spec) { }); </code></pre> <p>into this:</p> <pre><code>define(['Spec'], function(Spec) { }); </code></pre> <p>I've tried various combinations of settings but have not hit upon the right one yet. </p>
<javascript><formatting><resharper><resharper-9.0>
2016-05-13 12:40:35
HQ
37,210,801
Which Theme Editor I can use for the develop Shopify theme?
<p>Is there any theme Editor is available for Shopify theme development? </p> <p>I have an idea for Desktop Theme Editor for the Shopify. But that Editor is used for Mac OS. If there is any other editor is available then Please suggest me. </p> <p>Thanks</p>
<themes><editor><shopify>
2016-05-13 13:03:17
LQ_CLOSE
37,210,984
Show an activity indicator at the end of a ListView in React-Native
<p>Looking for a way to append an activity indicator to the end of a ListView when the user has reached the end and the app is querying for more data from a server. I can add the indicator after the ListView but then it always show up.</p>
<reactjs><react-native>
2016-05-13 13:11:20
HQ
37,211,115
How to enable a virtualenv in a systemd service unit?
<p>I want to "activate" a virtualenv in a systemd service file.</p> <p>I would like avoid to have a shell process between the systemd process and the python interpreter.</p> <p>My current solution looks like this:</p> <pre><code>[Unit] Description=fooservice After=syslog.target network.target [Service] Type=simple User=fooservice WorkingDirectory={{ venv_home }} ExecStart={{ venv_home }}/fooservice --serve-in-foreground Restart=on-abort EnvironmentFile=/etc/sysconfig/fooservice.env [Install] WantedBy=multi-user.target </code></pre> <p>/etc/sysconfig/fooservice.env</p> <pre><code>PATH={{ venv_home }}/bin:/usr/local/bin:/usr/bin:/bin PYTHONIOENCODING=utf-8 PYTHONPATH={{ venv_home }}/... VIRTUAL_ENV={{ venv_home }} </code></pre> <p>But I am having trouble. I get ImportErrors since some enties in sys.path are missing.</p>
<python><environment-variables><virtualenv>
2016-05-13 13:18:13
HQ
37,211,313
Using combo box in c#
<p>I have prepared a program about grocery management. In one place I have to put product category and product brand. Product brands are in one combo box and categories are in another combo box. I want to change the brand combo box according to the text display in category combo box. Eg: if you choose chocolates in category combo box, the brand combo box shows "Mars"," Snickers" and so on. Please help me. I want the c# code for this work. Thank you. I am Sandu.</p>
<c#>
2016-05-13 13:28:20
LQ_CLOSE
37,212,371
Extension API internal error: org.powermock.api.extension.reporter.MockingFrameworkReporterFactoryImpl
<p>I'm trying to write a unit test using PowerMockRunner but I got the following error:</p> <blockquote> <p>java.lang.IllegalStateException: Extension API internal error: org.powermock.api.extension.reporter.MockingFrameworkReporterFactoryImpl could not be located in classpath. at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.getFrameworkReporterFactory(AbstractTestSuiteChunkerImpl.java:190) at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.getMockingFrameworkReporter(JUnit4TestSuiteChunkerImpl.java:140) at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:119) at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53) at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)</p> </blockquote> <p>I've checked all the dependencies and it's ok, do I need somehthing else?</p>
<java><eclipse><junit><powermock><powermockito>
2016-05-13 14:16:35
HQ
37,212,649
need help to move image to left center of page
I want to know how i can move a image when i click on that it should move to left center. code is <div id="myanm" > <a href="#"><img src="img/home/Services.png" class="service animated fadeInUp img_move"> <h2 class="txt1 shadow animated fadeInUp">SERVICES</h2> </a> </div> css file is .service{ position:absolute; left:0px; bottom:0; z-index:1; animation-delay: 3.5s; height:324px; width:433px; } though already animation is applied i am unable to do click function. please help me out. thank you in advance.
<javascript><jquery><html><css><web-deployment>
2016-05-13 14:28:29
LQ_EDIT
37,212,922
Avoid for blindly declaring variables in perl
my $scalarVar = ""; my $scalarVar = ''; my $scalarVar = (); my $scalarVar; my @arrayVar = ""; my @arrayVar = ''; my @arrayVar = (); my @arrayVar; my %hashVar = ""; my %hashVar = ''; my %hashVar = (); my $hashVar; Please provide a sample and explanation about this to learn proper declaration of the variables. And it would be appreciate if someone can?
<perl>
2016-05-13 14:40:24
LQ_EDIT
37,212,945
AWS: can't connect to RDS database from my machine
<p>The EC2 instance/live web can connect just fine to the RDS database. But when I want to debug the code in my local machine, I can't connect to the database and got this error:</p> <blockquote> <p>OperationalError: (2003, "Can't connect to MySQL server on 'aa9jliuygesv4w.c03i1 ck3o0us.us-east-1.rds.amazonaws.com' (10060)")</p> </blockquote> <p>I've added <code>.pem</code> and <code>.ppk</code> keys to <code>.ssh</code> and I already configure EB CLI. I don't know what should I do anymore.</p> <p>FYI: The app is in Django</p>
<mysql><django><database><amazon-web-services><amazon-rds>
2016-05-13 14:41:08
HQ
37,212,990
Segmentation Fault fgets() two pass assembler
<pre><code> #include&lt;string.h&gt; typedef struct{ char Mnemonic[7]; int code; } code; typedef struct{ char label[10]; unsigned int location; } symbolTab; int opLook(char * mnemonic, code * optable) { int i = 0; int value = 0; for(i ; i&lt;25 ; i++) { if(strcmp(mnemonic, optable[i].Mnemonic) == 0) { value = optable[i].code; return value; } } return value; } int opValid(char * mnemonic, code * optable) { int i = 0; for(i ; i&lt;25 ; i++) { if(strcmp(mnemonic, optable[i].Mnemonic) == 0) { return 1; } } return 0; } int labelcheck(char * label, symbolTab * Table, int counter) { int i = 0; int flag = 0; if (counter == 0) { return flag; } else { for(i; i &lt;counter; i ++) { if(strcmp(label, Table[i].label) == 0) { flag = 1; } } return flag; } } unsigned int labelVal(char * label, symbolTab * Table, int counter) { int i = 0; for(i; i &lt;counter; i ++) { if(strcmp(label, Table[i].label) == 0) { return Table[i].location; } } } void Assemble(char* filename) { unsigned int locctr = 0; /*location counter*/ unsigned int prolen = 0; /*program length*/ int mnemoVal; /*mnemonic Value in Int*/ int labelctr = 0; code Opta[25] = {{"ADD", 24},{"AND",88},{"COMP",40},{"DIV",36},{"J",60}, {"JEQ",48},{"JGT",52},{"JLT",56},{"JSUB",72},{"LDA",00}, {"LDCH",80},{"LDL", 8},{"LDX", 4},{"MUL",32},{"OR",68}, {"RD",216},{"RSUB",76},{"STA",12},{"STCH",84},{"STL",20}, {"STX",16},{"SUB",28},{"TD",224},{"TIX",44},{"WD",220}}; symbolTab symTab[500]; char buffer[255]; FILE * source; FILE * interFile; FILE * objF; FILE * ListFile; interFile = fopen("intermidiateFile.txt", "w+"); ListFile = fopen("ListingFile.txt", "w+"); objF = fopen("ObjectFile.txt", "w+"); source = fopen("source.txt", "r"); char * lab; /*label*/ char * mnemo; /*mnemonic*/ char * operand; char * address = "adress"; unsigned int opeaddress; fgets(buffer, 255, source); if (buffer[0] != '.') { fprintf(interFile, "%s", buffer); } /*Getting first line and initialization of Location Counter*/ if(buffer[0] == '.') /* if the line is a comment continue with the next iteration of the loop*/ { locctr = 0; } else { if(buffer[0] == ' ' || buffer[0] == '\t') { mnemo = strtok(buffer, " \t"); operand = strtok(NULL, " \t"); if(strcmp(mnemo, "START") == 0) { locctr = strtol(operand, NULL, 16); } else { /*error*/ } } else { lab =strtok(buffer, " \t"); mnemo = strtok(NULL, " \t"); operand = strtok(NULL, " \t"); if(strcmp(mnemo, "START") == 0) { locctr = strtol(operand, NULL, 16); } else { /*error*/ } } } /* End of the location counter initialization */ /*start while loop*/ while(!feof(source)) { memset(lab, '\0', strlen(lab)); memset(mnemo, '\0', strlen(mnemo)); memset(operand, '\0', strlen(operand)); fgets(buffer, 255, source); fprintf(interFile, "%s", buffer); if(buffer[0] == '.') /* if the line is a comment continue with the next iteration of the loop*/ { continue; } else /* Else for... If it is not a comment, then check if it start with a character or a space*/ { if(buffer[0] == ' ' || buffer[0] == '\t') /* If it start with a space, then it is just a mnemonic or mnemonic &amp; operand*/ { mnemo = strtok(buffer, " \t\n\r"); if (strcmp(mnemo, "END") == 0) { break; } if(strcmp(mnemo, "RSUB") == 0) { mnemoVal = opLook(mnemo, Opta); fprintf(interFile, "%x %02x\n", locctr, mnemoVal); } else { operand = strtok(NULL, " \t\r\n"); mnemoVal = opLook(mnemo, Opta); fprintf(interFile, "%x %02x %s\n", locctr, mnemoVal, operand); } } else { lab = strtok(buffer, " \t\n\r"); /* it has a label, mnemonic and operand*/ if(labelcheck(lab, symTab, labelctr) == 0) /* check if the label is already in the symTab, if not, add it, otherwise it is an error*/ { strcpy(symTab[labelctr].label, lab); symTab[labelctr].location = locctr; labelctr++; mnemo = strtok(NULL, " \t\n\r"); if (strcmp(mnemo, "END") == 0) { break; } operand = strtok(NULL, " \t\n\r"); mnemoVal = opLook(mnemo, Opta); } else { mnemo = strtok(NULL, " \t\n\r"); if (strcmp(mnemo, "END") == 0) { break; } operand = strtok(NULL, " \t\n\r"); mnemoVal = opLook(mnemo, Opta); } fprintf(interFile, "%x %s %02x %s\n", locctr, lab, mnemoVal, operand); } } if(strcmp(mnemo, "WORD") == 0 ) { locctr = locctr + 3; } else if(strcmp(mnemo, "BYTE") == 0 ) { unsigned int val; if (operand[0] =='C') { val = strlen(operand) - 3; locctr = locctr + val; } else { val = (strlen(operand) - 3)/2; locctr = locctr + val; } } else if(strcmp(mnemo, "RESB") == 0) { locctr = locctr + atoi(operand); } else if(strcmp(mnemo, "RESW") == 0) { locctr = locctr + (3*atoi(operand)); } else { locctr= locctr + 3; } } /* End of While loop*/ prolen = locctr - symTab[0].location; fprintf(interFile, "\n%x", prolen); fclose(source); fclose(interFile); interFile = fopen("intermidiateFile.txt", "r"); /*Start the Listing File and Object File ---------------------Pass 2----------- */ fgets(buffer, 255, interFile); if(buffer[0] == '.') /* if the line is a comment continue with the next iteration of the loop*/ { locctr = 0; /*Error missung Start or Misplaced*/ } else { if(buffer[0] == ' ' || buffer[0] == '\t') { mnemo = strtok(buffer, " \t"); operand = strtok(NULL, " \t"); if(strcmp(mnemo, "START") == 0) { locctr = strtol(operand, NULL, 16); strcpy(address, operand); fprintf(ListFile, "%X %s %s\n", locctr, mnemo, operand); } else { /*error*/ } } else { lab =strtok(buffer, " \t"); mnemo = strtok(NULL, " \t"); operand = strtok(NULL, " \t"); if(strcmp(mnemo, "START") == 0) { locctr = strtol(operand, NULL, 16); fprintf(ListFile, "%x %s %s %s\n", locctr, lab, mnemo, operand); fprintf(objF, "H%s__%06x%06x\n", lab, locctr, prolen); } else { /*error*/ } } } while(!feof(interFile)) { memset(lab, '\0', strlen(lab)); memset(mnemo, '\0', strlen(mnemo)); memset(operand, '\0', strlen(operand)); memset(address, '\0', strlen(address)); memset(buffer, '\0', strlen(buffer)); fgets(buffer, 255, interFile); if (buffer[0] == '\r') { continue; } if(buffer[0] == ' ' || buffer[0] == '\t') { mnemo = strtok(buffer, " \t\n\r"); if (strcmp(mnemo, "END") == 0) { break; } if(strcmp(mnemo, "RSUB") == 0) { memset(buffer, '\0', strlen(buffer)); fgets(address, 255, interFile); mnemoVal = opLook(mnemo, Opta); fprintf(ListFile, "%s %s %X0000", address, mnemo, mnemoVal); } else { operand = strtok(NULL, " \t\r\n"); mnemoVal = opLook(mnemo, Opta); memset(buffer, '\0', strlen(buffer)); fgets(address, 255, interFile); if (labelcheck(operand, symTab, labelctr) == 1) { opeaddress = labelVal(operand, symTab, labelctr); } else { opeaddress = 0; /* error*/ } fprintf(ListFile, "%s %s %s %02X%04X", address, mnemo, operand, mnemoVal, opeaddress); } } else if (buffer[0] == '.') { fprintf(ListFile, "%s\n", buffer); } else { lab = strtok(buffer, " \t\n\r"); mnemo = strtok(NULL, " \t\n\r"); operand = strtok(NULL, " \t\n\r"); mnemoVal = opLook(mnemo, Opta); memset(buffer, '\0', strlen(buffer)); fgets(address, 255, interFile); if (labelcheck(operand, symTab, labelctr) == 1) { opeaddress = labelVal(operand, symTab, labelctr); } else { opeaddress = 0; /* error*/ } fprintf(ListFile, "%s %s %s %s %02X%04X", address, lab, mnemo, operand, mnemoVal, opeaddress); } } fclose(interFile); fclose(objF); fclose(ListFile); } </code></pre> <p>The error occurs in the last while loop when executing fgets(); I have looked if I had any variable or syntax wrong, but everything looks fine. This is a part of a two pass assemble. The error varies between the fgets in the last while loop. At first I thought that it was the memset function, but the error still happened when I mark them as comments</p>
<c>
2016-05-13 14:43:11
LQ_CLOSE
37,213,283
Why does Boolean.getBoolean never seem to return true
<p>Based upon the java doc I have no logical explanation for this. Any ideas?</p> <pre><code>Boolean.getBoolean(Boolean.TRUE.toString()) == false </code></pre> <p>See it for yourself: <a href="https://ideone.com/rKa2dS" rel="nofollow">https://ideone.com/rKa2dS</a></p> <p>Nothing clear to me why in the Java Doc <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html#getBoolean-java.lang.String-" rel="nofollow">https://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html#getBoolean-java.lang.String-</a></p>
<java>
2016-05-13 14:56:01
LQ_CLOSE
37,213,551
ansible SSH connection fail
<p>I'm trying to run ansible role on multiple servers, but i get an error:</p> <blockquote> <p>fatal: [192.168.0.10]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}</p> </blockquote> <p>My /etc/ansible/hosts file looks like this:</p> <pre><code>192.168.0.10 ansible_sudo_pass='passphrase' ansible_ssh_user=user 192.168.0.11 ansible_sudo_pass='passphrase' ansible_ssh_user=user 192.168.0.12 ansible_sudo_pass='passphrase' ansible_ssh_user=user </code></pre> <p>I have no idea what's going on - everything looks fine - I can login via SSH, but ansible ping returns the same error.</p> <p>The log from verbose execution:</p> <blockquote> <p>&lt;192.168.0.10> ESTABLISH SSH CONNECTION FOR USER: user &lt;192.168.0.10> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.0.10 '/bin/sh -c '"'"'( umask 22 &amp;&amp; mkdir -p "<code>echo $HOME/.ansible/tmp/ansible-tmp-1463151813.31-156630225033829</code>" &amp;&amp; echo "<code>echo $HOME/.ansible/tmp/ansible-tmp-1463151813.31-156630225033829</code>" )'"'"''</p> </blockquote> <p>Can you help me somehow? If I have to use ansible in local mode (-c local), then it's useless.</p> <p>I've tried to delete ansible_sudo_pass and ansible_ssh_user, but it did'nt help.</p>
<ssh><connection><ansible>
2016-05-13 15:09:47
HQ
37,213,696
How can I get the path that the application is running with typescript?
<p>I am trying to create a desktop application with electron, angular2, typescript and neDB.In order to be able create a 'file' database with neDB I want the path to my project.How can I get this with typescript ? </p>
<typescript><electron><nedb>
2016-05-13 15:17:45
HQ
37,213,789
Split a string and loop through values in MySql Procedure
<p>I got a situation where I have to pass a comma separated string to MySQL procedure and split that string and insert those values as rows in to a table.</p> <p>As show below</p> <p>For example if I passed 'jhon,swetha,sitha' string to mysql procedure then it have to split that string by comma and insert those values as 3 records into a table.</p> <pre><code> CREATE PROCEDURE new_routine (IN str varchar(30)) BEGIN DECLARE tmp varchar(10); DECLARE inc INT DEFAULT 0; WHILE INSTR(str, ',') DO SET tmp = SUBSTRING(SUBSTRING_INDEX(str,',',inc),LENGTH(SUBSTRING_INDEX(str,',',inc-1))+1),',',''); SET str = REPLACE(str, tmp, ''); //insert tmp into a table. END WHILE; END </code></pre> <p>But this does not worked any solution please.</p>
<mysql><sql><stored-procedures>
2016-05-13 15:22:42
HQ
37,214,884
How do I choose an optimizer for my tensorflow model?
<p>Tensorflow seems to have a large collection of optimizers, is there any high level guideline (or review paper) on which one is best adapted to specific classes of loss functions ?</p>
<tensorflow>
2016-05-13 16:20:09
HQ
37,215,213
How can i get rid of Duplacates in this java code?
**How can i make this Code not have any repeating numbers in it?** All i would like to do is make it so that it doesn't output any duplicates in this little block. int[] arr = {5,10,44,2, 44,44,5,10,44,2, 44,44}; int startScan; int index; int minindex; int minValue; for (startScan=0;startScan<(arr.length-1);startScan++){ minindex=startScan; minValue =arr[startScan]; for (index=startScan+1; index<arr.length;index++){ if (arr[index]<minValue){ minValue=arr[index]; minindex=index; } } arr[minindex]=arr[startScan]; arr[startScan]=minValue; } for(int x=0; x<arr.length;x++){ System.out.println(arr[x]);
<java>
2016-05-13 16:38:07
LQ_EDIT
37,216,188
Cannot make C++ Hello World program, binary not found
I am just starting C++ and downloaded a compiler and an IDE, both eclipse, and tried to make my first C++ program. I use the Hello World C++ Makefile Project, and add the all the stuff on the next page. I then build the program, and the build says this: ***12:30:00 **** Build of configuration Default for project HelloWorld! **** make all Cannot run program "make": Launching failed Error: Program "make" not found in PATH PATH=[C:/Program Files (x86)/Java/jre1.8.0_91/bin/client;C:/Program Files (x86)/Java/jre1.8.0_91/bin;C:/Program Files (x86)/Java/jre1.8.0_91/lib/i386;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\12.0\DLLShared\;C:\Program Files (x86)\Windows Live\Shared;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Users\Jen\Desktop\eclipse;] 12:30:00 Build Finished (took 122ms)*** I run the program, and it says: ***Launch failed. Binary not found.*** This is the code for the program: `#include <stdio.h> #include <stdlib.h> int main(void) { puts("Hello World!"); return EXIT_SUCCESS; }` There are two errors, too: 1. Function "puts" couldn't be resolved. 2. Symbol "EXIT_SUCCESS" couldn't be resolved. Thanks in advance! Nate N.
<c++><eclipse>
2016-05-13 17:38:52
LQ_EDIT
37,216,542
Download video file from youtube to internal storage
<p>I have a youtube video link, like this <a href="https://www.youtube.com/watch?v=UCysW3PCzvo" rel="nofollow">https://www.youtube.com/watch?v=UCysW3PCzvo</a> I want to get list of video source urls (for diffrent qualities). I have this method in php. How i can do that trick in android?</p> <p>Thanks in advance and sorry for my english.</p>
<java><android><youtube>
2016-05-13 18:00:37
LQ_CLOSE
37,216,560
How can I specify a python version using setuptools?
<p>Is there a way to specify a python version to be used with a python package defined in setup.py? </p> <p>My setup.py currently looks like this: </p> <pre><code>from distutils.core import setup setup( name = 'macroetym', packages = ['macroetym'], # this must be the same as the name above version = '0.1', description = 'A tool for macro-etymological textual analysis.', author = 'Jonathan Reeve', author_email = 'jon.reeve@gmail.com', url = 'https://github.com/JonathanReeve/macro-etym', download_url = 'https://github.com/JonathanReeve/macro-etym/tarball/0.1', # FIXME: make a git tag and confirm that this link works install_requires = ['Click', 'nltk', 'pycountry', 'pandas', 'matplotlib'], include_package_data = True, package_data = {'macroetym': ['etymwm-smaller.tsv']}, keywords = ['nlp', 'text-analysis', 'etymology'], classifiers = [], entry_points=''' [console_scripts] macroetym = macroetym.main:cli ''', ) </code></pre> <p>It's a command-line program. My script runs using Python 3, but a lot of operating systems still have Python 2 as the default. How can I specify a python version to be used here? I can't seem to find anything in <a href="https://pythonhosted.org/setuptools/setuptools.html#declaring-dependencies" rel="noreferrer">the docs</a>, but maybe I'm not looking in the right place? </p>
<python><setuptools>
2016-05-13 18:01:39
HQ
37,217,271
Static Polymorphism with boost variant single visitor vs multi visitor vs dynamic polymorphism
<p>I am comparing the performance of the following methods of C++ Polymorphism:</p> <p>Method [1]. static polymorphism using boost variants with a separate visitor for each method Method [2]. static polymorphism using boost variants with a single visitor that calls different method using method overloading Method [3]. Plain old dynamic polymorphism</p> <p>Platform: - Intel x86 64 bit Red Hat modern multi-core processor, 32 GB RAM - gcc (GCC) 4.8.1 with -O2 optimization - Boost 1.6.0</p> <p>Some findings:</p> <ul> <li>Method [1] seems to have significantly outperform Methods [2] and [3]</li> <li>Method [3] outperforms Method [2] most of the time</li> </ul> <p>My question is, why does Method [2] where I am using a visitor but using method overloading to call the correct method give worse performance than virtual methods. I would expect static polymorphism to fare better than dynamic polymorphism. I understand there is some cost of the extra parameter that is being passed in method [2] to figure which visit() method of the class to call and possibly some more branching due to method overloading? But shouldn"t this still outperform virtual methods?</p> <p>Code is below:</p> <pre><code>// qcpptest.hpp #ifndef INCLUDED_QCPPTEST_H #define INCLUDED_QCPPTEST_H #include &lt;boost/variant.hpp&gt; class IShape { public: virtual void rotate() = 0; virtual void spin() = 0; }; class Square : public IShape { public: void rotate() { // std::cout &lt;&lt; "Square:I am rotating" &lt;&lt; std::endl; } void spin() { // std::cout &lt;&lt; "Square:I am spinning" &lt;&lt; std::endl; } }; class Circle : public IShape { public: void rotate() { // std::cout &lt;&lt; "Circle:I am rotating" &lt;&lt; std::endl; } void spin() { // std::cout &lt;&lt; "Circle:I am spinning" &lt;&lt; std::endl; } }; // template variation // enum class M {ADD, DEL}; struct ADD {}; struct DEL {}; class TSquare { int i; public: void visit(const ADD&amp; add) { this-&gt;i++; // std::cout &lt;&lt; "TSquare:I am rotating" &lt;&lt; std::endl; } void visit(const DEL&amp; del) { this-&gt;i++; // std::cout &lt;&lt; "TSquare:I am spinning" &lt;&lt; std::endl; } void spin() { this-&gt;i++; // std::cout &lt;&lt; "TSquare:I am rotating" &lt;&lt; std::endl; } void rotate() { this-&gt;i++; // std::cout &lt;&lt; "TSquare:I am spinning" &lt;&lt; std::endl; } }; class TCircle { int i; public: void visit(const ADD&amp; add) { this-&gt;i++; // std::cout &lt;&lt; "TCircle:I am rotating" &lt;&lt; std::endl; } void visit(const DEL&amp; del) { this-&gt;i++; // std::cout &lt;&lt; "TCircle:I am spinning" &lt;&lt; std::endl; } void spin() { this-&gt;i++; // std::cout &lt;&lt; "TSquare:I am rotating" &lt;&lt; std::endl; } void rotate() { this-&gt;i++; // std::cout &lt;&lt; "TSquare:I am spinning" &lt;&lt; std::endl; } }; class MultiVisitor : public boost::static_visitor&lt;void&gt; { public: template &lt;typename T, typename U&gt; void operator()(T&amp; t, const U&amp; u) { // std::cout &lt;&lt; "visit" &lt;&lt; std::endl; t.visit(u); } }; // separate visitors, single dispatch class RotateVisitor : public boost::static_visitor&lt;void&gt; { public: template &lt;class T&gt; void operator()(T&amp; x) { x.rotate(); } }; class SpinVisitor : public boost::static_visitor&lt;void&gt; { public: template &lt;class T&gt; void operator()(T&amp; x) { x.spin(); } }; #endif // qcpptest.cpp #include &lt;iostream&gt; #include "qcpptest.hpp" #include &lt;vector&gt; #include &lt;boost/chrono.hpp&gt; using MV = boost::variant&lt;ADD, DEL&gt;; // MV const add = M::ADD; // MV const del = M::DEL; static MV const add = ADD(); static MV const del = DEL(); void make_virtual_shapes(int iters) { // std::cout &lt;&lt; "make_virtual_shapes" &lt;&lt; std::endl; std::vector&lt;IShape*&gt; shapes; shapes.push_back(new Square()); shapes.push_back(new Circle()); boost::chrono::high_resolution_clock::time_point start = boost::chrono::high_resolution_clock::now(); for (int i = 0; i &lt; iters; i++) { for (IShape* shape : shapes) { shape-&gt;rotate(); shape-&gt;spin(); } } boost::chrono::nanoseconds nanos = boost::chrono::high_resolution_clock::now() - start; std::cout &lt;&lt; "make_virtual_shapes took " &lt;&lt; nanos.count() * 1e-6 &lt;&lt; " millis\n"; } void make_template_shapes(int iters) { // std::cout &lt;&lt; "make_template_shapes" &lt;&lt; std::endl; using TShapes = boost::variant&lt;TSquare, TCircle&gt;; // using MV = boost::variant&lt; M &gt;; // xyz std::vector&lt;TShapes&gt; tshapes; tshapes.push_back(TSquare()); tshapes.push_back(TCircle()); MultiVisitor mv; boost::chrono::high_resolution_clock::time_point start = boost::chrono::high_resolution_clock::now(); for (int i = 0; i &lt; iters; i++) { for (TShapes&amp; shape : tshapes) { boost::apply_visitor(mv, shape, add); boost::apply_visitor(mv, shape, del); // boost::apply_visitor(sv, shape); } } boost::chrono::nanoseconds nanos = boost::chrono::high_resolution_clock::now() - start; std::cout &lt;&lt; "make_template_shapes took " &lt;&lt; nanos.count() * 1e-6 &lt;&lt; " millis\n"; } void make_template_shapes_single(int iters) { // std::cout &lt;&lt; "make_template_shapes_single" &lt;&lt; std::endl; using TShapes = boost::variant&lt;TSquare, TCircle&gt;; // xyz std::vector&lt;TShapes&gt; tshapes; tshapes.push_back(TSquare()); tshapes.push_back(TCircle()); SpinVisitor sv; RotateVisitor rv; boost::chrono::high_resolution_clock::time_point start = boost::chrono::high_resolution_clock::now(); for (int i = 0; i &lt; iters; i++) { for (TShapes&amp; shape : tshapes) { boost::apply_visitor(rv, shape); boost::apply_visitor(sv, shape); } } boost::chrono::nanoseconds nanos = boost::chrono::high_resolution_clock::now() - start; std::cout &lt;&lt; "make_template_shapes_single took " &lt;&lt; nanos.count() * 1e-6 &lt;&lt; " millis\n"; } int main(int argc, const char* argv[]) { std::cout &lt;&lt; "Hello, cmake" &lt;&lt; std::endl; int iters = atoi(argv[1]); make_virtual_shapes(iters); make_template_shapes(iters); make_template_shapes_single(iters); return 0; } </code></pre>
<c++><performance><templates><boost><polymorphism>
2016-05-13 18:45:49
HQ
37,217,705
Is possible to use cookie based authentication with ASP.NET Web API and SPA?
<p>I want to create the web application which will be based on angularjs frontend and ASP.NET Web API. I need create the secure api but I can't use the token based authentication on the company's server where will be implemented this web application.</p> <p>Is possible use the cookie based authentication for SPA and ASP.NET Web API?</p> <p>How can I configure the cookie based authentication on the ASP.NET project for this scenario where I have the SPA and Web API?</p>
<c#><asp.net><angularjs><cookies>
2016-05-13 19:14:13
HQ
37,217,948
eliminate line in stacked bar ggplot
<p>this graph is made by ggplots but I don't know how to eliminate the lines between the stacked bars (e.g. I want to combine two pink bars into one). </p> <p><a href="https://i.stack.imgur.com/YLG7U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YLG7U.png" alt="enter image description here"></a></p>
<r><ggplot2>
2016-05-13 19:28:39
LQ_CLOSE
37,218,777
Conflicting type in C but no clear difference between lines
<p>I am trying to run a model written by someone else. When running the make file, I get the following error regarding one of the fonctions: </p> <pre><code>ground_layer.c:4391:6: error: conflicting types for 'func_' real func_(R_fp funk, real *x) ^ ground_layer.c:4360:17: note: previous declaration is here extern real func_(U_fp, real *); </code></pre> <p>I feel like it must be a silly mistake, bu my C is really rusty at this point, and I just can't identify the error. I've tried removing all the differences: adding an <code>x</code> in the first definition, removing the <code>funk</code>, but those changes seem to only make things worse. </p> <p>For info, I am on MacOSX 10.11. Here is the code from the definition till the end:</p> <pre><code>/* Local variables */ static real a, b; static integer j; static real x; static integer it; static real del, tnm, sum, ddel; extern real func_(U_fp, real *); /* ********************************************************************** */ b = exp(-(*aa)); a = 0.f; if (*n == 1) { r__1 = (a + b) * .5f; *s = (b - a) * func_((U_fp)funk, &amp;r__1); it = 1; } else { tnm = (real) it; del = (b - a) / (tnm * 3.f); ddel = del + del; x = a + del * .5f; sum = 0.f; i__1 = it; for (j = 1; j &lt;= i__1; ++j) { sum += func_((U_fp)funk, &amp;x); x += ddel; sum += func_((U_fp)funk, &amp;x); x += del; /* L11: */ } *s = (*s + (b - a) * sum / tnm) / 3.f; it *= 3; } return 0; } /* midexp_ */ /* ********************************************************************** */ /* ********************************************************************** */ real func_(R_fp funk, real *x) { /* System generated locals */ real ret_val, r__1; /* Builtin functions */ double log(doublereal); /* ********************************************************************** */ r__1 = -log(*x); ret_val = (*funk)(&amp;r__1) / *x; return ret_val; } /* func_ */ </code></pre>
<c>
2016-05-13 20:20:44
LQ_CLOSE
37,219,064
c# Thread.Sleep(value in NumericUpDown)
I'm new here in Stack Overflow. I've got a question. I've a `NumericUpDown` in my form. And I want the value here: `Thread.Sleep(ValueInNumericUpDown)` But I don't know how to do that. can someone help me? Thanks in advance.
<c#>
2016-05-13 20:44:47
LQ_EDIT
37,219,348
Jenkins Pipeline sh bad substitution
<p>A step in my pipeline uploads a .tar to an artifactory server. I am getting a Bad substitution error when passing in env.BUILD_NUMBER, but the same commands works when the number is hard coded. The script is written in groovy through jenkins and is running in the jenkins workspace.</p> <pre><code>sh 'curl -v --user user:password --data-binary ${buildDir}package${env.BUILD_NUMBER}.tar -X PUT "http://artifactory.mydomain.com/artifactory/release-packages/package${env.BUILD_NUMBER}.tar"' </code></pre> <p>returns the errors:</p> <pre><code>[Pipeline] sh [Package_Deploy_Pipeline] Running shell script /var/lib/jenkins/workspace/Package_Deploy_Pipeline@tmp/durable-4c8b7958/script.sh: 2: /var/lib/jenkins/workspace/Package_Deploy_Pipeline@tmp/durable-4c8b7958/script.sh: Bad substitution [Pipeline] } //node [Pipeline] Allocate node : End [Pipeline] End of Pipeline ERROR: script returned exit code 2 </code></pre> <p>If hard code in a build number and swap out <code>${env.BUILD_NUMBER}</code> I get no errors and the code runs successfully.</p> <pre><code>sh 'curl -v --user user:password --data-binary ${buildDir}package113.tar -X PUT "http://artifactory.mydomain.com/artifactory/release-packages/package113.tar"' </code></pre> <p>I use ${env.BUILD_NUMBER} within other sh commands within the same script and have no issues in any other places.</p>
<bash><jenkins><groovy><jenkins-pipeline>
2016-05-13 21:08:47
HQ
37,220,488
Importing data from multiple text files into Excel VBA
<p>I might have a question about VBA and Excel Macros. The thing that I need to do is to import data (actually integer values) from multiple text files that have random generated names (for example 12345678.txt, 8654321.txt, etc.) but which are stored in the same folder (let's call it Data folder) to excel into a column. </p> <p>The problem that I face is that I have the same name for the measured values (called MVA) that are repeating over and over in the text files. I don't need all the data from the text files, only some specific rows of these MVA (for the example below let's say that I need only the MVA number for the "LED 01 Intensity" which is 6250 to be stored in a new cell in Excel. And I need to get that value that comes after "LED 01 Intensity" in the MVA row from 10 multiple text files (with random names that I don't know) to be stored each one in separate cells in Excel (from A1 to A10).</p> <p>Example_____________________________________________________________________</p> <p>Name: 153588.txt</p> <p>Date: 14.05.2016</p> <p>Name of product: Electronic Device 01</p> <p>CHECK TEST</p> <p>Resistance 101</p> <p>MVA: 2 Ohm</p> <p>MAX: 5 Ohm</p> <p>MIN: 0 Ohm</p> <p>PASS</p> <p>LED 01 Intensity</p> <p>MVA: 6250</p> <p>MAX: 10000</p> <p>MIN: 5000</p> <p>PASS</p> <hr> <p>I need a lot of these MVA values to be stored in Excel for analysis and I need to get an idea if this problem can be solved with VBA. If you can offer me some help to create a macro for this I would be thankful (I have basic knowledge of programming but I'm a beginner in VBA).</p>
<vba><excel><text>
2016-05-13 22:54:29
LQ_CLOSE
37,220,723
How to cleanly reboot core OS when "Failed to talk to init daemon" is seen?
<p>How do I cleanly reboot my coreOS after the following issue shows up?</p> <pre><code>core@node2 ~ $ sudo reboot Failed to talk to init daemon core@node2 ~ $ sudo shutdown -r now Failed to talk to init daemon. core@node2 ~ $ sudo systemctl reboot Failed to get D-Bus connection: Operation not permitted core@contiv-node2 ~ $ shutdown Must be root. core@node2 ~ $ sudo shutdown Unable to perform operation without bus connection. core@node2 ~ $ cat /etc/lsb-release DISTRIB_ID=CoreOS DISTRIB_RELEASE=991.2.0 DISTRIB_CODENAME="Coeur Rouge" DISTRIB_DESCRIPTION="CoreOS 991.2.0 (Coeur Rouge)" </code></pre>
<coreos>
2016-05-13 23:21:56
HQ
37,220,951
How do I make a variable public?
I am making a game with c# (WINFORM Application) in Visual Studio. I have a int named "mode" and I want to make every function be able to access it. Here is my code. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form5 : Form { public Form5() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int wow = mode - 1; } private void Form5_Load(object sender, EventArgs e) { int mode = 4; } } }
<c#><visual-studio>
2016-05-13 23:53:51
LQ_EDIT
37,220,962
Can i use this fitness function?
i am working on a project using a genetic algorithm, and i try now to formulate a fitness function, my questions are : what is the effect of fitness formula choice on a GA ? it is possible to make the fitness function equals directly the number of violation (in case of minimisation) ? thanks you in advance ..
<optimization><artificial-intelligence><genetic-algorithm>
2016-05-13 23:55:23
LQ_EDIT
37,221,062
Observable<{}> not assignable to type Observable<SomeType[]>
<p>I'm learning Angular2 and Typescript. I'm working through the Heroes tutorial on angular.io, but applying it to a project I'm converting from ASP.Net. I've run into a problem which I think is due to my lack of understanding, though as far as I can see it matches what the relevant part of the tutorial is doing.</p> <pre><code>import { Injectable } from '@angular/core'; import {RiskListSummary} from '../Models/RiskListSummary'; import { Observable } from 'rxjs/Rx'; import { Http, Response } from '@angular/http'; @Injectable() export class RiskAssessmentListService { constructor(private http : Http) {} private serviceUrl = "http://myserviceurl/"; getRisks(): Observable&lt;RiskListSummary[]&gt; { return this.http.get(this.serviceUrl) .map(this.extractData()) .catch(this.handleError()); } private extractData(res: Response) { if (res.status &lt; 200 || res.status &gt;= 300) { throw new Error('Bad response status: ' + res.status); } let body = res.json(); return body.data || { }; } private handleError (error: any) { let errMsg = error.message || 'Server error'; console.error(errMsg); // log to console instead return Observable.throw(errMsg); } } </code></pre> <p>I'm getting the following error on the line "return this.http.get(this.serviceUrl)":</p> <blockquote> <p>Error:(20, 16) TS2322: Type 'Observable&lt;{}>' is not assignable to type 'Observable'. Type '{}' is not assignable to type 'RiskListSummary[]'. Property 'length' is missing in type '{}'.</p> </blockquote> <p>If it makes a difference, I'm using webstorm (latest version), but I think this error is coming straight from the typescript compiler. I was thinking maybe I need a typings file for rxjs, but the tutorial doesn't use one, and none of the ones that I found with a "typings search" made a difference</p> <p>The following are my dependencies from package.json:</p> <pre><code> "dependencies": { "@angular/common": "2.0.0-rc.1", "@angular/compiler": "2.0.0-rc.1", "@angular/core": "2.0.0-rc.1", "@angular/http": "2.0.0-rc.1", "@angular/platform-browser": "2.0.0-rc.1", "@angular/platform-browser-dynamic": "2.0.0-rc.1", "@angular/router": "2.0.0-rc.1", "@angular/router-deprecated": "2.0.0-rc.1", "@angular/upgrade": "2.0.0-rc.1", "systemjs": "0.19.27", "es6-shim": "^0.35.0", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.6", "zone.js": "^0.6.12" </code></pre>
<typescript><angular><rxjs>
2016-05-14 00:11:52
HQ
37,221,166
Return error to user if user enter wrong option in Python Tree
<p>i am totally new in Python, i try to do a simple code whereby if the user entered a wrong Product code, he will get an "error message" and he will be prompted to enter again. But i just cannot get it to work. Can somebody help. Thanks</p> <pre><code>class Node(object): def __init__(self,val,key,Number): self.val = val self.key = key self.number = Number self.left = None self.right = None def search(value,p): if(p.val == value): print("You bought item:",p.val,",description:", p.key,"cost:", p.number) return 1 else: if(p.val !=None): if(p.val &lt; value): search (value,p.right) if(p.val &gt; value): search (value,p.left) else: print("You've entered a wrong option") root = Node(3,"Chips", "$12" ) root.left = Node(1,"Chicken", "$13") root.left.right = Node(2,"Potato","$14") root.right = Node(5,"AisKrim","$15") root.right.left = Node(4,"Bag","$16") root.right.right = Node(6,"TV","$17") option = int(input("Please enter code:")) answer = search(option,root) while (answer != 1): print("You've entered a wrong option") option = int(input("Please enter code:")) answer = search(option,root) </code></pre>
<python><binary-tree>
2016-05-14 00:29:26
LQ_CLOSE
37,221,182
How can I flatten an array swiftily in Swift?
<p>I want to turn this:</p> <pre><code>let x = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] </code></pre> <p>into this:</p> <pre><code>[1, 2, 3, 4, 5, 6, 7, 8, 9] </code></pre> <p>very gracefully.</p> <p>The most straightforward way, of course, is</p> <pre><code>var y = [Int]() x.forEach { y.appendContentsOf($0) } </code></pre> <p>But that makes the resulting array mutable, which is unnecessary. I don't like this way.</p> <p>I tried using <code>reduce</code>:</p> <pre><code>let y = x.reduce([Int]()) { (array, ints) -&gt; [Int] in array.appendContentsOf(ints) return array } </code></pre> <p>But the compiler complains that <code>array</code> is immutable, so I can't call the mutating method <code>appendContentsOf</code>. </p> <p>Hence, I added some stuff:</p> <pre><code>let y = x.reduce([Int]()) { (array, ints) -&gt; [Int] in var newArr = array newArr.appendContentsOf(ints) return newArr } </code></pre> <p>This is just <em>plain bad</em>. I have an instinct that this is not swifty.</p> <p>How can I flatten an array more swiftily than the above methods? A one-liner would be good.</p>
<arrays><swift><flatten>
2016-05-14 00:32:47
HQ
37,221,281
Get URL from intranet link name using vba
I am new...I has been searching answers but still cant find it. Looking forward this forum can help me...every month we downloaded over-time form from intranet by clicking a link...So i want to make a vba to get the URL from one of the link name in site. The attach image is the example...i want to get the URL encircled in red and paste into excel (filename otform.xlsm cell A1)..really need help...thanks [enter image description here][1] [1]: http://i.stack.imgur.com/DL3o0.jpg
<excel><vba><url><hyperlink>
2016-05-14 00:46:27
LQ_EDIT
37,221,419
In Safari's "Responsive Design Mode" can you hide all of the device options on top for more screen real estate?
<p><a href="https://i.stack.imgur.com/a4yrk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/a4yrk.png" alt="enter image description here"></a></p> <p>Can I hide this?</p> <p>I'm having a poor user experience debugging my app in Safari (I decided to not use Chrome because it seems to demand more CPU). This bar takes up SOOO much screen real estate and almost forces me to dock the devtools on thee side. But as I said earlier can I hide this?</p>
<browser><responsive-design><safari>
2016-05-14 01:09:36
HQ
37,221,456
Why can I assign a value of different type to a variable?
<p>In the book "Go in Action", the author wrote "Values of two different types can’t be assigned to each other, even if they’re compatible".</p> <p>For example, we can't assign <code>Duration</code> to <code>int64</code> or <code>int64</code> to <code>Duration</code>.</p> <p>But this is not always true, the following assignment would work like the <code>X</code> value is converted back to <code>[]int</code> automatically:</p> <pre><code>type X []int var v []int = X([]int{1, 2, 3}) </code></pre> <p>What's the difference between these two situations?</p>
<go>
2016-05-14 01:18:07
HQ
37,222,081
PyQt QTableView Set Horizontal & Vertical Header Labels
<p>using QTableWidget i can do </p> <pre><code>table = QTableWidget() table.setHorizontalHeaderLabels(QString("Name;Age;Sex;Add").split(";")) table.horizontalHeaderItem().setTextAlignment(Qt.AlignHCenter) </code></pre> <p>how can i do same with QTableView ??</p>
<python><pyqt>
2016-05-14 03:10:11
HQ
37,222,085
How to itterate through int?
I'm confused on how i can iterate through my int, and then put the result in a int vector.. I'm needing to do this for a game, help would be very much appreciated.. honestly, i have no idea how to make this function, that will iterate through int... cout << "\n PLEASE ENTER A 4 DIGIT BINARY! OR PROGRAM WILL EXIT \n\n\t"; cin >> binaryCin; evaluateNum(binaryCin); void MasterMind::evaluateNum(int &bin) { //Need to itterate through binarycin, and then but it in a vector<int>.. }
<c++><iterator><int>
2016-05-14 03:10:42
LQ_EDIT
37,223,175
Image Effects of 2016 for Website Banner
<p>I've been searching about the name of this image effect but can't find an answer since I don't really know what to put on the search engine. So I decided to visit here to post a question to you guys hoping that I get an answer. Here is the <a href="http://postimg.org/image/57lz8c1td/" rel="nofollow">image effect</a></p>
<html><css><image><photoshop>
2016-05-14 05:55:17
LQ_CLOSE
37,223,194
uintptr_t is too small to store addresses
<p>In C, when I cast a pointer to type uintptr_t, it truncates part of the address. Is there anyway to store the entire address as an integer or some other data type that is no larger than 8 bytes?</p>
<c>
2016-05-14 05:57:42
LQ_CLOSE
37,223,695
AWS Cognito Error: 'identityPoolId' failed to satisfy constraint
<p>I am new Cognito. I am trying to implement AWS Cognito using Lambda. This is the <a href="https://java.awsblog.com/blog/author/Dhruv+Thukral" rel="noreferrer">tutorial</a> I am following. </p> <pre><code>AmazonCognitoIdentityClient client = new AmazonCognitoIdentityClient(); GetOpenIdTokenForDeveloperIdentityRequest tokenRequest = new GetOpenIdTokenForDeveloperIdentityRequest(); tokenRequest.setIdentityPoolId("us-east-1_XXXXXXX"); </code></pre> <p>This is the pool Id that I am using in the setIdentityPoolId</p> <p><a href="https://i.stack.imgur.com/D8tjS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/D8tjS.png" alt="enter image description here"></a></p> <p>This is the JUnit test</p> <pre><code>public class AuthenticateUser implements RequestHandler&lt;Object, Object&gt; { @Override public Object handleRequest(Object input, Context context) { AuthenticateUserResponse authenticateUserResponse = new AuthenticateUserResponse(); @SuppressWarnings("unchecked") LinkedHashMap inputHashMap = (LinkedHashMap)input; User user = authenticateUser(inputHashMap); return null; } public User authenticateUser(LinkedHashMap input){ User user = null; String userName = (String) input.get("userName"); String passwordHash = (String) input.get("passwordHash"); try { AmazonDynamoDBClient client = new AmazonDynamoDBClient(); client.setRegion(Region.getRegion(Regions.US_EAST_1)); DynamoDBMapper mapper = new DynamoDBMapper(client); user = mapper.load(User.class, userName); if(user != null){ System.out.println("user found"); if(user.getPasswordHash().equals(passwordHash)){ System.out.println("user password matched"); String openIdToken = getOpenIdToken(user.getUserId()); user.setOpenIdToken(openIdToken); return user; } else { System.out.println("password unmatched"); } } else { System.out.println("user not found"); } } catch (Exception e) { System.out.println("Error: " + e.toString()); } return user; } </code></pre> <p>This is the output</p> <pre><code>user found user password matched </code></pre> <p>But I am getting the following error and hence, the <code>return user</code> statement is failing</p> <pre><code>1 validation error detected: Value 'us-east-1_XXXXXX' at 'identityPoolId' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w-]+:[0-9a-f-]+ (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: ValidationException; </code></pre>
<amazon-web-services><amazon-cognito>
2016-05-14 07:02:13
HQ
37,224,073
SMTP AUTH extension not supported by server
<p>Using python I want to send email from my app but it shows the error</p> <pre><code>SMTP AUTH extension not supported by server </code></pre> <p>Code for the program,</p> <pre><code>import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText fromaddr = "test1@example.com" toaddr = "test2@example.com" msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] = "Test Mail" body = "Test mail from python" msg.attach(MIMEText(body, 'plain')) server = smtplib.SMTP('smtp.example.com', 25) server.ehlo() server.starttls() server.ehlo() server.login(fromaddr, "password") text = msg.as_string() server.sendmail(fromaddr, toaddr, text) server.quit() </code></pre> <p>Telnet Output:</p> <pre><code>ehlo test1.example.com 250-hidden 250-HELP 250-SIZE 104857600 250-ENHANCEDSTATUSCODES 250-8BITMIME 250-STARTTLS 250 OK </code></pre> <p>I need to authenticate and send mail from app.</p>
<python><smtp><smtplib>
2016-05-14 07:44:48
HQ
37,224,170
When function with for loop is called it only returns on value from dict.
<p>I dont understand why this function - with for loop, only returns one value from a dict. when called:</p> <pre><code>my_dict = {"key1": 2, "key2": 3, "key3": 4} def fun(): for x in my_dict: return my_dict[x] var = fun() print var </code></pre> <p>How to make it return all the values that the loop produces? I know there are smarter ways, but im very new to Python and trying to understand how it functions.</p>
<python>
2016-05-14 07:55:53
LQ_CLOSE
37,224,705
Is WPF the best solution for C# GUIs?
<p>I was working with Windows Forms for a while now, and due to certain limitations on Forms, I want to work my way up to a better way of making GUIs. I found WPF, which looks pretty promising, but I'm asking you guys, if there are any better ways for doing nice GUIs for Windows with C#? Thanks in advance!</p>
<c#><wpf><windows><user-interface>
2016-05-14 08:58:27
LQ_CLOSE
37,225,009
HTML5 Shiv Google CDN Link Not Working
<p>This Shiv Google CDN Link Not Working. What Should I Do?</p> <pre><code>&lt;!--[if lt IE 9]&gt; &lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt; &lt;![endif]--&gt; </code></pre>
<javascript><html><html5shiv>
2016-05-14 09:31:51
HQ
37,225,035
Serialize in JSON a base64 encoded data
<p>I'm writing a script to automate data generation for a demo and I need to serialize in a JSON some data. Part of this data is an image, so I encoded it in base64, but when I try to run my script I get:</p> <pre><code>Traceback (most recent call last): File "lazyAutomationScript.py", line 113, in &lt;module&gt; json.dump(out_dict, outfile) File "/usr/lib/python3.4/json/__init__.py", line 178, in dump for chunk in iterable: File "/usr/lib/python3.4/json/encoder.py", line 422, in _iterencode yield from _iterencode_dict(o, _current_indent_level) File "/usr/lib/python3.4/json/encoder.py", line 396, in _iterencode_dict yield from chunks File "/usr/lib/python3.4/json/encoder.py", line 396, in _iterencode_dict yield from chunks File "/usr/lib/python3.4/json/encoder.py", line 429, in _iterencode o = _default(o) File "/usr/lib/python3.4/json/encoder.py", line 173, in default raise TypeError(repr(o) + " is not JSON serializable") TypeError: b'iVBORw0KGgoAAAANSUhEUgAADWcAABRACAYAAABf7ZytAAAABGdB... ... BF2jhLaJNmRwAAAAAElFTkSuQmCC' is not JSON serializable </code></pre> <p>As far as I know, a base64-encoded-whatever (a PNG image, in this case) is just a string, so it should pose to problem to serializating. What am I missing?</p>
<json><python-3.x><serialization><base64>
2016-05-14 09:35:16
HQ
37,225,145
But i don't know how to classify customers after they signed in?
**The below is my class Ability. It means if you are admin you can do everything, else you just can read. But i don't know how to classify customers after they signed in? If you have any suggestion pls help me!** class Ability include CanCan::Ability def initialize(user) user ||= User.new # guest user (not logged in) if user.admin? can :manage, :all else can :read, :all end end end
<ruby-on-rails><cancan>
2016-05-14 09:47:54
LQ_EDIT
37,225,494
Check if path is a directory in Swift2?
<p>If like to attain functionality similar to that of Bash's <code>-d</code> <code>if</code> condition.</p> <p>I am aware of how to test if a file exists with <code>fileExistsAtPath()</code>, which returns a bool "true" if the file exists and "false" if it doesn't (assuming <code>path</code> is a string containing the path to the file):</p> <pre><code>if NSFileManager.fileExistsAtPath(path) { print("File exists") } else { print("File does not exist") } </code></pre> <p>However, I would like to check if the path specified in <code>path</code> is a directory, similar to the following <code>bash</code> code:</p> <pre><code>if [ -d "$path" ]; then echo "$path is a directory" elif [ -f "$path" ]; then # this is effectively the same as fileExistsAtPath() echo "$path is a file" fi </code></pre> <p>Is this possible, and if yes, how should it be performed?</p>
<swift><directory><swift2><nsfilemanager>
2016-05-14 10:29:14
HQ
37,225,722
ng-content select bound variable
<p>I'm trying to create a form builder using angular 2. An very basic example is as follows:</p> <pre><code>this.fields = [{name: 'Name', type: 'text'}, {name: 'Age', type: 'number'}]; </code></pre> <p>But I also want to support custom elements like:</p> <pre><code>this.fields = [ {name: 'Name', type: text}, {name: 'Age', type: 'custom', customid: 'Ctl1'}, {name: 'Whatever', type: 'custom', customid: 'Ctl2'} ]; // template: &lt;super-form [fields]="fields"&gt; &lt;Ctl1&gt;&lt;input type="number" ...&gt;&lt;Ctl1&gt; &lt;Ctl2&gt;&lt;whaterver-control ...&gt;&lt;Ctl2&gt; &lt;/super-form&gt; </code></pre> <p>In my form builder component I then have something like:</p> <pre><code>&lt;div *ngFor="let f of fields"&gt; &lt;div [ngSwitch]="f.type"&gt; &lt;span *ngSwitchWhen="'custom'"&gt; &lt;ng-content select="f.customid"&gt;&lt;/ng-content&gt; &lt;/span&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>But given that I'm here this obviously does not work. Is this an ng2 limitation? If so, I guess I could hard code say 5 optional content elements and check if they are specified and not have dynamic selects but this is a hack.</p> <p>Cheers</p>
<angular><angular2-forms>
2016-05-14 10:52:04
HQ
37,225,775
Idea, sbt, unable to reparse warning
<p>I've pushed my artifact to oss nexus repo, added it as dependency to another project. Idea keeps me warning:</p> <pre><code>[warn] Unable to reparse com.github.kondaurovdev#jsonapi_2.11;0.1-SNAPSHOT from sonatype-snapshots, using Fri May 13 17:12:52 MSK 2016 [warn] Choosing sonatype-snapshots for com.github.kondaurovdev#jsonapi_2.11;0.1-SNAPSHOT </code></pre> <p>Maybe i pushed artifact somehow in a wrong way? But i did it earlier, everything was ok. How to get rid of these warnings? Or just ignore them?</p>
<intellij-idea><sbt><nexus><publishing>
2016-05-14 10:57:32
HQ
37,226,147
What is curl and how to use it with nodejs?
<p>I Can not understand the purpose and use case of curl. what it is meant to be doing?</p> <p>There is this command that i saw in a tutorial and i don't know how it is working </p> <pre><code>curl -d 'hello' http://localhost:8080 </code></pre> <p>we are passing the hello string to the server as a request and can't we do that in browser, if we can , can you please explain how to write the same thing in the browser</p>
<javascript><node.js><curl>
2016-05-14 11:35:16
LQ_CLOSE
37,226,197
How to Find Neighboring States through State Zip code information in R
<p>I want to find the neighboring states for a given particular state in US through its zip code information in R, can anyone please help me on how to go ahead with it?</p> <p>thanks in advance!</p>
<r><geocoding><zipcode>
2016-05-14 11:40:24
LQ_CLOSE
37,226,253
What is unicode character of location?
<p>I want use character for the location (like in Google Maps) – <a href="http://i.stack.imgur.com/s0Nb6.png" rel="noreferrer">location symbol</a>.</p> <p>I want to ask if there is such a unicode character?</p>
<unicode><location><character>
2016-05-14 11:46:08
HQ
37,227,421
How do I add a second die to this elm effects example?
<p>I am new to Elm and have been looking at the following example (note this is under the newer 0.17 architecture, where Action is now Command): <a href="http://elm-lang.org/examples/random" rel="noreferrer">http://elm-lang.org/examples/random</a></p> <p>There is a follow up challenge to add a second die to the example, so that a single click of the button rolls a new value for each die. My idea is to change the model to hold two separate values, one for each die, ala</p> <pre><code>type alias Model = { dieFace1 : Int , dieFace2 : Int } </code></pre> <p>This works fine until I get to the update block. I am not sure how to update the Random number generator to create two values. The function is a bit confusing to me.</p> <pre><code>type Msg = Roll | NewFace Int Int update : Msg -&gt; Model -&gt; (Model, Cmd Msg) update msg model = case msg of Roll -&gt; **(model, Random.generate NewFace (Random.int 1 6))** &lt;-- not sure what to do here NewFace newFace1 newFace2 -&gt; (Model newFace1 newFace2, Cmd.none) </code></pre> <p>The documentation for the Random.generate function is a bit light - </p> <blockquote> <p>generate : (a -> msg) -> Generator a -> Cmd msg</p> <p>Create a command that will generate random values.</p> </blockquote> <p>Is this even the correct approach to handle two dice, or is there a better way? I am an elm noob, please be nice :)</p>
<elm>
2016-05-14 13:45:38
HQ
37,228,080
Python/Flask web development
<p>I using flask web development to create a mini-web with python 2.7.</p> <pre><code>import settings from flask import Flask, render_template app = Flask(__name__) app.config.from_object(settings) @app.route("/") def hello(): return "Hello World!" @app.route("/login") def login_template(): return render_template("login.html") if __name__=="__main__": app.run() </code></pre> <p>The <code>@app.route("/")</code> is working perfectly fine but i got an error in <code>@app.route("/login")</code> because im tryng to <code>render_template("login.html")</code>.</p> <p>The file is in a directory <code>/templates/login.html</code> in the same working directory</p> <p>I got this error:</p> <p><a href="https://i.gyazo.com/761c169e0d55de45e3dd6c7af346c48c.png" rel="nofollow">https://i.gyazo.com/761c169e0d55de45e3dd6c7af346c48c.png</a></p> <p><a href="https://i.gyazo.com/571c079b44c6216612c16798d57d200a.png" rel="nofollow">https://i.gyazo.com/571c079b44c6216612c16798d57d200a.png</a></p>
<python><python-2.7><flask><web-deployment>
2016-05-14 14:49:34
LQ_CLOSE
37,229,093
Why my image is not displayed?
<p></p> <pre><code>&lt;div class "nuhoLogo"&gt; &lt;a class "nuhoLogo" href="http://www.nuho.com"&gt; </code></pre> <p>//should't this path always work?</p> <pre><code> &lt;img src="C:/Users/Chibas/Desktop/html/MyWebSite/Logo/logo.gif" border="0" width="100" height="80" alt ="nuho-logo"/&gt; &lt;/a&gt; &lt;/div&gt; </code></pre>
<html><css>
2016-05-14 16:22:49
LQ_CLOSE
37,229,298
Difference between scope and access modifier in Java
<p>Let me know the difference between scope and access modifier in Java.Do these have any similarity?</p>
<java>
2016-05-14 16:42:49
LQ_CLOSE
37,229,811
"warning: useless storage class specifier in empty declaration" in struct
<pre><code>typedef struct item { char *text; int count; struct item *next; }; </code></pre> <p>So I have this struct with nodes defined as above, but Im getting the error below and Im not able to figure out whats wrong.</p> <blockquote> <p>warning: useless storage class specifier in empty declaration };</p> </blockquote>
<c><struct><error-handling><compiler-errors><linked-list>
2016-05-14 17:33:17
HQ
37,230,326
How to add image/ads to the sides of main content
<p>Let's say that I got a div called <code>container</code> that is 1000px wide and aligned to the center of the screen. I would like to add images/ads to the blank space that is left over the the left and right side of that div. It should be fixed and should not move into the <code>content</code> div if the screen is smaller but should instead disappear to the sides when zooming in on the website or having smaller screen.</p> <p>I am pretty much trying to accomplish what probuilds.net did: <a href="https://i.gyazo.com/746c89429d9ca0e23016469120f2b607.jpg" rel="nofollow">https://i.gyazo.com/746c89429d9ca0e23016469120f2b607.jpg</a></p> <p>How could that be done? Each side should have individual ad/image code.</p>
<html><css>
2016-05-14 18:21:54
LQ_CLOSE
37,231,118
How do I save the output of this code into a file? (PHP)
<p>This code that loops through some mysql tables:</p> <pre><code>foreach($tables as $table) { echo "&lt;h2&gt;" . $table[0] . "&lt;/h2&gt;"; $query = "DESCRIBE " . $table[0]; $result = $mysqli-&gt;query($query); $columns = $result-&gt;fetch_all(); foreach($columns as $column) { echo $column[0]. '&lt;br /&gt;'; } } </code></pre> <p>How do I make it output to a file? (Just the names of the tables and the column names)</p>
<php><mysql><file>
2016-05-14 19:46:16
LQ_CLOSE
37,231,487
Error: no match for operator []
<p>I am writing a C++ code and I am getting the above on the title mentioned error at some lines. I do not know why this is happening.</p> <p><strong>CODE:</strong></p> <pre><code>#include &lt;iostream&gt; #include &lt;ctime&gt; #include &lt;cstdio&gt; #include &lt;cstring&gt; #include &lt;cstdlib&gt; #include &lt;vector&gt; #include &lt;map&gt; #include &lt;algorithm&gt; #include &lt;list&gt; //#include &lt;Winbase.h&gt; using namespace std; // A struct describing a product. typedef struct Products { string category; string name; float price; } Product; inline void scenario1(int num_cashiers) { vector&lt;Product&gt; products; // It is a vector(a pseudo-second dimension) of products which will be used for each customer vector&lt;vector&lt;Product&gt;&gt; customers; // A vector containing all customers vector&lt;vector&lt;vector&lt;Product&gt;&gt;&gt; cashiers; // A vector describing the supermarket cashiers declaring a queue of customers for each cashier cashiers.reserve(num_cashiers); // I create as many cashiers as the user wants. double start = GetTickCount(); // It will be used for counting 10 secs until next update vector&lt;int&gt; total_products(num_cashiers); // A vector keeping the total number of products of each queue list&lt;string&gt; categories; // A list containing all the categories of the products list&lt;float&gt; categories_prices; // A list containing all category prices map&lt;string,float&gt; statistics; // A map that keeps the statistical report of the supermarket. It keeps the name of each category and the total amount having been paid by customers for products of this category string want_new_customers; int number_new_customers; int number_products; string new_answer; int pos_min_cashier; string seeQueue; int select_cashier; string seeAvgTime; string seeStatistics; while (true) { double current_time = GetTickCount() - start; // We are taking each and every second. // Update every 10 secs (=10000msecs) if (current_time &gt;= 10000) // { ... // Creation of the list with the totally paid amount for each category by the customers //for (int &amp;i : categories_prices) categories_prices[i] = 0; for (int i = 0; i &lt; customers.size(); i++) { for (int j = 0; j &lt; products.size(); j++) { Products products[i][j]; if (products[i][j].category == categories[i]) // HERE I AM GETTING THE ERROR categories_prices = categories_prices + products[i][j].price; // HERE I AM GETTING AN NO MATCH FOR OPERATOR + ERROR } } // Statistical mapping for (int i = 0; i &lt; categories.size(); i++) statistics[categories[i]] = categories_prices[i]; // HERE I AM GETTING THE ERROR ... } </code></pre> <p>One thought crossed my mind was to create a function of the following form:</p> <pre><code>int* operator[](int index) { return arr[index]; // where arr could be the name of any vector of mine } </code></pre> <p>So, was my thought correct? What should I change in my code?</p> <p>How can I fix the errors I referred to?</p> <p>Thank you in advance!</p>
<c++>
2016-05-14 20:24:11
LQ_CLOSE
37,231,683
Can you save the data from the Visual Studio Diagnostic Tools Windows to review after application is done processing?
<p>When using Visual Studio 2015 Enterprise Edition, can you save the data that is accumulated in all the windows (Timeline, CPU Usage, Memory Usage, etc) of the Diagnostic Tools to review after the application completes?</p>
<visual-studio><visual-studio-2015>
2016-05-14 20:46:36
HQ
37,231,841
Beginner JavaScript OOP vs Functional
<p>I'm just starting to research different programming styles (OOP, functional, procedural).</p> <p>I'm learning JavaScript and starting into underscore.js and came along <a href="http://underscorejs.org/#oop" rel="noreferrer">this</a> small section in the docs. The docs say that underscore.js can be used in a Object-Oriented or Functional style and that both of these result in the same thing.</p> <pre><code>_.map([1, 2, 3], function(n){ return n * 2; }); _([1, 2, 3]).map(function(n){ return n * 2; }); </code></pre> <p>I don't understand which one is functional and which one is OOP, and I don't understand why, even after some research into these programming paradigms.</p>
<javascript><oop><functional-programming><underscore.js>
2016-05-14 21:01:56
HQ
37,232,061
Lazarus - No Form Window, Dialogue Grey'd Out
<p>I've got a wee bit of experience with Pascal, as I've used it to create mods via TES5Edit for Skyrim, and I've hit a wee snag with modding Dark Souls, and I figured flexin' me Pascalerrific muscles would be a good exercise.</p> <p>But, uh, it's all buggered right from the get go. Lazarus supposedly has this "Form Window" feature, where ya can just click one of the icons and then click on the IDE, and bam. Automated GUI creation.</p> <p>I ain't got that. The window isn't up, and the option to open it is grey'd out. 'Eres an image to demonstrate:</p> <p><a href="http://i.stack.imgur.com/rBvYu.png" rel="nofollow">'Ere 'tis, lads.</a></p> <p>Bit sad that, right from the get go, I'm flummoxed. LEND ME YO' EARS, MA HOMIES! A BROTHA NEEDS AID!</p> <p><em>Achem</em> So, uh, what do I do to enable it? Google gives absolutely nothing in regards to using Lazarus in pretty much any way, so that bridge wasn't even built 'afore it was burnt.</p>
<pascal><lazarus>
2016-05-14 21:26:43
LQ_CLOSE
37,232,103
TreeMap implementation in java returns only last element
<p>This is a class whose object I want to put in a TreeMap. </p> <pre><code>public class JobDefinition { private static String jobDescription; private static String datasetName; private static String jobName; private static String responsiblePerson; public JobDefinition(String jobDesc, String dataSet, String jobName2, String person) { jobDescription=jobDesc; datasetName=dataSet; jobName=jobName2; responsiblePerson=person; } public String getJobDescription() { return jobDescription; } public String getDatasetName() { return datasetName; } public String getJobName() { return jobName; } public String getResponsiblePerson() { return responsiblePerson; } } </code></pre> <p>Here I am fetching values from Spreadsheet using POI library. TreeMap uses a integer as Key and Object of above class as its value.</p> <pre><code>for (int rowCount = rowStartIndex+1; rowCount &lt; rowEndIndex; rowCount++) { String jobDesc=spreadsheet.getRow(rowCount).getCell(0).toString(); String dataSet=spreadsheet.getRow(rowCount).getCell(1).toString(); String jobName=spreadsheet.getRow(rowCount).getCell(2).toString(); String person =spreadsheet.getRow(rowCount).getCell(3).toString(); if(!jobName.equals("N/A") &amp;&amp; jobName!=""){ validJobCount++; jobDefinitionInfo.put(validJobCount, new JobDefinition(jobDesc,dataSet,jobName,person)); } } for(Map.Entry&lt;Integer,JobDefinition&gt; entry : jobDefinitionInfo.entrySet()) { System.out.println(entry.getKey()+"::"+entry.getValue().getJobDescription()); } </code></pre> <p>When all value is set in Map. And I iterate over it. I get correct key but all corresponding values (which is an object of JobDefinition class) against it is the last value which was placed.</p> <p><strong>Output::</strong></p> <pre><code>1::Monthly UPDTMEND File 2::Monthly UPDTMEND File 3::Monthly UPDTMEND File 4::Monthly UPDTMEND File 5::Monthly UPDTMEND File 6::Monthly UPDTMEND File 7::Monthly UPDTMEND File 8::Monthly UPDTMEND File 9::Monthly UPDTMEND File 10::Monthly UPDTMEND File </code></pre> <p><strong>Expected Output</strong></p> <pre><code>1::VRSFEND - TRANSACTION SWEEP 2::XCTLOAD 3::CHEKDATE - TO IDENTIFY BACKDATED TRANSACTIONS 4::EDITALIVE 5::EDITB 6::PRICE LOAD 7::ACCTSIM - run manually 8::ACCTLIV - run manually by DVG 9::Check Sybase jobs 10::Monthly UPDTMEND File </code></pre> <p>I feel there is something wrong with Implementation. Please tell me what more should be added to make it run correctly.</p>
<java><treemap>
2016-05-14 21:31:21
LQ_CLOSE
37,232,446
IPython console can't locate "backports.shutil_get_terminal_size" and won't load
<p>I'm running Python2.7 on windows 10 doing env and most pkg management with Anaconda. After upgrading a number of packages, my ipython console now fails to start in any IDE or at the console. When I attempt to run it at the console I get this error:</p> <pre><code>Traceback (most recent call last): File "C:\Anaconda3\Scripts\ipython-script.py", line 3, in &lt;module&gt; import IPython File "C:\Anaconda3\lib\site-packages\IPython\__init__.py", line 48, in &lt;module&gt; from .core.application import Application File "C:\Anaconda3\lib\site-packages\IPython\core\application.py", line 24, in &lt;module&gt; from IPython.core import release, crashhandler File "C:\Anaconda3\lib\site-packages\IPython\core\crashhandler.py", line 28, in &lt;module&gt; from IPython.core import ultratb File "C:\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 121, in &lt;module&gt; from IPython.utils.terminal import get_terminal_size File "C:\Anaconda3\lib\site-packages\IPython\utils\terminal.py", line 27, in &lt;module&gt; import backports.shutil_get_terminal_size ImportError: No module named backports.shutil_get_terminal_size </code></pre> <p>The first thing I tried to do was:</p> <pre><code>pip install --upgrade backports.shutil_get_terminal_size </code></pre> <p>output:</p> <pre><code>Requirement already up-to-date: backports.shutil_get_terminal_size in c:\anaconda3\lib\site-packages </code></pre> <p>I've uninstalled and reinstalled ipython with both</p> <pre><code>conda uninstall ipython conda install ipython </code></pre> <p>and</p> <pre><code>pip uninstall ipython pip install ipython </code></pre> <p>Still won't work. Help please!</p>
<python><python-2.7><terminal><ipython><anaconda>
2016-05-14 22:13:53
HQ
37,232,450
Positive and negative numbers with ArrayList
<p>How do I seprate positive and negative numbers? I have this code:</p> <pre><code>import java.util.ArrayList; import java.swing.JOptionPane; public class Test { public static void main(String[] args) { ArrayList al = new ArrayList(); int num=Integer.parseInt(JOptionPane.showInputDialog("How many numbers?")); for (int i=0 ; i &lt; num ; i++) { al.add(Integer.parseInt(JOptionPane.showInputDialog("What numbers?"))); } } } </code></pre> <p>Let's say I want to add 5 numbers. <code>-2, -7, 8, 4, -1</code></p> <p>I need the output to be <code>Positive = 8, 4</code> and <code>Negative = -2, -7, -1</code></p>
<java><arraylist><input><joptionpane>
2016-05-14 22:14:49
LQ_CLOSE
37,232,827
AWS lambda function stops working after timed out error
<p>I have a simple lambda function that asynchronously makes an API calls and then returns data. 99% of the time this works great. When ever the API takes longer then the lambda configured timeout, it gives an error as expected. Now the issue is that when I make any subsequent calls to the lambda function it permanently gives me the timeout error.</p> <pre><code> "errorMessage": "2016-05-14T22:52:07.247Z {session} Task timed out after 3.00 seconds" </code></pre> <p>In order to test that this was the case I set the lambda timeout to 3 seconds and have a way to trigger these two functions within the lambda. </p> <p><strong>Javascript</strong></p> <pre><code>function now() { return response.tell('success'); } function wait() { setTimeout(function() { return response.tell('success'); }, 4000); } </code></pre> <p>When I call the <code>now</code> function there are no problems. When I call the <code>wait</code> function I get the timeout error and then any subsequent calls to <code>now</code> give me the same error.</p> <p>Is this an expected behavior? I would think that any subsequent calls to the lambda function should work. I understand I can always increase the configuration timeout, but would rather not. </p>
<node.js><amazon-web-services><aws-lambda>
2016-05-14 23:13:06
HQ
37,232,833
python: creating a dictionary, coming up as "None" in a file
<p>when reading the file it is coming up as "None", how can i fix this so that it is a dictionary(made from two varibles) in a file.</p> <pre><code>with open('RPS.txt','r') as f: highscores = [line.strip() for line in f] f = open('RPS.txt','a') high = {player_score: name} highscores = highscores.append(high) print(highscores, file=f) f.close() </code></pre>
<python><dictionary>
2016-05-14 23:14:11
LQ_CLOSE
37,232,884
In Python: How to remove an object from a list if it is only referenced in that list?
<p>I want to keep track of objects of a certain type that are currently in use. For example: Keep track of all instances of a class or all classes that have been created by a metaclass.</p> <p>It is easy to keep track of instances like this:</p> <pre><code>class A(): instances = [] def __init__(self): self.instances.append(self) </code></pre> <p>But if an instance is not referenced anywhere outside of that list it will not be needed anymore and I do not want to process that instance in a potentially time consuming loop.</p> <p>I tried to remove objects that are only referenced in the list using sys.getrefcount.</p> <pre><code>for i in A.instances: if sys.getrefcount(i) &lt;=3: # in the list, in the loop and in getrefcount # collect and remove after the loop </code></pre> <p>The problem I have is that the reference count is very obscure. Opening a new shell and creating a dummy class with no content returns 5 for</p> <pre><code>sys.getrefcount(DummyClass) </code></pre> <p>Another idea is to copy the objects then deleting the list and checking which objects have been scheduled for garbage collecting and in the last step removing those objects. Something like:</p> <pre><code>Copy = copy(A.instances) del A.instances A.instances = [i for i in Copy if not copy_of_i_is_in_GC(i)] </code></pre> <p>The objects don't have to be removed immediately when the reference count goes to 0. I just don't want to waste too much ressources on objects that are not used anymore.</p>
<python><list><object><reference><garbage-collection>
2016-05-14 23:21:08
HQ
37,233,934
Swift NSURLConnection deprecated in iOS 9.0
<p>I am trying to do a URL request to an api and return the results.</p> <p>I am using NSURLConnection in Swift 2</p> <pre><code>let requestString = "URL HERE" let urlPath: String = requestString let url: NSURL = NSURL(string: urlPath)! let request: NSURLRequest = NSURLRequest(URL: url) let connection: NSURLConnection = NSURLConnection(request: request, delegate: self, startImmediately: true)! connection.start() </code></pre> <p>but I keep getting this warning:</p> <pre><code>'init(request:delegate:startImmediately:)' was deprecated in iOS 9.0: Use NSURLSession (see NSURLSession.h) </code></pre> <p>I googled the warning and came up with nothing....how do I fix this?</p>
<ios><swift><swift2>
2016-05-15 02:30:28
LQ_CLOSE
37,234,089
Tallying values in single column and separating into Rows in R
<p>I have a single row of numbers. I'm wondering how I can separate it out so that it outputs columns that total the tally of each set of numbers. I've tried playing around with "separate" but I can't figure out how to make it work. </p> <pre><code>Here's my data frame: 2 2 2 2 2 4 4 4 I'd like it to be 2 4 5 3 </code></pre>
<r>
2016-05-15 02:54:17
LQ_CLOSE
37,234,877
Upload from camera and gallery is not working properly in all the versions
<p>I am trying number of tutorials and sample codes for take an image from gallery or camera then crop the image and upload it to server. I was implemented the code for that in that code am facing few problems the are.</p> <ol> <li>In pre Lollipop devices when I crop the image using photos app the image is not getting reflected in image view but it's showing the message as image saved..</li> <li>In nexus phone both camera and gallery is not working.</li> <li><blockquote> <p>5.0 versions in few devices when I crop the image am getting the image like shown below <a href="https://i.stack.imgur.com/vBsgi.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/vBsgi.jpg" alt="image"></a></p> </blockquote></li> </ol> <p>below is my code snippet.`</p> <pre><code>public void getPhoto() { final String[] items = new String[] { "Take from camera", "Select from gallery" }; ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(getActivity(), android.R.layout.select_dialog_item, items); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Select Image"); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { // pick from // camera if (item == 0) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra( "android.intent.extras.CAMERA_FACING", android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT); mImageCaptureUri = Uri.fromFile(new File(Environment .getExternalStorageDirectory(), "tmp_avatar_" + String.valueOf(System.currentTimeMillis()) + ".jpg")); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageCaptureUri); try { intent.putExtra("return-data", true); startActivityForResult(intent, PICK_FROM_CAMERA); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } else { // pick from file Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); // startActivityForResult(intent, SELECT_PICTURE); startActivityForResult(intent, PICK_FROM_FILE); } } }); final AlertDialog dialog = builder.create(); dialog.show(); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != Activity.RESULT_OK) return; switch (requestCode) { case PICK_FROM_CAMERA: doCrop(); break; case PICK_FROM_FILE: mImageCaptureUri = data.getData(); doCrop(); break; case CROP_FROM_CAMERA: Bundle extras = data.getExtras(); if (extras != null) { photo = extras.getParcelable("data"); profile_image = encodeTobase64(photo); saveType = "photo"; try { JSONObject obj = new JSONObject(); obj.put("user_id", user_id); obj.put("mode", saveType); obj.put("photo", profile_image); obj.put("is_profile", 1); saveResponse(obj); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } File f = new File(mImageCaptureUri.getPath()); if (f.exists()) f.delete(); break; } } private void doCrop() { final ArrayList&lt;CropOption&gt; cropOptions = new ArrayList&lt;CropOption&gt;(); Intent intent = new Intent("com.android.camera.action.CROP"); intent.setType("image/*"); List&lt;ResolveInfo&gt; list = getActivity().getPackageManager() .queryIntentActivities(intent, 0); int size = list.size(); if (size == 0) { Toast.makeText(getActivity(), "Can not find image crop app", Toast.LENGTH_SHORT).show(); return; } else { intent.setData(mImageCaptureUri); intent.putExtra("crop", "true"); intent.putExtra("outputX", 300); intent.putExtra("outputY", 300); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("scale", true); intent.putExtra("circleCrop", new String("")); intent.putExtra("return-data", true); if (size == 1) { Intent i = new Intent(intent); ResolveInfo res = list.get(0); i.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); startActivityForResult(i, CROP_FROM_CAMERA); } else { for (ResolveInfo res : list) { final CropOption co = new CropOption(); co.title = getActivity().getPackageManager() .getApplicationLabel( res.activityInfo.applicationInfo); co.icon = getActivity().getPackageManager() .getApplicationIcon( res.activityInfo.applicationInfo); co.appIntent = new Intent(intent); co.appIntent .setComponent(new ComponentName( res.activityInfo.packageName, res.activityInfo.name)); cropOptions.add(co); } CropOptionAdapter adapter = new CropOptionAdapter( getActivity(), cropOptions); AlertDialog.Builder builder = new AlertDialog.Builder( getActivity()); builder.setTitle("Choose Crop App"); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { startActivityForResult( cropOptions.get(item).appIntent, CROP_FROM_CAMERA); } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (mImageCaptureUri != null) { getActivity().getContentResolver().delete( mImageCaptureUri, null, null); mImageCaptureUri = null; } } }); AlertDialog alert = builder.create(); alert.show(); } } } public String encodeTobase64(Bitmap image) { Bitmap immagex = image; ByteArrayOutputStream baos = new ByteArrayOutputStream(); immagex.compress(Bitmap.CompressFormat.JPEG, 100, baos); image_Array = baos.toByteArray(); String imageEncoded = Base64 .encodeToString(image_Array, Base64.DEFAULT); return imageEncoded; } </code></pre> <p>` </p> <p>comment below before duplicating this question because i was checked a lot but didn't find any solution for this, please let me know if you need more information.</p>
<android><android-camera><image-uploading><android-gallery><android-camera-intent>
2016-05-15 05:27:13
HQ
37,234,969
Is it correct to return null shared_ptr?
<p>For example, there is a function that finds an object and returns shared_ptr if object is found, and must indicate somehow that no object was found.</p> <pre><code>std::vector&lt;std::shared_ptr&gt; Storage::objects; std::shared_ptr&lt;Object&gt; Storage::findObject() { if (objects.find) { return objects[x]; } else { return nullptr; } } std::shared_ptr&lt;Object&gt; obj = Storage::findObject(); if (obj) { print("found"); } else { print("not found"); } </code></pre> <ol> <li><p>Is it correct to return shared_ptr implicitly initialized with nullptr like in upper example? It will work, but can be it done this way? Or should I return shared_ptr default constructed instead?</p></li> <li><p>What in case it would be weak_ptr? What is proper way to check that empty weak_ptr has been returned? by weak_ptr::expired function or are there other ways? If checking by weak_ptr::expired is the only way then how can I distinguish that function returned empty pointer, or object was just deleted(multi-thread environment)?</p></li> </ol>
<c++><shared-ptr><smart-pointers><weak-ptr>
2016-05-15 05:42:59
HQ
37,235,170
How can I pass a generic type parameter to an Angular2 component?
<p>Let's say I got a component with a fixed input parameter type,</p> <pre><code>@Component({ selector: 'fixed', template: '&lt;div&gt;{{value}}&lt;/div&gt;' }) export class FixedComponent { @Input() value: string; } </code></pre> <p>How do I go about making that parameter type generic, i.e.</p> <pre><code>@Component({ selector: 'generic', template: '&lt;div&gt;{{value}}&lt;/div&gt;' }) export class GenericComponent&lt;T&gt; { @Input() value: T; } </code></pre> <p>That is, how do I pass the type in the template of the parent component?</p> <pre><code>&lt;generic ...&gt;&lt;/generic&gt; </code></pre>
<angular><angular2-template>
2016-05-15 06:16:23
HQ
37,236,056
in c# Pass selected row one gridview to another gridview on another form
private void btnpass_Click(object sender, EventArgs e) { Inventory coo = new Inventory(dataGridView1.SelectedRows[0].Cells[0].Value.ToString(), dataGridView1.SelectedRows[0].Cells[1].Value.ToString(), dataGridView1.SelectedRows[0].Cells[2].Value.ToString(), dataGridView1.SelectedRows[0].Cells[3].Value.ToString(), dataGridView1.SelectedRows[0].Cells[4].Value.ToString(), dataGridView1.SelectedRows[0].Cells[5].Value.ToString(), dataGridView1.SelectedRows[0].Cells[6].Value.ToString()); coo.Show(); } Itried Pass selected row gridview to another gridview on another form but show error. error is (Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index) i use different method but not my problem solve
<c#>
2016-05-15 08:27:24
LQ_EDIT
37,236,206
Run artisan command in laravel 5
<p>I have controller like this</p> <pre><code> public function store(Request $request) { Artisan::call("php artisan infyom:scaffold {$request['name']} --fieldsFile=public/Product.json"); } </code></pre> <p>Show me error </p> <blockquote> <p>There are no commands defined in the "php artisan infyom" namespace.</p> </blockquote> <p>When I run this command in CMD it work correctly </p>
<php><laravel><laravel-5><laravel-5.2><artisan>
2016-05-15 08:45:02
HQ
37,236,381
Difference between Calendar.HOUR and Calendar.HOUR_OF_DAY?
<p>What is the difference between <code>Calendar.HOUR</code> and <code>Calendar.HOUR_OF_DAY</code> ? When to use <code>Calendar.HOUR</code> and <code>Calendar.HOUR_OF_DAY</code> ? I am confused sometime <code>Calendar.HOUR</code> this works fine and othertime <code>Calendar.HOUR_OF_DAY</code> this works fine. What they return in the form of int? I have read <a href="http://developer.android.com/reference/java/util/Calendar.html">this</a> documentation but not understood the difference. Any suggestions Thanks.</p>
<java><android><calendar>
2016-05-15 09:03:51
HQ
37,236,691
Can we use angularjs for job portals?
<p>For job portals, do we make SEO? If we use angularjs for jobportal site, will it make any issues on SEO?</p> <p>Kindly help me to get an idea on this. Thanks in advance</p>
<angularjs><asp.net-mvc>
2016-05-15 09:38:27
LQ_CLOSE
37,236,747
How can i print a line of an html with python keeping the right format?
I have this code: ENSG00000001461'&nbsp';'&nbsp';'&nbsp';'&nbsp';ENST00000432012'&nbsp';'&nbsp';'&nbsp';'&nbsp';NIPAL3'&nbsp';'&nbsp';'&nbsp';'&nbsp';5'&nbsp';'&nbsp';'&nbsp';'&nbsp';1'&nbsp';'&nbsp';'&nbsp';'&nbsp';Forward'&nbsp';'&nbsp';'&nbsp';'&nbsp';NIPA-like domain containing 3 [Source:HGNC Symbol;Acc:HGNC:25233]<'br /'> I want this output: ENSG00000001461 ENST00000432012 NIPAL3 5 1 Forward NIPA-like domain containing 3 [Source:HGNC Symbol;Acc:HGNC:25233] But the output is only: ENSG00000001461 Thanks, Federico
<python><beautifulsoup>
2016-05-15 09:45:33
LQ_EDIT
37,236,890
One domain multiple servers
<p>I have a domain <strong>mydomain.com</strong></p> <p>I need to use this domain on multiple servers. I have greengeeks shared hosting as well as AWS with few EC2 machines for my web applications.</p> <p>mydomain.com is hosting a marketing site via greengeeks hosting and it also provides my email server. </p> <p>I want one sub domain app.mydomain.com that will point to one of my ec2 instance, another subdomain appadmin.mydomain.com point to another ec2 instance, What is the best way to setup domains and sub-domains like this. (currently i am using different domain (mydomain.org) for my aws instance, which isn't elegant)</p> <p>As my mail server is on greengeeks, and I programatically send email from my ec2 app server using an email id app@mydomain.com, some email clients shows warning as "cannot verify email origin" and some pushes it in spam folder, is there a solution to it, I read about MX and SPF record but I am confused how to create them and where to put them.</p> <p>Thanks, K</p>
<email><amazon-ec2><web-hosting><ubuntu-server>
2016-05-15 10:00:13
LQ_CLOSE
37,236,892
Force `stack` to rebuild an installed package
<p>I often install a package which depends on external libraries and manage to move those external libraries to other locations afterwards, so that compiled programs exit with a loader error.</p> <p>In those cases I just want stack to rebuild an already installed package, but I don't see how that is possible. <code>stack install --force-dirty</code> doesn't seem to work, as it just tries to rebuild the project in the current working directory.</p> <hr> <p>Recent example:</p> <p>I'd liked to see whether <code>regex-pcre</code> requires a C library not present on Windows systems, so I hit <code>stack install regex-pcre</code>. That went fine, but then I realized I installed <code>mingw-w64-x86_64-pcre</code> via <code>stack</code>s <code>pacman</code> prior to this. I removed it again via <code>pacman -R</code> and tried to run <code>stack install regex-pcre</code> again, which did not rebuild it. Neither did adding <code>--force-dirty</code> work for the above reason.</p>
<haskell><haskell-stack>
2016-05-15 10:00:17
HQ
37,237,336
Binary Search Tree? Algorithm
<p>Does anyone know how to make an algorithm that transforms a binary search tree into an AVL tree, and yes transform it and not make another tree (so it will only be done using rotations) and not with the DSW technique... and in C. The tricky part here is that there is lots of cases since a binary search tree can be unbalanced in various ways and there being 4 types of rotations.</p>
<search>
2016-05-15 10:49:37
LQ_CLOSE
37,237,850
Typescript - Allowed values for a property
<p>What it the best way in Typescript to only allow a number of value for a property ?</p> <pre class="lang-js prettyprint-override"><code>class Foo { public type:string; // Possible values for type: ['foo1', 'foo2', 'foo3'] constructor() {} } </code></pre> <p>I'd like to make those types the only allowed types, preventing me to put a wrong type when extending Foo class.</p>
<typescript>
2016-05-15 11:44:24
HQ
37,237,855
Add name os file to Array of strings
I have this code witch detect file on usb, I want to add the name of the files to array list of strings, how can I continue? final String CP = "cp "; final String DEST = " /home/user/Desktop"; final String TERMINAL_COMMAND = "ls /media/user/"; String USB_UUID = null; //System.out.println(TERMINAL_COMMAND); try { Process p = Runtime.getRuntime().exec( TERMINAL_COMMAND ); BufferedReader in = new BufferedReader( new InputStreamReader(p.getInputStream()) ); while ((USB_UUID = in.readLine()) != null) { //System.out.println(USB_UUID); final String FILETOSTART = "/media/user/"+USB_UUID; } in.close(); }
<java><string>
2016-05-15 11:44:55
LQ_EDIT
37,238,699
Python mock.patch: replace a method
<p>I'd like to replace a method in a class with mock:</p> <pre><code>from unittest.mock import patch class A(object): def method(self, string): print(self, "method", string) def method2(self, string): print(self, "method2", string) with patch.object(A, 'method', side_effect=method2): a = A() a.method("string") a.method.assert_called_with("string") </code></pre> <p>...but I get insulted by the computer:</p> <pre><code>TypeError: method2() missing 1 required positional argument: 'string' </code></pre>
<python><mocking>
2016-05-15 13:10:06
HQ
37,238,846
Have an "'Resource.Attribute' does not contain a definition for 'actionBarSize'" error
<p>Was trying to debug an empty app and got "'Resource.Attribute' does not contain a definition for 'actionBarSize'" error. I have reinstalled android SDK's.</p> <pre><code> public static void UpdateIdValues() { global::Xamarin.Forms.Platform.Android.Resource.Attribute.actionBarSize = global::L1NQ.Droid.Resource.Attribute.actionBarSize; } public partial class Attribute { static Attribute() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); } private Attribute() { } } </code></pre>
<c#><xamarin.forms><xamarin-studio>
2016-05-15 13:24:04
HQ
37,239,759
Tools/Solutions :Remote push notifications iOS for users
<p>I've got a database who store the device Token, country Code and language of my users and I need to send remote notifications for all the user. What kind of tool can I used to send all notifications by country with a batch?</p> <p>Thanks,</p>
<ios><push-notification><apple-push-notifications><apn>
2016-05-15 14:53:05
LQ_CLOSE
37,239,881
Create implementation of Java class dynamically based on provided dependencies at runtime
<p>I'm trying to determine the best way to create a new instance of a class based on which classes are available on the classpath at runtime.</p> <p>For example, I have a library that requires a JSON response to be parsed in multiple classes. The library has the following interface:</p> <p><code>JsonParser.java</code>:</p> <pre><code>public interface JsonParser { &lt;T&gt; T fromJson(String json, Class&lt;T&gt; type); &lt;T&gt; String toJson(T object); } </code></pre> <p>This class has multiple implementations, i.e. <code>GsonJsonParser</code>, <code>JacksonJsonParser</code>, <code>Jackson2JsonParser</code>, and currently, the user of the library is required to "pick" their implementation to be used based on which library they've included in their project. For example:</p> <pre><code>JsonParser parser = new GsonJsonParser(); SomeService service = new SomeService(parser); </code></pre> <p>What I'd like to do, is dynamically pick up which library is on the classpath, and create the proper instance, so that the user of the library doesn't have to think about it (or even have to know the internal implementation of another class parses JSON).</p> <p>I'm considering something similar to the following:</p> <pre><code>try { Class.forName("com.google.gson.Gson"); return new GsonJsonParser(); } catch (ClassNotFoundException e) { // Gson isn't on classpath, try next implementation } try { Class.forName("com.fasterxml.jackson.databind.ObjectMapper"); return new Jackson2JsonParser(); } catch (ClassNotFoundException e) { // Jackson 2 was not found, try next implementation } // repeated for all implementations throw new IllegalStateException("You must include either Gson or Jackson on your classpath to utilize this library"); </code></pre> <p>Would this be an appropriate solution? It seems kind of like a hack, as well as uses exceptions to control the flow.</p> <p>Is there a better way to do this?</p>
<java>
2016-05-15 15:05:47
HQ
37,239,887
how to use mutiple inner joins
How can I create a single sql comman to display the statements of accounts of one of the customer using inner join? help please, thanks. [![enter image description here][1]][1] [1]: http://i.stack.imgur.com/pes5w.png
<mysql><sql>
2016-05-15 15:06:34
LQ_EDIT
37,239,911
D3.js add heading to graph
I want to add heading to my graph. Something like this : [What i want to achieve...][1] I have tried append.svg , append.text....etc but nothing seems to work. I,m just not able to write the correct CSS for this i guess. This code here works: header= d3.select("svg").append("text") .attr("x", 70) .attr("y", 20) .style("font-size", "16px") .style("text-decoration", "underline") .text("My graph heading..."); but i have problems in this one as i am unable to assign it width and height and background fill. When i assign it width or height it just does,nt gets applied. Also changing the display to block is not working... Running the code above makes a figure like this : [My current graph picture...][2] [1]: http://i.stack.imgur.com/lkREE.png [2]: http://i.stack.imgur.com/CRsGH.png
<javascript><css><d3.js><svg>
2016-05-15 15:08:39
LQ_EDIT
37,240,287
Can I create multiple canvas elements on same page using p5js
<p>I tried using p5js to draw some points it does work well but I also wanted another canvas element which can show the live video from camera. When I added another canvas element the first canvas goes blank. For now I tried using multiple javascript files to process different canvas.</p> <p>camera.js</p> <pre><code>var capture; function setup() { var video=createCanvas(390, 240); capture = createCapture(VIDEO); capture.size(320, 240); capture.hide(); //set parent to div with id left video.parent("left"); } function draw() { background(255); image(capture, 0, 0, 320, 240); filter('INVERT'); } </code></pre> <p>drawshapes.js</p> <pre><code>function setup() { // Create the canvas var plot=createCanvas(720, 400); background(200); //set parent to div with id right plot.parent("right"); // Set colors fill(204, 101, 192, 127); stroke(127, 63, 120); // A rectangle rect(40, 120, 120, 40); // An ellipse ellipse(240, 240, 80, 80); // A triangle triangle(300, 100, 320, 100, 310, 80); // A design for a simple flower translate(580, 200); noStroke(); for (var i = 0; i &lt; 10; i ++) { ellipse(0, 30, 20, 80); rotate(PI/5); } } </code></pre> <p>index.html</p> <pre><code>&lt;div class="container"&gt; &lt;div id="left"&gt;&lt;/div&gt; &lt;div id="right"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre>
<javascript><jquery><html5-canvas>
2016-05-15 15:43:16
HQ
37,240,621
Django-Rest-Framework. Updating nested object
<p>I'm having a problem of updating a nested object.</p> <p>So I have a model which structure is similar to this one:</p> <pre><code>class Invoice(models.Model): nr = models.CharField(max_length=100) title = models.CharField(max_length=100) class InvoiceItem(models.Model): name = models.CharField(max_length=100) price = models.FloatField() invoice = models.ForeignKey(Invoice, related_name='items') </code></pre> <p>I need to create child objects from parent, and what I mean by that, is to create <code>InvoiceItems</code> directly when creating an <code>Invoice</code> object. For this purpose, I've wrote the following serializers:</p> <pre><code>class InvoiceItemSerializer(serializers.ModelSerializer): invoice = serializers.PrimaryKeyRelatedField(queryset=Invoice.objects.all(), required=False) class Meta: model = InvoiceItem class InvoiceSerializer(serializers.ModelSerializer): items = InvoiceItemSerializer(many=True) class Meta: model = Invoice def create(self, validated_data): items = validated_data.pop('items', None) invoice = Invoice(**validated_data) invoice.save() for item in items: InvoiceItem.objects.create(invoice=invoice, **item) return invoice </code></pre> <p>Up till now, the create/read/delete methods work perfectly, except the <code>update</code>. I think the below logic should be correct, but it misses something.</p> <pre><code>def update(self, instance, validated_data): instance.nr = validated_data.get('nr', instance.nr) instance.title = validated_data.get('title', instance.title) instance.save() # up till here everything is updating, however the problem appears here. # I don't know how to get the right InvoiceItem object, because in the validated # data I get the items queryset, but without an id. items = validated_data.get('items') for item in items: inv_item = InvoiceItem.objects.get(id=?????, invoice=instance) inv_item.name = item.get('name', inv_item.name) inv_item.price = item.get('price', inv_item.price) inv_item.save() return instance </code></pre> <p>Any help would be really appreciated.</p>
<python><django><rest><django-rest-framework>
2016-05-15 16:12:18
HQ
37,241,037
Create Round Button with Border IN UWP Windows 10 C#
<p>I am trying to create a round button, with a White Border and a Transparent Background (as the old AppBarButtons in Windows 8.1) in UWP Windows 10. </p> <p>I have found several samples like these:</p> <p><a href="https://comentsys.wordpress.com/2015/05/23/windows-10-universal-windows-platform-custom-button/" rel="noreferrer">https://comentsys.wordpress.com/2015/05/23/windows-10-universal-windows-platform-custom-button/</a></p> <p><a href="https://social.msdn.microsoft.com/Forums/sqlserver/en-US/cda7a526-5e99-4d4a-a73c-0be4ce77f961/uwpwindows10-how-to-make-button-with-round-edges?forum=wpdevelop&amp;prof=required" rel="noreferrer">https://social.msdn.microsoft.com/Forums/sqlserver/en-US/cda7a526-5e99-4d4a-a73c-0be4ce77f961/uwpwindows10-how-to-make-button-with-round-edges?forum=wpdevelop&amp;prof=required</a> </p> <p>But the problem is with the Border. When I setting the BorderBrush to a certain color, it turns out the Border is for Button's "Rectangle".</p> <p>Is there a way I can create a Round border for a button?</p>
<c#><xaml><button><win-universal-app>
2016-05-15 16:50:49
HQ
37,241,060
Python 3.5 Pandas
i have a two diff frames df1.csv Reg1 Reg2 aaa eee bbb fff ccc ggg ddd hhh df2.csv Reg,Rank aaa,1 bbb,3 ccc,4 ddd,5 eee,7 fff,9 ggg,10 hhh,11 newfram.csv Reg1,Rank1,Reg2,Rank2 aaa,1,eee,7 bbb,3,fff,9 ccc,4,ggg,10 ddd,5,hhh,11 How do I acheive the newdata frame in pandas? but in native python it takes much time since it has huge no of rows.
<python><pandas><dataframe>
2016-05-15 16:52:59
LQ_EDIT
37,241,065
Mysql field type for </textarea>?
<p>I have a mysql field type "tinytext" and am using performing and update via my form with following extract:</p> <pre><code>&lt;!-- Text input &lt;div class="control-group"&gt; &lt;label class="control-label" for="myinput"&gt; Input code&lt;/label&gt; &lt;div class="controls"&gt; &lt;textarea class="form-control" id="myinput" name="myinput" rows="4" &gt;&lt;?php echo $myinput;?&gt; &lt;/textarea&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>However the field is not recieving the data properly. What mysql field type do I use for a textarea of about 4 lines?</p>
<php><html><mysql>
2016-05-15 16:53:30
LQ_CLOSE
37,241,957
MySql: join two table and get not common data
I have two tables all_jobs and jobs_applied. Problem is i want to get the list of jobs from all_jobs table. At the moment i have this query but it is only giving me common records from both table. SELECT b.uid,a.jobtitle, a.job_id, FROM job_posting a left join job_applied b on a.job_id = b.job_id Where b.uid != 10 and disable=0 and draft =0 Can anybody advise me on this? Thanks
<mysql>
2016-05-15 18:14:35
LQ_EDIT
37,242,227
Phalcon -¿BeforeSave not receive data before saving?
I want to validate before saving if the variable "$ CONT_CEDULA" meets the requirements otherwise not be saved. But when saving is as if the variable "$ CONT_CEDULA" not send data. I want to know if I'm doing well or some other event or function. The "echo" Initial no data > Blockquote public function beforeSave() { echo $this->$CONT_CEDULA; switch (strlen($this->$CONT_CEDULA)) { case 10: return validarCI($this->$CONT_CEDULA); break; case 13: return validarRUC($this->$CONT_CEDULA); break; default: echo "Numero de caracteres invalidos" ; return FALSE; } <pre> <?php class SpmContacto extends \Phalcon\Mvc\Model { public $CONT_CODIGO; public $CONT_CEDULA; public $CONT_RUCIDE; public $CONT_NOMBRE; public $CON_ESTADO; public $CONT_TELEFO; public $CONT_DIRECC; public $CONT_AREA; public $CONT_CARGO; public $CONT_TIPOXX; public $CONT_EMAIL; public $CONT_USUARIO; public $CONT_CLAVE; public $CONT_CLAVEE; public $CONT_FECNACI; public $CONT_FECINSC; public $CONT_TIPOCODIGO; /** * Initialize method for model. */ public function initialize() { $this->setSchema("SPOLS"); $this->hasMany('CONT_CODIGO', 'SPMREFERENCIA', 'CONT_CODIGO', array('alias' => 'SPMREFERENCIA')); $this->hasMany('CONT_CODIGO', 'SPTDETALLE', 'CONT_CODIGO', array('alias' => 'SPTDETALLE')); $this->hasMany('CONT_CODIGO', 'SPTENCABEZADO', 'CONT_CODIGO', array('alias' => 'SPTENCABEZADO')); } function validarCI($strCedula) { $suma = 0; $strOriginal = $strCedula; $intProvincia = substr($strCedula, 0, 2); $intTercero = $strCedula[2]; $intUltimo = $strCedula[9]; if (!settype($strCedula, "float")) return FALSE; if ((int) $intProvincia < 1 || (int) $intProvincia > 23) return FALSE; if ((int) $intTercero == 7 || (int) $intTercero == 8) return FALSE; for ($indice = 0; $indice < 9; $indice++) { //echo $strOriginal[$indice],'</br>'; switch ($indice) { case 0: case 2: case 4: case 6: case 8: $arrProducto[$indice] = $strOriginal[$indice] * 2; if ($arrProducto[$indice] >= 10) $arrProducto[$indice] -= 9; //echo $arrProducto[$indice],'</br>'; break; case 1: case 3: case 5: case 7: $arrProducto[$indice] = $strOriginal[$indice] * 1; if ($arrProducto[$indice] >= 10) $arrProducto[$indice] -= 9; //echo $arrProducto[$indice],'</br>'; break; } } foreach ($arrProducto as $indice => $producto) $suma += $producto; $residuo = $suma % 10; $intVerificador = $residuo == 0 ? 0 : 10 - $residuo; return ($intVerificador == $intUltimo ? TRUE : FALSE); } function validarRUC($strRUC) { if (strlen($strRUC) != 13) return FALSE; $suma = 0; $strOriginal = $strRUC; $intProvincia = substr($strRUC, 0, 2); $intTercero = $strRUC[2]; if (!settype($strRUC, "float")) return FALSE; if ((int) $intProvincia < 1 || (int) $intProvincia > 23) return FALSE; if ((int) $intTercero != 6 && (int) $intTercero != 9) { if (substr($strRUC, 10, 3) == '001') return validarCI(substr($strRUC, 0, 10)); return FALSE; } if ((int) $intTercero == 6) { $intUltimo = $strOriginal[8]; for ($indice = 0; $indice < 9; $indice++) { //echo $strOriginal[$indice],'</br>'; switch ($indice) { case 0: $arrProducto[$indice] = $strOriginal[$indice] * 3; break; case 1: $arrProducto[$indice] = $strOriginal[$indice] * 2; break; case 2: $arrProducto[$indice] = $strOriginal[$indice] * 7; break; case 3: $arrProducto[$indice] = $strOriginal[$indice] * 6; break; case 4: $arrProducto[$indice] = $strOriginal[$indice] * 5; break; case 5: $arrProducto[$indice] = $strOriginal[$indice] * 4; break; case 6: $arrProducto[$indice] = $strOriginal[$indice] * 3; break; case 7: $arrProducto[$indice] = $strOriginal[$indice] * 2; break; case 8: $arrProducto[$indice] = 0; break; } } } else { $intUltimo = $strOriginal[9]; for ($indice = 0; $indice < 9; $indice++) { //echo $strOriginal[$indice],'</br>'; switch ($indice) { case 0: $arrProducto[$indice] = $strOriginal[$indice] * 4; break; case 1: $arrProducto[$indice] = $strOriginal[$indice] * 3; break; case 2: $arrProducto[$indice] = $strOriginal[$indice] * 2; break; case 3: $arrProducto[$indice] = $strOriginal[$indice] * 7; break; case 4: $arrProducto[$indice] = $strOriginal[$indice] * 6; break; case 5: $arrProducto[$indice] = $strOriginal[$indice] * 5; break; case 6: $arrProducto[$indice] = $strOriginal[$indice] * 4; break; case 7: $arrProducto[$indice] = $strOriginal[$indice] * 3; break; case 8: $arrProducto[$indice] = $strOriginal[$indice] * 2; break; } } } foreach ($arrProducto as $indice => $producto) $suma += $producto; $residuo = $suma % 11; $intVerificador = $residuo == 0 ? 0 : 11 - $residuo; //echo "$intVerificador == $intUltimo"; return ($intVerificador == $intUltimo ? TRUE : FALSE); } function validarID($strId) { switch (strlen($strId)) { case 10: return validarCI($strId); break; case 13: return validarRUC($strId); break; default: return FALSE; } } public function beforeSave() { echo $this->$CONT_CEDULA; switch (strlen($this->$CONT_CEDULA)) { case 10: return validarCI($this->$CONT_CEDULA); break; case 13: return validarRUC($this->$CONT_CEDULA); break; default: echo "Numero de caracteres invalidos"; return FALSE; } //echo $op; } public function getSource() { return 'SPM_CONTACTO'; } public static function find($parameters = null) { return parent::find($parameters); } public static function findFirst($parameters = null) { return parent::findFirst($parameters); } </pre>
<php><phalcon><before-save>
2016-05-15 18:39:38
LQ_EDIT
37,242,316
I don't understand why "Null pointer Exception" in Unity?
<p>in my C# lives class I have a class attribute: public int life = 0; and in my C# loose class (so, another script), I want to access to my life attribute of my lives class, but i don't succeed, how to do it ?</p> <p>When I do</p> <pre><code>var lv = new lives (); int lv1 = lv.life; </code></pre> <p>It shows me that Unity does not allow. I MUST use GetComponent</p> <p>so I do with get component</p> <pre><code>var lv = gameObject.GetComponent&lt;lives&gt; (); int lv1 = lv.life; </code></pre> <p>And I have a null pointer exception, so it is not understandable ?</p>
<c#><unity3d>
2016-05-15 18:47:32
LQ_CLOSE
37,242,721
How do i generate a random number in c++ between 1 and 16?
<p>I don't know how to generate a random number between 1 and 16 in c++, i only know the <code>int random = rand() % 100</code> method to generate a number between 0-99. can someone help me out please?</p>
<c++>
2016-05-15 19:25:58
LQ_CLOSE