input
stringlengths
51
42.3k
output
stringlengths
18
55k
Java - Unzip and Progress Bar <p>My program uses Tasks from JavaFX to download and unzip files and to show the progress on the screen, by using the <code>updateProgress(workDone, max)</code> method and the <code>progressProperty().bind(observable)</code> method. It works for Download : </p> <pre><code>package com.fran...
<p>It is because you use length of compressed zipFile as the maximum, and the count of bytes raeded from each uncompressed zipEntry as the postion - the size of compressed file is in most cases different from the uncompressed one, also you can have multiple files in the zip package - so the progres will jump from 0 to ...
Prevent text wrapping within an element <p>How can you force text within an element to not wrap, and have the element's width still determined by its contents (instead of manually setting width)?</p> <p><strong>Example:</strong></p> <p>On this page you can see a green button with the text "Get Started". For smaller s...
<p>Add this to your css:</p> <pre><code>white-space: nowrap; </code></pre>
Application Not Working Correctly C# <p>My code isn't storing a response as user input. It jumps to the else statement every time I get here. Then it throws the sum as 50? When I store input like Value of first number = 2 and value of second = 3. I'm doing a class at home and I have been working for a few hours trying ...
<p>In your addition calculator, changing the following line:</p> <pre><code>aNum[number - 1] = Convert.ToInt32(Console.Read()); </code></pre> <p>from Console.Read() to Console.ReadLine() seems to fix the issue. ReadLine() will block the execution until Enter is hit - Read() will not... So when you enter your second...
Error: Declaration of non-variable 'strlen' in 'for' loop initial declaration - C <p>The title is the exact error my compiler(geany on ubuntu) gives me when I try to compile. The part of code in question is the following:</p> <pre><code>for(int q=strlen(stringA)-1;q&gt;0;q--) { //do stuff } </code></pre> <p>I've alre...
<p>I assume you are missing an include. Try:</p> <p><code>#include &lt;string.h&gt;</code></p>
counter not inceasing in python <p>I have looked at other while loops and am stuck on why this one is not working.</p> <pre><code>points = int(input('How many points: ')) while True: u_cnt, c_cnt = 0, 0 if u_cnt &lt; points or c_cnt &lt; points: if u &lt; c: c_cnt += 1 elif u &gt; c...
<p>The code have to be right there:</p> <pre><code>points = int(input('How many points: ')) u_cnt, c_cnt = 0, 0 # asign the values before the loop while True: if u_cnt &lt; points or c_cnt &lt; points: if u &lt; c: c_cnt += 1 elif u &gt; c: u_cnt += 1 </code></pre>
Ruby docs rindex example <p>This example is from the ruby docs.</p> <pre><code>"hello".rindex(/[aeiou]/, -2) #=&gt; 1 </code></pre> <p>Why does this output 1 instead of 4? </p>
<p>Because the second parameter. From the doc</p> <blockquote> <p>If the second parameter is present, it specifies the position in the string to end the search—characters beyond this point will not be considered.</p> </blockquote> <p>So</p> <pre><code>"hello".rindex(/[aeiou]/) =&gt; 4 </code></pre>
hybris commerce 5.7 and 6.1 installation and administration guide <p>I have downloaded hybris commerce 5.7 and 6.1 as a sap partner . Where can I find detailed installation and administration guide ? does sap provide it ?</p>
<p>The main page: <a href="https://wiki.hybris.com/dashboard.action" rel="nofollow">wiki.hybris</a></p> <p>hybris release 5 documentation: <a href="https://wiki.hybris.com/display/release5/Release+5+Documentation+Home" rel="nofollow">Release-5-Documentation</a></p> <p>hybris release 6 page: <a href="https://help.hybr...
configuring pyramid_beaker to use with mysql <p>i am using pyramid_beaker as session factory .I want to save session in mysql database.so i want to know how to configure that? i have gone through this <a href="http://docs.pylonsproject.org/projects/pyramid_beaker/en/latest/" rel="nofollow">http://docs.pylonsproject.org...
<p>pyramid_beaker is a thin wrapper around beaker which can pull the settings from your INI file into beaker. Beaker [1] itself which contains docs on how to use its various backends. For example, if you're using the <code>beaker.ext.database</code> backend, then you should set <code>session.url = mysql://user:password...
Find positions of transparent areas in images using PIL <p>I want to fill transparent blocks in images by others images. For example: In this images we have 4 transparent blocks, witch need to fill.</p> <p>Need to find positions of the blocks and determine x,y,x2,y2 coords so i will know how to resize the thumbnail to...
<p>You can do that at the command-line with <strong>ImageMagick</strong>, or in Python, Perl, PHP or C/C++.</p> <p>First, extract the alpha channel:</p> <pre><code>convert input.png -alpha extract alpha.png </code></pre> <p><a href="https://i.stack.imgur.com/eD04t.png" rel="nofollow"><img src="https://i.stack.imgur....
How to force Windows to create the running user's profile directory <p>I am having an issue with a process being run, where the profile directory of the process' user has not yet been created.</p> <p>To explain, here are the details of how this is happening:</p> <p>We run a large distributed server grid, and are usin...
<p>If the running account has admin privileges, the following code will cause the creation of the running account's profile, including its UserProfile directory. Without admin, I don't know if it is possible:</p> <pre><code>using System.Runtime.InteropServices; ... [DllImport("userenv.dll", CharSet = CharSet.Auto, Se...
xPages radiobutton group onchange event doesn't work <p>Here is my simple page whit a listbox control that should refresh its values according to the radiobutton group selection. The list box uses a scope variable array as a source. So when I click on the radiobutton I want to change list box values. It works after fir...
<p>Radio button events can be strange with certain browsers (IE). Do you have this setting in your xsp properties file?</p> <p><a href="http://www-01.ibm.com/support/docview.wss?uid=swg21631834" rel="nofollow">http://www-01.ibm.com/support/docview.wss?uid=swg21631834</a></p> <p>Don't use both onclick and on change.</...
Constant 'XXX' used before being initialized <p>I am new in swift .. anyone help me to understand why this error throwing </p> <blockquote> <p>Constant 'parsedResult' used before being initialized </p> </blockquote> <p>on the other hand if i set <code>return</code> in the <code>catch</code> then compile error g...
<p>This is easily fixed by declaring parseResult as AnyObject? which means it will be initialised to nil. The print will print an optional value which it can do just fine. </p> <p>Be careful with the words you use. "// error throwing this line " is totally misleading. There is no error thrown at this line. Errors are ...
Cannot import urllib in Python <p>I would like to import <code>urllib</code> to use the function '<code>request</code>'. However, I encountered an error when trying to download via Pycharm: </p> <blockquote> <p>"Could not find a version that satisfies the requirement urllib (from versions: ) No matching distribution...
<p>A few things:</p> <ol> <li>As metioned in the comments, <code>urllib</code> is not installed through <code>pip</code>, it is part of the standard library, so you can just do <code>import urllib</code> without installation. </li> <li>Python 3.x has a <a href="https://docs.python.org/3/library/urllib.request.html" re...
More efficient way to loop through PySpark DataFrame and create new columns <p>I am converting some code written with Pandas to PySpark. The code has a lot of <code>for</code> loops to create a variable number of columns depending on user-specified inputs.</p> <p>I'm using Spark 1.6.x, with the following sample code:<...
<p>There is a small overhead of repeatedly calling JVM method but otherwise for loop alone shouldn't be a problem. You can improve it slightly by using a single select:</p> <pre><code>df = spark.range(1, 11).toDF("val1") def make_col(i): return (F.pow(F.lit(i), 2) + F.col("val1")).alias("val_{0}".format(i)) spar...
How to open the chrome browser to a chrome dev tool url <p>With the most recent version of node,</p> <p>Typing <code>node --inspect ajavascriptfile.js</code></p> <p>Outputs a url for you to visit in your chrome browser, great!</p> <p>(Documentation for V8 inspector <a href="https://nodejs.org/api/debugger.html#debug...
<p><code>open</code> doesn't support the <code>chrome-devtools</code> protocol, so it just tries to open a local file path instead. Since it doesn't exist, it gives you the error you are getting. </p> <p>I looked around for another solution and I found that you can use an <code>osascript</code> to tell the application...
How taxing would running an NSTimer every second be? <p>I've got a tableview of information that is locked/unlocked based on timestamps.</p> <p>If I've got cell A B and C and they unlock in 30 seconds, 1 min, and 1min 30 respectively based on timestamps pulled from Firebase, I need a way to check those timestamps to u...
<p>Several thoughts:</p> <ol> <li><p>The tableview would not need to reload every second based on the scenario you described. You would be <em>checking</em> every second the timer fires but it would only need to be reloaded when the posts in question actually need to be unlocked (seems like that is roughly at 30 secon...
Timer does not run in Swift 3.0 playground <p>Working in playground with Swift 3.0 I have this code:</p> <pre><code>struct Test { func run() { var timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: false) { timer in print("pop") } } } let test = Test() test.run() </code></p...
<p>You need to start a run loop.</p> <pre><code>RunLoop.main.run(until: Date(timeIntervalSinceNow: 3)) </code></pre> <p>The timer doesn't do anything unless there is a working run loop accepting input. The program simply ends.</p> <p><a href="https://developer.apple.com/reference/foundation/timer" rel="nofollow"><co...
root.query_pointer()._data causes high CPU usage <p>I'm a total noob in Python, programming and Linux. I wrote a simple python script to track usage time of various apps. I've noticed that after some time python is going nuts utilizing 100% of the CPU. Turns out it's the code obtaining mouse position is causing issues....
<p>To keep the CPU usual steady I put <code>display.Display().screen()</code> before the loop so that it didn't have to do so much work all the time. The screen shouldn't change so nor should that value so it made sense to set it up before.</p> <pre><code>import time from Xlib import display disp = display.Display().s...
Android Studio 2.2 not displaying view properties <p>After upgrading my android studio to version 2.2 i'm getting following error when i click on a view in layout designer to see it properties:</p> <blockquote> <p>Exception in plugin Android Support Moments Ago. </p> <p>Missing attribute definition for focusabl...
<p>It might be problem with OpenJDK. Please remove it and install Oracle JDK instead using this post: <a href="http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html" rel="nofollow">http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html</a></p> <p>Then go to <code>File -&gt; P...
Forward iterator with a moving end() <p>So, I'm designing a class which connects (over network) to a service to receive some data. I don't know how man data points I will be receiving in advance. Nevertheless I was wondering, if there is a way to make this class iterable using a forward_iterator in order to enjoy the S...
<p>Do as the standard library do with <code>istream_iterator</code>: when you run out of data, set your iterator state such that it compares equal to a default-constructed object of that type. And then there's your <code>end()</code> equivalent.</p>
R: absolute coordinates in grid package <p>In the grid package, per default the x- and y-positions in a new viewport range between 0 and 1 (relative to width / height of the viewport). In order to plot values I have to transform the values to a range between 0 and 1:</p> <pre><code>library(grid) vect1 &lt;- rnorm(20)...
<p>One option is to use <code>dataViewport</code> and <code>native</code> units.</p> <pre><code>library(grid) d &lt;- data.frame(x=100*rnorm(10),y=1e4*rnorm(10)) grid.newpage() pushViewport(viewport(width=0.8,height=0.8)) grid.rect(gp=gpar(fill="grey98")) vp &lt;- dataViewport(xData = d$x, yData = d$y) grid.points(d$...
What alternatives to If-Else statements do batch files have? <p>I'm trying to create a .bat file for my shell:startup for ease-of-access. .bat does not accept else as a term. What can I do to make my code work? And if there is no 'else' alternative,is there an operator for not-equivilant?</p> <p>Code:</p> <pre><code>...
<p>Why using else ? Logically if its not equal to 1 or 2 it will go to the invalid statement</p> <pre><code>if %x% == 1 goto heavy if %x% == 2 goto light echo Invalid. pause goto :start </code></pre> <p>If you really want to use the <code>else</code></p> <pre><code>if %x% == 1 goto heavy if %x% == 2 (goto light )...
Nestable Sortable List with Knockout Bindings? <p>I've been looking at building a draggable, sortable list in javascript using knockout, and I've found several strictly javacript based implementations that can handle the task, but I haven't been able to get any knockout bindings working for them.</p> <p>I've taken a l...
<p>Using the following jsfiddle, I managed to make a working version using knockout-sortable: <a href="http://jsfiddle.net/rniemeyer/UHcs6/" rel="nofollow">http://jsfiddle.net/rniemeyer/UHcs6/</a>.</p> <p>To accomplish this, I only slightly modified the source. The hardest portion was getting knockout to find everythi...
Incorrect day format returned from momentJS countdown <p>I used this simple script from: <a href="https://github.com/icambron/moment-countdown" rel="nofollow">https://github.com/icambron/moment-countdown</a> to make a simple countdown. The code below i'm using.</p> <blockquote> <p><strong>Used Code:</strong></p> </b...
<blockquote> <p><strong>The following output was correct if remaining days was not 0:</strong></p> </blockquote> <pre><code>$scope.daysCountdown = moment($scope.nextDate).format('D'); </code></pre> <blockquote> <p><strong>If remaining days was 0 it would set remaining days on 14 so this work around did the trick...
Merge Query in SQL Server with conditional update <p>I have a table with duplicate records. The table format is like this </p> <p>FIRST Day input Table Name-ABC</p> <pre><code>ani cdate 7076419812 2016-10-12 00:00:00.000 9168919394 2016-10-12 00:00:00.000 6282358407 2016-10-12 00:00:00.000 9168834643 2016...
<p>This was too long for a comment, but posting this for others.</p> <p>Your query seems fine, you need to elaborate on what isn't returning correctly for you. Here is some test data using your same logic...</p> <pre><code>if object_id ('tempdb..#PRQ') is not null drop table #PRQ create table #PRQ (mdn bigint, ts dat...
Ionic2/Angular2 CORS settings <p>Please help me to figure out with CORS on my Ionic2/Angular2 application. I'm trying to get data with http 'GET' request. When I'm running '$npm run build' at laptop, I get an expected response. When I'm running '$ cordova run android', I always get 'Response with status: 0 for URL: nul...
<p>Hmm... It looks like I figured out by myself. I did this: 1) ionic platform rm android 2) ionic platform add android It's weird, but works like a charm.</p>
custom control validator with same modification <p>I did the same modification on 3 kind of BaseValidator. I search a way to remove the duplicate code.</p> <p>I did the same code for RequiredFieldValidator , RegularExpressionValidator and CustomValidator</p> <pre><code>Public Class CustomValidator Inherits System...
<p>I ran into the same issue you have with these exact classes; I wanted to add some additional features to the validation controls. The way I ended up sharing some common code was implementing my own classes that inherited from the validator classes and then implementing the shared logic in a utility class. I'm not fa...
MiniBatchKMeans OverflowError: cannot convert float infinity to integer? <p>I am trying to find the right number of clusters, <code>k</code>, according to silhouette scores using <code>sklearn.cluster.MiniBatchKMeans</code>.</p> <pre><code>from sklearn.cluster import MiniBatchKMeans from sklearn.feature_extraction.tex...
<p>Let's analyze your code:</p> <ul> <li><code>for k in range(5)</code> returns the following sequence: <ul> <li><code>0, 1, 2, 3, 4</code></li> </ul></li> <li><code>model = MiniBatchKMeans(n_clusters = k)</code> inits model with <code>n_clusters=k</code></li> <li>Let's look at the first iteration: <ul> <li><code>n_...
Javascript getDate()and getMonth() return wrong result <p>I create a new Date object, using timestamp. If I print out that object, it returns correct date and time. But if I try to use getDate()and getTime(), they get me back wrong numbers.</p> <p>My code:</p> <pre><code>var textDate = new Date(timestamp); console.l...
<p>The getMonth() method returns the month from 0 to 11.</p> <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth</a></p> <p>When you print the date, it ...
XML still empty? <p>This may be a very stupid question, but I can't seem to get this thing working. I'm trying to form an XML with the following structure, and be able to add additional data into it at any point in time, as well as read the data. Right now all I get is:</p> <pre><code>&lt;?xml version="1.0" encoding="...
<p>In your XML method, you never append the <code>session</code> element to the document after you create it. So, even though you create and add all those children to the element, none of it gets added to the document.</p> <p>You need to add this line before you save the document:</p> <pre><code>document.DocumentEle...
i want to find the perfect number between 0 to 1000 and its not runing <pre><code>int num; num = 0; for (int i = 1; i &lt; 1000; i++) { for (int j = 1; j &lt;= i / 2; j++) { if (i % j == 0) num = num + j; } if (num == i) Console.WriteLine(num); } </code></pre> <p>I try to f...
<p>As others have mentioned move <code>num = 0</code> inside the outer loop. </p> <pre><code>int num; for (int i = 1; i &lt; 1000; i++) { num = 0; for (int j = 1; j &lt;= i / 2; j++) { if (i % j == 0) { num = num + j; } } if (num == i) { Console.Writ...
What is wrong with my PSQL view table? <p>I have two tables player and match:</p> <pre><code>CREATE TABLE player( id serial PRIMARY KEY NOT NULL, name varchar(255) NOT NULL ); CREATE TABLE match( id serial PRIMARY KEY, winner serial REFERENCES player(id) NOT NULL, loser serial REFERENCES player(id) NOT NULL CHECK (lo...
<p>Try</p> <pre><code>CREATE VIEW matchplayers AS SELECT winner.name as winner_name, loser.name as loser_name, m.id from player winner, player loser, match m WHERE m.winner = winner.id AND m.loser = loser.id; </code></pre> <p>to get unambiguous column names of the view.</p>
Dictionary key and value flipping themselves unexpectedly <p>I am running python 3.5, and I've defined a function that creates XML SubElements and adds them under another element. The attributes are in a dictionary, but for some reason the dictionary keys and values will sometimes flip when I execute the script.</p> <...
<pre><code>attributes = [{'xmlns:g', 'http://base.google.com/ns/1.0'}] </code></pre> <p>This is a list containing a set, not a dictionary. Neither sets nor dictionaries are ordered.</p>
Setting a Checkbox in ImageJ Macro <p>this is a basic question but I can't find the answer anywhere. </p> <p>When using the run command for macros in ImageJ how do I set the checkboxes (that I'd see when running it manually) using the macro.</p> <p>eg. I have: run("Subtract Background...","radius=1") </p> <p>But I w...
<p>You can get those GUI commands easily with the macro recorder of ImageJ, see:</p> <p><a href="https://imagej.nih.gov/ij/docs/guide/146-31.html#sub:Record" rel="nofollow">https://imagej.nih.gov/ij/docs/guide/146-31.html#sub:Record</a>...</p> <p>The option you are searching is 'sliding', e.g.:</p> <pre><code>run("S...
re-displaying the same drop-down in HTML below original drop-down option? <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;!DOCTYPE html&gt; &lt;html lang="en-US"&gt; &l...
<p>If I've understood you right, you've been searching something like this:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en-US"&gt; &lt;head&gt; &lt;title&gt;Query Tool&lt;/title&gt; &lt;meta charset="ISO-8859-1"&gt; &lt;script src="//code.jquery.com/jquery-1.11.3.min.js"&gt;&lt;/script&gt; &lt;script&gt; ...
make: *** [main.o] Error 1 <p>I am executing a simple makefile that contait 3 parts but it does not work well these are details of my files .h and .c : 1) main.c</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include "hello.h" int main (void) { hello(); return EXIT_SUCCESS; } </code><...
<p>When you write <code>#define hello</code> you define <code>hello</code> to be an empty token. Thus the function declaration on the next string effectively becomes this:</p> <pre><code>void (void); </code></pre> <p>which is not valid C code.</p> <p>What you are trying to do is probably the <a href="https://en.wiki...
How to run ShellCommandActivity on my own EC2 instance? <p>I am trying to run a simple command to test a ShellCommandActivity with Data Pipeline from AWS.</p> <pre><code>&gt;&gt;&gt; /usr/bin/python /home/ubuntu/script.py </code></pre> <p>That script should create a file on a S3, I know I could create a S3 file using...
<p>One workaround is directly execute script.py like </p> <p>"command": "script.py"</p> <p>Be sure your script.py with header </p> <pre><code>#!/usr/bin/env python </code></pre>
Ansible: How to use backslash in lineinfile module? <pre><code>--- - hosts: local tasks: - name: Update cataline.properties 1 lineinfile: dest=/home/folder1/catalina.properties insertafter="# been granted." line="package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,\" </code></pre> ...
<p>You need to use <code>\\</code>, otherwise you are escaping the last <code>"</code> and the expression is not closed.</p> <pre><code>- hosts: local tasks: - name: Update cataline.properties 1 lineinfile: dest: /home/folder1/catalina.properties insertafter: "# been granted." line: "package...
Find object in NSOrderedSet in CoreData. index(ofAccessibilityElement :) <p>I have an ordered To Many relationship and Xcode 8 has generated an attribute of type NSOrderedSet with a bunch of helper functions to insert and remove elements.</p> <p>Now I am trying to find an object and the Apple documentation indicates t...
<p>Autocompletion can and often is wrong. It can be handy but it's not a reference for what's correct.</p> <p>I don't know what you mean about the compiler wanting to use that method, because it's not what you need to look up objects in an ordered set. The correct method would be <code>index(of:)</code>, as in</p> <p...
MSDeploy get error during upload big file to IIS server <p>I get following error, when I try to deploy a web app to IIS server using MSDeploy. I believe the cause of the issue is the size of the file. The file, which cause the problem, is the biggest file in the package with size 8M. May I know how to deal with it? </p...
<p>We had this same error a while back and it was a network issue. Pulled in our Network Operations team and they ran a diagnostic test and found the issue. Not sure what it was but I bet this is the same.</p>
Using a Lambda Expression inside a function <pre><code>public int[] MyFunction(List&lt;T&gt; dataList, DateTime dateType, int howFarBack, string columnName, Boolean distinct) </code></pre> <p>I have created code to query a list of objects that have come from a SQL database. I'd like to store the code inside of a func...
<p>Without resorting to more advanced techniques, maybe a little bit of IoC will do:</p> <p>(contrived, just to show the idea)</p> <pre><code> public static int MyFunction&lt;T&gt;(IEnumerable&lt;T&gt; data, Func&lt;T, DateTime&gt; dateColumnSelector, DateTime startDate, DateTime endDate, bool distinct) { ...
SoftLayer SSL VPN Portal java.lang.NullPointerException @macOS Sierra <p>After updating the macOS to Sierra Version 10.12 I'm getting an error on the connection to the SoftLayer SSL VPN:</p> <pre><code>Exception Name: JavaNativeException Description: java.lang.NullPointerException at sun.awt.SunToolkit.getSys...
<p>It could be the same issue:</p> <p><a href="http://stackoverflow.com/questions/39833751/java-applets-in-macos-sierra-crashes">Java applets in macOs Sierra crashes</a></p> <p>Try to download JDK 9, if the issue persist submit a ticket to SoftLayer, perhaps they can provide another workaround</p>
error() function from Stroustrup's book behavior in Visual Studio 2015 <p>So I've arrived at Chapter 5 exercises in Programming Principles and Practices Using C++</p> <p>I'm using VS 2015 as my IDE and I encountered a problem with errors.</p> <p>If I run the code in Visual Studio 2015 and enter -280 to check the temp...
<p>When an exception is not caught in the program, it is terminated abnormally. Different run time environments treat that differently. The standard does not guarantee any uniform mechanism that we can rely on.</p> <p>There is nothing you can do about that other than learn how to deal with them.</p>
"The multi-part identifier 'xxx' could not be bound" when attempting to join three tables <p>I'd like to start off with the fact that I'm a SQL beginner with only 5 or 6 hours of experience. I'm learning fast though. </p> <p>Ultimately I am trying to select the addresses of clients by product line. The first table (ar...
<pre><code> arinvch JOIN ( SELECT aritrsh.clineitem FROM aritrsh JOIN icitemh ON aritrsh.citemno = icitemh.citemno WHERE icitemh.ctype = 'CRM' ) table2 ON arinvch.ccustno = aritrsh.ccustno; </code></pre> <p>the second table is table2 in you...
Polling I/O (MIPS) <p>I am attempting to write a program in MIPS that uses polling to read a character from the keyboard and then displays it using the builtin Keyboard and Display MMIO Simulator. Unfortunately, I am having trouble grasping the concept behind the registers used and the control bits, but have been tryin...
<p>You probably didn't click "Connect to MIPS".</p> <p>See this answer: <a href="http://stackoverflow.com/questions/10325970/how-to-print-to-the-screen-from-mips-assembly">How to print to the screen from MIPS assembly</a></p> <p>When I was testing I've found that if you stop simulation, reload your program, you proba...
Equivalent function of MatLab's "dateshift(...)" in Python? <p>MatLab can take a date and move it to the end of the month, quarter, etc. using the <code>dateshift(...)</code> <a href="https://www.mathworks.com/help/matlab/ref/dateshift.html" rel="nofollow">function</a>.</p> <p>Is there an equivalent function in Python...
<p>I'm not sure if it counts as the same, but the <a href="https://docs.python.org/3/library/datetime.html" rel="nofollow"><code>datetime</code></a> module can make times available as a <a href="https://docs.python.org/3/library/datetime.html#datetime.date.timetuple" rel="nofollow"><code>timetuple</code></a>, with sepa...
angular 2 subscribe to boolean from service <p>I have a service that has a changing boolean value, I want to subscribe to that boolean change in a component. How can this be achieved?</p> <p>here is my service...</p> <pre><code>private subBoolShowHideSource = new Subject&lt;boolean&gt;(); subBoolShowHide$ = this.sub...
<p>You have some formatting issues in your subscription. This should work:</p> <pre><code> this.subscription = this.service.subBoolShowHide$.subscribe( (data:boolean) =&gt; { this.boolShowGTMDetails = data }, error =&gt; console.log(error), () =&gt; console.log("winner winner chicken dinner") ...
RecyclerView height changes if keyboard is visible <p>I have a RecyclerView in my app. It is part of a fragment (one of several) in an activity. The problem is, when the keyboard is closed it will max out in height and use its internal scroller. When the keyboard opens, the internal scroller turns off and the RecyclerV...
<p>I've encounter an issue using last RecyclerView version.. and even AOSP project don't use the last RecyclerView version.</p> <p>So ,maybe this will solve your problem, use 23.x.x version and let me know if that resolved the problem :)</p>
phoenix ecto relationships on delete <p>There are two models: resource and metadata:</p> <pre><code>defmodule Myapp.Repo.Migrations.CreateResources do use Ecto.Migration def change do create table(:resources) do add :name, :string add :parent_id, references(:resources, on_delete: :delete_all) ...
<p><strong>:delete_all</strong> does not cascade to child records unless set via database migrations. To fix the problem make sure you change your metadata migration script line to</p> <pre><code>add :resource_id, references(:resources, on_delete: :delete_all) </code></pre>
Loop for ARMA model estimation <p>Suppose that I have the following "for" loop in R.</p> <pre><code>USDlogreturns=diff(log(prices)) for(i in 0:5){ for(j in 0:5){ fit &lt;- arima(USDlogreturns, order=c(i,0,j), include.mean=TRUE) } } </code></pre> <p>How do you tell R to substitute a NA matrix with the coef...
<p>You will need a matrix <code>M</code> with dimensions 36 times 13. Then use</p> <pre><code>M=matrix(NA,36,13) k=0 # current row being filled in for(i in 0:5){ for(j in 0:5){ k=k+1 fit &lt;- arima(USDlogreturns, order=c(i,0,j), include.mean=TRUE) if(i&gt;0) M[k,c(1: i) ]=fit$coef[c( 1 : i )] # AR...
Retaining punctuations in a word <p>How can i remove punctuations from a line, but retain punctuation in the word using <strong><em>re</em></strong> ??</p> <p>For Example :</p> <pre><code>Input = "Hello!!!, i don't like to 'some String' .... isn't" Output = (['hello','i', 'don't','like','to', 'some', 'string', 'isn't...
<p>You can use lookarounds in your regex:</p> <pre><code>&gt;&gt;&gt; input = "Hello!!!, i didn''''t don't like to 'some String' .... isn't" &gt;&gt;&gt; regex = r'\W+(?!\S*[a-z])|(?&lt;!\S)\W+' &gt;&gt;&gt; print re.sub(regex, '', input, 0, re.IGNORECASE).split() ['Hello', 'i', "didn''''t", "don't", 'like', 'to', 'so...
LayoutInflater not working for Android <p>I am trying to add a LinearLayout as a child to another LinearLayout component, but it will not show up on the screen at all. </p> <p>XML:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:a...
<p>Your question is not correct but I will answer it in two different ways</p> <p>First, if the LinearLayout you want to add is in a different xml file then you can inflate the xml file and add it to parent LinearLayout in your Activity class like this</p> <pre><code>Button testMessageButton = (Button) findViewById(R...
How to save extra fields in archive table using Ejabberd mod_mam (Message Archive Management, XEP-0313)? <p>I am using Ejabberd server for chatting application. It works to save messages in arhieve table, but I want to save additional field in the table when message is sent. This field will be per message.</p>
<p>There are some ways to achieve this. The first and the simplest way (but it only affects 'xml' field in the 'archive' table) is an implementation of 'store_mam_message' hook in your custom module. You can modify Packet inside that hook and return new packet which should be saved in the DB. This hook is available sin...
Rails, Heroku and contact form <p>I am trying to implement a simple contact form inside my app. Read through couple of SO posts but still no full solution.</p> <p>My contact form is working in the development environment. Here is my setup in the config file:</p> <pre><code> config.action_mailer.raise_delivery_error...
<p>I ended up using Sendgrid free plan. Good documentation so it was simple to implement.</p>
Add Field Wrapping JSON - PowerShell <p>I have an array that I convert to json. But I want each object in the array to be wrapped by another field.</p> <pre><code>$Array = Field1; Field2 ----------------- Value11; Value12 Value21; Value22 </code></pre> <p>If I convert that array to JSON it looks like this:</p> <pre...
<p>Try the following:</p> <pre><code>$Array | ForEach-Object { @{ NewWrapper=$_ } } | ConvertTo-Json </code></pre> <p><code>@{ NewWrapper=$_ }</code> wraps each input object in a hashtable (<code>@{ ... }</code>) whose one and only entry, <code>NewWrapper</code>, is the input object (<code>$_</code>).</p> <p>When <c...
Using raw_input inside functions <p>I can't figure out why <code>raw_input</code> isn't being called when I run the function. Instead of being asked <code>"At bats?"</code> I get the below error:</p> <pre><code>Traceback (most recent call last): File "ex19a.py", line 9, in &lt;module&gt; Slugging() TypeError: Sl...
<p>Try removing the parameters from your Slugging function! Your current error is because you are calling the Slugging function with 0 arguments and it expects 2 (At_Bats and Total_Bases).</p> <pre><code>def Slugging(): At_Bats = float(raw_input("At bats?")) Total_Bases = int(raw_input("Total Bases?")) Per...
Recursive method call on es2015 class method transpiled with babel <p>I'm having problems when i try to call a instance method recursively. </p> <p>The code looks as follows:</p> <pre><code>import fs from 'fs'; import fsWatcher from 'filewatcher'; import path from 'path'; export default class SearchService { initia...
<p>I could solve the problem. As @zerkms mentioned is was using the <em>this</em> keyword false. I tried to bind <em>this</em> with the <code>.bind</code> keyword what does not work with anonymous functions.</p> <p>So I applied the the solution described here: <a href="http://stackoverflow.com/questions/22814097/how-t...
How to get a temporary (or permanent) regular URL for a file in OneDrive using the Microsoft Graph API <p>Using <a href="http://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/item_createlink" rel="nofollow">createLink</a>, for example with the POST parameters: {"type": "view", "scope": "anonymous"}, you get a res...
<p>There are four ways of linking to a file in OneDrive via Microsoft Graph:</p> <ul> <li>The web preview for the file, which is accessed from the webUrl property of DriveItem. This requires the user to be signed in to access.</li> <li>The WebDAV URL for the file, which is accessed from the webDavUrl property of Drive...
Loop for pandas columns <p>I want to apply kruskal test for several columns. I do as bellow</p> <pre><code>import pandas as pd import scipy df = pd.DataFrame({'a':range(9), 'b':[1,2,3,1,2,3,1,2,3], 'group':['a', 'b', 'c']*3}) </code></pre> <p>and then the Loop</p> <pre><code>groups = {} res = [] for grp in df['grou...
<p>Your for loops are upside down: the one-column algorithm is your loop invariant with regards to the column you chose. So the column for loop must be the outer loop. In plain English "for each column apply the kruskal algorithm which consists of this group.unique for loop:</p> <pre><code>groups = {} res = [] for col...
Database for counting page accesses <p>So let's say I have a site with appx. 40000 articles. What Im hoping to do is record the number of page visits per each article overtime.</p> <p>Basically the end goal is to be able to visualize via graph the number of lookups for any article between any period of time.<br> Here...
<p>SQL is fine. It supports <code>UPDATE</code> statements that guarantee your count is correct rather than just eventual consistency.</p> <p>Although most people will just use a log file, and process this on-demand. Unless you are Google scale, that will be fast enough.</p> <p>There exist many tools for this, often ...
generalizing scalar inputs to array inputs for user-defined fucntions <p>The <code>round</code> function can take a scalar and operate on it. However it can also take an array and operate on it in expected manner. </p> <pre><code>&gt;&gt; round(2.3) ans = 2 &gt;&gt; round([2.3,3.4]) ans = 2 3 </code...
<p>What you are looking for is the <em>arrayfun</em> function. Here is the documentation: <a href="http://www.mathworks.com/help/matlab/ref/arrayfun.html" rel="nofollow">http://www.mathworks.com/help/matlab/ref/arrayfun.html</a></p> <p>Say, I have this function:</p> <pre><code>function res = myTest(a,b) size(a) % for...
Laravel blade global variable <p>I have a problem in global variables in laravel. I know about view composer and my question is not related to that subject. How can I do such a simple thing in laravel view (*.blade.php | <em>.php) template engine? for example this is a sample code from one of my views (</em>.blade.php ...
<p>The best solution is to use the <code>Config</code> facade. You can create a new config file and set, in your case, global variables statically. But the best feature of this facade, are the <code>get()</code> and <code>set()</code> methods, which allow you to define these variables dynamically. See: <a href="http://...
how to sum multiple columns into one result from database in php? is that posible? <p>i have big database table and i need result from multiple columns into one. its about how much people is checked from some conturies and every contry has own column. here is some of it: <code>rs_turista</code>, <code>rs_nocenja</code>...
<p>Don't do it in PHP, that's needlessly selecting too much data from a database. All you gotta do is use a <code>SUM()</code> and <code>+</code> like so:</p> <pre><code>SELECT SUM(column1) + SUM(column2) + SUM(column3) + ... AS total FROM table WHERE &lt;filters for a date or other requirements&gt; </code></pre>
Qicli not starting on Naoqi SDK 2.4.3.28 <p>I tried to use qicli provided in the Naoqi SDK 2.4.3.28 on MacOS (10.12) but it doesn't start:</p> <pre><code>dyld: Library not loaded: libboost_date_time.dylib Referenced from: ..../naoqi-sdk-2.4.3.28-mac64/bin/./qicli Reason: image not found Abort trap: 6 </code></pr...
<p>There are apparently some broken dependencies in the SDK's binaries.</p> <p>Would you mind having a go at the script <a href="http://pastebin.com/WgPdUBXr" rel="nofollow" title="here">here on pastebin</a>? It should fix the dependencies issue for the 2.4.3 SDK. You need to be either on El Capitan or Sierra, with ei...
React Native _this2.refs.myinput.focus is not a function <p>Using React-Native, I have a custom component which extends from TextInput like so:</p> <p><strong>TextBox.js</strong></p> <pre><code>... render() { return ( &lt;TextInput {...this.props} style={styles.textBox}/&gt; ); } ... </code></pre> <p><...
<p>Maybe it's because the ref doesn't return an HTML element? I don't think it has to do anything with the this scope, it just says .focus is not a function, so it can't be executed probably because .focus does not exist on a non HTML element?</p> <p><a href="https://developer.mozilla.org/en/docs/Web/API/HTMLElement/f...
How to combine SUM, LEFT JOIN and WHERE, the where is with a date range <p>I have 5 tables (all have the same name fields, except id), and I need to do a SUM but the SUM depends of a range of date.</p> <pre><code>$query2= "SELECT SUM(i.unidadesllantas)+SUM(c.unidadesllantas)+SUM(t.unidadesllantas)+SUM(s.unidadesllanta...
<p>When dealing with multiple tables, prefix all column names with the table name (or the table alias) in the WHERE clause of your statement so that MYSQL will know where to look for them.</p> <p>Assuming the field <code>fecha</code> is in the <code>insurgentes</code> table, this should give you the result you want:</...
Python Flask: RQ Worker raising KeyError because of environment variable <p>I'm trying to setup a redis queue and a worker to process the queue with my flask app. I'm implementing this to handle a task that sends emails. I'm a little confused because it appears that the stack trace is saying that my 'APP_SETTINGS' envi...
<p>Thanks to the prompting of @danidee, I discovered that the environment variables need to be defined in each terminal. Hence, APP_SETTINGS was defined for the actual app, but not for the worker.</p> <p>The solution was to set APP_SETTINGS in the worker terminal. </p>
Form validation HTML5 <p>I am using the 'required' attribute in my form child tags for validation. The problem that I have is that, when I first click submit, no validation takes place and an empty form also gets submitted. </p> <p>From the second time on wards, each time I click submit the validation check kicks in a...
<p>The problem is you are intercepting the click action on the button - so the html form validation never takes place and the POST will process happily because you never check that the form is valid before sending it.</p> <p>It works fine the second time because after the first click you have unbound your click handle...
Flow HTMLElement.querySelector returning an iframe <p>Flow doesn't seem to recognize that <code>querySelector</code> may return subtypes of <code>HTMLElement</code>:</p> <pre><code>var myIframe = document.querySelector('iframe'); function foo(iframe: HTMLIFrameElement): void { // I want to do iframe stuff! } foo(m...
<p>Flow doesn't know how to parse a selector, which it would need to do to understand what kind of element would be returned. It is able to understand <code>getElementsByTagName</code>'s simpler API, though, so <a href="https://github.com/facebook/flow/blob/efd42c2cade13f42a9be7522580a108c0e2a20b2/lib/dom.js#L811" rel=...
Strange behaviour when computing svd on a covariance matrix: different results between Microsoft R and vanilla R <p>I was doing some principal component analysis on my macbook running Microsoft R 3.3.0 when I got some strange results. Double checking with a colleague, I've realised that the output of the SVD function w...
<p>The typical example forms an ill-conditioned matrix. There are some SV closest to zero making the SVD decomposition numerical sensitive to different implementations of the SVD, which is probably what you are seen </p>
bootstrap hidden-xs not working <p>I just found out about hidden-xs, hidden-sm etc, so am trying it out for the first time..</p> <p>How come this doesn't hide the review div on any screen size?</p> <pre><code>&lt;div class="row hidden-sm"&gt; &lt;div class="col-xs-12"&gt; &lt;result-reviews [result]='selecte...
<blockquote> <p>How come this doesn't hide the review div on any screen size?</p> </blockquote> <p>Read this part of the bootstrap documentation: <a href="http://getbootstrap.com/css/#responsive-utilities-classes" rel="nofollow">http://getbootstrap.com/css/#responsive-utilities-classes</a></p> <p><code>hidden-sm</c...
Communication error between Arduino and Qt using Xbee PRO S1 <p>I've been trying to do a Lights GUI with an Arduino Mega 2560 with its Xbee Shield and two Xbee Pro S1, one connected to the Arduino and the other one to the PC. My problem is: however I can send data from Qt to my arduino and read it, i can't do the same ...
<p>Try use <code>serial-&gt;readLine()</code> instead of <code>serial-&gt;readall()</code> you can for example wait in loop after the <code>serial-&gt;canReadLine()</code> returns the true then you be sure that the data are you received is a full string.</p>
Mod x Page not updating <p>I've created a snippet and included it on my template and when I make changes to the file it does not show. If I view the snippet it looks like it has changed</p> <p>This is my snippet (really simple):</p> <pre><code>echo date(); </code></pre> <p>This is my update:</p> <pre><code>echo ran...
<p>If partial cache is enabled then you will find you have will to clear the Modx cache manually.</p> <p>To do this, log into the admin area, and go to:</p> <p><code>Site</code> -> <code>Clear Cache</code></p>
Merge Multiple records into a single record <p>I have the following query that produces multiple records for a single id. I'm trying to figure out how to merge these multiple records into one record:</p> <pre><code>SELECT DISTINCT id, gender, dateofbirth, city, state, zip FROM t </code></pre> <p>This may give me the ...
<p>The query below appears to be working, at least for your sample data. Have a look at the Fiddle below for a demo. I used MySQL, because Fiddle tends to break for any other database type.</p> <pre><code>SELECT t1.* FROM yourTable t1 INNER JOIN ( SELECT id, MAX(city || ', ' || state || ', ' || zip) AS location ...
Append new items in database only <p>I have a table called <code>classes</code> Which has fields:</p> <p><code>course name</code><br> <code>times_mentioned</code></p> <p>So what I'm trying to do is. Set <code>course_name</code> and <code>times_Mentioned</code> to null at first. But when a user for instance in my web...
<p>1- change type of <code>times_mentioned</code> to <code>integer</code></p> <p>2- use <code>count</code> func to check if instance exist if so increase counter else create a new one</p> <pre><code>def AddCourseName(coursename): if db.session.query(popular_courses.id).filter(popular_courses.nam‌​e==coursenam...
RegExp: Match numbers inside the brackets, but not the brackets <p>Brackets cannot be nested, and I only need to match a number that's inside the round brackets, but not include the brackets themselves!</p> <p>Example: <code>asd asdfad(000) asdda</code> and <code>aaa_. (000000)11xx(</code>, match should be <code>000</...
<p>If you're looking to extract the number, you can use capture groups.</p> <pre><code>str.match(/\((\d+)\)/)[1] </code></pre> <p>The important parts to note are that the literal parentheses are escaped like so <code>\(</code> and <code>\)</code> while the unescaped parentheses define the capture group.</p> <p><code...
VBS script to rename files using the pathname <p>i am new to VBS scripting and I have done few stuff with Excel VBA before. Now I have a script which renames single files with the pathname of the files (truncated to 4 letter each))see below. It is some script which I modified a bit to fit my purpose. However, I would l...
<p>Walking a tree requires recursion, a function calling itself for each level.</p> <pre><code>On Error Resume Next Set fso = CreateObject("Scripting.FileSystemObject") Dirname = InputBox("Enter Dir name") ProcessFolder DirName Sub ProcessFolder(FolderPath) On Error Resume Next Set fldr = fso.GetFolder(Folder...
Editing Highcharts.js donut data programmatically va JS <p>I am trying to do the same for donut (editing the donut data programmatically), but the code just wouldn't work for me, although the syntax seems to be straghtforward here. </p> <p>My goal is to find the data point in the donut which corresponds to the given ...
<p>Actually, you are looking for a point by its name, not its x value, because x value is a number, name is a string (for categorized data there is natural mapping between those two).</p> <pre><code>btnEdit.click(function() { // chart.series[0].data[0].update(x += 10); - this code doesn't work var i = 0, points = ...
Convert string to array in php, output it and then output in ascending and descending order <p>I have so far I have managed to convert a string to an array in php and out put it with a foreach and an echo statement. But when I try to sort it I get an error like this:</p> <blockquote> <p>Warning: asort() expects para...
<p>You have to sort before the loop. I.e.</p> <pre><code>asort($name); foreach($name as $value){ echo $value."&lt;br&gt;"; } $myarray = $names; $name = explode(' ', $myarray); arsort($name); foreach($name as $value){ echo $value."&lt;br&gt;"; } </code></pre>
Return from page not triggering `INavigationAware.OnNavigatedTo` <p>I have a <code>NavigationPage</code> with <code>ContentPage</code>s. When I use the back arrow provided by the <code>NavigationPage</code> instead of <code>INavigationService.GoBackAsync</code>, my implementation of <code>INavigationAware.OnNavigatedTo...
<p>This is a known issue. You can follow the request here:</p> <p><a href="https://github.com/PrismLibrary/Prism/issues/634" rel="nofollow">https://github.com/PrismLibrary/Prism/issues/634</a></p> <p>The problem is that there is no unified API for Prism to use in order to call INavigationAware when a Page is popped....
Template argument deduction for class templates and multiple parameters packs <p>In C++17 template arguments for a class template will be deduced more or less as it happens nowadays for a function template.<br> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0091r2.html" rel="nofollow">Here</a> is the...
<p>This:</p> <pre><code>template&lt;typename... U, typename... T&gt; struct S { ... }; </code></pre> <p>is just ill-formed per [temp.param]:</p> <blockquote> <p>If a <em>template-parameter</em> of a primary class template, primary variable template, or alias template is a template parameter pack, it shall be the l...
postgres json_populate_recordset not working as expected <p>I have a table called <code>slices</code> with some simple json objects that looks like this:</p> <pre><code>id | payload | metric_name ---|---------------------------------------|------------ 1 | {"a_percent":99.97,"c_percent":...
<p>You don't need to use <code>json_agg</code>, since it appears you want to get the set of <code>a_percent</code> and <code>c_percent</code> values for each <code>id</code> in a separate record. Rather just call <code>json_populate_recordset</code> as follows:</p> <pre><code>SELECT id, (json_populate_record(null::c_...
PHP - Can't insert into table with PDO <p>I am connected to my database using PDO. My problem is, I can't insert stuff into the table for some reason. I could do it when I connected using <code>mysqli_connect();</code> but that isn't secure enough for me.</p> <p>Here is my code that connects to the database:</p> <pre...
<pre><code>$sql = "INSERT INTO `users` (`first`, `last`, `uid`, `pwd`) VALUES (:first, :last, :uid, :pwd)"; $sth = $conn-&gt;prepare($sql); $sth-&gt;bindValue(':first', $first); $sth-&gt;bindValue(':last', $last); $sth-&gt;bindValue(':uid', $uid); $sth-&gt;bindValue(':pwd', $pwd); $sth-&gt;execute(); </code></pre>
WPF Custom control binding image source <p>I have a custom control based on a button, and I put an image inside. I can set the source of the image in the xaml, but if I try and bind it, it doesn't work.</p> <p>Generic.xaml</p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/prese...
<p>Figured it out myself after about 2 hours. The xaml binding should look like,</p> <pre><code>&lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type local:MyCustomControl}"&gt; &lt;Grid x:Name="InnerGrid"&gt; &lt;Image Source="{Binding ...
How to get out of the maze using recursion? <p>Let's consider a maze represented by a matrix of ints: 0 - not visited, 1 - obstacles (blocked positions), 2 - visited, -1 - output, (x,y) - start position. I want to find a path from start to some output by using recursion.</p> <pre><code>int[] x_dir = new int[] { 0, 0, ...
<p>To print a path, you need to keep track of it, which suggests adding a parameter for that purpose. Care must be taken to not include wrong turns in it, or at least to remove them once you know that is what they are.</p> <p>Alternatively, if you print out the step you took for each call to <code>dfs</code> that ret...
How to save a JavaScript string on a server with PHP and request it again later? <p>So my problem is actually pretty simple:</p> <p>I have this function (simplified) - it is triggered when a button is clicked:</p> <pre class="lang-js prettyprint-override"><code>$search.onclick = function () { // let's just say t...
<p>You can use <code>localStorage</code> to store a file at users browser configuration folder : user filesystem. If file exists at <code>localStorage</code>, use the file from <code>localStorage</code> without making <code>$.getJSON()</code> request, else call <code>$.getJSON()</code>; at <code>success</code> of <code...
Angular2 ng-bootstrap - no provider error <p>I am trying to integrate ng bootstrap UI into my Angular 2 project. After following the simple instructions found here: <a href="https://ng-bootstrap.github.io/#/getting-started" rel="nofollow">https://ng-bootstrap.github.io/#/getting-started</a> i get the following error ...
<p>import NgbModule in your app.module.ts like this-</p> <pre><code>import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; </code></pre> <p>and add it in imports section of ngmodule-</p> <pre><code>@NgModule({ declarations: [AppComponent, ...], imports: [NgbModule.forRoot(), ...], bootstrap: [AppComponent] }) <...
Compare if two vectors are the same <p>How do I check if two vectors are identical? I've tried to do it with a <code>for</code> loop and <code>if</code> statement but that option is not suited for the amount of data that I've got to work with. Is there any smart way to do it? I would like to create an <code>if</code> s...
<p>For just checking whether 2 vectors are equal you can use the <code>==</code> operator on a vector and then use <code>all( )</code> to check that every element of the returned logical array is true. Andras Deak link in the comments has some great methods on finding a vector in a larger set.</p> <pre><code>v1 = [1 ...
Move view up on TextView Edit Swift 3.0 <p>I know this question has asked several times, but I'm looking for an implementation that uses Swift 3.0. To be clear I have a Text VIEW, not a text FIELD. </p> <p>I tried doing something like this...</p> <p>In <code>viewDidLoad()</code>:</p> <pre><code>NotificationCenter.de...
<p>You need to modify your add observer code as mentioned below. As per Swift 3 migration guide this is the new way that should be followed to declare the add observer of notification.</p> <p><strong>Code :</strong></p> <pre><code> NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillS...
How to mount shared volume across EC2 instances via Vagrant? <p>I'm using <a href="https://github.com/mitchellh/vagrant-aws" rel="nofollow">vagrant-aws</a> Vagrant plugin to run multiple disposable EC2 instances which are running tests, however my problem is that the provisioning script takes too long time (e.g. apt-ge...
<p>If I get your question right, you want to save your instance the way it is before you terminate them.</p> <p>First let me ask, isn't it easier if you just pause your instance? No hourly charges applied on a stopped instance, you only pay for the volumes reserved (full size of your volumes).</p> <p>Another approach...
The compiler suggests I add a 'static lifetime because the parameter type may not live long enough, but I don't think that's what I want <p>Sorry for the vague title, but I'm fairly new to Rust, so I don't exactly know how to succinctly sum up my issue.</p> <p>I'm trying to implement something that (showing minimal ex...
<p>Check out the entire error:</p> <pre class="lang-none prettyprint-override"><code>error[E0310]: the parameter type `U` may not live long enough --&gt; src/main.rs:9:24 | 9 | self.data.push(Box::new(x)); | ^^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `U: 's...
How can I specify the user inside my docker container? <p>I don't want to be root inside a docker container.</p> <p>I have tried the -u option but without success, if I call "id" inside the docker container I'm always root, what am I doing wrong?</p> <pre><code>docker run coursera -u 1000:1000 /grader/executeGrader.s...
<p>Sorry, got the order wrong:</p> <pre><code>docker run -u 1000:1000 coursera /grader/executeGrader.sh HgVwK </code></pre>
Custom navbar with changed collpase breakpoint <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;nav class="navbar navbar-default"&gt; &lt;div class="container-fluid"&gt...
<p>Try this out. adding a class that has position:fixed when scroll is greater than a number.</p> <p>CSS</p> <pre><code>.content { position: relative; height: 800px; } .sticky { position: fixed; left: 0; right: 0; } .no-border { background-color: transparent; border: none } </code></pre> <p>JS</p> <pre...
How to plot two level x-axis labels for a histogram? <p>Is there a way to do the same of this two x-axis labels but for a histogram plot? <a href="http://stackoverflow.com/questions/31803817/how-to-add-second-x-axis-at-the-bottom-of-the-first-one-in-matplotlib/40053591#40053591">How to add second x-axis at the bottom ...
<p>just replace your <code>hist</code> call by:</p> <pre><code>n, bins, patches = ax1.hist(x, num_bins, normed=1, facecolor='green', alpha=0.5) </code></pre> <p>Check the <a href="http://matplotlib.org/api/axes_api.html" rel="nofollow">documentation for <code>Axes</code></a> to see what member functions are available...
Yii2 get access only using pretty URLs <p>I'm using URL manager like the following:</p> <pre><code>'urlManager' =&gt; [ 'enablePrettyUrl' =&gt; true, 'showScriptName' =&gt; false, 'rules' =&gt; [ 'verses/view/&lt;id:\d+&gt;' =&gt; 'verses/view', ...
<p>What is the point of such restriction?</p> <p>Anyway, one way to do it is something like this:</p> <pre><code>public function actionView($id) { if (strpos(\Yii::$app-&gt;request-&gt;getUrl(), '?') !== false) { throw new \yii\web\BadRequestHttpException; } // ... the rest of action } </code></pr...
Interleaving in OCaml <p>I am trying to create a function which interleaves a pair of triples such as ((6, 3, 2), ( 4, 5 ,1)) and create a 6-tuple out of this interleaving. I made some research but could understand how interleaving is supposed to work so I tried something on my own end ended up with a code that is crea...
<p>The problem statement uses the word "max" without defining it. If you use the built-in <code>compare</code> function of OCaml as your definition, it uses <a href="https://en.wikipedia.org/wiki/Lexicographical_order" rel="nofollow">lexicographic order</a>. So you want the largest value (of the 6 values) in the first ...
Can prolog be used to determine invalid inference? <p>If I have two premises as follows:</p> <ol> <li>a -> c (a implies c)</li> <li>b -> c (b implies c)</li> </ol> <p>and a derived conclusion:</p> <ol start="3"> <li>a -> b (a therefore implies b),</li> </ol> <p>then the conclusion can be shown to be invalid because...
<p>@coder has already given a very good answer, using <a href="/questions/tagged/clpb" class="post-tag" title="show questions tagged &#39;clpb&#39;" rel="tag">clpb</a> constraints.</p> <p>I would like to show a slightly different way to show that the conclusion does <em>not</em> follow from the premises, also using&nb...
PHP equivalent of Python's `urljoin` <p>What is the PHP equivalent for building a URL from a base URL and a potentially-relative path? Python provides <a href="https://docs.python.org/2/library/urlparse.html#urlparse.urljoin" rel="nofollow"><code>urlparse.urljoin</code></a> but there does not seem to be any standard im...
<p>Because there is clearly a need for this functionality and none of the random scripts out there cover all the bases, I've started a <a href="https://github.com/plaidfluff/php-urljoin" rel="nofollow">project on Github</a> to try to do it right.</p> <p>The implementation of <code>urljoin()</code> is currently as foll...
advanced tab menu angular <p>I'm designing a website based on AngularJS, and I saw an already existed website with a wonderful upper tab menu: <a href="http://brilliantbritz.com/" rel="nofollow">http://brilliantbritz.com/</a> . I've searched for hours and hours for bootstrap/any file that could contain the menu code (w...
<p>By using Google. Try researching your problem a little bit more before asking a question. When asking a question, please provide some code and various methods of how you tried solving your problem. Please read <a href="http://stackoverflow.com/help/how-to-ask">How to properly ask a question</a> and this <a href="htt...
How do I increment and decrement a field and limit it once for users? <p>Hello people I am developing an app, where I have a book table that has two columns ‘foo’ and ‘bar’ both are integer.</p> <p>Now I have set the default values to zero. I want a user to be able to click a button and increment them by one ...
<p>By your description, it sounds like you want to maintain the counts per user, not just by the book.</p> <p>one possible solution is to create a join table:</p> <pre><code>class Book has_many :user_votes class UserVotes belongs_to :books belongs_to :users class User has_many :user_votes </code></pre> <p>The foo ...