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
39,209,917
Difference between frontend/backend and listen in haproxy
<p>Hopefully a simple question. I apologize if this has been covered before. I'm learning haproxy and overall seems very straightforward and simple. However I am curious what the difference is between using frontend/backend and listen config blocks? My assumption is that listen is just simpler, for basic configurations, while frontend/backend is more advanced, allowing you to dynamically switch backends or share backends, etc. Is that it in a nutshell?</p> <p>Thanks,</p> <p>Al</p>
<load-balancing><haproxy>
2016-08-29 15:28:54
HQ
39,210,274
how do i backup a database in docker
<p>i'm running my app using docker-compose with the below yml file</p> <pre><code> postgres: container_name: postgres image: postgres:${POSTGRES_VERSION} volumes: - postgresdata:/var/lib/postgresql/data expose: - "5432" environment: - POSTGRES_DB=42EXP - POSTGRES_USER=${POSTGRES_USER} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} node: container_name: node links: - postgres:postgres depends_on: - postgres volumes: postgresdata: </code></pre> <p>As you can see here ,i'm using a <code>named volume</code> to manage postgres state.</p> <p>According to the official docs, i can backup a volume like the below</p> <pre><code>docker run --rm --volumes postgresdata:/var/lib/postgresql/data -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /dbdata </code></pre> <p>Some other tutorials suggested i use the <code>pg-dump</code> function provided by postgres for backups.</p> <pre><code>pg_dump -Fc database_name_here &gt; database.bak </code></pre> <p>I guess i would have to go inside the postgres container to perform this function and mount the backup directory to the host.</p> <p>Is one approach better/preferable than the other?</p>
<postgresql><docker>
2016-08-29 15:48:58
HQ
39,210,731
Parsing JSON as String in Javascript
<p>I have a String whose value is a JSON object.</p> <pre><code>var json = '{ "Name": { "1": "Adam", "2": "Tim", "3": "Bob" }, "Height": { "1": "181", "2": "157", "3": "173" } }'; </code></pre> <p>How to parse it to get values <strong>Adam</strong>, <strong>Tim</strong> and <strong>Bob</strong> and print it ?</p>
<javascript><jquery>
2016-08-29 16:15:37
LQ_CLOSE
39,211,047
Convert code from C++ to C
Does anyone know how to convert this line from C++ to C programming language? i wrote this code in C++ and i want to convert it in C. bool compare(string a, string b) { return a+b > b+a; }
<c++><c>
2016-08-29 16:35:58
LQ_EDIT
39,211,189
Javascript to parse string that may contain invalid daylight date
I need help to convert input string that looks something like '20160313023000' (invalid daylight saving date) to date in 'yyyyMMddHHmmss' format using javascript. Thanks in advance.
<javascript>
2016-08-29 16:44:48
LQ_EDIT
39,211,235
Pass PHP variable to Javascript won't work
<p>I have two different pages for my site, lets call them page1 and page2. On the first page I have a HTML form of which handles some information. Then I have a php document to process that information into a .txt file. Then I have an image on my page2, this image I would like to change depending on a specific variable. This variable is set in the php script, where it checks if a certain value is right then it will set this specific variable to either 1 or 2. Then as said on page2 I have this image I would like to change depending on whether the php variable is 1 or 2. This I am trying to do by getting the php variable through javascript on page2 and then displaying it first to make sure I am getting the right values. But when doing this I just get "null" and pretty much nothing really happens. It loads the page but doesn't display anything. Keep in mind when I am saying pages etc it is because the page1 is one HTML document, page2 is another HTML document and then of course the php function is a separate php document. </p> <h2>HTML page1 where the user would pick from a drop down menu</h2> <pre><code>&lt;div id="sKind"&gt; &lt;select border="0" size="1" name="produKind" id="cSK" data-selected="" required=""&gt; &lt;option value=""&gt;enter color&lt;/option&gt; &lt;option value="white"&gt;White&lt;/option&gt; &lt;option value="black"&gt;Black&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; </code></pre> <h2>php file I am using to pass values and variables</h2> <pre><code>&lt;?php $field_skind = $_POST['produKind']; $imgShow = 1; if ($field_skind == white){ $imgShow = 1; } else if ($field_skind == black) { $imgShow = 2; } echo json_encode($imgShow); ?&gt; </code></pre> <h2>Code I am using on page2 html</h2> <pre><code>&lt;script&gt; var imgNumber = &lt;?php echo json_encode($imgShow)?&gt;; document.getElementById("insert").innerHTML = imgNumber; &lt;/script&gt; &lt;p id="insert"&gt;&lt;/p&gt; </code></pre>
<javascript><php><html><json>
2016-08-29 16:48:33
LQ_CLOSE
39,211,689
'Batch' script using file names from an xml to organise files
I have a library of sounds that are pretty ambiguous in what they are, the only way to find the sounds is by rummaging through an xml file which has the reference to each, so what I want to do is create a script that reads from the xml with conditions to get the right files and streams in the right folders by renaming and putting the files in the correct directory... here is the code and the conditions: <File Id="14518742" Language="SFX"> <ShortName>Creatures\Fish_Large_Swim_03.wav</ShortName> <Path>SFX\Creatures\Fish_Large_Swim_03_9344E057.wem</Path> </File> I want to look for the file call, and get the ID (14518742), this will be a name of a file (14518742.ogg) and I want to move it to this directory: SFX\Creatures\Fish_Large_Swim_03_9344E057 (Renaming the file to Fish_Large_Swim_03_9344E057.ogg, ignore the .wem) which is preceded by "Path" The thing is that I don't know how to read through files in such scripts, if or if not possible in .bat, where is it possible?
<xml><batch-file><batch-rename>
2016-08-29 17:16:05
LQ_EDIT
39,212,726
i get an error "Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)"
[this is the error occured when i debugging the program][1] [1]: http://i.stack.imgur.com/HucHf.jpg Below is the code where error occured -> public function does_user_exist($email,$password) { $query = "Select * from users where email = '$email' and password='$password'"; **$result = mysqli_query(this -> connection, $query);**
<android><notepad++><postman>
2016-08-29 18:24:29
LQ_EDIT
39,213,171
Hash iteration keys
I have this hash: games = {"Mario" => "SNES", "Ico" => "PS2", "Tetris" => "Gameboy"} I want to make a method that will convert the keys to integers and then add all of the keys in the hash together and return a single integer I looked up some methods on rubydocs and came across the string method .ord which converts letters to their numerical values. I know I will want to split('') the keys I'm just not sure how to get it all to work.
<ruby><hash><sum><iteration>
2016-08-29 18:50:24
LQ_EDIT
39,213,386
TypeError: Cannot read property 'valid' of undefined
<p>I have the following textarea:</p> <pre><code>&lt;textarea class="form-control" [(ngModel)]="content" name="content" required&gt; &lt;/textarea&gt; </code></pre> <p>and the following submit button:</p> <pre><code> &lt;button type="submit" class="btn btn-default" [disabled]="content.valid"&gt;New comment&lt;/button&gt; </code></pre> <p>As I saw in the angular 2 form guide (<a href="https://angular.io/docs/ts/latest/guide/forms.html">https://angular.io/docs/ts/latest/guide/forms.html</a>) I can use the <code>x.valid</code> in order to check if it's not empty.</p> <p>Why do I get <code>TypeError: Cannot read property 'valid' of undefined</code> error?</p>
<angular>
2016-08-29 19:04:16
HQ
39,213,531
spring boot test unable to inject TestRestTemplate and MockMvc
<p>I am using spring boot <code>1.4.0.RELEASE</code>. I am writing tests for my controller class. I get the following exception.</p> <pre><code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.concur.cognos.authentication.service.ServiceControllerITTest': Unsatisfied dependency expressed through field 'restTemplate': No qualifying bean of type [org.springframework.boot.test.web.client.TestRestTemplate] found for dependency [org.springframework.boot.test.web.client.TestRestTemplate]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.test.web.client.TestRestTemplate] found for dependency [org.springframework.boot.test.web.client.TestRestTemplate]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} </code></pre> <p>Here is my test class</p> <pre><code>public class ServiceControllerITTest extends ApplicationTests { @Autowired private TestRestTemplate restTemplate; @Autowired private MockMvc mvc; @Test public void exampleTest() throws Exception { // test } } </code></pre> <p><code>ApplicationTests.java</code></p> <pre><code>@RunWith(SpringRunner.class) @SpringBootTest @WebAppConfiguration //@DirtiesContext public class ApplicationTests { @Autowired Environment env; @Test public void contextLoads() { } } </code></pre>
<spring-mvc><spring-boot><spring-test>
2016-08-29 19:14:24
HQ
39,216,085
Angular2 - http Post not executing to ASP.NET. GET executs
I'm trying to make a post request in Angular2. For some reason I cant make POST request. I changed both the client and server to GET request and left everything else the same, and it works fine. So im wondering if i can to configure the header a different way to be able to make the POST request. Client let headers = new Headers(); headers.append('Content-Type', 'application/json') let body = latitude+','+longitude ; this.http.post('/api/SampleData/CurrentForecasts',body, { headers: headers }) .map(response => response.json()) .subscribe( data => this.Debug(data), err => console.log("Error: \n"+err), () => console.log('Get Complete') ); Server [HttpPost] public async Task<IActionResult> CurrentForecasts(string location) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(" https://api.forecast.io/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // HTTP GET HttpResponseMessage response = await client.GetAsync("forecast/APIKEY/"+location); if (response.IsSuccessStatusCode) { var forecast = await response.Content.ReadAsStringAsync(); return Content(forecast, "application/json"); } } return Json("Failed");
<javascript><c#><http><angular><asp.net-core>
2016-08-29 22:23:00
LQ_EDIT
39,216,746
Issue with new database for android application
I have a problem when I run my android application , it still remember old DB even I changed DB in assets/databases Could you please help me Many thanks
<android><sqlite><android-sqlite>
2016-08-29 23:37:20
LQ_EDIT
39,217,116
How do I check for reference equality in F#?
<p>F# uses structural equality for the <code>=</code> operator, which is almost always what you want:</p> <pre><code>let a = [1; 2; 3] let b = [1; 2; 3] printfn "%A" (a = b) // Prints "true" </code></pre> <p>But in some algorithms, it can be important to be able to ask "Are these two things <em>the same object</em>?" This can help with detecting cycles in a graph, for example. So how do I ask for reference equality in F#? I.e., how do I write the <code>isSameObject</code> function below?</p> <pre><code>let isSameObject x y = ??? let a = [1; 2; 3] let b = [1; 2; 3] let a' = a printfn "%A" (isSameObject a b) // Prints "false" printfn "%A" (isSameObject a a') // Prints "true" </code></pre>
<f#><equality>
2016-08-30 00:27:18
HQ
39,217,275
Date.now().toISOString() throwing error "not a function"
<p>I am running Node v6.4.0 on Windows 10. In one of my Javascript files I am trying to get an ISO date string from the Date object:</p> <pre><code>let timestamp = Date.now().toISOString(); </code></pre> <p>This throws: Date.now(...).toISOString is not a function</p> <p>Looking through stackoverflow this should work...possible bug in Node?</p>
<node.js>
2016-08-30 00:50:17
HQ
39,217,690
PHP function, call only one variable
<p>I need help with a PHP function im writing. My code:</p> <pre><code>function get_config() { $db = dbServer::getInstance(); $mysqli = $db-&gt;getConnection(); $sql_query = 'SELECT * FROM server_config'; $result = $mysqli-&gt;query($sql_query); if ($result-&gt;num_rows &gt; 0) { while($row = $result-&gt;fetch_assoc()) { $serverStatus = $row['server_status']; $serverTitle = $row['server_title']; } } } </code></pre> <p>Now, If I'd want to call the function and only echo let's say, $serverTitle, how should I do that? I.e:</p> <pre><code>get_config($serverStatus)? </code></pre> <p>I'm a total rookie when it comes to PHP.</p>
<php>
2016-08-30 01:58:25
LQ_CLOSE
39,217,717
In computer vision, what does MVS do that SFM can't?
<p>I'm a dev with about a decade of enterprise software engineering under his belt, and my hobbyist interests have steered me into the vast and scary realm of computer vision (CV).</p> <p>One thing that is not immediately clear to me is the division of labor between <strong>Structure from Motion (SFM)</strong> tools and <strong>Multi View Stereo (MVS)</strong> tools.</p> <p>Specifically, <a href="http://www.di.ens.fr/cmvs/" rel="noreferrer">CMVS</a> appears to be the best-in-show MVS tool, and <a href="http://www.cs.cornell.edu/~snavely/bundler/" rel="noreferrer">Bundler</a> seems to be one of the better open source SFM tools out there.</p> <p>Taken from CMVS's own homepage:</p> <blockquote> <p>You should ALWAYS use CMVS after Bundler and before PMVS2</p> </blockquote> <p>I'm wondering: <strong>why?!?</strong> My <em>understanding</em> of SFM tools is that they perform the 3D reconstruction for you, so why do we need MVS tools in the first place? What value/processing/features do they add that SFM tools like Bundler can't address? Why the proposed pipeline of:</p> <pre><code>Bundler -&gt; CMVS -&gt; PMVS2 </code></pre> <p>?</p>
<computer-vision><structure-from-motion>
2016-08-30 02:02:38
HQ
39,217,732
Is it possible to change the order of list items using CSS3?
<p>Is it possible to change the order of list items using CSS3?</p> <p>For example, if a list is coded in HTML in 1,2,3,4,5 order, but I want it to show in 5,1,2,3,4 order.</p> <p>I'm using a CSS overlay to modify a Firefox extension, so I can't just change the HTML.</p> <p>HTML Code</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;ul&gt; &lt;li&gt;1&lt;/li&gt; &lt;li&gt;2&lt;/li&gt; &lt;li&gt;3&lt;/li&gt; &lt;li&gt;4&lt;/li&gt; &lt;li&gt;5&lt;/li&gt; &lt;/ul&gt;</code></pre> </div> </div> </p>
<html><css><firefox><firefox-addon>
2016-08-30 02:04:26
HQ
39,219,394
How to Manage back press in Fragments
<p>I want to manage all fragment in back press. When i click back press then open previous fragment and finish present fragment.</p>
<android><fragment><android-fragmentactivity><back>
2016-08-30 05:32:25
LQ_CLOSE
39,219,414
In TensorFlow, how can I get nonzero values and their indices from a tensor with python?
<p>I want to do something like this.<br> Let's say we have a tensor A. </p> <pre><code>A = [[1,0],[0,4]] </code></pre> <p>And I want to get nonzero values and their indices from it. </p> <pre><code>Nonzero values: [1,4] Nonzero indices: [[0,0],[1,1]] </code></pre> <p>There are similar operations in Numpy.<br> <code>np.flatnonzero(A)</code> return indices that are non-zero in the flattened A.<br> <code>x.ravel()[np.flatnonzero(x)]</code> extract elements according to non-zero indices.<br> Here's <a href="http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.flatnonzero.html" rel="noreferrer">a link</a> for these operations.</p> <p>How can I do somthing like above Numpy operations in Tensorflow with python?<br> (Whether a matrix is flattened or not doesn't really matter.)</p>
<python><tensorflow><indices>
2016-08-30 05:34:07
HQ
39,220,225
ImageMagick path error on Sierra (beta)
<p>I'm trying to put watermark on iOS app's appIcon. For that I'm following <a href="https://www.raywenderlich.com/105641/change-app-icon-build-time">Ray's</a> blog and I installed ImageMagick using binary release from <a href="http://www.imagemagick.org/script/binary-releases.php#macosx">here</a>. I also added <strong>/bin</strong> and <strong>/lib</strong> in my paths using <code>sudo nano /etc/paths</code> so convert command seems to be working. </p> <p>The problem statement: when I use <strong>convert</strong> command from tutorial I get the following error</p> <pre><code>dyld: Library not loaded: /ImageMagick-7.0.1/lib/libMagickCore-7.Q16HDRI.0.dylib Referenced from: /Users/Username/Library/ImageMagick-7.0.1/bin/convert Reason: image not found Abort trap: 6 </code></pre> <p>Even though the image is there the error is "image not found." Any idea community ?</p>
<macos><terminal><imagemagick><imagemagick-convert>
2016-08-30 06:27:04
HQ
39,221,032
How to turn off spell checking in CSS?
<p>Any attributes or some tweak to ignore the red-colored underline? or it's ignoreable due to browser settings?</p> <p><a href="https://i.stack.imgur.com/c24pg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/c24pg.png" alt="enter image description here"></a></p>
<css>
2016-08-30 07:11:43
HQ
39,221,298
Navigation Drawer item remains selected Android
<p>My navigation drawer keeps showing the last selected item.Is there any way to remove it.I want that if the user is at Home page, the navigation drawer items should be non-highlighted.</p> <p>I have tried </p> <pre><code>drawer.setSelected(false); </code></pre> <p>in onResume(). But it doesn't help.</p> <p>Please refer the attached screenshot, it will help understand.</p> <p><a href="https://i.stack.imgur.com/siTn1.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/siTn1.jpg" alt="See the seetings options is highlighted even when I have come back from Settings activity"></a></p>
<android><android-activity><android-menu><navigation-drawer>
2016-08-30 07:26:36
HQ
39,221,325
How to create an overlay page in ionic 2?
<p>How to creating an transparent guide overlay page when i enter into new page </p> <p>How can i implement in ionic 2 ?</p> <p><a href="https://i.stack.imgur.com/zlu9a.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/zlu9a.jpg" alt="enter image description here"></a></p>
<angular><typescript><ionic-framework><ionic2>
2016-08-30 07:28:07
HQ
39,222,359
Test trigger performance
<p>how can I test my trigger ,how much time does it take on a table to execute?</p>
<postgresql>
2016-08-30 08:25:18
LQ_CLOSE
39,222,388
Need A Modulus Formula In Php
<p>I am creating a fee calculator and fee is calculated on based of capital. So I want a formula in php.</p> <p>if capital is &lt;=1000000 then fee is 1000 if capital is 1100000 - 2000000 fee is 2000 if capital is 2100000 - 3000000 fee is 3000 if capital is 3100000 - 4000000 fee is 4000 if capital is 4100000 - 5000000 fee is 5000 and so on so what i want is i want a formula that will give me a fee of 1000 per 10 Lakh </p>
<php><math><formula>
2016-08-30 08:27:13
LQ_CLOSE
39,222,561
How to set up the Twitter gem in rails app? please help me please
i have installed ruby rails on my computer. i would like to create twitter API with ruby rails. [i downloaded this gem zip file also ][1] [1]: http://i.stack.imgur.com/eMNsJ.jpg i have twitter API token and key. i don't know how to move up so please help.
<ruby-on-rails><ruby><api><twitter>
2016-08-30 08:35:16
LQ_EDIT
39,222,622
unable to store one function value in variable
<p>im getting value from jquery ajax call but unable to save in global variable, which value i want to use in another function. i want to get assign dustValue in initialize function.</p> <p>javascript code</p> <pre><code>var dustValue; $.ajax({ type: "GET", url: "http://my url", dataType: "json", success: function (data) { dustValue = data.sensorsdata.PHValue; } }); var myCenter = new google.maps.LatLng(22.8046, 86.2029); function initialize() { var mapProp = { center: myCenter, zoom: 17, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("googleMap"), mapProp); var value = dustValue;//78.55 var dustbinstatus = ''; if (value &lt; 50) { dustbinstatus = 'img/dustbinempty.png'; } else if (value &gt; 50 &amp;&amp; value &lt; 90) { dustbinstatus = 'img/dustbinfull.png'; } else if (value &gt; 90) { dustbinstatus = '3.jpg'; } var marker = new google.maps.Marker({ position: myCenter, icon: v_icon }); marker.setMap(map); } google.maps.event.addDomListener(window, 'load', initialize); </code></pre> <p>body </p> <pre><code> &lt;div id="googleMap" style="width:1580px;height:780px;"&gt;&lt;/div&gt; </code></pre>
<javascript><jquery><ajax><google-maps><jquery-ajaxq>
2016-08-30 08:38:39
LQ_CLOSE
39,222,707
Most efficient way to store and retrieve data
<p>What is the best way to store data permanently in the code? I have the data e.g. Roll No. (Unique Key) Values: Name, DOB, Weight, Height etc.</p> <p>These are going to be static information and I want to store them as the part of application. While using, I want to load them in hashmap so that I can quickly access any student based on the key (Roll number). The data size can go up to 100K entries.</p> <p>I tried with enum, e.g.</p> <pre><code>2015CSE3245(“John”, “1997-08-13”, “73”, “176”); </code></pre> <p>Is this the best and most efficient way to store the data? Is there any better way in terms of memory and time to read?</p>
<java><android><performance><hashmap>
2016-08-30 08:43:34
LQ_CLOSE
39,223,249
Multiple RUN vs. single chained RUN in Dockerfile, what is better?
<p><code>Dockerfile.1</code> executes multiple <code>RUN</code>:</p> <pre><code>FROM busybox RUN echo This is the A &gt; a RUN echo This is the B &gt; b RUN echo This is the C &gt; c </code></pre> <p><code>Dockerfile.2</code> joins them:</p> <pre><code>FROM busybox RUN echo This is the A &gt; a &amp;&amp;\ echo This is the B &gt; b &amp;&amp;\ echo This is the C &gt; c </code></pre> <p>Each <code>RUN</code> creates a layer, so I always assumed that less layers is better and thus <code>Dockerfile.2</code> is better.</p> <p>This is obviously true when a <code>RUN</code> removes something added by a previous <code>RUN</code> (i.e. <code>yum install nano &amp;&amp; yum clean all</code>), but in cases where every <code>RUN</code> adds something, there are a few points we need to consider:</p> <ol> <li><p>Layers are supposed to just add a diff above the previous one, so if the later layer does not remove something added in a previous one, there should be not much disk space saving advantage between both methods...</p></li> <li><p>Layers are pulled in parallel from Docker Hub, so <code>Dockerfile.1</code>, although probably slightly bigger, would theoretically get downloaded faster.</p></li> <li><p>If adding a 4th sentence (i.e. <code>echo This is the D &gt; d</code>) and locally rebuilding, <code>Dockerfile.1</code> would build faster thanks to cache, but <code>Dockerfile.2</code> would have to run all 4 commands again.</p></li> </ol> <p>So, the question: <strong>Which is a better way to do a Dockerfile?</strong></p>
<docker><dockerfile>
2016-08-30 09:09:53
HQ
39,223,286
How to refresh text in Matplotlib?
<p>I wrote this code to read data from an excel file and to plot them. For a certain x-value, I desire to know the y-values of all the lines so I create a slider to change this x-value but I'm not able to refresh the text which prints the y-value.</p> <p>The code is this</p> <pre><code>import numpy as np from openpyxl import load_workbook as ld import matplotlib matplotlib.use('TkAgg') import matplotlib.pyplot as plt from matplotlib.widgets import Slider wb = ld(filename='example.xlsx') data = wb['data'] time = wb['time'] row = data.max_row column = data.max_column x = np.ones((row, column)) y = np.ones((row, column)) result = np.ones(row) for i in range(0, row): for j in range(0, column): x[i][j] = time.cell(row=i+1, column=j+1).value y[i][j] = data.cell(row=i+1, column=j+1).value fig, ax = plt.subplots() plt.subplots_adjust(left=0.25, bottom=0.25) plt.plot(x[0], y[0], label='line1') plt.plot(x[1], y[1], label='line2') plt.plot(x[2], y[2], label='line3') line, = plt.plot((np.amin(x), np.amin(x)), (np.amin(y), np.amax(y))) plt.legend() plt.grid(True) axtime = plt.axes([0.25, 0.1, 0.65, 0.03]) stime = Slider(axtime, 'time', np.amin(x), np.amax(x), valinit=np.amin(x)) def y_text(r): ax.text(10, 8, str(r), style='italic') def find(t): global x, y, result for i in range(0, row): for j in range(0, column): if x[i][j] == t or (t &lt; x[i][j] and j == 0) or (t &gt; x[i][j] and j == column): result[i] = y[i][j] elif x[i][j] &lt; t &lt; x[i][j+1]: result[i] = ((t-x[i][j])/(x[i][j+1]-x[i][j]))*(y[i][j+1]-y[i][j])+y[i][j] return result def update(val): line.set_xdata(stime.val) find(stime.val) y_text(stime.val) fig.canvas.draw() stime.on_changed(update) plt.show() </code></pre> <p>and the result is this</p> <p><a href="https://i.stack.imgur.com/ZVRRP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZVRRP.png" alt="enter image description here"></a></p> <p>As you can see the text is overwritten.</p>
<python><python-3.x><text><matplotlib><plot>
2016-08-30 09:11:31
HQ
39,223,342
Firebase onAuthStateChanged callback takes 20+ seconds sometimes
<p>We've been using Firebase on our applications after moving away from our own NodeJS backend running express and during this transition we've noticed one major drawback. The amount of time it takes for the initial auth state to be received by the client.</p> <p>When my application is opened I <strong>immediately</strong> register the <code>onAuthStateChanged</code> callback to start listening for changes in authentication state, that way I can route the user to either their personal hub or the authentication screen. </p> <p>The problem is that while sometimes this only takes a few milliseconds, at other times (Independant of internet connection) it takes anywhere from 20+ seconds, causing an extremely poor user experience. </p> <p>We're using the Firebase WEB API on a UIWebView component.</p> <p>I've tested this on 3G, 4G, LTE and Wifi and it's completely random. Sometimes it loads like lightning. Sometimes it's so slow that I question the reliability of the service. </p> <p>Some may argue that this is due to the user data we have to download, but the 20-30 seconds that we're waiting is before we even attempt to pull data from the server. This is just to get the initial authorization state. We're only using email providers.</p> <p>Does anyone know what we could do to improve this? On average the <code>onAuthStateChanged</code> callback is defined <code>562ms</code> after the applications execution. After this sometimes it can take <code>20-200ms</code> (Average latency) and sometimes it takes 20000ms+</p>
<firebase><firebase-authentication>
2016-08-30 09:13:51
HQ
39,224,865
Dependency injection into abstract class typescript(Angular2)
<p>I have abstract class(without constructor) and I want to inject another class into it.</p> <p>Abstract class:</p> <pre><code>import { ErrorHandler } from '../../shared/services/errorHandler.service'; import { Inject } from '@angular/core'; export abstract class BaseApiComponent&lt;T&gt; { @Inject(ErrorHandler) errorHandler: ErrorHandler; this.errorHandler.test(); } </code></pre> <p>Injected class:</p> <pre><code>import { Injectable } from '@angular/core'; @Injectable() export class ErrorHandler { constructor() { } public test() { console.log('Test'); } } </code></pre> <p>And I have next error</p> <pre><code>ORIGINAL EXCEPTION: TypeError: Cannot read property 'test' of undefined </code></pre> <p>How i can fix this? </p>
<angular><typescript><dependency-injection><abstract-class>
2016-08-30 10:21:59
HQ
39,225,106
No provider for ControlContainer when a child component has a ngModelGroup
<p>I can't seem to figure this out, it's simply not working.</p> <p>This is the original <a href="http://embed.plnkr.co/LLf7Il/" rel="noreferrer">plunker</a> which is written by Pascal Prekht , which is an explanation on template driven forms: </p> <p>And <a href="https://embed.plnkr.co/Q8pjSIVJHhfubILtvqWw/" rel="noreferrer">here</a> is my fork which is exactly the same thing , except I'm trying to load one of the fieldsets as a separate child component.</p> <p>Here is the code :</p> <pre><code>@Component({ selector:'form-group-component', template:` &lt;fieldset ngModelGroup="anotherAddress"&gt; &lt;div&gt; &lt;label&gt;Street2:&lt;/label&gt; &lt;input type="text" name="street2" ngModel&gt; &lt;/div&gt; &lt;/fieldset&gt; ` }) export class FormGroupComponent{ } @Component({ selector: 'form-component', directives:[FormGroupComponent], template: ` &lt;form #form="ngForm"&gt; &lt;form-group-component&gt;&lt;/form-group-component&gt; &lt;fieldset ngModelGroup="address"&gt; &lt;div&gt; &lt;label&gt;Street:&lt;/label&gt; &lt;input type="text" name="street" ngModel&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt;Zip:&lt;/label&gt; &lt;input type="text" name="zip" ngModel&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt;City:&lt;/label&gt; &lt;input type="text" name="city" ngModel&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/form&gt; ` }) export class FormComponent { } </code></pre> <p>So after cutting one of the feildsets and loading it inside a seperate directive , it won't work anymore!,</p> <p>There are couple of closed issues , but non of them is working.</p> <p><a href="https://github.com/mgechev/angular2-seed/issues/399" rel="noreferrer">This </a> and <a href="https://github.com/angular/angular/issues/6374" rel="noreferrer">This</a></p>
<angular><angular2-forms>
2016-08-30 10:32:14
HQ
39,225,161
Convert Uint8Array into hex string equivalent in node.js
<p>I am using node.js v4.5. Suppose I have this Uint8Array variable.</p> <pre><code>var uint8 = new Uint8Array(4); uint8[0] = 0x1f; uint8[1] = 0x2f; uint8[2] = 0x3f; uint8[3] = 0x4f; </code></pre> <p>This array can be of any length but let's assume the length is 4. </p> <p>I would like to have a function that that converts <code>uint8</code> into the hex string equivalent. </p> <pre><code>var hex_string = convertUint8_to_hexStr(uint8); //hex_string becomes "1f2f3f4f" </code></pre>
<node.js><string-conversion>
2016-08-30 10:34:52
HQ
39,225,717
Part of button outside of the dialog in android
I'm trying to achive something like this: [enter image description here][1] [1]: http://i.stack.imgur.com/u4kmI.png Anyone have idea how to make button stay partially outside the dialog and be always under the text ?
<android><xml><android-layout><android-dialog>
2016-08-30 11:00:52
LQ_EDIT
39,226,177
How to clear focus from an inputfield in React Native?
<p>I have an inputfield and I want to get rid of the focus on it, after i click the submit button.</p> <p>Any suggestions on how I would go about this?</p>
<react-native>
2016-08-30 11:23:30
HQ
39,226,259
General function for two List<>
I have two List<> with the same field that I need to edit. How to write a common function for these lists? public List<?> CutField(List<?> list) { foreach(var element in list) { element.Field = // ; } return List<?>; }
<c#><list><generics>
2016-08-30 11:26:57
LQ_EDIT
39,226,928
React - adding class to children components
<p>im using react and I have a component that simply needs to render the children and add them a class according to a condition. Whats the best way of doing it?</p>
<reactjs>
2016-08-30 11:59:59
HQ
39,227,521
How to pass int optional parameter in webmethod using C#
I am passing int optional parameter in webmethod but i am getting ' Cannot convert to System.Int32.', my code is : [WebMethod] public string Test([Optional] int ID) { return "Test"; } can you please let me know that where is the issue, and what i am missing . please anyone reply me asap..
<c#><web-services>
2016-08-30 12:28:08
LQ_EDIT
39,227,832
Advantages of using immutable.js over Object.assign or spread operators
<p>So far most of "starter boilerplates" and some posts about react / redux I've seen encourage usage of <a href="https://facebook.github.io/immutable-js/" rel="noreferrer">immutable.js</a> to address mutability. I personally rely on <code>Object.assign</code> or spread operators to handle this, hence don't really see advantage in immutable.js as it adds additional learning and shifts a bit from vanilla js techniques used for mutability. I was trying to find valid reasons for a switch, but wasn't able to hence I am asking here to see why it is so popular.</p>
<javascript><reactjs><redux><immutability>
2016-08-30 12:41:36
HQ
39,227,930
Double trouble, subtracting
<p>Im getting totally wrong when calling CorrectDecimals with the following parameters:</p> <p>203,30 - 203,00. Gives me: 0.30000000000001137 (the variable double d). With my mathematical skills it should just be 0.3</p> <pre><code>string a = CorrectDecimals("203,30", "203,00", "12"); public static string CorrectDecimals(string unitPrice, string netAmount, string length) { double unitP = (Double.Parse(unitPrice)); double netAmoun = (Double.Parse(netAmount)); double d = unitP - netAmoun; </code></pre>
<c#><double>
2016-08-30 12:46:04
LQ_CLOSE
39,228,128
Can't decrypt RSA data with open SSL
<p>I try to encrypt some data in matlab using a public key I created with openssl</p> <p>I created the keys using:</p> <pre><code>openssl genrsa -des3 -out private.pem 1024 openssl rsa -in private.pem -pubout -outform DER -out public.der </code></pre> <p>I encrypt my data using this matlab code (with Java libraries):</p> <pre><code>import java.security.spec.RSAPublicKeySpec import javax.crypto.Cipher; import java.security.KeyFactory import java.math.BigInteger fid = fopen('public.der'); a = fread(fid); key = java.security.spec.X509EncodedKeySpec(a); kf = KeyFactory.getInstance('RSA'); KEY = kf.generatePublic(key); cipher = Cipher.getInstance('RSA/ECB/PKCS1Padding'); cipher.init(Cipher.ENCRYPT_MODE, KEY) plaintextBytes = [24]; ciphertext = cipher.doFinal(plaintextBytes)' ; fid2 = fopen('msg.txt','w'); fwrite(fid2,ciphertext); fclose(fid2); </code></pre> <p>I try to decrypt it using:</p> <pre><code>openssl rsautl -decrypt -inkey private.pem -in msg.txt -keyform PEM -pkcs </code></pre> <p>Then I get this error:</p> <pre><code>RSA operation error 80305:error:0407109F:rsa routines:RSA_padding_check_PKCS1_type_2:pkcs decoding error:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-59.40.2/src/crypto/rsa/rsa_pk1.c:267: 80305:error:04065072:rsa routines:RSA_EAY_PRIVATE_DECRYPT:padding check failed:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-59.40.2/src/crypto/rsa/rsa_eay.c:614: </code></pre>
<java><matlab><encryption><rsa>
2016-08-30 12:56:00
HQ
39,228,386
Java if statement. user input
i am using scanner to take user input. Scanner scanner = new Scanner(System.in); Int choice = scanner.nextInt(); if(choice==1) { System.out.println(" you chosed number 1!") } if(choice==2) { System.out.println(" you chosed number 2!") } if(choice==3) { System.out.println(" you chosed number 3!") } if(choice==q) { System.out.println("the game will end now!"); } so when you enter the game you have a meny that poops up. you can chose between 1, 2, 3 or q. if you press any of the numbers the game will take you to those sections. but if you press q the game will end. i dont know how to fix so that i can enter q and game ends. help please
<java><if-statement>
2016-08-30 13:08:17
LQ_EDIT
39,228,465
How to decode JWT Token payload on client side?
<p>I'm using a jwt token for authentication and would like to read the payload information on the client-side. Right now I'm doing something like this:</p> <pre><code>var payload = JSON.parse(window.atob(token.split('.')[1])); </code></pre> <p>Is there a better way to work with jwt tokens within the browser? </p>
<javascript><jwt>
2016-08-30 13:11:38
HQ
39,229,398
How to update controls of FormArray
<p>My form group code is as</p> <pre><code>this.myForm = this._fb.group({ branch_name: ['', [Validators.required]], branch_timing: this._fb.array([ this.initBranchTiming(), ]) }); initBranchTiming() { return this._fb.group({ day: ['', []], open_from: ['00:00:00', []], open_till: ['00:00:00', []] }); } </code></pre> <p>branch_name is updated by this code </p> <pre><code>(&lt;FormControl&gt;this.myForm.controls['branch_name']).updateValue(this.branch_detail.branch_name); </code></pre> <p>Now i have to update the 'day' field of form array. what to do to update the 'day' field of form array branch_timing ?</p>
<angular><angular2-forms>
2016-08-30 13:51:47
HQ
39,229,607
Error while accessing dictionary in python
I have a dictionary named json_dict given below. I need to access the element ==> json_dict['OptionSettings'][3]['Value']. I need to access the element like print(json_dict[param]). When I giving param like param="['OptionSettings'][3]['Value']" OR param="'OptionSettings'][3]['Value'" I am getting below error KeyError: "['OptionSettings'][3]['Value']" OR KeyError: "'OptionSettings'][3]['Value'" I tried below thing also but it just print the string str1="json_dict" print(str1+param) { "ApplicationName": "Test", "EnvironmentName": "ABC-Nodejs", "CNAMEPrefix": "ABC-Neptune", "SolutionStackName": "64bit Amazon Linux 2016.03 v2.1.1 running Node.js", "OptionSettings": [ { "Namespace": "aws:ec2:vpc", "OptionName": "AssociatePublicIpAddress", "Value": "true" }, { "Namespace": "aws:elasticbeanstalk:environment", "OptionName": "EnvironmentType", "Value": "LoadBalanced" }, { "Namespace": "aws:ec2:vpc", "OptionName": "Subnets", "Value": "param1" }, { "Namespace": "aws:autoscaling:launchconfiguration", "OptionName": "SecurityGroups", "Value": "param2" }, { "Namespace": "aws:autoscaling:asg", "OptionName": "MinSize", "Value": "1" }, { "Namespace": "aws:autoscaling:asg", "OptionName": "MaxSize", "Value": "4" }, { "Namespace": "aws:autoscaling:asg", "OptionName": "Availability Zones", "Value": "Any" }, { "Namespace": "aws:autoscaling:asg", "OptionName": "Cooldown", "Value": "360" }, { "Namespace": "aws:autoscaling:launchconfiguration", "OptionName": "IamInstanceProfile", "Value": "NepRole" }, { "Namespace": "aws:autoscaling:launchconfiguration", "OptionName": "MonitoringInterval", "Value": "5 minutes" }, { "Namespace": "aws:autoscaling:launchconfiguration", "OptionName": "RootVolumeType", "Value": "gp2" }, { "Namespace": "aws:autoscaling:launchconfiguration", "OptionName": "RootVolumeSize", "Value": "10" }, { "Namespace": "aws:elasticbeanstalk:sns:topics", "OptionName": "Notification Endpoint", "Value": "sunil.kumar2@pb.com" }, { "Namespace": "aws:elasticbeanstalk:hostmanager", "OptionName": "LogPublicationControl", "Value": "false" }, { "Namespace": "aws:elasticbeanstalk:command", "OptionName": "DeploymentPolicy", "Value": "Rolling" }, { "Namespace": "aws:elasticbeanstalk:command", "OptionName": "BatchSizeType", "Value": "Percentage" }, { "Namespace": "aws:elasticbeanstalk:command", "OptionName": "BatchSize", "Value": "100" }, { "Namespace": "aws:elasticbeanstalk:command", "OptionName": "HealthCheckSuccessThreshold", "Value": "Ok" }, { "Namespace": "aws:elasticbeanstalk:command", "OptionName": "IgnoreHealthCheck", "Value": "false" }, { "Namespace": "aws:elasticbeanstalk:command", "OptionName": "Timeout", "Value": "600" }, { "Namespace": "aws:autoscaling:updatepolicy:rollingupdate", "OptionName": "RollingUpdateEnabled", "Value": "false" }, { "Namespace": "aws:ec2:vpc", "OptionName": "ELBSubnets", "Value": "param3" }, { "Namespace": "aws:elb:loadbalancer", "OptionName": "SecurityGroups", "Value": "param4" }, { "Namespace": "aws:elb:loadbalancer", "OptionName": "ManagedSecurityGroup", "Value": "param4" } ] }
<python><json><python-2.7><python-3.x><dictionary>
2016-08-30 14:01:12
LQ_EDIT
39,229,718
Java == != && || operator?
<p>I have a problem with my code. This code should check login and password. The problem is the else if statement showing a wrong output. Example, when i enter username == admin and password == 1234, it display username is incorrect.</p> <pre><code>import java.io.*; public class login { public static void main(String [] args) throws IOException { String username = "admin"; String password = "123"; BufferedReader inData = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter username : "); username = inData.readLine(); System.out.print("Enter password : "); password = inData.readLine(); if((username == "admin") &amp;&amp; (password == "123")) { System.out.println("Welcome " + username + "\n*** Login Sucessfully ***" + "\n*** Access Granted ***"); } else if((username != "admin") &amp;&amp; (password == "123")) { System.out.println("Sorry, username is incorrect!\n*** Access Denied ***"); } else if((username == "admin") &amp;&amp; (password != "123")) { System.out.println("Sorry, password is incorrect!\n*** Access Denied ***"); } else if((username != "admin") &amp;&amp; (password != "123")) { System.out.println("Sorry, username and password is incorrect!\n*** Access Denied ***"); } } } </code></pre>
<java>
2016-08-30 14:05:24
LQ_CLOSE
39,229,831
How do I use my input from 2 cases in to a 3rd case? All in one switch
So, I have been stuck with this problem for 3 hours now. My google-fu is rubbish so I haven't been able to word out my problem accurately. Scanner in = new Scanner(System.in); int menuSel; do{ System.out.println("1. Adult Tickets"); System.out.println("2. Child Tickets"); System.out.println("3. Finalise Order"); System.out.println("4. Cancel Order"); System.out.println("Please select an option from the list:"); menuSel = in.nextInt(); switch(menuSel){ case 1: System.out.println("Number of tickets:"); int adult = in.nextInt(); double adultTotal=(adult*15.5); System.out.println("Total price for " + adult + " tickets is $" + adultTotal); break; case 2: System.out.println("Number of tickets:"); int child = in.nextInt(); double childTotal=(child*5.75); System.out.println("Total price for " + child + " tickets is $" + childTotal); break; case 3: adult=?; child=?; adultTotal=(adult*15.5); childTotal=(child*5.75); System.out.println("Your order of " + adult + "adult ticket(s) and "+ child + "child ticket(s) amounts to $" +(childTotal+adultTotal)); } In this code I have an issue with case 3. I cannot seem to get the variables 'adult' and 'child' to display properly. I get the "local variable may not be initialized" error. I do not want to declare variables at the main because I am inputting the values in case 1 and 2. I would like case 3 to display what I input in case 1 in case 2 as values. Sorry if this is a stupid question, I have been stuck at this problem for 3 hours and unfortunately I do not know how to progress further.
<java><switch-statement>
2016-08-30 14:10:22
LQ_EDIT
39,230,865
I need help in finding the server details where the Websphere mq queue manger has been configured
I need help in finding the server details where the Websphere mq queue manger has been configured. In WAS console i see a queue manager name in the connection properties but I dont know in which server the queue manager is configure, Is there a way to find out the details ?
<websphere><message-queue><ibm-mq>
2016-08-30 14:55:55
LQ_EDIT
39,231,102
SQL Replace multiple different characters in string
<p>I need to replace multiple characters in a string. The result can't contain any '&amp;' or any commas.</p> <p>I currently have: </p> <pre><code>REPLACE(T2.[ShipToCode],'&amp;','and') </code></pre> <p>But how do you put multiple values in?</p> <p>Many thanks!</p>
<sql><replace><sql-server-2016>
2016-08-30 15:05:56
HQ
39,231,761
Singleton Class or Class with only static fields?
<p>what is the better approach? </p> <p>Let us assume a scenario in which there is a utility class that is used by other classes. What is better to use in this case, a singleton class which can be instantiated exactly once or should i make all the fieds static?</p>
<java><design-patterns>
2016-08-30 15:36:32
LQ_CLOSE
39,231,797
AWS Cognito - User stuck in CONFIRMED and email_verified = false
<p>How do I go about email verifying a user who is CONFIRMED yet email_verified is false?</p> <p>The scenario is roughly an agent signs up user on their behalf, and I confirm the user through the admin call adminConfirmSignUp. At that point, the user cannot change their password because of the email_verified flag being false.</p> <p>I can't call resendConfirmationCode because the user is already confirmed.</p> <p>I can't call forgotPassword because the email_verified flag is false.</p> <p>The best I can think of is deleting the user account and calling signUp (prompting them to re-enter their password or a new password), hence recreating their account.</p>
<amazon-cognito>
2016-08-30 15:38:05
HQ
39,232,438
Use PHP to deploy 20 minutes trial VPS powered by Scaleway
i just knew thats the http://instantcloud.io api link is https://try.cloud.online.net and i want to provide free 20 minutes VPS to my site visitors to enjoy more , ***of course i will leave credits to the instantcloud.io*** becoz they are the hosters can someone tell me some php examples to start building?
<php><vps>
2016-08-30 16:14:40
LQ_EDIT
39,232,599
Pass a value to another screen
<p>I have a screen where the user can select an option (not a browse gallery as it does not do what is required).</p> <p>I want to pass the item the user has selected to the pre-made "DetailScreen1" which is used by the browse gallery. </p> <p>I looked at the browse screen but did not see how it does it as the navigate onselect event is just normal navigation.</p> <p>Code:</p> <pre><code>Navigate(DetailScreen1, ScreenTransition.Fade) </code></pre> <p>I want to do something like </p> <pre><code>Navigate(DetailScreen1, ScreenTransition.None {Last(listOfStuff)}) </code></pre> <p>Thanks</p>
<powerapps>
2016-08-30 16:23:13
HQ
39,232,741
How to parse several log nginx files using goaccess
<p>I want to parse all my logs of nginx (you can see here):</p> <pre><code>ls /var/log/nginx/ access.log access.log.21.gz error.log.1 error.log.22.gz access.log.1 access.log.22.gz error.log.10.gz error.log.23.gz access.log.10.gz access.log.23.gz error.log.11.gz error.log.24.gz access.log.11.gz access.log.24.gz error.log.12.gz error.log.2.gz access.log.12.gz access.log.2.gz error.log.13.gz error.log.3.gz access.log.13.gz access.log.3.gz error.log.14.gz error.log.4.gz access.log.14.gz access.log.4.gz error.log.15.gz error.log.5.gz access.log.15.gz access.log.5.gz error.log.16.gz error.log.6.gz access.log.16.gz access.log.6.gz error.log.17.gz error.log.7.gz access.log.17.gz access.log.7.gz error.log.18.gz error.log.8.gz access.log.18.gz access.log.8.gz error.log.19.gz error.log.9.gz access.log.19.gz access.log.9.gz error.log.20.gz access.log.20.gz error.log error.log.21.gz </code></pre> <p>but I don't know how to do that. First of all, it seems like goaccess can't parse .gz files.</p> <p>What's the best way of parse all the information contained in these logs?</p>
<logging><nginx><goaccess>
2016-08-30 16:32:08
HQ
39,233,130
Checkbox checked if boolean is true with Angular2
<p>I would like to know how to make a checkbox checked if the value is true, and unchecked if false with <code>Angular2</code>.</p> <pre><code>Adult &lt;input type="checkbox" value="{{person.is_adult}}"&gt; </code></pre> <p>{{person.is_adult}} is a <code>boolean</code></p> <p>Can someone please suggest anything? Thanks</p>
<html><checkbox><angular><boolean>
2016-08-30 16:56:41
HQ
39,233,403
How to restrict runners to a specific branch and lock the .gitlab-ci.yml from changes?
<p>Right now, anyone that creates a branch in my project and adds a .gitlab-ci.yml file to it, can execute commands on my server using the runner. How can I make it so that only masters or owners can upload CI config files and make changes to them?</p> <p>I'm using <a href="https://gitlab.com/gitlab-org/gitlab-ci-multi-runner" rel="noreferrer">https://gitlab.com/gitlab-org/gitlab-ci-multi-runner</a> running on bash.</p>
<gitlab-ci><gitlab-ci-runner><gitlab-ce>
2016-08-30 17:13:03
HQ
39,233,459
How to get/set Trello custom fields using the API?
<p>I'm already in love with the <a href="https://blog.trello.com/trello-custom-fields/" rel="noreferrer">Custom Fields</a> feature in Trello. Is there a way to get and set custom fields via the API?</p> <p>I tried using the <a href="https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-field" rel="noreferrer">get field</a> API call to get a field (on a board with a custom field defined called "MyCustomField"):</p> <p><code>curl "https://api.trello.com/1/cards/57c473503a5ef0b76fddd0e5/MyCustomField?key=${TRELLO_API_KEY}&amp;token=${TRELLO_OAUTH_TOKEN}" </code></p> <p>to no avail. </p>
<api><trello>
2016-08-30 17:16:42
HQ
39,234,016
C# get windows list from primary screen only
How can I get list of windows from primary screen only on multi-monitor configuration?
<c#><multiple-monitors>
2016-08-30 17:50:05
LQ_EDIT
39,234,206
list() function php does not works in Mac OSx
I was wondering how come the php function list() does not works on Max OSx but on Windows it does. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> list($songAuthor, $songName, $songDate, $songSummary, $songPic, $songLyrics) = split(";", $data, 6); <!-- end snippet --> I'm trying to parse a string ($data) into six different variables. My PHP version is 7.0.8. How can i make the code run in my Mac OSx?
<php><php-7>
2016-08-30 18:01:27
LQ_EDIT
39,234,359
Access to headers in request-promise get response
<p>I am complete newbie to JS world. I am trying to write a test case that tests user's actions on a site. I am using request-promise module to test the asyn calls. I could not find any api documentation for request-promise. How do I get access to status code of the response? Right now it prints undefined. Also, can anyone please confirm, how do we know what promise returns when it is successful, is it a single value that it resolves to or all the parameters that the async function returns. How do we know what are the parameters to function() in <code>request.get(base_url).then(function(response, body)</code>. </p> <pre><code>var request = require("request-promise"); var promise = require("bluebird"); // var base_url = "https://mysignin.com/" // describe("My first test", function() { it("User is on the sign in page", function(done) { request.get(base_url).then(function(response, body){ // expect(response.statusCode).toBe('GET /200'); console.log("respnse " + response.statusCode); console.log("Body " + body); done(); }).catch(function(error) { done("Oops somthing went wrong!!"); }); }); }); </code></pre>
<javascript><promise>
2016-08-30 18:10:04
HQ
39,234,428
How do you clear your Visual Studio Code cache on a Mac/Linux Machine?
<p>How do I flush the cache for my Visual Studio Code on my Mac El Capitan OS?</p>
<linux><macos><visual-studio-code>
2016-08-30 18:14:09
HQ
39,234,639
basic SQL: selecting AVG() values depending two columns
I want to get AVG values depending two columns value. Here is my table example [example][1]; And this is what i need to [get][2]; I'm using that code to get required data but it gives me average for issue not isssue and owner and here is my code; select issue, owner, AVG(time) from myTable group by issue, owner Any suggestion about that? [1]: http://i.stack.imgur.com/ptSqg.png [2]: http://i.stack.imgur.com/ZZK28.png
<sql-server><average>
2016-08-30 18:27:46
LQ_EDIT
39,235,353
ES6: Find an object in an array by one of its properties
<p>I'm trying to figure out how to do this in ES6...</p> <p>I have this array of objects..</p> <pre><code>const originalData=[ {"investor": "Sue", "value": 5, "investment": "stocks"}, {"investor": "Rob", "value": 15, "investment": "options"}, {"investor": "Sue", "value": 25, "investment": "savings"}, {"investor": "Rob", "value": 15, "investment": "savings"}, {"investor": "Sue", "value": 2, "investment": "stocks"}, {"investor": "Liz", "value": 85, "investment": "options"}, {"investor": "Liz", "value": 16, "investment": "options"} ]; </code></pre> <p>..and this new array of objects where I want to add each person's total value of their investment types (stocks, options, savings)..</p> <pre><code>const newData = [ {"investor":"Sue", "stocks": 0, "options": 0, "savings": 0}, {"investor":"Rob", "stocks": 0, "options": 0, "savings": 0}, {"investor":"Liz", "stocks": 0, "options": 0, "savings": 0} ]; </code></pre> <p>I loop through originalData and save each property of the "current object" in a let..</p> <pre><code>for (let obj of originalData) { let currinvestor = obj.investor; let currinvestment = obj.investment; let currvalue = obj.value; ..but here I want to find the obect in newData that has the property = currinvestor (for the "investor" key) ...then add that investment type's (currinvestment) value (currvalue) } </code></pre>
<javascript><arrays>
2016-08-30 19:10:08
HQ
39,235,605
Self referential class
<p>Trying to write a class for a directory which can have a parent and a list of children.</p> <p>Class definition:</p> <pre><code>class Directory { public string name; public Directory parentDir; public List&lt;Directory&gt; subDirs; public Directory(string name) { this.name = name; } public void addSubDir(Directory x) { subDirs.Add(x); } } </code></pre> <p>Sample code trying to create two instances and set one as a child of the other:</p> <pre><code>Directory temp1 = new Directory("root"); Directory temp2 = new Directory("games"); temp1.addSubDir(temp2); </code></pre> <p>The error I get is: </p> <pre><code>System.NullReferenceException was unhandled Message=Object reference not set to an instance of an object. </code></pre>
<c#><class><pointers>
2016-08-30 19:27:02
LQ_CLOSE
39,235,704
Split Spark Dataframe string column into multiple columns
<p>I've seen various people suggesting that <code>Dataframe.explode</code> is a useful way to do this, but it results in more rows than the original dataframe, which isn't what I want at all. I simply want to do the Dataframe equivalent of the very simple:</p> <pre><code>rdd.map(lambda row: row + [row.my_str_col.split('-')]) </code></pre> <p>which takes something looking like:</p> <pre><code>col1 | my_str_col -----+----------- 18 | 856-yygrm 201 | 777-psgdg </code></pre> <p>and converts it to this:</p> <pre><code>col1 | my_str_col | _col3 | _col4 -----+------------+-------+------ 18 | 856-yygrm | 856 | yygrm 201 | 777-psgdg | 777 | psgdg </code></pre> <p>I am aware of <code>pyspark.sql.functions.split()</code>, but it results in a nested array column instead of two top-level columns like I want. </p> <p>Ideally, I want these new columns to be named as well.</p>
<apache-spark><pyspark><apache-spark-sql><spark-dataframe><pyspark-sql>
2016-08-30 19:32:59
HQ
39,236,068
I want to change the order of a list in C#
I have a list in C# whit 4 items, this list is used to send a response in a web service and i need a specific order for the items, but I'm having a problem, because for any reason the list change the order when I fill it. firs, this is the class of the list using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Serialization; namespace Mvm.SATWeb.Domain { [Serializable, DataContract] public class puntoDeAtencion { public puntoDeAtencion() { } [DataMember] public string codigoPuntoAtencion { get; set; } [DataMember] public decimal montoIngreso { get; set; } [DataMember] public decimal montoEgreso { get; set; } [DataMember] public decimal ingresoNeto { get; set; } } } I use a SQL server query to fill the list with a dataset List<puntoDeAtencion> valores = new List<puntoDeAtencion>(); DataSet ds; Database baseDatos = DatabaseFactory.CreateDatabase(); DbCommand comandoConsulta = baseDatos.GetStoredProcCommand("USP_RiesgoLiqui"); comandoConsulta.CommandTimeout = 600000; baseDatos.AddInParameter(comandoConsulta, "@pvstrIdAgencia", DbType.String, "-1"); baseDatos.AddInParameter(comandoConsulta, "@pvstrFechaInicial", DbType.String, FechaIni); baseDatos.AddInParameter(comandoConsulta, "@pvstrFechaFinal", DbType.String, FechaFin); comandoConsulta.CommandTimeout = 1000000; // baseDatos.ExecuteDataSet(); ds = baseDatos.ExecuteDataSet(comandoConsulta); if (ds.Tables.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count ; i++) { // valores.Add(s) //valores.Add (new punptoDeAtencion(){} valores.Add(new puntoDeAtencion() { codigoPuntoAtencion = Convert.ToString(ds.Tables[0].Rows[i]["Agencia"]), montoIngreso = Convert.ToDecimal(ds.Tables[0].Rows[i]["INGRESONETO"]), montoEgreso = Convert.ToDecimal(ds.Tables[0].Rows[i]["MONTOEGRESO"]), ingresoNeto = Convert.ToDecimal(0.00) }); // var list1 = (from p in ds.Tables[0].Rows[i] select p).ToList(); } } return valores.ToList<puntoDeAtencion>(); this is the response(Using SOAP UI, but when I debug show the same values in the response object) this is the actual response <b:listaPuntosDeAtencion> <b:puntoDeAtencion> <b:codigoPuntoAtencion>001</b:codigoPuntoAtencion> <b:ingresoNeto>0</b:ingresoNeto> <b:montoEgreso>53266155.0000</b:montoEgreso> <b:montoIngreso>138285187.0000</b:montoIngreso> </b:puntoDeAtencion> and this is how this should be <listaPuntosDeAtencion> <puntoDeAtencion> < codigoPuntoAtencion>00654</codigoPuntoAtencion> <montoIngreso>79000.0</montoIngreso> <montoEgreso>30000.0</montoEgreso> <ingresoNeto>0.0</ingresoNeto> </puntoDeAtencion> Please, I want to order the list or the response, I don't know if LINQ works in this case.
<c#><linq><soapui>
2016-08-30 19:56:32
LQ_EDIT
39,236,132
Creating a new variable in R
<p>The data set contains four columns (id, x1, x2, and y1). Notice that there are some multiple records (by id).</p> <p>Here is the data:</p> <pre><code>id &lt;- c(1, 1, 1, 1, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6) x1 &lt;- c("a","b","c","a","a","a","c","c","b", "e", "w", "r", "b", "c", "w", "r") x2 &lt;- c(0.12, 0.76, 0.08, 0.11, 0.80, 0.24, 0.19, 0.07, 0.70, 0.64, 0.97, 0.04, 0.40, 0.67, 0.25, 0.01) y1 &lt;- c(1132, 1464, 454, 1479, 167, 335, 280, 391, 973, 1343, 777, 1333, 293, 694, 76, 114) mdat &lt;- data.frame(id, x1, x2, y1) </code></pre> <p>I want to create a new column (let's call it y2). ys is defined as</p> <p>y2(i) = y1(i-1) for the same id. Not that for data with onlu one id, then y2=NA.</p> <p>Here is the output:</p> <pre><code>id x1 x2 y1 y2 1 a 0.12 1132 1 b 0.76 1464 1132 1 c 0.08 454 1464 1 a 0.11 1479 454 2 a 0.8 167 3 a 0.24 335 3 c 0.19 280 335 3 c 0.07 391 280 4 b 0.7 973 4 e 0.64 1343 973 4 w 0.97 777 1343 4 r 0.04 1333 777 5 b 0.4 293 5 c 0.67 694 293 5 w 0.25 76 694 6 r 0.01 114 </code></pre>
<r>
2016-08-30 20:00:32
LQ_CLOSE
39,236,250
How to iterate formgroup with array in Angular2
<p>I'm working on a model driven form and I can't get it to add items to a list being displayed with ngFor. I'm currently getting an error when trying to iterate my list.</p> <p>Error:</p> <pre><code>Error: Cannot find control with path: 'locations -&gt; i' at new BaseException (exceptions.ts:21) at _throwError (shared.ts:80) at Object.setUpFormContainer (shared.ts:66) at FormGroupDirective.addFormGroup (form_group_directive.ts:74) at FormGroupName.AbstractFormGroupDirective.ngOnInit (abstract_form_group_directive.ts:37) at DebugAppView._View_PersonFormComponent4.detectChangesInternal (PersonFormComponent.ngfactory.js:3197) at DebugAppView.AppView.detectChanges (view.ts:260) at DebugAppView.detectChanges (view.ts:378) at DebugAppView.AppView.detectContentChildrenChanges (view.ts:279) at DebugAppView._View_PersonFormComponent2.detectChangesInternal (PersonFormComponent.ngfactory.js:1995) Raw person-form-builder.service.ts </code></pre> <p>formBuilderService:</p> <pre><code>import {Injectable} from "@angular/core"; import {Validators, FormBuilder} from '@angular/forms'; import {Person} from './../components/person/person'; @Injectable() export class PersonFormBuilderService { constructor(private fb: FormBuilder) { } getForm(person: Person) { return this.fb.group({ _id: [person._id], name: this.fb.group({ first: [person.name.first], middle: [person.name.middle], last: [person.name.last], full: [person.name.full], }), locations: this.fb.array([ this.initLocation(), ]), files: this.fb.array([ this.initFiles(), ]), skills: this.fb.array([ this.initSkills(), ]), }); } initLocation() { return this.fb.group({ isDefault: [false, Validators.required], location: ['', Validators.required], roles: ['', Validators.required], isContact: [false, Validators.required], contactPhone: ['', Validators.required], contactPhoneExt: ['', Validators.required], }); } initFiles() { return this.fb.group({ originalName: ['', Validators.required], }); } initSkills() { return this.fb.group({ name: ['', Validators.required], isrequired: [false, Validators.required], expireDate: ['', Validators.required], canOverride: [false, Validators.required], }); } addLocation(control) { control.push(this.initLocation()); } removeLocation(i: number, control) { control.removeAt(i); } } </code></pre> <p>form:</p> <pre><code>&lt;div formGroup="form"&gt; &lt;div formArrayName="locations"&gt; &lt;div *ngFor="let location of form.controls.locations.controls; let i=index"&gt; &lt;span&gt;Location {{i + 1}}&lt;/span&gt; &lt;div formGroupName="i"&gt; &lt;label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect"&gt; &lt;input type="checkbox" class="mdl-checkbox__input" formControlName="isDefault" [checked]=""&gt; &lt;/label&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>form-component.ts:</p> <pre><code>import {Component} from '@angular/core'; import {FormGroup, FormArray} from '@angular/forms'; @Component({ moduleId: module.id, selector: 'person-form-component', templateUrl: 'person-form.component.html', providers: [PersonService, PersonFormBuilderService] }) export class PersonFormComponent { getPerson(personId) { this.personService.getPerson(this.personId).subscribe(res =&gt; { this.person = res.data; this.form = this.personFormBuilderService.getForm(this.person); }); } addLocation() { let control = &lt;FormArray&gt; this.form.controls['locations']; this.personFormBuilderService.addLocation(control); } } </code></pre> <p><a href="https://gist.github.com/jpstokes/11551ff5d8c76514005c6c9fd8a554dd">https://gist.github.com/jpstokes/11551ff5d8c76514005c6c9fd8a554dd</a></p>
<forms><angular><angular2-formbuilder>
2016-08-30 20:08:25
HQ
39,236,414
How does Bitmoji work?
<p>does anyone have an idea, how bitmoji or other similar services work? I have an idea for an app, which should have custom Avatars. </p> <p>There are multiple libraries for 3D-Games, which are based on Morphing. Easy. All the 2D-Characters however are seamingly made with sprites. But if you consider how many options bitmoji has, do you think, they basically have drawn all the possible sprites? Or am I to stupid to find the "yellow brick road"?</p> <p>Thanks for any advice.</p>
<android><ios><2d><morphing>
2016-08-30 20:19:27
HQ
39,236,863
Restrict scipy.optimize.minimize to integer values
<p>I'm using <code>scipy.optimize.minimize</code> to optimize a real-world problem for which the answers can only be integers. My current code looks like this: </p> <pre><code>from scipy.optimize import minimize def f(x): return (481.79/(5+x[0]))+(412.04/(4+x[1]))+(365.54/(3+x[2]))+(375.88/(3+x[3]))+(379.75/(3+x[4]))+(632.92/(5+x[5]))+(127.89/(1+x[6]))+(835.71/(6+x[7]))+(200.21/(1+x[8])) def con(x): return sum(x)-7 cons = {'type':'eq', 'fun': con} print scipy.optimize.minimize(f, [1,1,1,1,1,1,1,0,0], constraints=cons, bounds=([0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7])) </code></pre> <p>This yields: </p> <pre><code>x: array([ 2.91950510e-16, 2.44504019e-01, 9.97850733e-01, 1.05398840e+00, 1.07481251e+00, 2.60570253e-01, 1.36470363e+00, 4.48527831e-02, 1.95871767e+00] </code></pre> <p>But I want it optimized with integer values (rounding all <code>x</code> to the nearest whole number doesn't always give the minimum). </p> <p>Is there a way to use <code>scipy.optimize.minimize</code> with only integer values?</p> <p>(I guess I could create an array with all possible permutations of <code>x</code> and evaluate f(x) for each combination, but that doesn't seem like a very elegant or quick solution.)</p>
<python><optimization><scipy><minimize>
2016-08-30 20:49:44
HQ
39,237,556
Delphi type mismatch in expresion when try to filter dbgrid
Am geting this error when i try to filter `DBGrid` by date with `DateTimePicker` component > Type mismatch in expresion **Code** procedure TGrupeForm.DateCreatedFilterChange(Sender: TObject); begin if CreatedEditPicker.Date <> Date then begin ClientDataSet1.Filter := 'Created LIKE '+QuotedStr('%'+DateToStr(CreatedEditPicker.Date)+'%'); ClientDataSet1.Filtered := True; end else ClientDataSet1.Filtered := False; end; What i do wrong ?
<delphi>
2016-08-30 21:43:45
LQ_EDIT
39,238,366
UITextView with hyperlink text
<p>With a non-editable UITextView, I would like to embed text like this in iOS9+:</p> <blockquote> <p>Just <a href="http://example.com" rel="noreferrer">click here</a> to register</p> </blockquote> <p>I can create a function and manipulate the text but is there a simpler way? </p> <p>I see that I can use NSTextCheckingTypeLink so getting the text clickable without the 'click here' part is straightforward in Interface Builder:</p> <blockquote> <p>Just <a href="http://example.com" rel="noreferrer">http://example.com</a> to register</p> </blockquote> <p>I'm using Xcode 8 and Swift 3 if that's relevant.</p>
<swift><interface-builder><ios9><xcode8>
2016-08-30 23:03:46
HQ
39,239,276
How to enable directory listing in apache web server
<p>I am not able to enable directory listing in my apache web server. I have tried various solutions posted but not working. I just freshly installed httpd 2.4.6 and enabled https using ssl.conf under /etc/httpd/conf.d/ssl.conf dir and trying to access <a href="https://server.example.com/" rel="noreferrer">https://server.example.com/</a> but this is not listing the dir. These are the config in ssl.conf</p> <pre><code>DocumentRoot "/home/userx/Downloads/" ServerName server.example.com:443 </code></pre> <p>Below is what it has in ssl.conf under the VirtualHost element. Files and the first Directory elements were already there when I installed, I just added Directory for "/home/userx/Downloads". I want to browse the contents of /home/userx/Downloads when I access the URL <a href="https://server.example.com/" rel="noreferrer">https://server.example.com/</a>. What am I missing here ?</p> <pre><code>&lt;Files ~ "\.(cgi|shtml|phtml|php3?)$"&gt; SSLOptions +StdEnvVars &lt;/Files&gt; &lt;Directory "/var/www/cgi-bin"&gt; SSLOptions +StdEnvVars &lt;/Directory&gt; &lt;Directory "/home/userx/Downloads"&gt; Options +Indexes AllowOverride all &lt;/Directory&gt; </code></pre>
<apache><httpd.conf>
2016-08-31 01:10:58
HQ
39,239,363
What is Axiom K?
<p>I've noticed the discussion of "Axiom K" comes up more often since HoTT. I believe it's related to pattern matching. I'm surprised that I cannot find a reference in TAPL, ATTAPL or PFPL.</p> <ul> <li>What is Axiom K?</li> <li>Is it used for ML-style pattern matching as in SML (or just dependent pattern matching)?</li> <li>What's an appropriate reference for Axiom K?</li> </ul>
<pattern-matching><programming-languages><agda><dependent-type>
2016-08-31 01:24:39
HQ
39,239,686
Nodemon Doesn't Restart in Windows Docker Environment
<p>My goal is to set up a Docker container that automatically restarts a NodeJS server when file changes are detected from the host machine.</p> <p>I have chosen nodemon to watch the files for changes.</p> <p>On Linux and Mac environments, nodemon and docker are working flawlessly.</p> <p>However, when I am in a <strong>Windows environment</strong>, nodemon doesn't restart the server.</p> <p>The files are updated on the host machine, and are linked using the <code>volumes</code> parameter in my docker-compose.yml file. </p> <p>I can see the files have changed when I run <code>docker exec &lt;container-name&gt; cat /path/to/fileChanged.js</code>. This way I know the files are being linked correctly and have been modified in the container.</p> <p><strong>Is there any reason why nodemon doesn't restart the server for Windows?</strong> </p>
<node.js><windows><docker><watch><nodemon>
2016-08-31 02:11:39
HQ
39,240,041
How to make UILabel resize to fit text
<p>I have a UILabel that I have layed out in a storyboard centred in the view. It has some initial text "tap to login".</p> <p>I am changing the value of the label to be the user's name once they have logged in. Once I do this, the label is no longer centered as the UILabel has not changed size.</p> <p>How can I do this with autolayout in interface builder?</p>
<ios><xcode><interface-builder><uistoryboard>
2016-08-31 02:55:59
HQ
39,240,259
weired data output about PHP & MySQLi
I am the beginner of PHP & MySQL and I am practicing about PHP & MySQL. It's wired that only Field name is correct but others. I can't get the the expected result from the code... How get the correct meta data from the database? [The expected result][1] [Actual result][2] [1]: http://i.stack.imgur.com/dESiN.jpg [2]: http://i.stack.imgur.com/asWKY.jpg <?php // Open a connection to the server and USE the winestore $link = mysqli_connect("localhost","root","","winestore"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } // Run a query on the wine table in the winestore database to retrieve // one row $query = "SELECT * FROM wine LIMIT 1"; $result = mysqli_query($link, $query); // Output a header, with headers spaced by padding print "\n" . str_pad("Field", 20) . str_pad("Type", 14) . str_pad("Null", 6) . str_pad("Key", 5) . str_pad("Extra", 12) . "\n"; // How many attributes are there? $x = mysqli_num_fields($result); // for each of the attributes in the result set for($y=0;$y<$x;$y++) { // Get the meta-data for the attribute $info = mysqli_fetch_field ($result); // Print the attribute name print str_pad($info->name, 20); // Print the data type print str_pad($info->type, 6); // Print the field length in brackets e.g.(2) print str_pad("({$info->max_length})", 8); // Print out YES if attribute can be NULL if ($info->not_null != 1) print " YES "; else print " "; // Print out selected index information if ($info->primary_key == 1) print " PRI "; elseif ($info->multiple_key == 1) print " MUL "; elseif ($info->unique_key == 1) print " UNI "; // If zero-filled, print this if ($info->zerofill) print " Zero filled"; // Start a new line print "\n"; } mysqli_free_result($result); mysqli_close($link); ?>
<php><mysqli>
2016-08-31 03:27:19
LQ_EDIT
39,240,278
Block ads with HTML/JS?
Thank you for reading. I don't know where this belongs so please don't downvote it, if you can help, it would be greatly appreciated. I have a site ([forum.tdp4teambattle.com][1]) and recently, i started getting ads in the footer. I looked in the footer and there is no code for the ad. I'm thinking they put it in another file and specified it to a certain div ID. What code in HTML or JavaScript can i use to hide the ad so others don't see it? Here is the ad image: http://is.mixmarket.biz/images/um/95480.gif it is 468x60 (maybe you guys can give me a code to block images of that specific size from showing up) Thank you very much! [1]: http://forum.tdp4teambattle.com
<javascript><html><forum><phpbb><ads>
2016-08-31 03:30:22
LQ_EDIT
39,240,533
Android Nougat requires the IDE to be running with Java 1.8 or later
<p><a href="https://i.stack.imgur.com/vGf1D.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vGf1D.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/qTT96.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qTT96.png" alt="enter image description here"></a></p> <p>Inspite of having JDK 8 installed, I'm getting this error. What can the issue be?</p>
<android-studio>
2016-08-31 04:01:43
HQ
39,241,046
Deepcopy in React
<p>In reducers,we always use <code>Object.assign({},state,newState)</code> to save a state. But <code>assign()</code> doesn't support deepcopy,because this method only copy a reference of multi-level object. This is my code in program.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const menuListState={ menuList: {}, menuListLoading:false } function getMenuList(state=menuListState,action=defaultAction){ switch(action.type){ //menuList begin case actions.GET_MENULIST_SUCCESS: return Object.assign({},state,{ menuList:action.data, menuListLoading:false }); default: return state; } }</code></pre> </div> </div> </p> <p>The property <code>menuList</code> is a multi-level Object. And when <code>action.data</code> changes, will <code>state.menuList</code> be changed immediately before the method <code>assign()</code> work?</p>
<javascript><reactjs><redux>
2016-08-31 04:57:33
HQ
39,241,643
"no module named PyPDF2" error
<p>I use Spyder, with Python 2.7, on a windows 10. I was able to install the PyPDF2 package with a conda command from my prompt. I said installation complete. Yet, If I try to run a simple import command:</p> <p><code>import PyPDF2 </code></p> <p>I get the error:</p> <p><code>ImportError: No module named PyPDF2 </code></p> <p>How can I fix this?</p>
<python><pdf-generation><importerror>
2016-08-31 05:47:29
HQ
39,241,851
Developing spring boot application with lower footprint
<p>In an attempt to keep our microservices, developed in spring-boot to run on Cloud Foundry, smaller in footprint, we are looking for best approach to achieve the same.</p> <p>Any inputs or pointers in this direction will be most welcomed.</p> <p>It's surely the best that one always builds the application upwards starting from bare minimum dependencies, and the add any more only when required. Is there more of good practices to follow to further keep the application smaller in size?</p>
<spring-boot>
2016-08-31 06:04:01
HQ
39,241,983
how to get a hidden value from HTML?
<p id="sub-total"> <strong>Total</strong>: <span id="stotal"></span></p> <p><input type="submit" id="submit-order" value="Submit" class="btn"/></p> how to get "stotal" value from the html and pass to server.Now the value is coming from Jquery.
<jquery><html>
2016-08-31 06:12:31
LQ_EDIT
39,243,756
I want Regular Expression For this Format(Years/M or Days/F) for ex:24Years/M or 24Days/F
<p>Any one please help me.</p> <p>the user enter age in textbox but the age format should be Years/M or Years/F or Days/M or Days/F </p>
<javascript><regex>
2016-08-31 07:52:13
LQ_CLOSE
39,244,073
I run into trouble when i make my java Procedures to package,i do not know why?
<p><a href="http://i.stack.imgur.com/fOBsN.jpg" rel="nofollow">i use hipster to builder my procedures,but it is wrong</a></p> <p>i use hipster to builder my procedures ,but it tell me this Problem</p>
<java><builder><jhipster>
2016-08-31 08:09:02
LQ_CLOSE
39,244,265
Azure web app redirect http to https
<p>I use Azure cloud with web app and my server side written on <code>nodejs</code>. When web app receive a http request I want to redirect the request to https I found the solution. I put that to my web.config file inside the <code>rules</code> tag </p> <pre><code> &lt;rule name="Force HTTPS" enabled="true"&gt; &lt;match url="(.*)" ignoreCase="false" /&gt; &lt;conditions&gt; &lt;add input="{HTTPS}" pattern="off" /&gt; &lt;/conditions&gt; &lt;action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="false" redirectType="Permanent" /&gt; &lt;/rule&gt; </code></pre> <p>The problem is when I type in the browser "<a href="https://myURL.com" rel="noreferrer">https://myURL.com</a>" it redirect to main screen every thing ok, but when I change https to http "<a href="http://myURL.com" rel="noreferrer">http://myURL.com</a>" it redirect to <a href="https://myURL.com/" rel="noreferrer">https://myURL.com/</a>" and add to the url "bin/www" according that the url looks like that "<a href="http://myURL.com/bin/www" rel="noreferrer">http://myURL.com/bin/www</a>", the response is: page doesn't find.</p> <p>The question is how to redirect a clear url without added data to the url?</p> <p>Part of my web.config file:</p> <pre><code>&lt;rewrite&gt; &lt;rules&gt; &lt;!-- Do not interfere with requests for node-inspector debugging --&gt; &lt;rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true"&gt; &lt;match url="^bin/www\/debug[\/]?" /&gt; &lt;/rule&gt; &lt;!-- First we consider whether the incoming URL matches a physical file in the /public folder --&gt; &lt;rule name="StaticContent"&gt; &lt;action type="Rewrite" url="public{REQUEST_URI}" /&gt; &lt;/rule&gt; &lt;!-- All other URLs are mapped to the node.js site entry point --&gt; &lt;rule name="DynamicContent"&gt; &lt;conditions&gt; &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" /&gt; &lt;/conditions&gt; &lt;action type="Rewrite" url="bin/www" /&gt; &lt;/rule&gt; &lt;!-- Redirect all traffic to SSL --&gt; &lt;rule name="Force HTTPS" enabled="true"&gt; &lt;match url="(.*)" ignoreCase="false" /&gt; &lt;conditions&gt; &lt;add input="{HTTPS}" pattern="off" /&gt; &lt;/conditions&gt; &lt;action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="false" redirectType="Permanent" /&gt; &lt;/rule&gt; &lt;/rules&gt; &lt;/rewrite&gt; &lt;!-- 'bin' directory has no special meaning in node.js and apps can be placed in it --&gt; &lt;security&gt; &lt;requestFiltering&gt; &lt;hiddenSegments&gt; &lt;remove segment="bin" /&gt; &lt;/hiddenSegments&gt; &lt;/requestFiltering&gt; &lt;/security&gt; </code></pre> <p>Thanks for answers, Michael.</p>
<azure><azure-web-sites><azure-web-app-service>
2016-08-31 08:18:41
HQ
39,245,016
json data with out array name
[{"ash_id":"1","asg_code":"1226","ash_name":"hello","ash_cell":"123","ash_nic":"123","ash_long":"34.015","ash_lat":"71.5805","zm_id":null,"created_by":"0","created_date":"0000-00-00 00:00:00","last_updated":"2016-08-29 07:52:35"}] i have array without array name i can read data if there is name of jason array but i am un able to do that with this type of array any suggestion my code for josn with array name`String json = serviceClient.makeServiceCall(URL_ITEMS, ServiceHandler.GET); // print the json response in the log Log.d("Get match fixture resps", "> " + json); if (json != null) { try { Log.d("try", "in the try"); JSONObject jsonObj = new JSONObject(json); Log.d("jsonObject", "new json Object"); // Getting JSON Array node matchFixture = jsonObj.getJSONArray(TAG_FIXTURE); Log.d("json aray", "user point array"); int len = matchFixture.length(); Log.d("len", "get array length"); for (int i = 0; i < matchFixture.length(); i++) { JSONObject c = matchFixture.getJSONObject(i); Double matchId = Double.parseDouble(c.getString(TAG_MATCHID)); Log.d("matchId", String.valueOf(matchId)); Double teamA = Double.valueOf(c.getString(TAG_TEAMA)); Log.d("teamA", String.valueOf(teamA)); String teamB = c.getString(TAG_TEAMB); Log.d("teamB", teamB);`
<android><json>
2016-08-31 08:54:09
LQ_EDIT
39,245,342
C# With Ram Optimize
<p>you can optimize the RAM usage of an application with the following code with AutoIt. How is this in C#, How do I set up?</p> <pre><code>Func _ReduceMemory($iPid) Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $iPid) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) Return $ai_Return[0] EndFunc </code></pre>
<c#><optimization><autoit><ram>
2016-08-31 09:09:57
LQ_CLOSE
39,245,572
VPN over PPTP on mac os sierra
<p>Lately I discovered that connecting to a VPN via PPTP option has been removed in the new mac os - sierra. I tried multiple application to do so - all failed. How can I connect to my VPN over PPTP?</p> <p>ps. I don't want to use L2TP because I don't have a pre shared key (I also don't know what it is).</p>
<vpn><pptp><macos-sierra>
2016-08-31 09:20:17
HQ
39,246,225
Java , to change the iso date format to required format
<p>I need to convert the current ISO Date to the required format . How ? Mongodb iso date: 2016-08-31T08:30:17.795Z</p> <p>required format type: Aug 31,2016 08:30 AM</p>
<java><angularjs><mongodb>
2016-08-31 09:48:34
LQ_CLOSE
39,246,532
Combobox control in application designers maximo 7.6
My clients requirement is to have a combobox on one of my custom application in maximo 76. How to bind a combobox in maximo application designer
<maximo>
2016-08-31 10:01:24
LQ_EDIT
39,246,678
Amazon Kinesis and guaranteed ordering
<p>Amazon claims their Kinesis streaming product guarantees record ordering.</p> <blockquote> <p>It provides ordering of records, as well as the ability to read and/or replay records in the same order (...)</p> </blockquote> <p>Kinesis is composed of Streams that are themselves composed of one or more Shards. Records are stored in these Shards. We can write consumer applications that connect to a Shard and read/replay records in the order they were stored.</p> <p>But can Kinesis guarantee, out of the box, ordering for the Stream itself without pushing ordering logic to the consumers? How can a consumer read records from multiple Shards of the same Stream, making sure the records are read in the same order they were added to the Stream?</p>
<amazon-web-services><amazon><amazon-kinesis>
2016-08-31 10:08:52
HQ
39,247,021
Trouble at creat a GIT repository in Bluemix
i write this topic for a problem that i have right now while coding on bluemix: When i try to create a GIT repository after creating an Application on bluemix, i receive this message error: "Impossible to connect at IBM DevOps Services. Try later" is this problem know to someone? Thank for answers, Alessandro
<git><repository><ibm-cloud>
2016-08-31 10:24:01
LQ_EDIT
39,247,312
How to remove digits that comes inside parentheses using javascript?
<p>Let say '<strong>Ben-Hur (2016)</strong>'. I want to remove '<strong>(2016)</strong>'.I need only <strong>Ben-Hur</strong>.</p>
<javascript>
2016-08-31 10:37:13
LQ_CLOSE
39,247,487
Why Spring Boot Application class needs to have @Configuration annotation?
<p>I am learning about the Spring Framework but I can't understand what exactly the <code>@Configuration</code> annotation means and which classes should be annotated so. In the Spring Boot docs it is said that the Application class should be <code>@Configuration</code> class.</p> <blockquote> <p>Spring Boot favors Java-based configuration. Although it is possible to call SpringApplication.run() with an XML source, we generally recommend that your primary source is a @Configuration class.</p> </blockquote> <p>Trying to learn about <code>@Configuration</code> I find that annotating a class with the <code>@Configuration</code> indicates that the class can be used by the Spring IoC container as a source of bean definitions. </p> <p>If that is so then how is this application class a source of bean definitions?</p> <pre><code>@SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScan public class App { public static void main(String[] args) throws Exception { SpringApplication.run(App.class, args); } } </code></pre> <p>I have pretty much understood most other basic concepts regarding Spring but I can't understand the purpose of <code>@Configuration</code> or which classes should be <code>@Configuration</code> classes? Can someone please help. Thanks !!</p>
<java><spring><spring-boot>
2016-08-31 10:45:14
HQ
39,247,635
Is this the wright way to implement upcasting and downcasting in the following java code?
package test; public class Test { public static void main(String[] args) { A a2= new B(); // 1 a2.display1(); a2.display(); ((B)a2).display2(); // 2 ((A)a2).display(); // 3 B b1=new B(); b1.display1(); // 4 } } class A { int a=10; void display() { System.out.println("parent class "+a); } void display1() { System.out.println("parent class "+ (a+10)); } } class B extends A { int a=30; @Override void display() { System.out.println("child class "+a); } void display2() { System.out.println("child class "+(a+10)); } } 1. whose object is created ?class A or B. 2. Is this downcasting 3. why this is not invoking the method of class A? how to invoke method of class A (override one) with this object and not with the object of A. 4. is this implicit upcasting? 5. If a class A have a nested Class B than during object creation of class A does object of class b is also formed ?i was not able to use method of class B from object of A
<java><nested><downcast>
2016-08-31 10:52:26
LQ_EDIT
39,247,777
Php different timezones
<p>I'm developing a web app in php mysql which should be usable in the whole world. In this app there is a big usage of time so I'm wondering if there is any work to do on the timezones differences or if php is automatically recognizing the different timezones before saving in the db ?</p> <p>Thanks for your help</p>
<php><mysql><time><timezone>
2016-08-31 10:59:51
LQ_CLOSE
39,247,993
Android TV RecyclerView focus interaction
<p>I'm currently using a regular <code>RecyclerView</code> with <code>GridLayoutManager</code>with different <code>spanCount</code> depeding on the <code>viewType</code> for an Android TV app. All is working decent but I have 2 issues:</p> <ol> <li>If you long press the dpad down to scroll fast between the items sometimes the focus is lost to a view that isn't a child of the RecyclerView.</li> <li>How can I tell the <code>RecyclerView</code> to keep the current focused view in the center of the grid?</li> </ol> <p>It seems that the issues listed are fixed by using the <code>VerticalGridView</code> from <code>LeanBack</code> library but the <code>LayoutManger</code> that it uses is internal and doesn't support <code>spanCount</code>.</p>
<android><android-recyclerview><android-tv>
2016-08-31 11:09:16
HQ