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,022,139
Android Studio: product flavor combination with more than two flavor dimensions (flavor groups)
<p>I am developing an Android application using Android Studio (v 2.1, gradle plugin v 2.1.0). My application has various versions which share a lot of common code so I decided to use flavor dimensions and product flavors to customize code and resources when and where it is requested. This worked fined as long as I only had two flavor dimensions. As an example, my <code>app.gradle</code> was</p> <pre><code>… flavorDimensions "fruit", "color" productFlavors { apple { dimension "fruit" } pear { dimension "fruit" } red { dimension "color" } yellow { dimension "color" } } … </code></pre> <p>and my <code>src</code> folder was</p> <pre><code>src/ appleRed/ appleYellow/ pearRed/ pearYellow/ </code></pre> <p>each one with a custom version of my code. Again, as an example</p> <pre><code>src/ appleRed/java/com/example/ExampleFragment.java appleYellow/java/com/example/ExampleFragment.java pearRed/java/com/example/ExampleFragment.java pearYellow/java/com/example/ExampleFragment.java </code></pre> <p>of course, there is no instance of <code>ExampleFragment</code> in <code>src/main</code>.</p> <p>At some point during development, I had to include a <em>free</em> and a <em>paid</em> version of the app. I thought that it could be easily achieved by adding a new flavor dimension named <code>version</code> and two product flavors named <code>free</code> and <code>paid</code>:</p> <pre><code> … flavorDimensions "fruit", "color”, “version” productFlavors { apple { dimension "fruit" } pear { dimension "fruit" } red { dimension "color" } yellow { dimension "color" } free { dimension "version" } paid { dimension “version” } } … </code></pre> <p>but all of a sudden the custom code generated by the combination of <code>fruit</code> and <code>color</code> was not detected by Android Studio anymore. So no <code>appleRed</code>, <code>appleYellow</code>, <code>pearRed</code> nor <code>pearYellow</code> can be used to have custom code and the only way I was able to regain my configuration was to use all the combinations of all the three flavour dimensions:</p> <pre><code> src/ appleRedFree/java/com/example/ExampleFragment.java appleRedPaid/java/com/example/ExampleFragment.java appleYellowFree/java/com/example/ExampleFragment.java appleYellowPaid/java/com/example/ExampleFragment.java pearRedFree/java/com/example/ExampleFragment.java pearRedPaid/java/com/example/ExampleFragment.java pearYellowFree/java/com/example/ExampleFragment.java pearYellowPaid/java/com/example/ExampleFragment.java </code></pre> <p>This is not good because <code>ExampleFragment</code> is duplicated across the same <code>fruitColor*</code> combination (<code>appleRedFree</code>, <code>appleRedPaid</code> have the same <code>ExampleFragment</code>). Same problem happens for resources (the ones in <code>res</code> folder).</p> <p>My questions are: </p> <p>1) Is this the expected behaviour from gradle in Android Studio (<em>i.e.</em>, not being able to combine a subset of product flavors, following their priority based on their dimension, when having more than two flavour dimensions)?</p> <p>2) Given the fact that this is the expected behaviour, is there another way I can achieve my customisation without duplicated code or without having a single file with an <em>if-statement</em> inside (<em>e.g.</em>, <code>if (BuildConfig.FLAVOR_version == "free") ...</code>) ? </p> <p>Please note that I’m talking about having custom code which could be complex, so I’m not asking for basic customisation like a build config variable, variant filtering, or something like that.</p>
<android><android-studio><android-gradle-plugin><android-productflavors><android-flavordimension>
2016-05-04 08:18:05
HQ
37,022,460
Best practies CodeIgniter Templating
<p>I'm using CodeIgniter for few years for my PHP project. Now I'm thinking how improve my view folder structure, using best practies.</p> <p>I'll explain better. Basically I divide my webpage into 3 view: </p> <ul> <li>Header (/view/inc/header.php)</li> <li>SomeContent (/view/content_of_myView)</li> <li>Footer (/view/inc/footer.php)</li> </ul> <p>My question is very simple: is this the best way? Or there are differents method to generate an header, maybe loading dinamycally all css/js assets with versioning? I don't want to use any template engine, sincerely I don't like very much.</p>
<php><css><codeigniter>
2016-05-04 08:34:34
LQ_CLOSE
37,022,526
Angular 2 - 404 traceur not found
<p>I've followed the starting guide and expanded a little upon for a previous angular 2 version. I've updated my revision and changed everything accordingly. When I am running the web server I now receive the error 404 for traceur... <a href="https://i.stack.imgur.com/hHyvT.png"><img src="https://i.stack.imgur.com/hHyvT.png" alt="Error 404 for traceur"></a></p> <p>Here is my project structure: <a href="https://i.stack.imgur.com/PoHLC.png"><img src="https://i.stack.imgur.com/PoHLC.png" alt="Project structure"></a></p> <p>Relevant files : </p> <p>Index.html:</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;title&gt;Kinepolis HR-tool&lt;/title&gt; &lt;base href="./"&gt; &lt;meta charset="utf-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;meta name="description" content="Kinepolis HR tool"&gt; &lt;meta name="author" content="Jeffrey Devloo!"&gt; &lt;link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css" /&gt; &lt;!-- CSS for PrimeUI --&gt; &lt;!-- 1. Load libraries --&gt; &lt;!-- Polyfill(s) for older browsers --&gt; &lt;script src="node_modules/es6-shim/es6-shim.min.js"&gt;&lt;/script&gt; &lt;script src="node_modules/zone.js/dist/zone.js"&gt;&lt;/script&gt; &lt;script src="node_modules/reflect-metadata/Reflect.js"&gt;&lt;/script&gt; &lt;script src="node_modules/systemjs/dist/system.src.js"&gt;&lt;/script&gt; &lt;!-- 2. Configure SystemJS --&gt; &lt;script src="systemjs.config.js"&gt;&lt;/script&gt; &lt;script&gt; System.import('app').catch(function(err){ console.error(err); }); &lt;/script&gt; &lt;/head&gt; &lt;!-- 3. Display the application --&gt; &lt;body&gt; &lt;my-app&gt;Loading...&lt;/my-app&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>systemjs.config.js</p> <pre><code>(function(global) { // map tells the System loader where to look for things var map = { 'app': 'app', // 'dist', 'rxjs': 'node_modules/rxjs', 'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', '@angular': 'node_modules/@angular', }; // packages tells the System loader how to load when no filename and/or no extension var packages = { 'app': { main: 'main.js', defaultExtension: 'js' }, 'rxjs': { defaultExtension: 'js' }, 'angular2-in-memory-web-api': { defaultExtension: 'js' }, }; var packageNames = [ '@angular/common', '@angular/compiler', '@angular/core', '@angular/http', '@angular/platform-browser', '@angular/platform-browser-dynamic', '@angular/router', '@angular/router-deprecated', '@angular/testing', '@angular/upgrade', ]; // add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' } packageNames.forEach(function(pkgName) { packages[pkgName] = { main: 'index.js', defaultExtension: 'js' }; }); var config = { map: map, packages: packages } // filterSystemConfig - index.html's chance to modify config before we register it. if (global.filterSystemConfig) { global.filterSystemConfig(config); } System.config(config); })(this); </code></pre> <p>tsconfig.json</p> <pre><code> { "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false }, "exclude": [ "node_modules", "typings/main", "typings/main.d.ts" ] } </code></pre> <p>A possible issue could be <a href="https://i.stack.imgur.com/4zFPw.png"><img src="https://i.stack.imgur.com/4zFPw.png" alt="enter image description here"></a> this is boycotting my progress.</p>
<angular><http-status-code-404>
2016-05-04 08:38:16
HQ
37,022,602
How to get sum of array with "for" loop
<p>I'm a total newbie in <code>JavaScript</code>. I'm trying to learn it using programming experience in <code>Python</code>... </p> <p>Let's say there is an array of integers <code>[2,3,4,5]</code>. I want to get sum of all items in it with <code>for</code> loop. In <code>Python</code> this gonna looks like</p> <pre><code>list_sum = 0 for i in [2,3,4,5]: list_sum += i </code></pre> <p>Result is <code>14</code></p> <p>But if I try same in <code>JavaScript</code>:</p> <pre><code>var listSum = 0; for (i in [2,3,4,5]) { listSum += i; } </code></pre> <p>This will return <code>00123</code>. Seems that item indexes concatenated in a string with initial <code>listSum</code> value. How to make code works as intended and to get sum of all array items as integer?</p>
<javascript><arrays>
2016-05-04 08:41:58
LQ_CLOSE
37,022,749
Is there a hdfs command to list files in HDFS directory as per timestamp
<p>Is there a hdfs command to list files in HDFS directory as per timestamp, ascending or descending? By default, <code>hdfs dfs -ls</code> command gives unsorted list of files. </p> <p>When I searched for answers what I got was a workaround i.e. <code>hdfs dfs -ls /tmp | sort -k6,7</code>. But is there any better way, inbuilt in <code>hdfs dfs</code> commandline?</p>
<hadoop><hdfs>
2016-05-04 08:48:26
HQ
37,023,066
lodash _.contains one of multiple values in string
<p>Is there a way in lodash to check if a strings contains one of the values from an array?</p> <p>For example:</p> <pre><code>var text = 'this is some sample text'; var values = ['sample', 'anything']; _.contains(text, values); // should be true var values = ['nope', 'no']; _.contains(text, values); // should be false </code></pre>
<javascript><lodash>
2016-05-04 09:01:24
HQ
37,023,201
How can I take care that the -> is after the text
<p>I have this page : <a href="https://ticketee-wissel.c9users.io/projects/new" rel="nofollow">https://ticketee-wissel.c9users.io/projects/new</a> So you can see the arrow is now under the text. </p> <p>How can I make it work that the arrow is after the text and still see the arrow move on hover ? </p>
<css>
2016-05-04 09:08:18
LQ_CLOSE
37,023,325
mysql_error() not displaying an error in php
<p>I am trying to save error message but its not showing errors </p> <pre><code>$selectquery=mysql_query("select * from employee where eid='$eid' and name='$name' and ssn='$ssn'"); if(mysql_num_rows($selectquery)&gt;0) { $state="success"; $sql="insert into pfupload(eid1,name,ssn,state) values('$eid','$name','$ssn','$state')"; $sqlquery=mysql_query($sql); } else { $state1= mysql_error(); $sql1="insert into pfupload(eid1,name,ssn,state) values('$eid','$name','$ssn','$state1')"; mysql_query($sql1); } </code></pre>
<php><mysql>
2016-05-04 09:12:33
LQ_CLOSE
37,023,552
Shortest way to iterate over non-list?
<p>Suppose I have 3 Scanner instances which I want to close.</p> <p>I could do</p> <pre><code>sc.close() </code></pre> <p>for each of the Scanners.</p> <p>Or I could do something like</p> <pre><code>for (Scanner sc: new Scanner[]{sc1,sc2,sc3}) { sc.close(); } </code></pre> <p>Is there any shorter way of doing this with Java 8?</p> <p>Something similar to?</p> <pre><code>{sc1,sc2,sc3}.forEach((sc) -&gt; sc.close()); </code></pre>
<java><java-8>
2016-05-04 09:22:39
HQ
37,023,557
What does version name 'cp27' or 'cp35' mean in Python?
<p>What does version name 'cp27' or 'cp35' mean in Python?</p> <p>Like the files in <a href="https://pypi.python.org/pypi/gensim#downloads" rel="noreferrer">https://pypi.python.org/pypi/gensim#downloads</a></p> <p><a href="https://i.stack.imgur.com/gIQRy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gIQRy.png" alt="enter image description here"></a></p> <p>I am using Python 2.7 on a 64-bit Window 7 PC, and don't know which version of python package I should install.</p> <p>There are three questions:</p> <ol> <li><p>Which of "<strong>gensim-0.12.4-cp27-none-win_amd64.whl</strong>" or "<strong>gensim-0.12.4.win-amd64-py2.7.exe</strong>" should I install? I have installed 'WinPython-64bit-2.7.10.3' on 64-bit Window 7 PC which I am using.</p></li> <li><p>What does '<strong>cp27</strong>' mean in Python or Python version name? I searched online with keywords 'Python cp27' but failed to find any answers.</p></li> <li><p>Are there differences between these two versions of python packages? ('<strong>0.12.4-cp27-none-win_amd64</strong>' and '<strong>win-amd64-py2.7</strong>') If there are, what are the differences? </p></li> </ol>
<python><python-2.7>
2016-05-04 09:23:04
HQ
37,023,662
How to implement full calendar using angular js
<p>I want to add a event calender which is same like Full calender.How to implement angular fullcalendar in my app?.</p>
<javascript><angularjs>
2016-05-04 09:27:21
LQ_CLOSE
37,023,920
android how to get all the parameter in following response
Bundle[{custom={"custom data":{"notification_type":"offer","offer_id":4348}}, from=1013970362419, badge=1, message=birds view, android.support.content.wakelockid=4, collapse_key=do_not_collapse}] i want offer_id and notification_id , in above notification data
<android><json><notifications><response>
2016-05-04 09:37:58
LQ_EDIT
37,024,263
Getting error in Android Studio 2.1 with java 8
<p>Currently I am using <code>java 8</code> with latest <code>android studio 2.1</code></p> <p>Here is my <code>build.gradle</code> file </p> <pre><code>android { compileSdkVersion 22 buildToolsVersion "24rc3" defaultConfig { applicationId "com.name" minSdkVersion 10 targetSdkVersion 19 jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } ....... } </code></pre> <p>I am getting the below compile time error that I have no clue</p> <blockquote> <p>Error:com.android.jack.frontend.FrontendCompilationException: Failed to compile at com.android.jack.Jack.buildSession(Jack.java:892) at com.android.jack.Jack.run(Jack.java:472) at com.android.jack.api.v01.impl.Api01ConfigImpl$Api01CompilationTaskImpl.run(Api01ConfigImpl.java:102) ... 8 more Warning:Exception while processing task java.io.IOException: com.android.jack.api.v01.CompilationException: Failed to compile :oTT:compileDebugJavaWithJack FAILED Error:Execution failed for task ':oTT:compileDebugJavaWithJack'.</p> <blockquote> <p>java.io.IOException: com.android.jack.api.v01.CompilationException: Failed to compile Information:BUILD FAILED</p> </blockquote> </blockquote> <p>Please feel to ask if you need some details.</p>
<java><android><android-studio><gradle><java-8>
2016-05-04 09:53:10
HQ
37,024,314
Possible regression in G++ 6.1.0
<p>The following code</p> <pre><code>#include &lt;string&gt; #include &lt;map&gt; #include &lt;cassert&gt; struct AV { explicit AV(std::string const&amp;) {} }; #if 1 static void check_cache_item( std::map&lt;std::string, std::string&gt; const&amp; items) // FIXME remove { assert(!items.empty()); } #endif static void check_cache_item( std::map&lt;std::string, AV&gt; const&amp; items) { assert(!items.empty()); } int main() { check_cache_item({ { "id", "0" }, { "pk", "#0" } }); check_cache_item({ { "id", "0" }, { "pk", "#1" } }); check_cache_item({ { "id", AV{"0"} }, { "pk", AV{"#1"} } }); } </code></pre> <p>is accepted by g++ 4.8.4, g++ 5.3.0, clang++ 3.9.0; but g++ 6.1.0 gives an error:</p> <pre><code>cci.cc: In function ‘int main()’: cci.cc:25:55: error: call of overloaded ‘check_cache_item(&lt;brace-enclosed initializer list&gt;)’ is ambiguous check_cache_item({ { "id", "0" }, { "pk", "#0" } }); ^ cci.cc:10:17: note: candidate: void check_cache_item(const std::map&lt;std::__cxx11::basic_string&lt;char&gt;, std::__cxx11::basic_string&lt;char&gt; &gt;&amp;) static void check_cache_item( ^~~~~~~~~~~~~~~~ cci.cc:16:17: note: candidate: void check_cache_item(const std::map&lt;std::__cxx11::basic_string&lt;char&gt;, AV&gt;&amp;) static void check_cache_item( ^~~~~~~~~~~~~~~~ cci.cc:26:55: error: call of overloaded ‘check_cache_item(&lt;brace-enclosed initializer list&gt;)’ is ambiguous check_cache_item({ { "id", "0" }, { "pk", "#1" } }); ^ cci.cc:10:17: note: candidate: void check_cache_item(const std::map&lt;std::__cxx11::basic_string&lt;char&gt;, std::__cxx11::basic_string&lt;char&gt; &gt;&amp;) static void check_cache_item( ^~~~~~~~~~~~~~~~ cci.cc:16:17: note: candidate: void check_cache_item(const std::map&lt;std::__cxx11::basic_string&lt;char&gt;, AV&gt;&amp;) static void check_cache_item( ^~~~~~~~~~~~~~~~ cci.cc: At global scope: cci.cc:10:17: warning: ‘void check_cache_item(const std::map&lt;std::__cxx11::basic_string&lt;char&gt;, std::__cxx11::basic_string&lt;char&gt; &gt;&amp;)’ defined but not used [-Wunused-function] static void check_cache_item( ^~~~~~~~~~~~~~~~ </code></pre> <p>If I #ifdef out the first constructor, then every compiler throws an error (rightly, because the AV constructor is explicit).</p> <p>Is this a regression in G++ 6.1.0 ?</p>
<c++><c++11>
2016-05-04 09:55:47
HQ
37,024,343
Why can't I use "return" in lambda function in python?
<p>This does not work:</p> <pre><code>print((lambda : return None)()) </code></pre> <p>But this does:</p> <pre><code>print((lambda : None)()) </code></pre> <p>Why?</p>
<python><lambda>
2016-05-04 09:56:44
HQ
37,028,316
Find the mode in array
<p>This code can only get the mode when single mode exist. I want to know how to return -1 when 2 modes exist. For example : 1 1 1 2 2 2 3. And return -1 when no mode exist, 1 2 3 4 5 6.</p> <pre><code> public Long getMode() { long [] num = this.getElements(); long maxValue=0, maxCount=0; for (int i = 0; i &lt; num.length; ++i){ long count = 0; for (int j = 0; j &lt; num.length; ++j){ if (num[j] == num[i]) ++count; } if (count &gt; maxCount){ maxCount = count; maxValue = num[i]; } } return maxValue; } </code></pre>
<java><arrays>
2016-05-04 12:48:09
LQ_CLOSE
37,030,662
visual studio - blank screen as output
'2.exe' (Win32): Loaded 'F:\cg project\2\Debug\2.exe'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\opengl32.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\lpk.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\usp10.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\glu32.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ddraw.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dciman32.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\setupapi.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\devobj.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dwmapi.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\glut32.dll'. Module was built without symbols. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmm.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Symbols loaded. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ig7icd32.dll'. Cannot find or open the PDB file. '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Symbols loaded. '2.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\version.dll' '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Symbols loaded. '2.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ole32.dll' '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Symbols loaded. '2.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ole32.dll' '2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\clbcatq.dll'. Symbols loaded. The program '[7212] 2.exe' has exited with code 0 (0x0).
<c++><dll>
2016-05-04 14:25:35
LQ_EDIT
37,032,342
C# : Loop without IF or SWITCH condition within it
I want to print the number like as shown below using the `loop` and without using `if` or `switch` condition. 1 2 3 4 5 5 5 6 6 7 8 9 9 10 **Note**: When loop comes to number 5 it has to iterate 3 times and when it comes to 6 and 9 it has to iterate 2 times. **Example**: I have the following code which prints numbers same as they meet the condition. #My Try: using System; public class Program { public static void Main() { Console.WriteLine("Print Numbers 1 To 10"); for (int i = 1; i <= 10; i++) { Console.WriteLine( i==5 || i == 6 || i == 9 ? i.ToString() + Environment.NewLine + i.ToString() : i.ToString()); } Console.ReadLine(); } }
<c#>
2016-05-04 15:40:44
LQ_EDIT
37,032,360
C programming, copying binary files.(Using fread & fwrite)
C programming, problem with copying binary files.(Using fread & fwrite):` #include <string.h> #define PER_READ 30 int main(void) { char buffer[500] = { 0 }; FILE* CSV = fopen( "CSV.csv", "rb" ); FILE* csvDest = fopen( "CSVDest.csv", "wb" ); unsigned int finished = 0; unsigned int counter = 0; do { finished = fread( buffer, sizeof( char*), PER_READ, CSV );//Read all from CSV to a string name buffer finished += PER_READ * counter; counter++; } while (finished == PER_READ * counter); fwrite( buffer, sizeof( char* ), finished, csvDest );// write all to a the file CSVDest system( "PAUSE" ); return (0); }` THANKS PEPOLE. :)
<c><file><binaryfiles>
2016-05-04 15:41:30
LQ_EDIT
37,032,374
¿HOW CAN I SELECT DATA FROM DIFERENT TABLES? MYSQL
I have these tables: ARTICLE, ARTICLE_has_tag, TAG, POST_ARTICLE and USER. I would like to take all from ARTICLE, then the name of one tag (even that they have more than one), the number of comments and the user who made it. ¿Is it possible? ¿Should I do more than one query? ARTICLE `ID_ARTICLE` int(11) NOT NULL AUTO_INCREMENT, `TITLE_ARTICLE` varchar(45) NOT NULL, `SUBTITLE_ARTICLE` varchar(45) NOT NULL, `REFEREE_ARTICLE` text, `LINEUP_ARTICLE` text, `LINEUP_OPPONENT_ARTICLE` text, `CARD_ARTICLE` text, `CARD_OPPONENT_ARTICLE` text, `CHANGE_ARTICLE` text, `CHANGE_OPPONENT_ARTICLE` text, `GOALS_ARTICLE` text, `CONTENT_ARTICLE` text NOT NULL, `CREATED_ARTICLE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `IMAGE_ARTICLE` text, `MATCH_ID` int(11) NOT NULL, `USER_ID` int(11) NOT NULL, PRIMARY KEY (`ID_ARTICLE`), ARTICLE_has_TAG `ARTICLE_ID` int(11) NOT NULL, `TAG_ID` int(11) NOT NULL, POST_ARTICLE `ID_POST_ARTICLE` int(11) NOT NULL AUTO_INCREMENT, `CONTENT_POST_ARTICLE` text NOT NULL, `CREATED_POST_ARTICLE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `USER_ID` int(11) NOT NULL, `ARTICLE_ID` int(11) NOT NULL, TAG `ID_TAG` int(11) NOT NULL AUTO_INCREMENT, `NAME_TAG` text NOT NULL, USER `ID_USER` int(11) NOT NULL AUTO_INCREMENT, `USERNAME_USER` text NOT NULL, `FIRSTNAME_USER` varchar(45) NOT NULL, `LASTNAME_USER` varchar(45) NOT NULL, `EMAIL_USER` text NOT NULL, `PASSWORD_USER` text NOT NULL, `TYPE_USER` int(1) NOT NULL DEFAULT '1', `IMAGE_USER` varchar(100) DEFAULT '245x342.jpg', `KEY_USER` text NOT NULL, `ACTIVATED_USER` int(1) DEFAULT '0', `CREATED_USER` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
<mysql><select><join><union>
2016-05-04 15:42:07
LQ_EDIT
37,033,573
Migration from CVS to GIT - simplest way
<p>I'm starting my professional career in programming and needs help ! What is the simplest way to migrate from CVS to Git .</p>
<git>
2016-05-04 16:44:04
LQ_CLOSE
37,034,622
My C code gives me result that is not correct(array operation)
It should be simple,two arrays,one with 5 other with 6 elements. #include <stdlib.h> #include <stdio.h> int main() { int i=0; int k=0; int v[5] = {2,3,4,5,6}; int g[6]; for( i = 1; i <= 6; i++ ){ k= i + 1; if ( 1 == i && 2 == i) { g[k]=v[i]; } else { g[k]=(v[i]+10); } printf("%d\n",g[k]); } return 0; } I got this 13 14 15 16 32776 10 I really wanted 2 3 13 14 15 16 Where is my mistake?Should I create function or what?
<c><arrays><debugging>
2016-05-04 17:46:26
LQ_EDIT
37,034,926
Please if someone can center this for me, it's will be great
For the freaking code god, please if someone can center this code for me, it's will be great! Ok i'm just gave up on this, i'm always coming into a problem about centering things and i have no idea why i cant understand how to freaking do that. Please help me to center the code bellow and tell me how you did that :) div.img { margin: 5px; border: 1px solid #ccc; float: left; width: 180px; } div.iframe:hover { border: 1px solid #777; } div.img iframe { width: 100%; height: auto; } div.desc { padding: 15px; text-align: center; } https://jsfiddle.net/zuntcod0/
<html><css><center><centering>
2016-05-04 18:05:29
LQ_EDIT
37,035,043
Java if statement (beginner request)
<p>If someone can help me with this. I'm complete -n o o b, only started to learn and got stuck.</p> <p>If I'm asking this - </p> <pre><code>Scanner buck = new Scanner(System.in); String fname; System.out.println("Please Enter your Name "); fname = buck.next(); </code></pre> <p>which command do I use to make specific name only to be entered as an answer. For example name would be Vani.</p> <p>If name is "Vani" than "you are in". If any else name "than you go out".</p> <p>I understand this with numbers but not with letters. Any help would be appreciated.</p>
<java><if-statement>
2016-05-04 18:11:59
LQ_CLOSE
37,035,556
My PHP script is not returning data to AJAX script
<p>PHP script:- </p> <pre><code>&lt;?php header('Access-Control-Allow-Origin: *'); echo "Done"; ?&gt; </code></pre> <p>AJAX script:-</p> <pre><code>$(document).ready(function(){ $('#submit').click(function(){ $.ajax({ type : "POST", url : "http://127.0.0.1/ionic/retri.php", success : function(data){ alert(data); $('#card').text(data); } }) }); }); </code></pre> <p>HTML:-</p> <pre><code> &lt;button id="submit" class="button button-block button-positive"&gt; Submit &lt;/button&gt; &lt;div class="card"&gt; &lt;div id="card" class="item item-text-wrap"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I have just started learning AJAX and wrote this script just to echo simple text and update the html div but I am not getting any output. </p>
<php><ajax>
2016-05-04 18:41:50
LQ_CLOSE
37,036,425
c# write to file try catches
<p>This code works perfectly well. No issues with it.</p> <p>The issue is that I would like to put a try catch block around it. This is what I have come up with. Can any suggest any more catches? Or is it fine the way it is?</p> <pre><code>String strFileLine1 = "This is a folder that will be used by the Virtual Flashcard program."; String strFileLine2 = "Please do not delete."; String myFilePath; . . . SaveFileDialog saveFile = new SaveFileDialog(); saveFile.FileName = "FlashCard.txt"; saveFile.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; saveFile.ShowDialog(); myFilePath = Path.GetDirectoryName(saveFile.FileName); label2.Text = myFilePath; try { using (StreamWriter fileWrite = new StreamWriter(saveFile.FileName)) { fileWrite.WriteLine(strFileLine1); fileWrite.WriteLine(strFileLine2); } } catch (Exception ex) { MessageBox.Show("There is a problem"); } </code></pre>
<c#><try-catch>
2016-05-04 19:30:40
LQ_CLOSE
37,036,706
learn C# for Xamarin
<p>I want to build apps using Xamarin in C#. But unfortunately I don't know C#. I have tried looking around on Google but nothing really helpful comes along. If anyone uses Xamarin to make C# apps can you please tell me where you learn it. Thank you. </p>
<c#><.net><xamarin><xamarin.android><xamarin-studio>
2016-05-04 19:46:42
LQ_CLOSE
37,037,630
undefined reference to outputVLI?
I have to make 2 arrays and use functions to input, output, add, and compare them but I keep getting error message: "undefined reference to outputVLI(int*, int)". I am not sure what this means or how to fix it. Any help would be appreciated #include <iostream> using namespace std; const int maxDigits = 100; void inputVLI (int vli[], int size); // Inputs the very long integers void outputVLI (int vli[], int size); // Outputs the very long integers void addVLI (const int vli1[], const int vli2[], int vli3[], int size1, int size2, int& size3); // Adds the very long integers together int compVLI (const int vli1, const int vli2, int size1, int size2); // Compares the very long integers int main() { int vli1[maxDigits], vli2[maxDigits], vli3[maxDigits], size1, size2, size3; inputVLI (vli1, maxDigits); // Calls the individual functions outputVLI (vli1, maxDigits); // | inputVLI (vli2, maxDigits); // | outputVLI (vli2, maxDigits); // | /*addVLI (vli1, vli2, vli3, size1, size2, size3); // | compVLI (vli1, vli2, size1, size2);*/ // \/ return 0; } void inputVLI(int vli[], int size) { cout << "Enter a very long integer" << endl; cin >> vli[maxDigits]; } void output (int vli[], int size) { for (int i=maxDigits; i>=0; i--) cout << vli[i]; } void addVLI (const int vli1[], const int vli2[], int vli3[], int size1, int size2, int& size3) { /* for (int i=0; i<maxDigits; i++) { vli3[i]=vli1[i] + vli2[i]; cout << "The sum of the vli's is:" << vli3[i] << endl; } */ } int compVLI (const int vli1, const int vli2, int size1, int size2) { /* for (int i=0; vli1[maxDigits] && vli2[maxDigits]; i++) { if (vli1[maxDigits] != vli2[maxDigits]) { return (-1); // -1 is not equal } return (1); // 1 is equal } */ }
<c++>
2016-05-04 20:42:17
LQ_EDIT
37,037,787
Unable to perform php in command line
<p>I am new to php scripting and been following a tutorial video. I'm getting an error on trying to output an array from php via command line, this is the code named as array1.php:</p> <pre><code>&lt;? # Canada, USA, Mexico $arr1 = array("Toronto", "Ottawa", "Montreal", "Quebec"); $arr2 = array("Boston", "New York", "Santa Barbara", "San Francisco"); $arr3 = array("Mexico City", "Cozumel", "Cancun", "Aculpoco"); # array 4 is an associative array $arr4 = array("Canada" =&gt; $arr1, "USA" =&gt; $arr2, "Mexico" =&gt; $arr3); print_r($arr4); ?&gt; </code></pre> <p>The tutorial video says I'll just need to follow the instructions/code and perform "php array1.php" but getting this:</p> <pre><code>$ php array1.php &lt;? # Canada, USA, Mexico $arr1 = array("Toronto", "Ottawa", "Montreal", "Quebec"); $arr2 = array("Boston", "New York", "Santa Barbara", "San Francisco"); $arr3 = array("Mexico City", "Cozumel", "Cancun", "Aculpoco"); # array 4 is an associative array $arr4 = array("Canada" =&gt; $arr1, "USA" =&gt; $arr2, "Mexico" =&gt; $arr3); print_r($arr4); ?&gt; </code></pre>
<php><arrays><nested>
2016-05-04 20:52:14
LQ_CLOSE
37,039,642
Getting a specific value from array
<p>I have this query on mysql, and i'm getting this array with print_r():</p> <pre><code>$data = Array ( [2] =&gt; Array ( [0] =&gt; Array ( [sale_order_value_id] =&gt; 3 [sale_order_id] =&gt; 2 [name] =&gt; Comprobante Fiscal [value] =&gt; Consumidor Final [price] =&gt; 0.0000 ) [1] =&gt; Array ( [sale_order_value_id] =&gt; 4 [sale_order_id] =&gt; 2 [name] =&gt; RNC / Cédula [value] =&gt; 00111936266 [price] =&gt; 0.0000 ) ) ) </code></pre> <p>I want to extract just the [name] from $data for each input, i have tried explode() to separate the values but that does not help.</p>
<php><mysql><arrays>
2016-05-04 23:11:31
LQ_CLOSE
37,040,510
I can't run my phonegap app on mobile?
[![after i write command ionic -run --device android ,this problem in picture appear to me my phone LG android v 4.0.4 + I enable developer option ,I can't know problem .[1]][1] [1]: http://i.stack.imgur.com/KDCuk.jpg
<android><cordova><ionic-framework><lg>
2016-05-05 00:48:47
LQ_EDIT
37,040,934
C: Take parts from a string without a delimeter (using strstr)
I have a string, for example: "Error_*_code_break_*_505_*_7.8" I need to split the string with a loop by the delimeter "_*_" using the strstr function and input all parts into a new array, let's call it - char elements[4] = {"Error", "code_break", "505", "7.8"} but strstr only gives me a pointer to a char, any help? note: the second string "code_break" should still contain "_", or in any other case.
<c>
2016-05-05 01:41:01
LQ_EDIT
37,043,122
Find missing elements in an ordered array consists of number sequences (Ruby)
In an ordered array, how to find the missing elements in an ordered array? with a condition that the missing elements have to be one of the existing element (represent by `v`) + 1 or v - 1. The smallest element is 0. e.g. [0, 1, 2, 4, 5, 6, 9, 10, 12, 13, 17] returns [3, 7, 8, 11, 14, 16, 18]
<arrays><ruby>
2016-05-05 05:33:25
LQ_EDIT
37,043,653
change mobile number prefix i.e. +92 to 0
I am reading calllog record.I read numbers in format like `0333XXXXXXX` and `+92333XXXXXXX`. how can i convert the number +92 to 0 any idea
<java><android><android-fragments>
2016-05-05 06:14:29
LQ_EDIT
37,045,191
Is it possible to transfer data from Python to HTML template/Website (Using Flask)
<p>I am a noob to this topic and this is my first question here. I want to ask if it is possible to <em>upload a changing variable</em> <em>from python to an HTML</em> textbox/paragraph/forms? I've seen several methods but can't figure out a one which work. I'm using <em>Python 3.4 on my raspberry PI 2</em> from which I will be also hosting a web server <em>using flask</em>. I would preferabbly use flask too for this task too but anyways if it's not possible I can use any other methods as soon as they are easier.</p> <p>Thanks in Advance ! </p>
<python><html><variables><flask><webserver>
2016-05-05 07:43:27
LQ_CLOSE
37,045,741
What is the benefit of having user defined return type over predefined datatype for a method in C#?
<p>What is the benefit of having user defined like class,interface,struct name as return type over predefined datatype for a method? It would be more helpful if someone give me an example. Thanks in advance.</p>
<c#><asp.net>
2016-05-05 08:19:07
LQ_CLOSE
37,045,803
C# do something based on image detection
<p>I am making a program in C#. I want it to do something if image is detected on screen. For example let's say I am making a game bot. And my health is image on my screen filled with green color like so:</p> <p><a href="http://i.stack.imgur.com/3BuJT.jpg" rel="nofollow">FULL HP BAR</a></p> <p>And something took my hp to this level:</p> <p><a href="http://i.stack.imgur.com/9i4Jf.jpg" rel="nofollow">TAKEN HP BAR</a></p> <p>If the C# detects the image with hp taken, do something ... Is this possible and how can i do it ? Thanks.</p>
<c#><image><detection>
2016-05-05 08:22:32
LQ_CLOSE
37,045,886
PHP Imploding Multidimention Array
i need to implode an multidimentional array in a string using implode, i tried using the array_map shown here http://stackoverflow.com/a/16710869/2717182 but i failed. my array is as below : Array ( [0] => Array ( [code] => IRBK1179 [qty] => 1 ) [1] => Array ( [code] => IRBK1178 [qty] => 1 ) [2] => Array ( [code] => IRBK1177 [qty] => 1 ) ) i need to implode the array into string formatted like : IRBK1179:1|IRBK1178:1|IRBK1177:1 TQ
<php><arrays>
2016-05-05 08:28:19
LQ_EDIT
37,045,897
Is the identifier in a for loop a variable - Python?
Is the letter identifier considered a variable? text = ("Hello") for letter in text: print (letter)
<python>
2016-05-05 08:29:04
LQ_EDIT
37,047,049
There is an error in my app. Hlp me pls
I'm making an app that will show multiple location on google map and ive read it through csv file. I have an error at OnCreate and displarArrayList method and i need help pls. I'm a newbie in java and android This is the error: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference at com.w2s.where2shop.ShowAllMap$CSVFile.displayArrayList(ShowAllMap.java:267) at com.w2s.where2shop.ShowAllMap.onCreate(ShowAllMap.java:65) at android.app.Activity.performCreate(Activity.java:5975) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)  at android.app.ActivityThread.access$800(ActivityThread.java:147)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5264)  at java.lang.reflect.Method.invoke(Native Method)  This is onCreate private InputStream inputStream; private CSVFile csvFile; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_show_all_map); setUpMapIfNeeded(); inputStream = getResources().openRawResource(R.raw.allmap); csvFile = new CSVFile(inputStream); csvFile.read(); try { csvFile.displayArrayList(); } catch (IOException e) { e.printStackTrace(); } mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); // Create the LocationRequest object mLocationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_LOW_POWER) .setNumUpdates(1); } And this is where I read my csv file and inside the class CsvFile I got displayarrayItem method. public class CSVFile { InputStream inputStream; ArrayList<String[]> addressList; public CSVFile(InputStream is) { this.inputStream = is; } public ArrayList<String[]> read() { ArrayList<String[]> addressList = new ArrayList<>(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); try { String line; while ((line = reader.readLine()) != null) { String[] row = line.split(","); addressList.add(row); } } catch (IOException e) { Log.e("Main", e.getMessage()); } finally { try { inputStream.close(); } catch (IOException e) { Log.e("Main", e.getMessage()); } } return addressList; } public ArrayList<String[]> displayArrayList() throws IOException { for (int x = 0; x > this.addressList.size(); x++) { Geocoder gc = new Geocoder(ShowAllMap.this); List<Address> list = gc.getFromLocationName(addressList.get(x).toString(), 1); if (list.size() > 0) { Address add = list.get(0); double lat = add.getLatitude(); double lng = add.getLongitude(); LatLng latLng = new LatLng(lat, lng); MarkerOptions options = new MarkerOptions() .position(latLng); mMap.animateCamera(CameraUpdateFactory.zoomIn()); mMap.addMarker(options); } } return addressList; } } Hlp Pls....
<java><android><csv>
2016-05-05 09:29:44
LQ_EDIT
37,048,875
How to get list & total number of friends who are invited using FB.Mobile.AppInvite while integrating Facebook SDK in Unity3D
<p>I am using new Facebook sdk v7.5.0, i tried hard to get the list of the friends who are invited and also unable to get the total number, how many friends are invited in callback of FB.Mobile.AppInvite(). </p>
<facebook><unity3d><facebook-unity-sdk>
2016-05-05 11:00:14
LQ_CLOSE
37,049,465
Localstorage encryption alogorithms
I am using localStorage to store token value and other basic user details for offline application mechanism in an Ionic Application.Localstorage is not the secured way to store these sensitive data.Is there any plugin or any other ways to store so that data is protected ? Targetting for Windows Phone / iOS / Android.All the three
<javascript><html><cordova><ionic-framework><local-storage>
2016-05-05 11:30:11
LQ_EDIT
37,049,579
Dictionary being treated as NoneType (Python 3.5.1)
<pre><code>from statistics import stdev data = [line.rstrip('\n').split(',') for line in open('C:/Users/User/Downloads/documents-export-2016-05-04/Data.csv')] dates = list(open('C:/Users/User/Downloads/documents-export-2016-05-04/Dates.csv').read().split('\n')) stock_values = [int(x) for x in open('C:/Users/User/Downloads/documents-export-2016-05-04/stock_value.csv').read().split(',')] companies = open('C:/Users/User/Downloads/documents-export-2016-05-04/companies.csv').read().split(',') prices = dict(zip(companies, stock_values)) PRICE = 0 old_volatility = 0 new_volatility = 0 def get_change(values, invested): sum_product = ([x * y for x, y in zip(values, invested)]) return(sum(sum_product) / sum(invested)) def get_volatility(invested): changes = {} for i, j in enumerate(list(reversed(dates))): changes[j] = get_change(list(map(float, data[i])), invested.values()) vals = changes.values() volatility = stdev(vals) return volatility def tuner(invested, company): global PRICE global old_volatility temp_invested = invested.copy() temp_invested[company] += 1 new_volatility = get_volatility(temp_invested) new_price = PRICE + prices[company] if new_volatility - old_volatility &lt; -0.01 and new_price &lt;= BUDGET: old_volatility = new_volatility PRICE = new_price tuner(temp_invested, company) else: return invested if __name__ == "__main__": BUDGET = int(input()) invested = {} for company in companies: invested[company] = 0 invested['A'] = 1 old_volatility = get_volatility(invested) for company in companies: if PRICE &lt; BUDGET: invested = tuner(invested, company) else: break print("Price = ", PRICE) print("Volatility = ", old_volatility) </code></pre> <p>For some reason in the above code, after 3 iterations of the for loop "for company in companies", I get an error that says "'NoneType' object has no attribute 'copy'", referring to the dictionary 'invested'. I don't understand why after a few iterations, the dictionary would suddenly be treated as NoneType. The original data are just being read in as lists of strings so they don't really matter. Any help is appreciated. Thanks.</p>
<python><python-3.x><dictionary><nonetype><stocks>
2016-05-05 11:35:22
LQ_CLOSE
37,050,409
how to identify records based on most recent scan
Using SQL 2012 mgnt studio. I need to identify 'JobNumber' if any of the 'item_code_1' was scanned within last 2 hours only. 'item_code_1' contains 'JobNumber' day # and sequence number. table1 JobNumber |Item_code_1 |Scanned| 12345 |12345_01_01 |Y | 12345 |12345_01_02 |Y | 12345 |12345_01_03 |Y | 1234567 |1234567_01_01 |Y | 1234567 |1234567_01_02 |Y | 1234567 |1234567_01_03 |Y | Table2 (CURRENT TIME = 2016-02-08 16:52:32.547) Scanned_date_time |Item_Code_1 | 2016-02-08 16:52:32.547 |12345_01_01 | 2016-02-08 16:52:32.547 |12345_01_02 | 2016-02-08 16:52:32.547 |12345_01_03 | 2016-02-08 **13**:52:32.547 |1234567_01_01| 2016-02-08 **13**:52:32.547 |1234567_01_02| 2016-02-08 **13**:52:32.547 |1234567_01_03| see in this case, JobNumber 123456 item_code_1 were scanned more than 2 hours ago. I only want to see the JobNumber if it's (at least 1)item_code_1 were scanned within last two hours based on Scanned_date_time
<sql><sql-server><time><greatest-n-per-group>
2016-05-05 12:16:33
LQ_EDIT
37,050,914
if else condition in java, android
<p>i have a TextView which is set using...</p> <pre><code>// Declare view variables private TextView mInfoText; // Assign views from layout file to cor. vars mInfoText = (TextView) findViewById(R.id.infoText); </code></pre> <p>how do i do an if else statement for the text inside it, i thought about doing it like this, but it doesn't work, i get a red line under the word "Sand".</p> <pre><code>if (mInfoText = "Sand"){ //Show correct } else { //Show incorrect } </code></pre> <p>Any ideas?</p>
<java><android>
2016-05-05 12:42:39
LQ_CLOSE
37,051,928
C# class uses in classes wht it dosent work
I have class for connection to Database namespace DamianWprawka { class SQLcon { static SqlConnection konekt = new SqlConnection(); public SQLcon() { konekt.ConnectionString = "Data Source=.\\sqlexpress;" + "Initial Catalog=PRACA;" + "User id=sa;" + "Password=xxXXxx;"; } void open() { konekt.Open(); } void close() { konekt.Close(); } } } And other for query like insert, update, delete, dwonloadData itp: namespace DamianWprawka { class SQLquerry { SQLcon SQLcnn = new SQLcon(); public void PobierzPracownik { SQLcnn.Open(); } } } Why i can't call SQLcnn.Open(); i try with static field/class and i can only use it normaly in Main. I know i can do connection and querry in one class but i want understand this mistery for future.
<c#><sql-server><class><static>
2016-05-05 13:28:38
LQ_EDIT
37,052,180
Value of a for loop in Ruby
I understand that, in Ruby, a for loop is an expression and therefore has a value which can be assigned to a variable. For example, `x = for i in 0..3 do end` sets `x` to `0..3` - the range over which the loop iterates. Is the value of a for loop always the range as above, or can it differ depending on the body of the loop?
<ruby><for-loop><expression>
2016-05-05 13:39:38
LQ_EDIT
37,052,797
Create a Stored Procedure in Firebird from Delphi code
How to Create a Stored Procedure in Firebird from Delphi XE3 code i.e. want to add stored procedure given below through delphi code. I am using TSQLQuery ->ExecSQL() but it is giving error at line 9 column 10. CREATE PROCEDURE GET_BRANCH_ID ( EMPID Integer) returns ( EMPBRANCHID Integer) AS declare variable EmpBrch Integer; Begin select EMP_BRANCH_ID from EMPLOYEE where EMPLOYEE_ID= :EMPID into :EmpBrch; EMPBRANCHID = :EmpBrch; SUSPEND; End Delphi code I am using is: with SQLQueryExc do begin close; SQL.clear; SQL.Add(SPString.Text); ExecSQL(); End Any help will be appreciated. Thanks.
<delphi><stored-procedures><firebird>
2016-05-05 14:07:52
LQ_EDIT
37,055,169
Ms SQL 2012: Column names into result values
I need to include table column names into result values like in the below example. How can I do it? SELECT 'John' AS Name, 'Malkovich' AS Surname INTO #T Result table should have 'Name' and 'Surname' as values Name, Surname (column names) Name, Surname, John, Malkovich Regards, Przemek
<sql><sql-server>
2016-05-05 16:04:25
LQ_EDIT
37,060,178
binomial distribution with matlab
how can I calculate the binomial distribution with matlab through two parameters p and n?[![with this expression][1]][1] [1]: http://i.stack.imgur.com/HkibV.png
<matlab><binomial-theorem>
2016-05-05 21:00:19
LQ_EDIT
37,064,481
iBeacon possible to wake up an app?
<p>We have requirement to integrate ibeacon in our iphone app.When user reached nearest to a beacon ,</p> <p>1)App need to wake up and open automatically.Is it possible? or 2)We need a local notification first and click on it will open the app?</p> <p>First one is possible , help is highly appreciable</p> <p>Thanks,</p>
<iphone><ibeacon>
2016-05-06 04:54:20
LQ_CLOSE
37,065,677
Wierd behaviour of getline in C++ ?
<p>Well I know using cin we can't read multiple strings . But the behaviour of getline here in this program is hard to understand . I am not able to figure out what is issue in it . Is it I can't use cin and getline in tandem ?</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; int main() { std::string name; std::cout &lt;&lt; "What is your name? "; std::cin&gt;&gt;name; std::cout &lt;&lt; "Hello, " &lt;&lt; name &lt;&lt; "!"&lt;&lt;std::endl; getline (std::cin, name); std::cout &lt;&lt; "Hello, " &lt;&lt; name &lt;&lt; "!\n"; } Input : Jai Simha Verma Jai Simha Verma OUTPUT: What is your name? Hello, Jai! Hello, Simha Verma ! </code></pre>
<c++><string><getline>
2016-05-06 06:25:05
LQ_CLOSE
37,065,728
how to assign values from vardump output to variables in php?
<p>here i have json output as below.what i want do is i want to take scope,production,refreshtoken,access_token as separate php variables from var_dump output.</p> <p>here is the json output</p> <pre><code>array ( 'status' =&gt; 'OK', 'statusCode' =&gt; 200, 'time' =&gt; 1.628268, 'header' =&gt; array ( 0 =&gt; 'HTTP/1.1 200 OK Date: Fri, 06 May 2016 06:22:42 GMT Server: O2-PassThrough-HTTP Content-Type: application/json Pragma: no-cache Cache-Control: no-store Transfer-Encoding: chunked ', ), 'body' =&gt; '{"scope":"TARGET","token_type":"bearer","expires_in":2324,"refresh_token":"4567f358c7b203fa6316432ab6ba814","access_token":"55667dabbf188334908b7c1cb7116d26"}', ) </code></pre> <p>Here is my php</p> <pre><code>var_dump($r); echo $var[0]."&lt;br&gt;"; echo $var[1]."&lt;br&gt;"; echo $var[2]."&lt;br&gt;"; echo $var[3]."&lt;br&gt;"; echo $var[4]."&lt;br&gt;"; echo $var[5]."&lt;br&gt;"; echo $var[6]."&lt;br&gt;"; echo $var[7]."&lt;br&gt;"; echo $var[8]."&lt;br&gt;"; </code></pre>
<php><json>
2016-05-06 06:28:09
LQ_CLOSE
37,066,331
Using @Headers with dynamic values in Feign client + Spring Cloud (Brixton RC2)
<p>Is it possible to set dynamic values to a header ?</p> <pre><code>@FeignClient(name="Simple-Gateway") interface GatewayClient { @Headers("X-Auth-Token: {token}") @RequestMapping(method = RequestMethod.GET, value = "/gateway/test") String getSessionId(@Param("token") String token); } </code></pre> <p>Registering an implementation of RequestInterceptor adds the header but there is no way of setting the header value dynamically</p> <pre><code>@Bean public RequestInterceptor requestInterceptor() { return new RequestInterceptor() { @Override public void apply(RequestTemplate template) { template.header("X-Auth-Token", "some_token"); } }; } </code></pre> <p>I found the following issue on github and one of the commenters (<strong>lpborges</strong>) was trying to do something similar using headers in <code>@RequestMapping</code> annotation.</p> <p><a href="https://github.com/spring-cloud/spring-cloud-netflix/issues/288" rel="noreferrer">https://github.com/spring-cloud/spring-cloud-netflix/issues/288</a></p> <p>Kind Regards</p>
<spring><spring-cloud><spring-cloud-netflix>
2016-05-06 07:07:03
HQ
37,067,467
Sending a persistent message in RabbitMQ via HTTP API
<p>I want to send a persistent mesaage via HTTP API. Im using this command:</p> <pre><code>curl -u UN:PWD -H "content-type:application/json" -X POST -d'{"properties":{},"routing_key":"QueueName","payload":"HI","payload_encoding":"string", "deliverymode": 2}' http://url:8080/api/exchanges/%2f/amq.default/publish </code></pre> <p>My queue is durable and deliverymode is also set to 2(Persistent), but the messages published are not durable. What change needs to be done? When I send the same via Management Console, the message is persistent but not via HTTP API.</p>
<api><http><rabbitmq><persistent>
2016-05-06 08:13:48
HQ
37,067,619
Do I need to replace NSURLConnection in order to achieve mandatory support for IPv6-only services?
<p>As Apple is requesting app submitted for review must support IPv6-only network starting from 1st June 2016, I am checking if I need to replace certain API / libraries in my app. However I don't know much enough about networking and some related aspects, as a result I am unable to have a definite answer on this and would like to seek for help.</p> <p>Regarding the document <a href="https://developer.apple.com/library/mac/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW13" rel="noreferrer">Supporting IPv6 DNS64/NAT64 Networks</a> provided by Apple, it states that apps should be fine and no need to perform update if:</p> <blockquote> <p>you’re writing a client-side app using high-level networking APIs such as <strong>NSURLSession</strong> and the <strong>CFNetwork frameworks</strong> and you <strong>connect by name</strong></p> </blockquote> <p>By this I take it as 2 criteria:</p> <ol> <li>using NSURLSession or CFNetwork</li> <li>connect by name</li> </ol> <p>So the question here is:</p> <ol> <li><p>As far as I know NSURLConnection is based on CFNetwork, does this mean I will be fine too if my app is using NSURLConnection? (I saw NSURLConnection is also mentioned in <a href="https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/art/NetworkingFrameworksAndAPIs_2x.png" rel="noreferrer">this image in the above document</a>, but again I am not quite sure about this as NSURLConnection is kind of old? And seems I cannot find documents mentioning IPv4 and IPv6 support either.)</p></li> <li><p>By the criteria "calling by name", does this mean no matter I am using NSURLSession or NSURLConnection, if I happen to call or access certain resources / APIs by an IPv4 address, bad things will happen? (I've done some research, and from my understanding clients like iOS device with iOS 9+ will always use synthesized IPv6 address to access IPv4 server, as a result the client will fail to reach the resource if I call by IPv4 address?)</p></li> </ol> <p>Thanks for any help!</p>
<ios><ios9><nsurlconnection><ipv6>
2016-05-06 08:23:28
HQ
37,067,726
Javascript do both If and Else condition (PHP)
<p>I have a weird question about Javascript and PHP.</p> <p>These are my codes</p> <pre><code>&lt;script&gt; &lt;?php $servername = "localhost"; $username = "root"; $password = "rootroot"; $dbname = "onlinerecruitment"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn-&gt;connect_error) { die("Connection failed: " . $conn-&gt;connect_error); } $s_id = NULL; $pos_id = $_POST['position']; $s_name = $_POST['skill_name']; $s_wg = $_POST['skill_weight']; $click = $_POST['clicks']; $sum = array_sum($s_wg); ?&gt; var sum = '&lt;?php array_sum($s_wg); ?&gt;'; if( sum != 10){ alert("Weight-score is over or lower than 10."); }else{ &lt;?php for($i=0; $i &lt;= $click; $i++){ $sql = ("INSERT INTO required_skills VALUES ('".$s_id."' , '".$pos_id."' , '".$s_name[$i]."' ,'".$s_wg[$i]."')"); $resultt = ""; if ($conn-&gt;query($sql) == TRUE) { $resultt = "FINISH"; } else { $resultt = "ERROR"; } } $conn-&gt;close(); ?&gt; var Message = ' &lt;?php echo $resultt; ?&gt;'; if((Message + "") == "ERROR"){ alert("Something wrong, please contract web admin."); }else{ alert("Weight-score setup successful."); location.href = "Weight_Score_Setup.php" } } </code></pre> <p></p> <p>As you can see there is If and Else conditions, which I test this page to get the "If" condition. The result turns to be "If" but INSERT query also working which it should not to because they are all in "Else" condition. I have no idea how to fix this. Please help.</p>
<javascript><php>
2016-05-06 08:29:27
LQ_CLOSE
37,067,895
How to store the output of a command in a variable at the same time as printing the output?
<p>Say I want to <code>echo</code> something and capture it in a variable, at the same time I see it in my screen.</p> <pre><code>echo "hello" | tee tmp_file var=$(&lt; tmp_file) </code></pre> <p>So now I could see <code>hello</code> in my terminal as well as saving it into the variable <code>$var</code>.</p> <p>However, is there any way to do this without having to use a temporary file? <code>tee</code> doesn't seem to be the solution, since it says (from <code>man tee</code>) <em>read from standard input and write to standard output and files</em>, whereas here it is two times standard output.</p> <p>I am in Bash 4.3, if this matters.</p>
<bash><stdout><gnu>
2016-05-06 08:38:19
HQ
37,068,279
Grunt watch not running less after error correction
<p>I've got an issue with Grunt Watch currently not re-running tasks after compilation error correction.</p> <p>I get the error message, but then after correcting the error, grunt says the file has been changed, but no tasks are run after that point.</p> <p>Grunt file:</p> <pre><code>watch: { less: { files: ['public/assets/less/**/*.less'], tasks: ['css'], options: { atBegin: true, nospawn: true } }, scripts: { files: [ 'public/assets/js/homepage.js' ], tasks: ['jsApp'], options: { nospawn: true, } } }, </code></pre> <p>Error log:</p> <pre><code>&gt;&gt; ParseError: Unrecognised input in public/assets/less/template.less on line 114, column 31: &gt;&gt; 114 @media screen and (max-width: 767px) { &gt;&gt; 115 left: 0; Warning: Error compiling public/assets/less/main.less // ----- Corrected the file here, saved again ----- &gt;&gt; File "public/assets/less/template.less" changed. </code></pre> <p>End of file. Nothing after this point.</p>
<javascript><gruntjs><grunt-contrib-watch>
2016-05-06 08:59:44
HQ
37,068,723
extracting data from .txt file using python
<p>I have a txt file which contains the following information</p> <pre><code>03/05/2016 3020 04/05/2016 1605 05/05/2016 2015 06/05/2016 1014 07/05/2016 558 08/05/2016 509 09/05/2016 1510 10/05/2016 1010 </code></pre> <p>I want to extract this data form this txt file and store it in an variable in python.. How can i achieve this... I am using pyth</p>
<python><python-2.7>
2016-05-06 09:21:47
LQ_CLOSE
37,069,219
How to cut date from date?
$uname -a SunOS 5.10 Generic_150400-33 sun4v sparc sun4v $date Friday, 6 May 2016 7:43:41 PM AEST $ date | cut -d"," -f1 Friday Now I need to cut the date alone where the output is 6 May 2016 ???
<shell><date><unix><solaris>
2016-05-06 09:46:31
LQ_EDIT
37,069,609
Show loading screen when navigating between routes in Angular 2
<p>How do I show a loading screen when I change a route in Angular 2?</p>
<html><css><angular><angular2-routing>
2016-05-06 10:04:43
HQ
37,070,175
MySql Error- ASP.NET
<p>I am getting the following error while connecting to the MySql database in the wamp server.I have added the assemblies also. How can i fix the problem? Thanks a ton. Error: </p> <pre><code>Server Error in '/' Application. Parameter '@First__Name' must be defined. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: MySql.Data.MySqlClient.MySqlException: Parameter '@First__Name' must be defined. Source Error: Line 26: cmd.Parameters.Add(new MySqlParameter("@Country", DropDownCountry.Text)); Line 27: cmd.Parameters.Add(new MySqlParameter("@About_User", txtUserDescription.Text)); Line 28: cmd.ExecuteNonQuery(); Line 29: con.Close(); Line 30: </code></pre> <p>My C# Code Behind file - Registration</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using MySql.Data.MySqlClient; public partial class Registration : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void RegisterUser(object sender, EventArgs e) { MySqlConnection con = new MySqlConnection("Server=localhost;Database=FreedomKitchen;Uid=root;Password=;"); con.Open(); MySqlCommand cmd = new MySqlCommand("Insert into User_Details(User_ID,First__Name, Last_Name, Age, Gender, Country, About_User)values(@User_ID,@First__Name, @Last_Name, @Age, @Gender, @Country, @About_User)", con); cmd.Parameters.Add(new MySqlParameter("@User_ID",1)); cmd.Parameters.Add(new MySqlParameter("@First_Name", txtFirstName.Text)); cmd.Parameters.Add(new MySqlParameter("@FLast_Name", txtLastName.Text)); cmd.Parameters.Add(new MySqlParameter("@Age", txtAge.Text)); cmd.Parameters.Add(new MySqlParameter("@Gender", DropDownGender.Text)); cmd.Parameters.Add(new MySqlParameter("@Country", DropDownCountry.Text)); cmd.Parameters.Add(new MySqlParameter("@About_User", txtUserDescription.Text)); cmd.ExecuteNonQuery(); con.Close(); } } </code></pre>
<mysql><asp.net><wampserver>
2016-05-06 10:32:55
LQ_CLOSE
37,070,940
A list and it's positions
I'm creating a code where you enter a sentence, it splits each word in the sentence to become a separate member. When I enter a word, and I enter it again, those two words will have the same position below. For instance, This is a This is a 1 2 3 1 2 3 The problem is, that my code does this differently, for example, This This Is Is 1 1 2 3 If it's done it twice, it will just continue to count forever. Here is my code: sent = input("Enter your sentence:").lower() sentlist = sent.split() print (sent) if len(sent) < 1: print ("No value entered. ") exit() for i in sentlist: if sentlist.index(i) in newlist: newlist.append(sentlist.index(i)) else: newlist.append(int(count)) count = count + 1 Hopefully someone can help me.. Thanks stack gods.
<python><list>
2016-05-06 11:12:24
LQ_EDIT
37,071,329
Sammy.js cache and scroll position when going back in history
<p>I don't know if anyone is still using Sammy.js, but I found it perfectly suits my needs for a lightweight routing and templating library. If anyone has other ideas, please let me know.</p> <p>My problem is that when I have a long page and I scroll down, click on a link on this page and go back, the whole page is reloaded (in Sammy, the GET route is called) and it jumps to the top of the page.</p> <p>My question is: Is there a way to have Sammy cache the page and maintain the scroll position when going back in the history?</p> <p>Thanks in advance.</p>
<javascript><jquery><sammy.js>
2016-05-06 11:32:40
HQ
37,071,867
C# How can I get Process.Start to open an explorer window to the parent of c,d,e etc.)?
<p>I know I can open directory blah by doing </p> <p><code>System.Diagnostics.Process.Start(@"c:\");</code> </p> <p>But suppose I want to get the explorer window to the parent of c and list drives c,d,e e.t.c.. How can I do that? Note <code>(@"\")</code> doesn't do it.</p> <p>i.e. I want </p> <p><a href="https://i.stack.imgur.com/ZNpSx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZNpSx.png" alt="enter image description here"></a></p> <p>and not within <code>C:\</code> so I don't want</p> <p><a href="https://i.stack.imgur.com/k1Bmz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k1Bmz.png" alt="enter image description here"></a></p>
<c#>
2016-05-06 12:00:42
LQ_CLOSE
37,072,245
Check return status of psql command in unix shell scripting
<p>I am using psql command to connect and issue a query on postgreSQL database. Can anybody let me know how to check the return status of the executed query in shell script.</p> <p>I have used <code>echo $?</code> command to check the status but it always returning zero.</p> <p>Thanks for the help.</p>
<postgresql><shell>
2016-05-06 12:17:36
HQ
37,072,843
Docker php-fpm/nginx set-up: php-fpm throwing blank 500, no error logs
<p>Git repo of project: <a href="https://github.com/tombusby/docker-laravel-experiments" rel="noreferrer">https://github.com/tombusby/docker-laravel-experiments</a> (HEAD at time of writing is 823fd22).</p> <p>Here is my docker-compose.yml:</p> <pre><code>nginx: image: nginx:stable volumes: - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro volumes_from: - php links: - php:php ports: - 80:80 php: image: php:5.6-fpm volumes: - ./src:/var/www/html expose: - 9000 </code></pre> <p>Into src/ I've created a fresh laravel project. This all functions correctly if I swap out index.php for one with a basic <code>echo "hello world";</code> and if I use <code>echo "called";exit();</code> I can identify that part of laravel's index.php does get executed.</p> <p>It dies at line 53:</p> <pre><code>$response = $kernel-&gt;handle( $request = Illuminate\Http\Request::capture() ); </code></pre> <p>I have no idea why this happens, and I've tried using <code>docker exec -it &lt;cid&gt; bash</code> to have a look around my php-fpm container for error logs. All the logs are redirected to stderr/stdout (which is collected by docker).</p> <p>Here is the output that docker collects:</p> <pre><code>php_1 | 172.17.0.3 - 06/May/2016:12:09:34 +0000 "GET /index.php" 500 nginx_1 | 192.168.99.1 - - [06/May/2016:12:09:34 +0000] "GET /index.php HTTP/1.1" 500 5 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36" "-" </code></pre> <p>As you can see "500" does pretty much nothing to help me work out why there was an error, but I can't find any way of getting the stack trace or anything like the proper error logs that apache's php extension would have produced.</p>
<php><nginx><docker><error-logging>
2016-05-06 12:47:20
HQ
37,072,844
Select Subset of Columns based on Vector R
<p>I have a data frame with 300 columns of data. I created a vector with 126 elements that are the column names of 126 of the 300. I want to subset the 300 based on not being in my 126. They are NOT in order, so I can't simply remove by specifying -1:-126.</p> <p>I tried various things with grep and matrix operations, but they did not work. Such as the following which did not work. x has 300 columns. f contains vector of 126 column names I want to exclude from x1.</p> <pre><code>x1&lt;-x[,-which(names(x), %in% f)] </code></pre> <p>If I definitively use a variable name or several, I can get it to work, but I don't want to type out the 126 elements in f. </p>
<r>
2016-05-06 12:47:23
HQ
37,072,992
can anyone please tell me how to create a custom datePicker view in android. I have searched the whole google but could not find it.
<p>I want to learn how to create custom android views. I don't want to use any library. I have looked searched for it.</p>
<android><android-widget>
2016-05-06 12:54:21
LQ_CLOSE
37,073,271
Programatically create a complex JSONArray in Android?
I have been struggling trying to make this work properly. From what I have read the following example is a JSONArray. I need to be able to dynamically create such an array problematically within my Android code, so that it can output this array to a web service. I am most confused about adding the top "header" information and the nested "Position" JSONObject as the last property. I know how a basic JSONObject is created, as well as a basic JSONArray, but this combined one is really throwing me off. Any help would be much appreciated. This is the example I was given that I need to try to create: { "source": "REMOTE", "msgType": "event", "properties": [ { "IMEI": { "string": "1234567890" } }, { "My Time": { "string": "5/4/2016 12:00:00" } }, { "Position": { "geographicPosition": { "latitude": 34.89767579999999, "longitude": -72.03648269999997 } } } ] }
<java><json>
2016-05-06 13:08:27
LQ_EDIT
37,074,485
Angular2 rxjs missing observable.interval method
<p>I'm trying to use the interval method of an observable but I keep getting the error </p> <pre><code> Property 'interval' does not exist on type 'Observable&lt;any&gt;'. </code></pre> <p>I added these imports:</p> <pre><code>import "rxjs/Rx"; import "rxjs/add/observable/interval"; import "rxjs/observable/IntervalObservable"; </code></pre>
<typescript><angular><rxjs>
2016-05-06 14:06:36
HQ
37,074,872
Android : FileProvider on custom external storage folder
<p>I'm trying to set up a fileprovider for sharing file. My files are saved in a folder "AppName" in the external storage (same level as Android, Movies and Pictures folders).</p> <p>Here is my file provider config :</p> <pre><code>&lt;provider android:name="android.support.v4.content.FileProvider" android:authorities="com.mydomain.appname.fileprovider" android:exported="false" android:grantUriPermissions="true"&gt; &lt;meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/&gt; &lt;/provider&gt; </code></pre> <p>and the file_paths.xml :</p> <pre><code>&lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;external-path name="mypath" path="AppName" /&gt; &lt;/paths&gt; </code></pre> <p>When i try to access my file with :</p> <pre><code>Uri fileUri = FileProvider.getUriForFile(activity, "com.mydomain.appname.fileprovider", new File("/storage/emulated/0/AppName/IMG_20160419_095211.jpg")); </code></pre> <p>It returns an error: java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/AppName/IMG_20160419_095211.jpg at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:678) at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:377)</p> <p>It worked fine before when I was using built-in directory like Pictures or Movies, my file_paths.xml was define like this :</p> <pre><code>&lt;external-path name="photos" path="Pictures" /&gt; &lt;external-path name="videos" path="Movies" /&gt; </code></pre> <p>But now I want to store my file in my own folder. Did I miss something with the FileProvider config ?</p>
<android><android-fileprovider>
2016-05-06 14:24:18
HQ
37,075,030
Custom alerts in iOS 9
<p>I wonder what is the right way to show custom alerts in iOS 9? My alert should have an icon with a label and one button to hide it. It is designed not in iOS style so from what I understand I can't use UIViewAlert? </p>
<swift><ios9>
2016-05-06 14:31:16
LQ_CLOSE
37,075,486
VS Code: What is the difference between push and publish
<p>On the GIT tab in Visual Studio Code there is an context menu with there items:</p> <ul> <li>Sync</li> <li>Pull</li> <li>Pull (release)</li> <li>Push</li> </ul> <p>==================</p> <ul> <li>Publish</li> </ul> <p>==================</p> <p>...</p> <p>What does the publish button do?</p>
<git><visual-studio-code>
2016-05-06 14:54:12
HQ
37,075,663
Markdown: How to reference an item in a numbered list, by number (like LaTeX's \ref / \label)?
<p>Is there any way in markdown to do the equivalent of the cross-referencing in this LaTeX snippet? (Taken from <a href="http://texblog.org/2012/03/21/cross-referencing-list-items/" rel="noreferrer">here</a>.)</p> <pre><code>\begin{enumerate} \item \label{itm:first} This is a numbered item \item Another numbered item \label{itm:second} \item \label{itm:third} Same as \ref{itm:first} \end{enumerate} Cross-referencing items \ref{itm:second} and \ref{itm:third}. </code></pre> <p>This LaTeX produces</p> <pre><code>1. This is a numbered item 2. This is another numbered item 3. Same as 1 Cross-referencing items 2 and 3. </code></pre> <p>That is, I would like to be able to refer to items in a markdown list without explicitly numbering them, so that I could change the above list to the following without having to manually update the cross references:</p> <pre><code>1. This is the very first item 2. This is a numbered item 3. This is another numbered item 4. Same as 2 Cross-referencing items 3 and 4. </code></pre>
<latex><markdown>
2016-05-06 15:02:38
HQ
37,075,858
JavaScript giving nonsense errors
<p>So, me and a few friends are making a text adventure in JavaScript. in it, there is a possibility of the player using a heal spell, which runs the following code:</p> <pre><code>function heal() { alert('You chant some ominous-sounding words, and your wounds heal'); alert('Hit points restored!'); hitPoints += 60; blobsOfDoom -= 30; burn(); MonsAtt(); Choose Spell(); } </code></pre> <h2>Error Messages:</h2> <h3>Firefox:</h3> <pre><code>/* Exception: SyntaxError: missing ; before statement @Scratchpad/1:2703 */ </code></pre> <h3>Chrome:</h3> <p><code>SyntaxError: Unexpected identifier</code>.</p> <p>Why is this error showing up? How do I fix it?</p>
<javascript>
2016-05-06 15:13:32
LQ_CLOSE
37,075,871
Can i bind an error message to a TextInputLayout?
<p>I would like to bind a error message directly to a <code>android.support.design.widget.TextInputLayout</code>. I cannot find a way to set the error through the layout. Is this even possible?</p> <p>This is how I imagined it working:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"&gt; &lt;data&gt; &lt;import type="android.view.View" /&gt; &lt;variable name="error" type="String" /&gt; &lt;/data&gt; &lt;android.support.v7.widget.LinearLayoutCompat android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"&gt; &lt;android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:errorEnabled="true" app:errorText="@{error}"&gt; &lt;EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/username" android:inputType="textEmailAddress" /&gt; &lt;/android.support.design.widget.TextInputLayout&gt; &lt;/android.support.v7.widget.LinearLayoutCompat&gt; &lt;/layout&gt; </code></pre>
<android><android-layout><android-databinding>
2016-05-06 15:14:18
HQ
37,076,113
MockRestServiceServer simulate backend timeout in integration test
<p>I am writing some kind of integration test on my REST controller using MockRestServiceServer to mock backend behaviour. What I am trying to achieve now is to simulate very slow response from backend which would finally lead to timeout in my application. It seems that it can be implemented with WireMock but at the moment I would like to stick to MockRestServiceServer.</p> <p>I am creating server like this:</p> <pre><code>myMock = MockRestServiceServer.createServer(asyncRestTemplate); </code></pre> <p>And then I'm mocking my backend behaviour like:</p> <pre><code>myMock.expect(requestTo("http://myfakeurl.blabla")) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(myJsonResponse, MediaType.APPLICATION_JSON)); </code></pre> <p>Is it possible to add some kind of a delay or timeout or other kind of latency to the response (or maybe whole mocked server or even my asyncRestTemplate)? Or should I just switch to WireMock or maybe Restito?</p>
<java><spring><mocking><mockito><mockmvc>
2016-05-06 15:26:15
HQ
37,076,477
sort array of object for some keys in javascript
I have one array of object like. [ { id : 1, age : 23, }, { id : 1, age : 25, } { id : 2, age : 230, }, { id : 2, age : 255, } { id : 3, age : 232, }, { id : 1, age : 215, } ] I need to get the final array by sorting with hightest age for each id. so final array will be. [ { id : 1, age : 215, }, { id : 2, age : 255, }, { id : 3, age : 232, }, ]
<javascript><arrays><sorting><object>
2016-05-06 15:45:37
LQ_EDIT
37,076,814
Chrome console - breakpoint over whole file
<p>is there any option to set something like "breakpoint" on a file in chrome console (kindof shortcut to set breakpoint on every line of code in the file)?</p> <p>Would be extremely useful when trying to understand 3rd party scripts that you know are executed but have no idea which part of code and from where is executed when.</p> <p>My current example use case: I downloaded a script (form validation) which does not work as expected. The fastest way to solve the problem would be to pause execution anytime JS runtime enters this file and start exploring it from there.</p>
<javascript><google-chrome><developer-console>
2016-05-06 16:02:02
HQ
37,077,474
linq to sql how to select data from two tables with groupby and orderby
SELECT TOP (5) Sales.Product, Sales.Product_Price, COUNT(*) AS CNT, Products.Category, Products.IMG_URL, Products.Rate_Avg FROM Sales INNER JOIN Products ON Sales.Product = Products.Product GROUP BY Sales.Product, Sales.Product_Price, Products.Category, Products.IMG_URL, Products.Rate_Avg HAVING (COUNT(*) > 1) ORDER BY CNT DESC
<linq>
2016-05-06 16:41:40
LQ_EDIT
37,077,487
Enable CORS for /health endpoint in Spring Boot Actuator
<p>We want to enable Cors for all GET requests to the <code>/health</code> endpoint provided by spring boot actuator.</p> <p>We tried adding the following bean without success</p> <pre><code>@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/health").allowedMethods("GET"); } }; } </code></pre>
<spring><spring-boot><cors><spring-boot-actuator>
2016-05-06 16:42:16
HQ
37,077,707
Launch an event when checking a checkbox in Angular2
<p>I'm newbie in Angular2 and in web globally , I want to launch an action that changes an oject paramater value in the Database when checking a <code>checkbox</code> and or unchecking it using <code>Material-Design</code>, I tried with <code>[(ngModel)]</code> but nothing happened. the idea is that i have to add some propositions with <code>checked | unchecked</code> status to tell if it is a <code>true</code> or <code>false</code> proposition. Here is the proposition model </p> <pre><code> export class PropositionModel { id:string; wordingP:string; // the proposition propStatus:Boolean; // the proposition status } </code></pre> <p>here is the Html code for a proposition :</p> <pre><code>&lt;div class="uk-width-xlarge-1-1 uk-width-medium-1-2"&gt; &lt;div (submit)="addProp1()" class="uk-input-group"&gt; &lt;span class="uk-input-group-addon"&gt;&lt;input type="checkbox" data-md-icheck/&gt;&lt;/span&gt; &lt;label&gt;Proposition 1&lt;/label&gt; &lt;input [(ngModel)]="proposition1.wordingP" type="text" class="md-input" required class="md-input"/&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>here is the TypeScript code for adding the proposition:</p> <pre><code>addProp1() { this.proposition1 = new PropositionModel(); this.proposition1.propStatus = false; this.propositionService.addProposition(this.proposition1) .subscribe(response=&gt; { console.log(response); console.log(this.proposition1); this.proposition1 = new PropositionModel();}) } </code></pre> <p>And as you can see i made it a <code>false</code> by default for the <code>proposition status</code> and I want to change it once i checked the proposition. Here is an image how it looks for a better issue understanding. <a href="https://i.stack.imgur.com/on1ie.png" rel="noreferrer"><img src="https://i.stack.imgur.com/on1ie.png" alt="enter image description here"></a></p> <p>Any help Please ? </p>
<html><checkbox><data-binding><typescript><angular>
2016-05-06 16:55:44
HQ
37,077,892
I wan to generate a random even number between min and max using this function. what do i need to change in this function
I have this function which gives me a random number between mi and max excluding the numbers in notthis. How do I change it to give me a number that is an even number. <!-- begin snippet: js hide: false --> <!-- language: lang-js --> function getrandomnumber(min,max,notthis) { var num=min+Math.floor((max-min+1)*Math.random()); var j=notthis.indexOf(num) while (j!=-1) { num=min+Math.floor((max-min+1)*Math.random()); j=notthis.indexOf(num) } return num; } a=getrandomnumber(0,100,"0,10,20") document.write(a) <!-- end snippet -->
<javascript>
2016-05-06 17:06:35
LQ_EDIT
37,078,494
Dynamic routerLink value from ngFor item giving error "Got interpolation ({{}}) where expression was expected"
<p>I'm trying to set the <code>routerLink</code> value in a directive based on a dynamic set of items from the component. But an error is being thrown from Angular2:</p> <pre><code>EXCEPTION: Template parse errors: Parser Error: Got interpolation ({{}}) where expression was expected at column 1 in [ {{item.routerLink}} ] in AppHeader@5:40 (" &lt;a *ngFor="let item of headerItems" [ERROR -&gt;][routerLink]=" {{item.routerLink}} "&gt; {{item.text}} &lt;/a&gt; "): Header@5:40 </code></pre> <p><strong>header.component.ts</strong></p> <pre><code>import {Component} from '@angular/core'; import {ROUTER_DIRECTIVES} from '@angular/router-deprecated'; @Component({ selector: 'app-header', templateUrl: './app/components/header/header.component.html', directives: [ROUTER_DIRECTIVES] }) export class AppHeader { headerItems: Object[] = []; constructor() { this.headerItems.push( { classes: 'navLink', routerLink: ['/Home'], text: 'Home' } ); } } </code></pre> <p><strong>header.component.html</strong></p> <pre><code>&lt;div id="HeaderRegion"&gt; &lt;nav class="nav"&gt; &lt;a *ngFor="let item of headerItems" [routerLink]=" {{item.routerLink}} "&gt; {{item.text}} &lt;/a&gt; &lt;/nav&gt; &lt;/div&gt; </code></pre>
<angular><angular2-directives>
2016-05-06 17:45:21
HQ
37,078,709
Angular 2: check if shift key is down when an element is clicked
<p>In an Angular 2 app, i want the click event to trigger something different when <em>the shift key is being held down</em>. how to achieve this?</p> <p>html is below:</p> <pre><code>&lt;div class="item" *ngFor="#obj of available" (click)="toggleSelected(obj)"&gt;&lt;/div&gt; </code></pre> <p>and i want to do something like this:</p> <pre><code> toggleSelected(obj) { if(shift is pressed) { do this } else { do that } } </code></pre> <p>so how can i detect if shift key is pressed? thanks!</p>
<angular>
2016-05-06 18:00:09
HQ
37,078,710
How Do We Inherit Test Classes Across Android Library Modules?
<p>I have an Android Studio project with two library modules: <code>foo-module</code> and <code>bar-module</code>. Each implements a library, with <code>foo-module</code> defining a strategy interface and <code>bar-module</code> depending upon <code>foo-module</code> and implementing such a strategy. <code>foo-module</code> has instrumentation tests (<code>foo-module/src/androidTest/</code>) to test its core code, using a stub strategy implementation, and <code>bar-module</code> should have its own instrumentation tests.</p> <p>I defined an <code>AbstractTests</code> class in <code>foo-module/src/androidTest/</code> that does most of the actual testing. I also have a <code>StubTests</code> class in <code>foo-module/src/androidTest/</code> that extends <code>AbstractTests</code> and implements the necessary <code>abstract</code> methods to complete the test case (providing an implementation of the strategy, etc.). This all works great.</p> <p>In <code>bar-module/src/androidTest/</code>, I created a <code>BarStrategyTests</code> class, designed to mirror <code>StubTests</code>, but provide the strategy implemented in <code>bar-module</code>. However, <code>BarStrategyTests</code> cannot see <code>AbstractTests</code>, even though I have <code>compile project(':foo-module')</code> in my <code>build.gradle</code> file, and the main (non-test) classes in <code>bar-module</code> can work fine with the main (non-test) classes in <code>foo-module</code>. IOW, while the <code>project()</code> dependency handles regular code, it does not handle <code>androidTest/</code> code. I get "error: package com.commonsware.foo.test does not exist".</p> <p>I tried also adding <code>androidTestCompile project(':foo-module')</code>, with the same result.</p> <p>What is the recipe for sharing instrumentation test code between modules?</p> <p>Temporarily, I can clone <code>AbstractTests</code>, but that's not a great long-term solution.</p> <p><a href="https://stackoverflow.com/q/31814812/115145">This SO question</a> covers similar ground for ordinary Java. Has anyone tried the options in <a href="https://stackoverflow.com/a/32780697/115145">the one answer</a> and gotten them to work for Android instrumentation tests? The first option (move the common testing code into yet another module as regular non-test code) seems plausible, but I have no idea if the other two will work well with the <code>com.android.library</code> plugin instead of the <code>java</code> plugin.</p>
<android><android-gradle-plugin>
2016-05-06 18:00:20
HQ
37,078,774
Can't always set React Native breakpoints in Chrome
<p>While debugging my React Native app in Chrome, I'm often unable to set breakpoints in the Sources tab. When I click on a line of code to add the breakpoint, a breakpoint is added instead to the next function declaration line in my module.</p> <p>This doesn't happen in all of my source modules, but often enough that it prevents me from debugging efficiently.</p> <p>I'm currently using RN 0.22 but this has been happening on older versions of RN as well (e.g. RN 0.18).</p>
<react-native>
2016-05-06 18:05:06
HQ
37,078,838
HTML, CSS picture positioning
I'm working on a html page, and i run into a little problem. Here's a picture about what i want: https://i.imgsafe.org/2c4d808.png I've got a header section which contains the title and the picture, but i cant move the picture into the right side(red area) of the header. **the things should met at the same time:** 1.the title and the picture must be in the same div(header), however i can use nested divs in the header 2.the title must be centered 3.the picture must be completely on the right side of the header(both height are 100px) the header is 800x100px and the icture is 160x100 px I'm looking for the easiest / simplest way to solve it, and i can modify anything in my htlm or css code. just to be sure: the header is with the "TITLE TITLE TITLE TITLE" and it is blue
<html><css>
2016-05-06 18:09:07
LQ_EDIT
37,078,968
How to specify the path of `package.json` to npm?
<p>I use <code>npm</code> scripts to build my project. I'd like to be able to run the scripts from a different directory. That is, instead of doing the following:</p> <pre><code>cd project; npm run build; cd .. </code></pre> <p>...I'd like to simply do something like:</p> <pre><code>npm run build -config project/package.json; </code></pre> <p>or</p> <pre><code>npm run build -wd project; </code></pre> <p>Is this possible?</p>
<node.js><npm><package.json>
2016-05-06 18:17:58
HQ
37,078,970
Sequelize: Using Multiple Databases
<p>Do I need to create multiple instances of Sequelize if I want to use two databases? That is, two databases on the same machine.</p> <p>If not, what's the proper way to do this? It seems like overkill to have to connect twice to use two databases, to me.</p> <p>So for example, I have different databases for different functions, for example, let's say I have customer data in one database, and statistical data in another. </p> <p>So in MySQL:</p> <pre><code>MySQL [customers]&gt; show databases; +--------------------+ | Database | +--------------------+ | customers | | stats | +--------------------+ </code></pre> <p>And I have this to connect with sequelize</p> <pre><code>// Create a connection.... var Sequelize = require('sequelize'); var sequelize = new Sequelize('customers', 'my_user', 'some_password', { host: 'localhost', dialect: 'mysql', pool: { max: 5, min: 0, idle: 10000 }, logging: function(output) { if (opts.log_queries) { log.it("sequelize_log",{log: output}); } } }); // Authenticate it. sequelize.authenticate().nodeify(function(err) { // Do stuff.... }); </code></pre> <p>I tried to "trick" it by in a definition of a model using dot notation</p> <pre><code>var InterestingStatistics = sequelize.define('stats.interesting_statistics', { /* ... */ }); </code></pre> <p>But that creates the table <code>customers.stats.interesting_statistics</code>. I need to use an existing table in the stats database.</p> <p>What's the proper way to achieve this? Thanks.</p>
<javascript><mysql><node.js><sequelize.js>
2016-05-06 18:18:03
HQ
37,079,399
PHP - Difficulties Writing New Line
<p>I am encountering difficulties with writing to a new line in a basic text file. All the other text (including the comma) appears just fine, but no new line (no space or anything either). I would greatly appreciate any direction.</p> <pre><code>&lt;?php session_start(); $user = $_SESSION['store']; function format($input) { $input = trim($input); $input = stripcslashes($input); $input = htmlspecialchars($input); return $input; } $file = "messages/reminder.txt"; $image; $secFreqLabel; $freqLabel; $uploadDirectory = "corpImages/"; if(!file_exists($file)) { $temp = fopen($file, "w"); // create file fclose($temp); } $con = new PDO("sqlite:bk.db"); if($_SERVER['REQUEST_METHOD'] == "POST") { $secFreqLabel = 'reminder.jpg'; $freqLabel = 'reminderHourly.jpg'; $thirdFreqLabel = 'reminderThree.jpg'; $fourthFreqLabel = 'reminderFour.jpg'; $freqUploadFile = $uploadDirectory . $freqLabel; $secFreqUploadFile = $uploadDirectory . $secFreqLabel; $thirdFreqUploadFile = $uploadDirectory . $thirdFreqLabel; $fourthFreqUploadFile = $uploadDirectory . $fourthFreqLabel; $statement = $con-&gt;prepare("INSERT INTO slides (image, label) VALUES (:image, :label)"); if(!empty($_FILES['freqImage'])) { $con-&gt;exec("DELETE FROM slides where label = 'reminder.jpg'"); } if(!empty($_FILES['secFreqImage'])) { $con-&gt;exec("DELETE FROM slides where label = 'reminderHourly.jpg'"); } if(!empty($_FILES['thirdFreqImage'])) { $con-&gt;exec("DELETE FROM slides where label = 'reminderThree.jpg'"); } if(!empty($_FILES['fourthFreqImage'])) { $con-&gt;exec("DELETE FROM slides where label = 'reminderFour.jpg'"); } $image = file_get_contents($_FILES['freqImage']['tmp_name']); move_uploaded_file($_FILES['freqImage']['tmp_name'], $freqUploadFile); $statement-&gt;bindParam(":label", $freqLabel); $statement-&gt;bindParam(":image", $image); $statement-&gt;execute(); $image = file_get_contents($_FILES['secFreqImage']['tmp_name']); move_uploaded_file($_FILES['secFreqImage']['tmp_name'], $secFreqUploadFile); $statement-&gt;bindParam(":label", $secFreqLabel); $statement-&gt;bindParam(":image", $image); $statement-&gt;execute(); $image = file_get_contents($_FILES['thirdFreqImage']['tmp_name']); move_uploaded_file($_FILES['thirdFreqImage']['tmp_name'], $thirdFreqUploadFile); $statement-&gt;bindParam(":label", $thirdFreqLabel); $statement-&gt;bindParam(":image", $image); $statement-&gt;execute(); $image = file_get_contents($_FILES['fourthFreqImage']['tmp_name']); move_uploaded_file($_FILES['fourthFreqImage']['tmp_name'], $fourthFreqUploadFile); $statement-&gt;bindParam(":label", $fourthFreqLabel); $statement-&gt;bindParam(":image", $image); $statement-&gt;execute(); $text = format($_POST['freq']) . "," . format($_POST['freqMessage']) . "\n" . format($_POST['secFreq']) . "," . format($_POST['secFreqMessage']) . "\n" . format($_POST['thirdFreq']) . "," . format($_POST['thirdFreqMessage']) . "\n" . format($_POST['fourthFreq']) . "," . format($_POST['fourthFreqMessage']); $writer = fopen($file, "w"); fwrite($writer, $text); fclose($writer); touch("update.txt"); } $handler = fopen($file, "r"); $firstReminder = fgetcsv($handler, ","); $secondReminder = fgetcsv($handler, ","); $thirdReminder = fgetcsv($handler, ","); $fourthReminder = fgetcsv($handler, ","); fclose($handler); ?&gt; </code></pre>
<php><file>
2016-05-06 18:45:45
LQ_CLOSE
37,079,847
Is it ok to use ReactDOMServer.renderToString in the browser in areas where React isn't directly managing the DOM?
<p>I'm working on an app using <a href="http://leafletjs.com/" rel="noreferrer">Leaflet</a> (via <a href="https://github.com/PaulLeCam/react-leaflet" rel="noreferrer">react-leaflet</a>). Leaflet directly manipulates the DOM. The react-leaflet library doesn't change that, it just gives you React components that you can use to control your Leaflet map in a React-friendly way.</p> <p>In this app, I want to use custom map markers that are divs containing a few simple elements. The way to do that in Leaflet is to set your marker's <code>icon</code> property to a <a href="http://leafletjs.com/reference.html#divicon" rel="noreferrer">DivIcon</a>, in which you can set your custom HTML. You set that inner HTML by setting the DivIcon's <code>html</code> property to a string containing the HTML. In my case, I want that HTML to be rendered from a React component.</p> <p>In order to do that, it seems like the correct approach is to use <code>ReactDOMServer.renderToString()</code> to render the Component that I want inside the map marker into a string, which I would then set as the <code>html</code> property of the DivIcon:</p> <p><strong><em>MyMarker.js:</em></strong></p> <pre><code>import React, { Component } from 'react' import { renderToString } from 'react-dom/server' import { Marker } from 'react-leaflet' import { divIcon } from 'leaflet' import MarkerContents from './MarkerContents' export class MyMarker extends Component { render() { const markerContents = renderToString(&lt;MarkerContents data={this.props.data} /&gt;) const myDivIcon = divIcon({ className: 'my-marker', html: markerContents }) return ( &lt;Marker position={this.props.position} icon={myDivIcon} /&gt; ) } } </code></pre> <p>However, according to the <a href="https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostring" rel="noreferrer">React docs</a>:</p> <blockquote> <p>This [renderToString] should only be used on the server.</p> </blockquote> <p>Is this a strict rule, or is it only meant to dissuade people from circumventing ReactDOM's efficient management of the DOM?</p> <p>I can't think of another (better) way to accomplish what I'm after. Any comments or ideas would be greatly appreciated.</p>
<reactjs><leaflet><react-dom>
2016-05-06 19:13:42
HQ
37,080,472
How to fully pass a List?
<p>I use a list to contain data parsed from an XML file, using strings as its members:</p> <pre><code>public class ServerList { public string ServerName { set; get; } public string ServerReboot { set; get; } public string ServerShutdown { set; get; } public ServerList() { ServerName = ""; ServerReboot = ""; ServerShutdown = ""; } } </code></pre> <p>From the main form I launch an editor form and pass the list into it. On this editor form the user is able to add or remove entry entries form the list, as well as make changes to parts of the list. If they click the OK button I want to be able to pull the list form the editor form back into the main form, but if they click Cancel I want these changes to get dropped. This is the way the editor form is pulled up:</p> <pre><code> private void mnuEdit_Click(object sender, EventArgs e) { frmEditor theEditor = new frmEditor(); theEditor.updatedServerList = theServerList; DialogResult res = theEditor.ShowDialog(); if (res == DialogResult.OK) { theServerList = theEditor.updatedServerList.ToList(); SetupFilters(GroupOrBatch.Group); // other processing to update the main form from the updated list } } </code></pre> <p>And on the Edit form this is how it is received:</p> <pre><code>public partial class frmEditor : Form { private List&lt;ServerList&gt; myServerList = new List&lt;ServerList&gt;(); public List&lt;ServerList&gt; updatedServerList { get { return myServerList; } set { myServerList = value.ToList(); } } .... </code></pre> <p>What I am finding is that while the list structure appears to be copied to the new variable, the actual data is still linked to the original list. Even if the user clicks Cancel, and the modified list is not copied back to the original, the original has already been changed.</p> <p>This leaves me with one of two options - either I can find some way to do a full deep clone of the list to a new one (which can be dropped upon an Cancel), or I remove the Cancel button entirely and have all edits be live. </p>
<c#>
2016-05-06 19:59:25
LQ_CLOSE
37,080,490
Experiment With C
<pre><code>#include&lt;stdio.h&gt; int main() { int x = 99; printf("%d %d\n",1 &gt; scanf("%d",&amp;x) ? scanf("%d",&amp;x): scanf("%d",&amp;x),x); } </code></pre> <p>So What is happening to the scanned values. Lets say First Input is 11. so left most scanf is returning 1. So according to the rule the right most scanf will be executed. But The right most %d of printf is not printing the scanned value. It is showing 99.</p>
<c>
2016-05-06 20:00:51
LQ_CLOSE
37,080,635
slack webhook html table
<p>I have a html table that I am trying to post to slack via webhook. Is there a way to post html table to slack? Below is the html code -</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;HTML Tables&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;table border="1"&gt; &lt;tr&gt; &lt;td&gt;Row 1, Column 1&lt;/td&gt; &lt;td&gt;Row 1, Column 2&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Row 2, Column 1&lt;/td&gt; &lt;td&gt;Row 2, Column 2&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
<webhooks><slack-api><slack>
2016-05-06 20:09:16
HQ
37,081,177
I need to make my app work in background even if its closed
<p>Im beginner with android, I want to make my app work a cyclic behavior in background even if it’s closed. Can someone help me? Thanks!</p>
<android><background>
2016-05-06 20:48:38
LQ_CLOSE
37,081,350
Check how many times was form submited
<p>I am wondering how can I check is someone tried to log in on site and if he fails login few times to redirect him on forgot password page. I am little word less so I don't know what should I look for. I should try it with jquery and ajax. I think about something with if password is wrong to echo password is wrong but on third time to send user on forgot page. Now my question is how can I check how many times did someone press submit button with error message for wrong password or username. </p>
<javascript><php><jquery><ajax>
2016-05-06 21:00:26
LQ_CLOSE
37,081,521
Regex replace +46 to 0 JavaScript
<p>I'm trying to learn regex. I need to find +46 and replace it with 0. I've been racking my brain but I can't figure out the correct syntax. I'm trying to do it in JS with replace.</p> <p>Any takers?</p>
<javascript><regex><replace>
2016-05-06 21:13:11
LQ_CLOSE