input
stringlengths
51
42.3k
output
stringlengths
18
55k
Angular ternary with html <p>How can I include html in a ternary operator? </p> <pre><code>{{ (q.result === 1) ? "&lt;i class="fa fa-check" aria-hidden="true"&gt;&lt;/i&gt;" ? "&lt;i class="fa fa-times" aria-hidden="true"&gt;&lt;/i&gt;" }} </code></pre> <p>If not possible, I guess the obvious alternative is to do two...
<p>You can acccomplish what you want with ng-class. It actually supports the ternary operator</p> <pre><code>&lt;i class="fa" aria-hidden="true" ng-class"(q.result === 1) ? 'fa-check' : 'fa-times'"&gt;&lt;/i&gt; </code></pre>
Kafka topic per producer <p>Lets say I have multiple devices. Each device has different type of sensors. Now I want to send the data from each device for each sensor to kafka. But I am confused about the kafka topics. For processing this real time data</p> <p>Is it good to have kafka topic per device and all the senso...
<p>It depends on your semantics:</p> <ul> <li>a topic is a logical abstraction and should contain "unify" data, ie, data with the same semantical meaning</li> <li>a topic can easily be scaled out via its number of partitions</li> </ul> <p>For example, if you have different type of sensors collecting different data, y...
Comparing two text files and calculating how many times each number in the 2nd file apears in the first <p><em>Edit</em></p> <p>Here is the updated code, I got the string to be loaded up with the matches but now how do I match the strings with the second file.</p> <p>The strings contain this for reference:</p> <p>St...
<p>Once you got one number, store it for a future use, don't just display it.</p> <pre><code>Scanner INPUT_TEXT = new Scanner(new File("C:\\Users\\josep\\Downloads\\assignment3_1.txt")); INPUT_TEXT.useDelimiter(" "); int count=0; // ** Creating the storage for the numbers (as strings) ArrayList&lt;String&gt; numbersI...
Pass implicit Ordering[Int] argument to Ordering[T] parameter <p>I want to write some mergesort function. </p> <p>How to supply <strong>Ordering[T]</strong> to <strong>merge</strong> subfunction?</p> <p>The overall structure of application is the following: </p> <pre><code>object Main extends App { ... val array...
<p>Adding <code>implicit Ordering[T]</code> parameter to the outermost function should fix the problem, and passing non <code>Ordering[T]</code> arguments will result in compile error.</p> <p>Scala's sort functions do the same thing: <a href="https://github.com/scala/scala/blob/2.12.x/src/library/scala/collection/SeqL...
Exception: Cannot find PyQt5 plugin directories when using Pyinstaller despite PyQt5 not even being used <p>A month ago I solved my applcation freezing issues for Python 2.7 as you can see <a href="http://stackoverflow.com/questions/39135408/using-pyinstaller-on-parmap-causes-a-tkinter-matplotlib-import-error-why">here...
<p>Uninstall Anaconda and everything works... I conclude that you simply cannot have Anaconda installed and use the standard Python 3.5 compiler at the same time if you're using Pyinstaller. Maybe <a href="http://stackoverflow.com/questions/39728108/running-pyinstaller-after-anaconda-install-results-in-importerror-no-m...
How to get post with maximum likes or post with likes counts in rails <p>I am having two models post and like, having a relationship between them. Post has_many likes. I wanted an optimal way to find which post has maximum likes. One way of doing this by </p> <pre><code>count = {} Post.includes(:likes).each do |post| ...
<p><a href="http://yerb.net/blog/2014/03/13/three-easy-steps-to-using-counter-caches-in-rails/" rel="nofollow">Use <code>counter_cache</code></a> so that you always have a count of likes on the <code>Post</code> objects, then you can call <code>Post.maximum(:likes_count).first</code> to retrieve the one post that has t...
.c File via Bridging Header Not Working After Xcode 8 Update <p>The app I've been working on uses an external library, pdlib, which has it's own externals (.c files) which I've been importing via the bridging header <code>#import "Uzi.c"</code> and calling in my main Swift file via Uzi.c's setup function <code>Uzi_setu...
<p>Solved by @danomatika on GitHub: <a href="https://github.com/libpd/libpd/issues/149" rel="nofollow">https://github.com/libpd/libpd/issues/149</a></p> <p>"You generally shouldn't include/import an implementation file aka .c, .cpp, .m, etc. This is what is causing the duplicate symbol issue.</p> <p>This is what the ...
Resources to learn KnockoutJS <p>I have to work on an existing KnockoutJS project. I am trying to learn it by myself from KnockoutJS website and other places but having a hard time. Could you please guide me some good resources to get hang of it? Also, if there is any one to one help available on the web please let me ...
<p>The best place to look for would be <a href="http://knockoutjs.com/" rel="nofollow">KnockoutJS</a>. If you fully understood all the basic tutorials then all you need to do is to head to their Documentation page and search in the docs for what you need to learn/do. Everything that knockout is capable of is in there, ...
Where are location settings stored on KitKat? <p>I'm building KitKat using AOSP and would like Location setting to be set to "High accuracy" by default and without any user intervention.</p> <p>I've read various bits and pieces on how it's typically done and can trigger a dialog to present to the user, but I'd like to...
<p>I found a way to do this by modifying the AOSP code directly.</p>
Python : Extract one string from 100 lines of text <ol> <li><p>I need to extract a particular string from 100 lines of log data. I tried split and then tried to get the needed string but couldn't succeed. Any suggestions/help appreciated. Thanks!</p> <p>In the log below, I would like to extract the highlighted part, t...
<p>Looks like the string is in dictionary format (correct me if I'm wrong), so you could try converting it to one. Then you won't need regex.</p> <pre><code>import ast your_dict = ast.literal_eval(your_string) </code></pre> <p>Then what you want would be: </p> <pre><code>your_dict['status']['initiator0_iqn'] </code>...
I keep getting zero from my equations and do not know why <p>Here is my full code. I keep getting zero for my equations no matter what i do. Any help would be greatly appreciated. </p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;math.h&gt; int main(void) { int x, y; float a,t; //Inputs...
<p>Your first equation is equivalent to</p> <pre><code>a = ((((((x * 1) / 60) * 1) / 60) * 1) / 60) * 1000; </code></pre> <p>ie;</p> <pre><code>a = (x/(60*60*60)) * 1000; </code></pre> <p>or</p> <pre><code>a = (x/(216000)) * 1000; </code></pre> <p>Even though your a is a float, RHS of your equation is doing integ...
Load JSON object including escaped json string <p>I'm trying to load a JSON object from a string (via Python). This object has a single key mapped to an array. The array includes a single value which is another serialized JSON object. I have tried a few online JSON parsers / validators, but can't seem to identify what ...
<p>If you try out your string in the REPL, you'll see pretty quickly why it doesn't work:</p> <pre><code>&gt;&gt;&gt; '{"parent":["{\"key\":\"value\"}"]}' '{"parent":["{"key":"value"}"]}' </code></pre> <p>Notice the <code>\</code> have gone away because python is treating them as escape sequences ...</p> <p>One easy...
multiplying a variable without rewriting it <p>So I am fairly new to the "code world" and hopefully have a fairly simply question. </p> <pre><code>txtBox.Text = "x"; </code></pre> <p>How would I make it so I am able to see 10 X's in my <code>txtBox</code> without completely writing it out?</p>
<p><code>string</code> has a constructor that repeats a character for a given number of times:</p> <pre><code>txtBox.Text = new string('x', 10); </code></pre> <p>It's documented <a href="https://msdn.microsoft.com/en-us/library/xsa4321w(v=vs.110).aspx" rel="nofollow">here</a>.</p> <p>If what you want to repeat is a ...
How to hide <select> and toggle (open) with a button <p>I'm using bootstrap 3 and am trying to imitate jQueryMobile's select option where you can replace the standard select textbar and arrows with just a button which toggles the opening of said select.</p> <p>I don't want to use dropdowns either because they get hidd...
<p>Not totally sure on this, need a little more information. But you can create a button with:</p> <pre><code>&lt;button type="button" onclick="alert('Message')"&gt;Button&lt;/button&gt; </code></pre> <p>if that what you wanted?</p>
Have to display coins used in makeChange function? <p>I am creating a makeChange function using a useIt or loseIt recursive call. I was able to determine the least amount of coins that's needed to create the amount; however, I am unsure as to how to display the actual coins used.</p> <pre><code>def change(amount,coins...
<p>You want something like:</p> <pre><code>def change(amount, coins): ''' &gt;&gt;&gt; change(10, [1, 5, 25]) [5, 5] ''' if not coins or amount &lt;= 0: return [] else: return min((change(amount - coin, coins) + [coin] for coin in coins if amount &gt;= coin),...
SVG embed not loaded or unaccessible via contentDocument <p>I've been struggling for... hours on a simple problem even though it seems to have been described here :<a href="http://stackoverflow.com/questions/2753732/how-to-access-svg-elements-with-javascript">How to access SVG elements with Javascript</a></p> <p>I can...
<p>Try <code>getSVGDocument()</code> and see if it helps you:</p> <pre><code>window.onload = initAll; function initAll(){ var mySVG = document.getElementById("maptest"); console.log(mySVG); var svgDoc = mySVG.getSVGDocument(); console.log(svgDoc); } </code></pre>
`manage.py runserver` and Ctrl+C (Django) <p>When I quit Django <code>manage.py runserver</code> with Ctrl+C, do threads running HTTP request finish properly or are they interrupted in the middle?</p>
<p><strong>TL;DR</strong> running HTTP requests are stopped when Ctrl+C is hit on the django dev server</p> <p>I thought your question is really interesting and investigated:</p> <p>I made a view that takes 10 seconds to execute and after that sends a response. To test for your behaviour I stopped the development-ser...
Redirect client while performing a function with Express <p>Right now, I have an Express route that is posted to by a form, below is a truncated example. The initial form is inside an iframe, so after I receive a response from <code>http://example.com/endpoint</code>, I send a response back to the iframe with a link go...
<p>I would put the hellosign/whatever long running API call in its own module. Test that separately to make sure its working.</p> <p>Then your iframe or whatever (do you really need an iframe?) sends the request which is just a 'start order' request which gets an order id from the hellosign module. And then use a se...
How to create a thumbnail link to OmniFaces graphicImage method <p>I was wondering if and how it is possible to display an <code>&lt;o:graphicImage&gt;</code> as thumbnail inside a <code>&lt;p:lightbox&gt;</code>. To be more precise, I wanted to achieve something like this:</p> <pre><code>&lt;p:dataTable id="articles...
<p>For exactly this reason, OmniFaces 2.5 introduced the <code>#{of:graphicImageURL()}</code> EL function. This works only if your <code>ImageBean</code> is annotated with <code>@GraphicImageBean</code>.</p> <pre><code>import org.omnifaces.cdi.GraphicImageBean; @GraphicImageBean public class ImageBean { // ... ...
Excel Compare two sheets and update sheet 1 <p>Okay - This has been asked multiple times, but asking again for best possible solution : </p> <p>I have two excel files (not sheets). the first excel sheet is very huge and has close to 200,000 records. One of the column (Gender) is corrupted and i have to fix it.<br> I...
<p>One way to do this through VBA is to just loop through the 200 corrections, comparing the ID with the MATCH function to find the row it belongs on, as opposed to a second loop (a second loop through 20000 would take ages like you say).</p> <p>For the below sub I have copied and pasted the 200 table into columns 5:7...
Evaluate untrimmed mean in R <p>I was using the <code>mean()</code> in base package and wanted to calculate untrimmed mean which wasn't being evaluated even after putting <code>trim = 0</code> . The code in which i was implementing the above is :-</p> <pre><code>pollutantmean &lt;- function(directory,pollutant,id = 1:...
<p>The <code>mean()</code> function has the <code>trim</code> parameter and its default is 0. So using <code>mean(sample)</code> will give you the untrimmed mean. </p> <p>Analyzing your function, you are reading several csv, calculating their mean. Then you are storing this value in a vector and in the end you ca...
how to only insert an as many items are in my array with php to mysql from json <p>I have a php file that i am inserting data from a json into a mysql database, and i am using a foreach() to list the tech's and then insert them into mysql. my problem is it seems to just insert 3 of the same things into the database and...
<p>You have 2 foreach loops. The first consumes all the input data so leaving only the last occurance in the scalar variables. Your second foreach loops around <code>$jatech</code> which is the LAST version of <code>$jatech = $chunk['technician'];</code></p> <p>This should work a little better</p> <pre><code>$ijobid ...
If else state on Hiding a button in swift <p>I have two buttons in a view. If you tap the button on the left, then the button on the right should toggle whether it is hidden. </p> <p>I have defined outlets for both buttons but my if else statement is wrong. This is my if else statement:</p> <pre><code>@IBAction func ...
<p>If you just want to toggle the <code>hidden</code> property of <code>b</code> when the function runs you can use:</p> <pre><code>@IBAction func aa(sender: AnyObject) { b.hidden = !b.hidden } </code></pre>
Golfing postgres how can I return count number from the query <p>I am very new to Golang and am using the PQ package for postgres. What I am trying to do is prevent duplicate emails, so I have a query that checks to see if a user email is already in the database </p> <pre><code>check_duplicate_emails, err := db.Prepar...
<p>What's happening here is that you've told Go that your query won't be returning any rows (see <a href="https://golang.org/pkg/database/sql/#DB.Exec" rel="nofollow">docs for Exec()</a>)</p> <p>You should probably use either:</p> <ul> <li>a combination of <a href="https://golang.org/pkg/database/sql/#DB.QueryRow" re...
angular2 rc6 event emitter - parent child interaction example <p>I am looking for an example that explains how parent child interaction using event emission works in angular2-rc6 version (that no longer makes use of directives). Most of the links available online seem to have the directives tag functional (older versio...
<p>See this link on <a href="https://angular.io/docs/ts/latest/cookbook/component-communication.html#!#child-to-parent" rel="nofollow">COMPONENT INTERACTION</a></p> <p><strong>VoterComponent</strong></p> <pre><code>import { Component, EventEmitter, Input, Output } from '@angular/core'; @Component({ selector: 'my-vo...
Simplest and quickest way to portray an application for development <p>As a designer I sometimes feel the need to portray the main idea of an application in a graphical form like a flowchart. Something that is easy enough to understand for the development firms and could convey the purpose of the application and possib...
<p>This is a usual procedure that is followed when we plan over developing a new application:</p> <ul> <li>Start by creating <strong>User stories</strong>. Which define different scenarios that a user might face and explain why that feature is included in your application. This helps us further is second step</li> <li...
iOS asset sizes and design method <p>The code for my first iOS 2D game is written. Now, when it comes to assets I feel lost. One reason is the feeling of imperfection due to outdated articles. I need to know the image sizes, to begin designing. The device orientation of the game is <strong>portrait</strong> only. The s...
<p><strong>iPhone 5:<br></strong> <strong>Display Size:</strong> 4 in<br> <strong>Screen Size:</strong> 320 x 568 points<br> <strong>Rendered Pixels:</strong> 640 x 1136 (@2x)<br> <strong>Pixels Per Inch (PPI):</strong> 326<br> <strong>Browser Size Portrait:</strong> 320 x 460 px (320 x 528* / 320 x 548**)</p> <p><str...
Powershell - Get-AdGroupMember exceeding limit <p>I have the following query </p> <pre><code>$Groups = (Get-AdGroup -filter * | Where { ($_.name -like "*") } | select ObjectGUID -expandproperty ObjectGUID) $Table = @() $Record = [ordered]@{ "Group _ObjectGUID" = "" "Name" = "" "SamAcco...
<p>I ran into this problem just today as well. What you have to do is get the group with the properties of member:</p> <pre><code>$ADInfo = Get-ADGroup -Identity $Group -Properties Members </code></pre> <p>Now, $ADInfo holds the group and it's members. To get the list of members:</p> <pre><code>$ADInfo.Members </c...
Python2.7(on Windows) Need to capture serial port output into log files during Python/Robot script run <p>We are testing networking devices to which test interaction is done using serial ports. Python 2.7 with Windows is used to achieve this using the PySerial module of Python. The scripts are run using Robot framewor...
<p>I may be incorrect but perhaps you want to capture data sent/received between computer and device through serial port. If this is true then serial port sniffer will be required. Linux and mac os x does not support sniffing however you may use sniffing for windows.</p>
angular2 TypeError: self._el_11 is not a function <p>i want to add event listener to input ,here is my code </p> <pre><code>&lt;input ref-search (keyup)="search(search.value)"&gt; </code></pre> <p>and search method is </p> <pre><code>search(condition: string){ console.log(condition); } </code></pre> <p>then whe...
<p>That's because you define template reference variable with the same name as your method. </p> <p>So change it with:</p> <pre><code>&lt;input ref-searchInput (keyup)="search(searchInput.value)"&gt; </code></pre>
DatePicker doesn't work for Dialog in Partial view using asp.net mvc <p>I have 'jquery-1.12.4.js', 'jquery-ui-1.12.0.js' and my css in my shared layout.</p> <p>I'm using jquery dialog to popup. </p> <p>and I call my partial view and load it.</p> <pre><code>$element.dialog({ autoOpen: false, width: wSize, ...
<p>I had a similar situation to this and it only worked when I added the datepicker function after my partial view is rendered and not in the shared layout. </p> <p>So in your case would be after opening the dialog</p>
Match two strings based on patterns <p>Say i have the below data</p> <pre><code>string data1 = "2014SP"; string data2 = "2014DP"; string data3 = "2014AP-S1" </code></pre> <p>Is there a way I can tell while comparing the strings that they follow a pattern which is say NumberWordSpecialCharacter etc. So in this case da...
<p>The first idea pops into my head is you can try a simple pattern model by converting input string into a output integer. Such as: if it is a letter (or letter block), replace it with 1; number, replace it with 2; etc. Easy and efficient. I'm not sure this helps :)</p>
Loop through JSON object using jq <p>This is what my JSON array of objects looks like:</p> <pre><code>[ { "Description": "Description 1", "OutputKey": "OutputKey 1", "OutputValue": "OutputValue 1" }, { "Description": "Description 2", "OutputKey": "OutputKey 2", ...
<ol> <li><p>I'm afraid your question isn't very clear. If you want to produce the values for consumption by some tool or application other than jq, then it would be helpful to know what that tool expects. If you want to use the values in jq itself, then you could use <code>map</code> or <code>reduce</code>; alternati...
write to file \t creates spaces not tabs <p>So, I have a list of lists and trying to write the values to a file with <strong>tab</strong> delimited;</p> <pre><code>sorted_results=[ ["test1", 01], ["test2", 02], ] with open('outfile.txt', 'a') as write_file: for i in sorted_results: write_file.write(...
<p>You can read the file back in and inspect the resulting data.</p> <pre><code>&gt;&gt;&gt; open('outfile.txt').read() 'test1\t1\ntest2\t2\n' </code></pre> <p>This shows that the tab character is indeed written to the file. If you are still in doubt use a hex editor to view the characters.</p>
R - OpenBugs - Multiple Definitions on Node Error - Custom Distribution <p>I am relatively new to R and OpenBugs and have spent a lot of time troubleshooting this model. I have been able to figure out a fair amount of them on my own through resources online, but I am stuck on this error. It says that are "multiple defi...
<p>You have put the closing brace for the m1 loop at the end of the model, rather than before the start of the m2 loop. That means that all dummyy, loglikey, as well as a b and c are defined m1 times.</p> <p>Edit: Just to be clear, your model should be:</p> <pre><code>for (i in 1:m1) { dummyx[i]&lt;-0 dummy...
Pass JVM options to point to log4j.properties file in Pig Action in Oozie Workflow <p>In my Oozie workflow, there is a pig action.<br> While running, it is looking for log4j.properties file in CDH as I have not provided the file in my jars.<br> Now, I have the log4j.properties file with me and I just need to pass it as...
<p>You can pass the <code>log4j.properties</code> file like this:</p> <pre><code> &lt;argument&gt;-log4jconf&lt;/argument&gt; &lt;argument&gt;log4j.properties&lt;/argument&gt; </code></pre> <p>Add the <code>log4j.properties</code> file into your workflow application directory or using the <code>&lt;fil...
Python: range doesn't increase <p>I have to write a program that shows a column of kilograms and a column of pounds, starting at 1 kilogram and ending 99, increasing every step with 2.</p> <p>I have the following code, and the range() works for the pounds part, but not for the kilograms part. It stays always 1 for the...
<p>Because you use <code>break</code> with in a loop.</p> <p>In python you don't end a loop with anything but a decreased indentation. Remove your <code>break</code> statements and try again.</p> <p>The <code>break</code> statements ends the current loop unconditionally. For example,</p> <pre><code>s = 0 for i in ra...
Hangfire configuration - how often it pings the database <p>It looks like Hangfire hits the database few times a second, probably to find out if there are any jobs to pick up. I would like to slow it down as I don't mind if the checks are done every few seconds. </p> <p>Is it possible?</p> <p>Hangfire 1.6 docs say:</...
<p>Look at this : <a href="http://docs.hangfire.io/en/latest/configuration/using-sql-server.html#configuring-the-polling-interval" rel="nofollow">http://docs.hangfire.io/en/latest/configuration/using-sql-server.html#configuring-the-polling-interval</a></p> <p><code>var options = new SqlServerStorageOptions{ QueueP...
How to save a TFilestream to hard drive with Lazarus <p>I am having a problem with saving an xml-file after changing some values. I use Lazarus 1.6 as IDE with FPC Version 3.0.0 Here is the structure of my xml-file I use for this post:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;wbpickeys&gt; ...
<p>When you write the modified document back to disk you must replace the entire file, you cannot restrict the operation to just the modified node. Therefore, you must first delete the old xml file (or better: rename it, just in case that something goes wrong during writing) and then write the document using WriteXMLFi...
WooCommerce "CONTACT" button when out of stock <p>Trying to achieve something that should be simple, but I've tried 3 approaches with multiple code variations and I just can't make it work. I'm trying to create a button that will appear in place of the "ADD TO CART" button on single product pages when the item is out o...
<p>You can either hook into <code>woocommerce_loop_add_to_cart_args</code> using a filter in your <code>functions.php</code> or edit the template file directly by pulling it into your theme. Either way will require a bit of PHP.</p> <p>If doing it in your <code>functions.php</code>, it would look something like this (...
How can I use a configuration setting from config.yml in annotation <p>Sometimes, I just need to place the value with a config from the end user, just like the database prefix, uploaded File maxSize like below, and etc...</p> <pre><code>/** * File * * @ORM\Table(name="{projectName}media_file") * @ORM\Entity(reposi...
<p>As far as I know, this is not possible: the configuration parameters are only available in the container. </p> <p>For the table prefix, maybe you can use the following solution: <a href="http://stackoverflow.com/questions/7504073/how-to-setup-table-prefix-in-symfony2">How to setup table prefix in symfony2</a></p> ...
How often are Azure Database Transaction Unit (DTU) averaged? <p>Are DTU limits always like a policeman with a speed gun who just looks at your current speed and if it is above then you're busted or is like two cameras on a highway that measure your average speed?</p> <p>If it is an average how small is the window? </...
<p>Your database is controlled using Resource Governor and when the queries are in need of any resource like IO,CPU,Memory after exhausting their limits..They will be in queue ..<a href="https://azure.microsoft.com/en-in/documentation/articles/sql-database-resource-limits/" rel="nofollow">This has been documented here<...
R TIME-TO-EVENT <p>I am new to R (started to teach myself last week) and new to this forum.</p> <p>I am working on a dataset where I need to determine the time-to-event. I have three variables (Drug, Patient and Date) and I need to work out the time difference for each patient when they switch drugs. Also of note is t...
<p>....an answer to 'part deux' if I've understood the intent correctly. Note I've reduced the number of dates from 100 to 10, to get the sequences contemporaneous. </p> <pre><code>library(TraMineR) data &lt;- data.frame(Drug=sample(c("Drug A","Drug B", "Drug C", "Drug D", "Drug E"),100,replace=TRUE), P...
How (and when) do I use iCloud's encodeSystemFields method on CKRecord? <p><code>encodeSystemFields</code> is supposed to be used when I keep records locally, in a database.</p> <p>Once I export that data, must I do anything special when de-serializing it? </p> <p>What scenarios should I act upon information in that...
<p>encodeSystemFields is useful to avoid having to fetch a CKRecord from CloudKit again to update it (barring record conflicts).</p> <p>The idea is:</p> <p><strong>When you are storing the data for a record retrieved from CloudKit</strong> (for example, retrieved via <a href="https://developer.apple.com/reference/clo...
Subset a dataframe based on within-group quantile <p>My dataframe looks like this:</p> <pre><code>df city year wealth a 2001 1 a 2002 30 b 2001 2 b 2002 20 c 2001 3 c 2002 10 </code></pre> <p>I'm looking for a simple way to subset the dataframe based on city wealth relati...
<p>Here's an approach using the <code>dplyr</code> package. We group the data by year, then create a new column that indicates the group (which quantile) the city is in. We can then <code>split</code> up the dataset by the new group column:</p> <pre><code>library(dplyr) df &lt;- df %&gt;% group_by(year) %&gt;% mut...
How to handle threads that hang when using SemaphoreSlim <p>I have some code that runs thousands of URLs through a third party library. Occasionally the method in the library hangs which takes up a thread. After a while all threads are taken up by processes doing nothing and it grinds to a halt.</p> <p>I am using a ...
<p>As people have already pointed out, Aborting threads in general is bad and there is no guaranteed way of doing it in C#. Using a separate process to do the work and then kill it is a slightly better idea than attempting Thread.Abort; but still not the best way to go. Ideally, you want co-operative threads/processes,...
Locating label element using class <p>I'm trying to locate the label element and fill it with some value but I'm not able to get it. I'm using <code>Java</code>, <code>testNG</code> and <code>Selenium</code> to write the below code.</p> <p>The code that I used is below </p> <pre><code>driver.findElement(By.className(...
<p>Actually selenium doesn't support to locate an element using <code>By.className()</code> <strong>with compound class name</strong>. You should try using <code>By.cssSelector()</code> instead to locate <code>&lt;input&gt;</code> element as below :-</p> <pre><code>driver.findElement(By.cssSelector("input[placeholder ...
How to set a C++ program to start automatically when windows starts up?(By windows service solution) <p>I want to make my C++ program to start up automatically when the windows start up and run at the background. I searched something about it and find we can use register the C++ program to be a windows service so that ...
<p>As already mentioned in the comments you are not registering a service but create an auto run entry. Your application has to implement various things to qualify as service.</p> <p>There is a sample project on code.msdn.microsoft.com <a href="https://code.msdn.microsoft.com/windowsapps/CppWindowsService-cacf4948" re...
Safe to authenticate with userId supplied in Amazon Alexa request? <p>I want to record some persistent details/history against each device/userId. I don't want to link with a separate account in another system so I want to avoid using account linking. Docs suggest this is fine, see below.</p> <p>Is it safe to assume t...
<p>I don't think there is any way to id device's (you write "device/userId") so yes, you would be using userId, and it is pretty standard to use the Alexa userId as a key to store/lookup a users' details/history. And as you have concluded it doesn't sound like you need account linking.</p> <p>I would assume that user...
DESCRIBE WHY DIRECT ORDERS FOLLOWED BY THE NAME OF TABLES <p>DESCRIBE WHY DIRECT ORDERS FOLLOWED BY THE NAME OF TABLES ?</p> <p>Example : DESC CLASS_3C</p> <p>why not </p> <p>DESC TABLE CLASS_3C ?</p>
<p><br>Hi,<br> If you see the key word <strong>DESC</strong> the meaning is <strong>describe</strong> . In a common word if you need describe any thing, you will provide the structure. For example, if you need to describe a car, you will say the entire attributes (parts) of car rather than describing each seperately. L...
Return string that is not a substring of other strings - is it possible in time less than O(n^2)? <p>You are given an array of strings. you have to return only those strings that are not sub strings of other strings in the array. Input - <code>['abc','abcd','ab','def','efgd']</code>. Output should be - <code>'abcd'</co...
<p>Is memory an issue? You could turn to the tried and true...TRIE! </p> <p>Build a suffix tree!</p> <p>Given your input <code>['abc','abcd','ab','def','efgd']</code></p> <p>We would have a tree of </p> <pre><code> _ / | \ a e d / | \ b* f e ...
How is onchange and addEventListener different? <p>I am using a third-party slider library (unknown which) and I need it to update the text value whenever the slider is dragged to a new position. The current code, which works, looks like this:</p> <pre><code>opacitySlider = new Slider(document.getElementById("opacity...
<p>Essentially they are the same, but you can only bind one event to the <code>onchange</code> property because it replaces the existing event, whereas <code>addEventListener</code> can bind multiple change events, or other events.</p> <p>There is a browser compatibility difference as well, <code>addEventListener</cod...
Translating a div to the right and have it disappear behind an invisible line <p>Alright so the way i asked the question isn't the greatest because I'm not too sure on how to even explain what I'm trying to figure out.</p> <p><a href="https://jsfiddle.net/ff9ovhvp/" rel="nofollow">https://jsfiddle.net/ff9ovhvp/</a></p...
<p>Just add <code>overflow:hidden</code> to your <code>.row</code> and it works fine.</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-css lang-css prettyprint-override"><code>.row{ border: 2px solid black; ...
mysql select records with sum of two column less than a column <p>i am trying to write query which can select all records with below conditions <strong>sum of column a and b to be less than c</strong> i wrote below code but it does not works :</p> <pre><code>SELECT *,(`a` +`b`) as newfinal,c FROM mytable WHERE newfina...
<p>Try This one it will work for me</p> <pre><code>SELECT * FROM `mytable` WHERE (a+b) &lt; c </code></pre>
Matchdata not returning the same data set as scan <p>Given the following text:</p> <pre><code>text = '&lt;w:body&gt;&lt;w:p w14:paraId="56037BEC" w14:textId="3419ABF1" w:rsidR="001665B3" w:rsidRDefault="008B4AC6"&gt;&lt;w:r&gt;&lt;w:t xml:space="preserve"&gt;This is the story of a man who &lt;/w:t&gt;&lt;/w:r&gt;&lt;w...
<p><a href="https://ruby-doc.org/core-2.3.0/Regexp.html#class-Regexp-label-Capturing" rel="nofollow">From Ruby docs</a>:</p> <blockquote> <p><strong>Note:</strong> A regexp can't use named backreferences and numbered backreferences simultaneously.</p> </blockquote> <p>It is not a difference between <code>scan</code...
Running the .bat batch file in administrator mode <p>Iam trying to synch certain computers to a TimeServer within the network, hence i've written a simple batch script to do the task. I've put into our WDS server. How do i run it in administrator mode. If i open the cmd prompt as administrator it starts with "C:\Window...
<p>Add this to the start of your batch file:</p> <pre><code>runas.exe /savecred /user:#administratoraccount# "%windir%/System32/cmd.exe" </code></pre> <p>Replace #administratoraccount# with the username of an admin.</p> <p>The first time you run it, it will ask for the password of that admin account. Enter it. Unle...
SQLalchemy find id and use it to lookup other information <p>I'm making a simple lookup application for Japanese characters (Kanji), where the user can search the database using any of the information available.</p> <h2>My database structure</h2> <p><strong>Kanji</strong>:</p> <ul> <li>id</li> <li>character (A kanji...
<p>We would really have to be able to see your database schema to give real critique, but assuming no foreign keys, what you said is basically the best you can do.</p> <p>SQLAlchemy really begins to shine when you have complicated relations going on however. For example, if you properly had foreign keys set, you could...
Difference between != and <> <p>I've always been using <code>!=</code> as "not equal to" in C++ and PHP. I just realized <code>&lt;&gt;</code> does the same thing. What's the difference?</p> <p>Just in case if there is no difference, why does <code>&lt;&gt;</code> exist?</p>
<p>They are the same, just different syntax</p> <blockquote> <p>$a != $b Not equal TRUE if $a is not equal to $b after type juggling.</p> <p>$a &lt;> $b Not equal TRUE if $a is not equal to $b after type juggling.</p> </blockquote> <p>Source: <a href="http://php.net/manual/en/language.operators.compariso...
Is there a Sage command that tracks the execution of code in real time? <p>I'm on a Mac with OS 10.11.6 and I'm using Sage 7.2's notebook interface. I did things in Mathematica that I want to check in Sage, but I'm a beginner at Sage. In Mathematica it's possible to keep track of the execution of my code, especially to...
<p>Well, Mathematica doesn't have a debugger. So they tried to overcome this obstacle by introducing the <code>Dynamic[]</code> command. But when a programming language does have a debugger, why bother implementing something similar to <code>Dynamic</code>?</p> <p>There are some ways to debug a sage code, <a href="htt...
Phoronix-test-suite: gzip-decompress fails to download needed file <p>I am trying to download <code>pts/system-decompress-gzip-1.1.0</code> but during installation I receive the following message:</p> <pre><code>Phoronix Test Suite v6.6.0 To Install: pts/system-decompress-gzip-1.1.0 Determining File Requirements ......
<p>Turns out at</p> <blockquote> <p>/var/lib/phoronix-test-suite/test-profiles/pts/system-decompress-gzip-1.1.0#</p> </blockquote> <p>there is a <code>download.xml</code> file which I replaced the link! Now it works!</p>
Activity onStop() not called when home button is pressed in Android N multi window mode <p>I am trying to make our video app to support Android N multiwindow mode. I have discovered that activity lifecycle becomes confused in multiwindow mode. The phenomenon is when our app layouts on the top screen with the whole scre...
<p>When you hit the home button in multi-window mode, the system is in a transient state, allowing the user to select an app to start while your app continues to run (if you're the topmost app, you'll note you can still see the status bar from your app). There is no callback associated with going into this transient mo...
Best way to get licenses for mvn jars <p>My company needs a license file for every single transitive dependency in a mvn dependency. Is there a good CLI command that will grab just that?</p>
<p>I think you can work with the <code>license:download-licenses</code> goal of the License Maven Plugin:</p> <p><a href="http://www.mojohaus.org/license-maven-plugin/" rel="nofollow">http://www.mojohaus.org/license-maven-plugin/</a></p> <p>It is able to gather the licenses in one directory (and other formatting as d...
Create smoke container to link other docker container <p>I need to create a smoke container to link other docker container. Basically I have multiple container which are link to each other I am trying to create a smoke container where i can run some script to check if each container and there port are up after docker-c...
<p>If you're using <a href="https://docs.docker.com/compose/compose-file/#/version-2" rel="nofollow">Version 2</a> of the Compose spec, then your service containers will all run inside a Docker network. You can create your smoke test container in the same network and access containers by name, you don't need to find th...
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600) <p><strong>This is not a duplicate of <a href="http://stackoverflow.com/questions/35403605/ssl-certificate-verify-failed-ssl-c600">this question</a></strong></p> <p>I checked <a href="http://stackoverflow.com/question...
<p>You need to download the GoDaddy root certificates, available at <a href="https://certs.godaddy.com/repository" rel="nofollow">this site</a> and then pass it in as a parameter to <code>verify</code>, like this:</p> <pre><code>&gt;&gt;&gt; r = requests.get('https://aucoe.info', verify='/path/to/gd_bundle-g2-g1.crt')...
Resampling (Upsample) Pandas multiindex dataframe <p>Here is a sample dataframe for reference:</p> <pre><code>import pandas as pd import datetime import numpy as np np.random.seed(1234) arrays = [np.sort([datetime.date(2016, 8, 31), datetime.date(2016, 7, 31), datetime.date(2016, 6, 30)]*3), ['A', 'B', 'C', ...
<p>Edit: I have found a solution:</p> <pre><code>df.unstack().resample('W-FRI', how='last', fill_method='ffill') </code></pre> <p>but I wonder if there's a more efficient way to do this.</p>
how to implement nested multi level looping in dataweave in Mule <p>I am using <code>dataweave</code> for transforming XML to CSV. I want to know how to implement nested for loop in <code>dataweave</code>.</p> <p><strong>Below is the input xml:</strong></p> <pre><code> &lt;employee&gt; &lt;id&gt;1236&lt;/id&gt; &...
<p>This works for me. </p> <pre><code>%dw 1.0 %output application/csv --- flatten (payload map ((parent, parentindex) -&gt; { emplinfo:(parent.*emplinfo map ((emplinfo,empindex) -&gt; { jobinfo:(emplinfo.*jobinfo map ((jobinfo,jobindex) -&gt; { id: parent.id, emplid : emplinfo.empli...
ngOptions using basic expression providing odd rendered value <p>I have the following <code>Object</code> in <code>TypeScript</code> defining some options for a <code>&lt;select&gt;</code> using <code>ng-options</code>:</p> <pre><code>$scope.sOptions = [ { name: "Female" }, { name: "Male" }]; ...
<p>In order to achieve this requirement you have to use <code>track by</code> in <code>ng-select</code>. The track by will help you in binding the select option with a value tag. You should also provide an Unique Id field to track the select option. </p> <pre><code>&lt;select ng-model="selectedName" ng-options="item.N...
meaning of `button_map` in the form_field definition in flask-bootstrap <p>I am reading the documentation of <a href="https://pythonhosted.org/Flask-Bootstrap/forms.html" rel="nofollow">flask-boostrap doc</a>. In the <code>form_field</code> definition, what is the purpose of the <code>button_map</code>? </p> <pre><cod...
<p>According to your link (see <a href="https://pythonhosted.org/Flask-Bootstrap/forms.html#quick_form" rel="nofollow"><code>quick_form</code></a>):</p> <blockquote> <p><strong>button_map</strong> – A dictionary, mapping button field names to names such as <code>primary</code>, <code>danger</code> or <code>success...
How to dynamically change navigation bar item's logo in Java class? <p>I am integrating Google and Facebook to my application, i.e. I have 2 ways to login in the login page. I have a navigation drawer in the main activity. In the drawer, I have a logout item. I want to be able to set the icon to Google icon or Faceboo...
<p>Try this,</p> <pre><code>NavigationView navigationView = (NavigationView)findViewById(R.id.nav_view); navigationView.getMenu().getItem(1).setIcon(R.drawable.com_facebook_button_icon_white); </code></pre> <p>Hope this helps </p>
Div is not aligned properly when animation is running <p><a href="http://i.stack.imgur.com/gqmcO.png" rel="nofollow"><img src="http://i.stack.imgur.com/gqmcO.png" alt="enter image description here"></a>I'm trying to achieve an bell ringing animation. I have completely made a bell alike sample using pure css. When i set...
<p>I just gave <code>z-index: 999</code> to the <code>.bell div</code> and it solved the issue.</p> <p>It's looks like a bug with the chrome. firefox and IE, it's working fine.</p> <p>The div is initially at the right position. all I did is to bring the div in front using z-index.</p> <p><div class="snippet" data-la...
docker-compose up didn't finish npm install. <p>I'm new to docker-compose and I'd like to use it for my current development. </p> <p>after I ran <code>docker-compose up -d</code> everything was starting ok and it looks good. But my nodejs application wasn't installed correctly. It seems like <code>npm install</code> w...
<p>In your Dockerfile you are running <code>npm install</code> without any arguments first:</p> <pre><code>RUN npm install \ &amp;&amp; npm install -g mocha \ </code></pre> <p>This will cause a non-zero exit code and due to the <code>&amp;&amp;</code> the following commands are not executed. This should also fail t...
Java User's Name and Reverse Order <p>I am writing a code for class and I can't seem to find the error. Every time I run the code through Dr. Java, I am hit with about 15 different red errors which I haven't seen before. The code is supposed to take a users input and reverse the order of it. Any help? This is the code:...
<p><code>char beginning = nameOfPerson.charAt(lengthOfName);</code> - you are trying to access the 5th index, where as it will have intext from 0 to 4. That's why you are getting errors.</p> <p>Try this below code:</p> <pre><code>import java.util.Scanner; class Test{ public static void main (String [] args) {...
How to store fixed length string in c <p>I would like to read some fixed length string in a text file and store them in an array. The way I read the strings is by fscanf(fp,"%c",&amp;char[]);</p> <p>However, as the data are seperated by white space, I would like the array index to indicate each string instead of each...
<p>simple example of reading from file with fgets() </p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #define LINE_LENGTH 6 int main(int argc, char** argv) { int i = 0; FILE *file_ptr; char *string=(char*)calloc(LINE_LENGTH,sizeof(char)); file_ptr = fopen("file.txt", "r"); while(1) ...
Algorithm to find a set of "k" marked vertices in a binary tree that minimizes distance to marked ancestors for all nodes <p>This is the original problem I have:</p> <p><a href="http://i.stack.imgur.com/dai8Y.png" rel="nofollow"><img src="http://i.stack.imgur.com/dai8Y.png" alt="enter image description here"></a></p> ...
<p>Create a dynamic state with three variables as follows</p> <pre><code>func( index of node(ind), how many nodes can be colored in this subtree(k), distance to closest marked ancestor(d) ) </code></pre> <p>Now for each state you can calculate the best result like this:</p> <pre><code>if node is leaf ...
Specifying the order of jq results <p>I want to process some json from reddit: <a href="https://www.reddit.com/r/videos/top.json?limit=3" rel="nofollow">https://www.reddit.com/r/videos/top.json?limit=3</a></p> <pre><code>{ "kind": "Listing", "data": { "modhash": "", "children": [ { "kind": "t...
<p>The fields that you're interested in are in the <code>data</code> objects of each of the <code>children</code>. You'll want to keep them together so you should limit how many times you go through the child items, just do it once. And it seems you're outputting in a CSV format, so you could use <code>@csv</code> fo...
Why wamp (3.0.4) showing ::1 instead of 127.0.0.1 on localhost <p>I am trying to get ip address of my localhost via a php function,<br> </p> <pre><code>$user_ip = $_SERVER['REMOTE_ADDR']; echo $user_ip; </code></pre> <p>currently it is returning <code>**::1**</code> I want to return ipv4 <code>**(127.0.0.1)**</code> ...
<p>Windows like most OS's now are both old IPV4 and new IPV6 aware.</p> <p>Both have whats called a loopback address </p> <pre><code>IPV4 is 127.0.0.1 IPV6 is ::1 </code></pre> <p>As WAMPServer and your browser are both on the same PC your remote ip address will be the your local ip address i.e. the loopback address...
XCode 'NSLog is not a valid command'? <p>I am trying to get the full stack trace by using the solution here: <a href="http://stackoverflow.com/questions/15946499/xcode-full-stack-trace">Xcode full stack trace</a></p> <p>But I keep getting the following error:</p> <pre><code>(lldb) NSLog(@"Stack trace : %@",[NSThread...
<p>In (lldb), you can try <code>bt</code> command. <code>NSLog</code> is for Objective-C code.</p>
Excel formulas create <p>Hello I have a problem with excel formulas <strong><code>=IFERROR(OR(IF(C2=INDEX(data!A2:A70126;MATCH(C3;data!B2:B70126;0));TRUE;FALSE);IF(C2=INDEX(data!A2:A70126;MATCH(C3;data!B2:B70126;0));TRUE;FALSE));FALSE)</code></strong></p> <p>I have a column A where is contain data for cell C2 and colu...
<p>Your index function <code>INDEX(data!A2:A70126,MATCH(C3,data!B2:B70126,0)</code> returns <strong><em>551-021</em></strong> when C3 = <strong><em>010.551-025</em></strong>. This why when you search match <strong><em>010.551-025</em></strong> and <strong><em>1055102000002</em></strong> shows FALSE and for <strong><em>...
HTTP2 server that responds any response code / frame <p>What's the quickest way to setup an HTTP/2 server that can 1. dumbly respond any response code/payload at will 2. GOAWAY frame at will 3. stop responding to PING frame</p> <p>Assume I have access to Ubuntu, RHEL, SUSE, or any Linux distro AWS EC2 offers (Debian, ...
<p>That's what low-level HTTP/2 libraries allow you to do.</p>
Count with join still not displaing correct count <p>What I am trying to do is create a list of how many replies this thread has. I can count the number of replys fine.</p> <p>But what I would like to be able to do is count the user thread also.</p> <p>This is what the out put looks like. It only counts it from my re...
<p>Do sum 2 tables user_id columns</p> <pre><code>public function number_of_replies($user_id, $thread_id) { $this-&gt;db-&gt;select('t1.*, count(t2.user_id)+count(t1.user_id) AS total_posts'); $this-&gt;db-&gt;from('reply AS t1'); $this-&gt;db-&gt;join('thread AS t2', 't2.user_id = t1.user_id', 'left'); ...
considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms <p>i am new to solve this type of problems using java script</p> <p>Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 1...
<p>This works for me:</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>function* fibonacci(){ var fn1 = 0; var fn2 = 1; while (true){ var current = fn1; ...
I've Encountered a Segmentation Error Fortran on Reading Data Files from an Outside source <p>I've been writing a program that reads an integer value from a file using the OPEN statement and prints the value on the console.</p> <p>During the compiling, it seems to be okay and got no problems, but when I run the progra...
<p>Hmmm, the code should work. It would have been nice if you had actually given us the compiler version and -options as well. I mean there is the thing that you're not closing the file that you've opened, but since the program terminates anyway, it shouldn't be much of an issue.</p> <p>What I'd do is use the error st...
AVD not getting started in Android Studio. IDE internal error occured <p>I imported one of my android project and tried to run it in a simulator. A soon i clicked the run button and ADB was about to initialize i saw a red balloon" An Internal error occured". Logs show the following error</p> <pre><code>null java.lang....
<p>I just solved this problem by delete all files in <code>~/.android/avd</code> but my avd still can't run properly.</p>
How to understand, This part of debuging <p>Whenever i am debug my code I always facing this screen. Can anyone tell me how to understand this screen. Is it useful to us.</p> <p><a href="http://i.stack.imgur.com/XFZZ4.png" rel="nofollow"><img src="http://i.stack.imgur.com/XFZZ4.png" alt="enter image description here">...
<p>To get the human-readable version of the error try to write this line in debug area <strong>po $arg1</strong> or <strong>po $rax</strong></p> <p>Or add this line to <strong>Exception Breakpoint</strong> <a href="http://i.stack.imgur.com/0JdLy.png"><img src="http://i.stack.imgur.com/0JdLy.png" alt="enter image desc...
Setting onclick function dynamically in Javascript not working <p>hello =) I am trying to create a heading tag with some text in it.</p> <pre><code>var d = document.createElement("h5"); d.innerHTML = "Dungeon"; </code></pre> <p>and then assigning an onclick listener.</p> <pre><code>d.onclick = function(){myFunction...
<pre><code>elem.addEventListener("click", function, false); </code></pre>
Spring cloud config failed using filter <p>I'm using <a href="http://spring.io" rel="nofollow">Spring Cloud</a> Config to help <strong>build Rest Services</strong> and I choose <a href="https://github.com/" rel="nofollow">GitHub</a> to maintain my config files. There is a need when I change some config on <code>GitHub<...
<p>Problem solved. I found that when I checked the application.yml. I originally config rabbitmq ,github config mixed in the same yml file . So it may caused by the confuse yml file which may lead some config not loaded. </p>
npm run build:js throws error on Jupyter notebook code <p><strong>I just took the Jupyter Notebook raw code, made a small change in HTML/Javascript and tried re-building it. It threw the below error:</strong></p> <pre><code>WARNING in ./~/xterm/addons/attach/index.html Module parse failed: C:\Users\ytayal\Downloads\no...
<p>Post making changes to the code you can try <code>python setup.py build</code> and than run jupyter with <code>jupyter notebook</code>. It will reflect your changes.</p> <p>Not sure why getting error with <code>npm run build:js</code>.</p>
nginx PHP Forward Slash Before GET Params <p>How do I configure nginx to allow a slash between my /test_file.php/?param1=test ? Currently is only allowing /test_file.php?param1=test ...</p> <p>Here is my current configuration: </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babe...
<p>The block:</p> <pre><code>location ~ \.php$ { ... } </code></pre> <p>is responsible for processing any URI which ends with <code>.php</code>.</p> <p>A simple solution would be to change the regular expression to accept URIs which include pathinfo. However, you should also make other changes within the block to mi...
installing nodeclipse returning error <p><a href="http://i.stack.imgur.com/OWJ3f.png" rel="nofollow"><img src="http://i.stack.imgur.com/OWJ3f.png" alt="image"></a></p> <p>I am getting this error when installing using <code>MARKETPLACE (RECOMMENDED WAY: A BIT QUICKER)</code>. I am doing the tutorial from <a href="http:...
<p>You need to <strong>run eclipse as administrator</strong> because <code>nodeclipse</code> require write permission</p> <p>You may like to install <a href="https://nodejs.org/en/download/" rel="nofollow">node.js</a> and set path for it</p> <p><code>Update</code></p> <p>To set up path do as follows:</p> <p>You nee...
Centering a button in a vertical box <p>Im creating a JDialog and adding components to it as such:</p> <pre><code>Window thisWin = SwingUtilities.getWindowAncestor(ancestorPanel); final JDialog progressDialog = new JDialog(ancestorPanel, "There was an error"); progressDialog.setUndecorated(true); JPanel contentPane = ...
<p>I managed to solve the above by adding the button to a separate Box and then using Boxlayout to add both boxes to the panel as such:</p> <pre><code>Box vBox1 = Box.createVerticalBox(); vBox1.add(label); vBox1.add(Box.createVerticalStrut(7)); vBox1.add(area1); vBox1.add(Box.createVerticalStrut(7)); vBox1.add(scroll)...
Trying to swap my old domain for my new one <p>I purchased the "real" domain name for my website and I'd like to re-direct all traffic that was going to the old site, to the new site.</p> <p>Here's the scenario: I currently have <a href="http://www.wrestlestats.com" rel="nofollow">http://www.wrestlestats.com</a>, but ...
<p>Just do it in 2 steps ---</p> <ol> <li>Configure new domain (instead of old one)to your site.</li> <li>Use Forward Domain from your domain control panel with the option of path forwarding. </li> </ol> <p>Forward:- </p> <blockquote> <p>http:-//www.wrestlestats.com <strong>></strong> http:-//www.wrest...
what is the time complexity in my code <pre><code> #include&lt;stdio.h&gt; int main() { int T,i,sum,n; //Here T is the test case scanf("%d",&amp;T); while(T--) { scanf("%d",&amp;n); sum=0; for(i=1;i&lt;=n;i++) sum=sum+i; ...
<p>The concept of <a href="https://en.wikipedia.org/wiki/Big_O_notation" rel="nofollow">Big-O</a> analysis is not specific to certain values. <a href="https://en.wikipedia.org/wiki/Time_complexity" rel="nofollow">Time Complexity</a> , which is commonly expressed in Big-Oh , excludes coefficients and lower order terms. ...
Firefox + some javascript = tab with an endless spinning wheel that never finish loading (Chrome is okay!). Why? <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>function clickMe(...
<p>From the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/write" rel="nofollow">documentation</a></p> <blockquote> <p>Writing to a document that has already loaded without calling <code>document.open()</code> will automatically perform a <code>document.open</code> call. </p> <p>Once you h...
Optimize a query with MySQL in repeated <p>I have the following query that checks if two columns of a table are <code>in</code> another The query works, I hope you can optimize the call in because they are equal. I doubt if there is a performance penalty because two calls are made to the same query</p> <pre><code>SELE...
<p>There is a performance issue in using <code>OR</code> that you can use <code>UNION</code> instead like this:</p> <pre><code>SELECT name, lastname FROM TABLE_A WHERE name IN ( SELECT name FROM TABLE_B) UNION -- If there is not any duplicate use `UNION ALL` instead SELECT name, lastname FROM TABLE_A WHERE last...
CSS position - partly overlaping div <p>I have basic CSS layout isssue. DIV2 goes up by 150px and overlap partly DIV1. I have a problem with placing DIV3 just under DIV2. I could do it applying the same CSS as in DIV2 to DIV3, but thats not what i'm looking for, as they are many other divs under, and it seem i will hav...
<p>Add this to your <code>div2</code>, although it's not considered a best practice:</p> <p><code>margin-bottom: -150px</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-css lang-css prettyprint-override"><...
Material Design - Page content exceeding screen width <p>I'm having table content exceeding the screen width and I don't know how to fix it.</p> <p>Tried to get <code>&lt;class="md-layout__content"&gt;</code> or <code>&lt;class="page-content"&gt;</code> maxwidth set to 100% of the current screen size but couldn't.</p>...
<p>Please removed following property from your style sheet for Table. then this will solved your problem.</p> <pre><code>white-space: nowrap; </code></pre> <p>removed this property from <code>.mdl-data-table</code> class</p>
getting java.lang.ClassCastException: java.lang.String cannot be cast to java.sql.Timestamp <p>Problematic code:</p> <pre><code>public static final String DATEFORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; public static String getAsString(Object dateStr) { if ( dateStr== null || dateStr.toString().equalsIgnoreCase("null")...
<p>Instead of casting the String to a Timestamp, you can use the function <code>Timestamp.valueOf(String)</code>.</p>
Why Doesn't `std::basic_string::substr` Follow The [begin, end) Convention? <p>The method <a href="http://en.cppreference.com/w/cpp/string/basic_string/substr" rel="nofollow"><code>std::basic_string::substr</code></a> has the arguments <code>pos, count</code>, specifying the logical range of elements in positions <em>[...
<p>A simple guess:</p> <p>The different methods you cite have different behavior, which is probably why some use iterators and other don't.</p> <p><code>std::for_each</code> is generic - The easiest way to have a generic version of a method that works on any containers (and even on raw array) is to use iterators.</p>...
IOS 10 Speech Recognition API : Error Domain=kAFAssistantErrorDomain Code=1101 <p>I try using speech recognition as below</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [self startRecognizer]; } - (void)startRecognizer { ...
<p>add <code>NSSpeechRecognitionUsageDescription</code> key in your <code>info.plist</code> and run this project in device if you are testing in <code>simulator</code>. You need ios real device running <code>ios10</code> to test this!</p> <p>You can refer <a href="https://www.hackingwithswift.com/ios10" rel="nofollow"...
How to store values to array when doing recursion? <p>For example, in this method, the method builds an array of sorted from a BST</p> <pre><code>public E[] inOrderSort(TreeNode tree){ E[] array1 = new E[tree.size]; inOrder(tree, array1, 0); return array1; } public void inOrder(TreeNode node, E[] array, i...
<p>Primitive values are passed-by-value. So anything that is done to the <code>index</code> variable in <code>inOrder</code> won't have an effect in the caller. The array is not a primitive and is passed-by-reference, thus, any modification to it will be visible to the caller.</p> <p>Now you have two options:</p> <ul...