input
stringlengths
51
42.3k
output
stringlengths
18
55k
Reading and Printing Weird Things in file Java <p>Well, i'm trying to make an input/output file, so at the start of my application it reads the file and put the information on the right places, and when I'm in the app, i could add info to this file.</p> <p>The problem is that it reads and writes really weird things li...
<p>This because when you read you set explicit encoding. But when writing not and the default one is used - usually UTF-8.</p> <p>Use the same text encoding when writing and when reading (and UTF-8 is would be best choice).</p> <p>Try with something simple:</p> <pre><code> File f=new File("/tmp/test.txt"); tr...
How can i make the contents of the mail to be in html format rather than string of text? <p>In the below code whenever the button is clicked sendmail function is called and makes a ajax post request to the php page.The php intern sends the mail.I am getting the contents sent by the ajax function in the text format rath...
<p>You just have to add headers to your mail</p> <pre><code>&lt;?php $headers = "From: ... \r\n"; $headers .= "Reply-To: ... \r\n"; $headers .= "CC: ... \r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1 \r\n"; $var1=$_POST['div_content']; $var2=fopen("somefile.txt",...
Using strlen to strikeout specified words in string <p>Using the following function, I am able to pass in two strings (char *hide, char *phrase). The *phrase is the overall string and * hide is what words (can be repeated) have to be censored by replacing all letters in the word with '*'. It currently works so that it ...
<p>Since I don't seem to understand your question, I thought of making a function for you to see if this is what you're looking for:</p> <pre><code> string phrase = "hello my name is" string hide = "lame" //strikeout function void strikeout(string phrase, string hide) { for (int i = 0;...
Spring Security / MVC / JPA --> Request method 'POST' not supported <p>I am having errors login from the HTML using Spring Security, Spring MVC and JPA.</p> <p>This is my login.HTML</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre c...
<p>Try adding</p> <pre><code>.formLogin().loginPage("/xxx").permitAll() .defaultSuccessUrl("/xxx") .failureUrl("/xxx?error") </code></pre> <p>In addition</p> <p>One typical reason in Spring MVC Applications for controller methods and pages not found is Spring's weird mapping conventio...
Angular / Jasmine Testing - How to Stub Both a Constructor and Property <p>In Jasmine, I can mock a constructor function with the following:</p> <pre><code>window.Notification = jasmine.createSpy('Notification').and.returnValue('returned value'); </code></pre> <p>I can stub a property for the same object with an assi...
<p><code>jasmine.createSpy</code> returns function and functions like any other objects can have properties. As long as you don't override properties used by Jasmine like <code>and</code> or <code>calls</code> it should be safe to add properties to created spy functions:</p> <p><code>var mockNotification = jasmine.cre...
Copy (update if exists) document from one collection to another <p>I want to copy a document from one collection of mongodb to another collection (or update if exist) through java.</p> <p>I don't want to append each field of existing collection and then insert to another. How can I do this?</p> <p>Here are two collec...
<p>If you want replace Doc2 with Doc1 you can use replaceOne()</p> <p><strong>replaceOne() replaces the first matching document in the collection that matches the filter, using the replacement document.</strong></p> <p><a href="https://docs.mongodb.com/v3.2/reference/method/db.collection.replaceOne/" rel="nofollow">h...
array undeclared ,first used in the function error during dynamic memory allocation <p>Here i am writing a program which will do two things</p> <p>1.get a number between 0 to 102,separate them and store them in an array</p> <p>2.print the array for each number</p> <p>For that purpose i wrote an if-else block which w...
<p>The scope of pointer <code>arr</code> is only within the if-else block. So, it's not available outside of it. Declare it outside the if-else block and you'll be able to use it as you have.</p> <pre><code> int *arr; if(num&lt;(int)pow(10,range)) { arr = malloc(range*sizeof(int)); }e...
Java class getdata <p>I can't find the problem. When i use the class and use first setpostcode to 5000. and then getUrl i get still 1000 in my url idk why. when i debug the postcode is changed to 5000 but when i print the url i get 1000.</p> <pre><code>public class weer { private int postcode = 1000; private Str...
<p>The URL member variable is declared and initialized once upon creation of the class instance. It starts at 1000 and never changes. </p> <p>Updates to one value aren't reflected to the other. </p> <p>You don't really don't need the URL member variable if you only are updating the postcode, just change the getter to...
How to register a User in Firebase using Node.js? <p><strong>PROBLEM:</strong></p> <p>0) The user is created in the auth system in Firebase (I see it in the Auth tab),</p> <p>1) But no changes are made to the database. </p> <p>2) The page seems to be stuck infinitely loading. </p> <p>3) Only "Started 1..." is logge...
<p>not sure this is all, but here's what i think happens:</p> <p>the user is created, but you are not handling it properly. there is no handling of a success case (fulfilled promise), only a rejected one. also, when you're trying to write to the database when an error occurs, that means the user is not authenticated, ...
Python. Best way to match dictionary value if condition true <p>I'm trying to build a parser now part of my code is looks like this:</p> <pre><code> azeri_nums = {k:v for k,v in zip(range(1,10),("bir","iki","uc","dord","beş","altı","yeddi","səkkiz","doqquz"))} russian_nums = {k:v for k,v in zip(range(1,1...
<p>Change your dict to be</p> <pre><code>azeri_nums = {v.lower():k for k,v in zip(range(1,10),("bir","iki","uc","dord","beş","altı","yeddi","səkkiz","doqquz"))} russian_nums = {v.lower():k for k,v in zip(range(1,10),("один","два","три","четыре","пять","шесть","семь","восемь","дÐ...
Variables staying null in vue.js application for shopify <p>I am building up a vue.js application for Shopify's JavaScript Buy SDK, but i am having problems with one variable not being updated. </p> <p>Basically the <code>shopClient</code> variable is updated, but the <code>shopCart</code> stays null for some reason.<...
<p>You have a problem with scoping. <code>this</code> in the promise isn't the vue instance.</p> <p>try this</p> <pre><code>var vueApp = new Vue({ el: '#shopify-app', created: function() { this.setupShopAndCart(); }, data: { shopCart: null, shopClient: null, }, methods:...
Firebase / Facebook SDK login - request password <p>Not sure if it's Firebase issue or facebook SDK issue:</p> <p>In my case, there is <strong>one</strong> device with an option to login via Facebook. Once an user logging into his facebook account, he will be asked for his email ans password. In the second time, click...
<p>Facebook takes the last logged in user on the Device. The only solution to require a password with Facebook is to open Facebook in the device's browser or Facebook app and logout there.</p>
Negate condition of an if-statement <p>if I want to do sth like:</p> <pre><code>if (!(condition)) { } </code></pre> <p>What is the equivalent expression in Scala? Does it looks like?</p> <pre><code>if (not(condition)) { } </code></pre> <p>For example, in C++, I can do: </p> <pre><code>bool condition = (x &gt; 0) i...
<p>In Scala, you can check <code>if</code> two operands are equal (<code>==</code>) or not (<code>!=</code>) and it returns true if the condition is met, false if not (<code>else</code>).</p> <pre><code>if(x!=0) { // if x is not equal to 0 } else { // if x is equal to 0 } </code></pre> <p>By itself, <code>!</...
Avoid overridding of default message field in logstash <p>I am using logstash to parse my logs. when i am parsing the json (which contains a "message" field) overrides the default message field. I tried using remove_field option of json{ } filter but that didn't work work for me.</p> <p>Here is my filter code: </p> <...
<p>Two options come to mind:</p> <ol> <li>move the [message] field out of the way before calling the json{} filter (mutate->rename).</li> <li>use the 'target' param of the json{} filter to put the json data somewhere other than the root of the document.</li> </ol>
Declare two different types of variables with general Scope using an if...else statement? <p>Depending on a condition, I have to declare a new variable that is either a NumericVector or NumericMatrix that later will be used for further processing. I have attempted the following approach:</p> <pre><code>if(condition) ...
<p>This is what a template is for.</p> <pre><code>template&lt;typename var_type&gt; void do_something_with_var(var_type &amp;var) { // The rest of the code that uses var. } // ..... if(condition) { NumericVector var(n_samples); do_something_with_var(var); } else { NumericMatrix var(n_samples, n_c...
Find longest repeating substring in string? <p>I came across below program which looks perfect. Per me its time complexity is nlogn where n is the length of String.</p> <p>n for storing different strings,nlog for sorting, n for comparison. So time complexity is nlogn. Space complexity is n for storing the storing n su...
<p>Have a look at this algorithm given in geeksforgeeks, this might be helpful:</p> <pre><code>http://www.geeksforgeeks.org/suffix-tree-application-3-longest-repeated-substring/ </code></pre>
Inner class is not public error when instantiating new inner class <p>I have this class</p> <pre><code>package com.rafael; public class Vehicle { public class InnerVehicle { InnerVehicle() { System.out.println("This is InnerVehicle"); } } } </code></pre> <p>And in the main functi...
<p>Make the inner class <code>public static</code></p> <p>Otherwise you need an object of your outer class to creat an instance of the inner as Tim Biegeleisen already mentioned</p> <p>And make the constructor of your inner class <code>public</code> too</p> <p>Something like:</p> <pre><code>public class Vehicle { ...
Android: enable/disable app widgets programmatically <p><strong>Question</strong>: Is there a way to enable some of the homescreen widgets that I give out with my app programmatically? For example, having a "premium" widget and giving access to it only after payment?</p> <hr> <p>As the Android <a href="https://develo...
<p>You can have <code>android:enabled="false"</code> on the <code>&lt;receiver&gt;</code> element for the app widget in the manifest, then use <code>PackageManager</code> and <code>setComponentEnabledSetting()</code> to enable it at runtime when the the user does something (e.g., pay up).</p> <p>However, it is possibl...
Building a function of a random variable dynamically in python <p>I have some random variables using <code>scipy.stats</code> as follows:</p> <pre><code>import scipy.stats as st x1 = st.uniform() x2 = st.uniform() </code></pre> <p>Now I would like make another random variable based on previous random variables and ma...
<p>Not directly, I think. However, this approach might be of use to you.</p> <p>Assume to begin with that you know either the pdf or the cdf of the function of the random variables of interest. Then you can use rv_continuous in scipy.stats to calculate the variance and other moments of that function using the recipe o...
Xamarin, Android. Exception when opening *.axml files in VS2015 using F#, <p>I receive the following error message when opening layout files in <code>F#</code> project.</p> <p><a href="https://i.stack.imgur.com/ayVoo.png" rel="nofollow"><img src="https://i.stack.imgur.com/ayVoo.png" alt="enter image description here">...
<p>As mentioned, this appears to be <a href="https://bugzilla.xamarin.com/show_bug.cgi?id=44956" rel="nofollow">public bug report 44956</a>, which is currently under investigation. Bug 44797 was filed as a private issue by the individual reporting it; as such, only the original reporter and the Xamarin team can access ...
Swift time between run function <p>I am nearly new to swift Xcode and I am building an app, when the end user is near a iBeacon hi will get a local push notification.<br>The problem I have is each time he comes near to it(if he got back and forward he will get each time he is near).<br> So I think to limit by time like...
<p>You Can create a Variable: beaconsHasBeenRecognized to turn to true when the beacon has been recognized, then the next time user goes back and forth, before triggering notification, your code should evaluate it beaconsHasBeenRecognized,its false, otherwise, if it is true, it will not trigger the notification. Then w...
Google Chrome dev tools variable tip bubble too little to see the content <p>I have just now sended the following message to google chrome developer:</p> <p>Chrome version: 54.0.2840.59 m</p> <blockquote> <p>As you know, when debugging a web page with javascript, the Chrome debugger allows to pause the execution ...
<p>You can scroll the tool tip as per the animation below:</p> <p><a href="https://i.stack.imgur.com/iRtQg.gif" rel="nofollow"><img src="https://i.stack.imgur.com/iRtQg.gif" alt="Scrollable tool tip"></a></p>
Real - time adjustment of route based on Traffic condition <p>With the similarities of WAZE App.</p> <p>I wonder what API i can possibly use to make an mobile application that will dynamically / automatically adjust its route based on traffic level / condition.</p>
<p>If you are using google maps in android you need to call setTrafficEnabled(true) on your googleMaps object.</p> <p><a href="https://developers.google.com/maps/documentation/javascript/examples/layer-traffic" rel="nofollow">https://developers.google.com/maps/documentation/javascript/examples/layer-traffic</a></p> <...
creating a sorted list in database <p>So basically I have a table named <code>contents</code> where users can store their items. Normally here when a user add a new item, The item is added at the end of rows. </p> <p>Something like:</p> <pre><code>|ID | Name | Item | -------------------- |1 | Jack | pen | |2 | Ma...
<p>Add index(es) for any column (or combination of columns) you want to <em>search</em> for and/or want to <em>order by</em>.</p> <p>Do <em>not</em> reorder the table, nor re-number the ids.</p> <p>If you are talking about 1000 rows, you are unlikely to notice any performance problems even if you don't do proper inde...
What is the replacement of d3.scale.category10().range() in Version 4 <p>I am using d3 graph library v4, There is a code which using the library d3 version3 not working with version4. Particularly the function is the following </p> <pre><code>d3.scale.category10().range() </code></pre> <p>what could be the replacemen...
<p>To translate the line above to D3 v4, replace it with the following:</p> <pre><code>d3.scaleOrdinal(d3.schemeCategory10).range() </code></pre> <p>See also the <a href="https://github.com/d3/d3-scale/blob/master/README.md#schemeCategory10" rel="nofollow">D3 v4 documentation on scales</a>.</p>
Loop through employee numbers and see if certain date falls within a period <p>Who can help a beginner out. I've added two screenshots to make my story clearer.</p> <p><a href="https://i.stack.imgur.com/vSoTW.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/vSoTW.jpg" alt="Calculation"></a></p> <p><a href="htt...
<p>Since your screenshots appear to be Excel for Windows consider an SQL solution using Windows' JET/ACE Engine (.dll files) as you simply need to join the two worksheets with a <code>WHERE</code> clause for date filter. In this approach you avoid any need for looping and use of arrays/collections. </p> <p>To integrat...
Use an enter key to perform a text field function <p>My Code that I tried to use. Please tell me what I have done wrong. I am not very good at JavaScript so, don't judge. </p> <p> </p> <pre><code>&lt;!-- Textfield with Floating Label --&gt; &lt;form action="...
<p>You probably wanted to pass the event, not just <code>e</code></p> <pre><code>&lt;input class="mdl-textfield__input" type="text" id="userInput" onkeypress="handle(event)"&gt; </code></pre> <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false"> <div class="snippet-code snip...
Can someone explain me this bit of code (from decimal to binary) <p>So this is the code i am trying to understand what is "i" standing for, and how this function works. I know what every line do, but i cant understand how is this going to display, let's say 5 into 0101. Thanks in advance!</p> <pre><code>int decimal_bi...
<pre><code>int decimal_binary(int n) /* Function to convert decimal to binary.*/ { int rem, i=1, binary=0; // declaring and initializing variables if you // understand that concept. // Another way to write this would be //int rem; //int i=1; //int binary=0; while (n!=0) //while loop to keep executing until (n not ...
HANA procedure for CONDENSE and SPLIT <p>I am trying to condense and split a string into single rows, e.g. </p> <pre><code>A B C </code></pre> <p>into</p> <pre><code>A B C </code></pre> <p>So far, the below procedure works fine for CALL Z_SPLITROW('A B C'), but not if I have more whitespace between the chars. A...
<p>To filter out a flexible number of whitespace characters, you can use REPLACE_REGEXPR:</p> <pre><code>select 'A B C' as orig, replace_regexpr ( '[[:space:]]+' IN 'A B C' WITH ' ') as repl from dummy; ORIG | REPL ---------+------- A B C| ...
Vue.js 1.0 select <p>In my webapp I've a select like this:</p> <pre><code>&lt;select class="Form-group-item" v-model="user.corporation_id"&gt; &lt;option value="" disabled selected&gt;Corporatie&lt;/option&gt; &lt;option v-for="corporation in corporations" v-bind:value="corporation.id"&gt;{{ corporation.name }...
<p>Remove 'selected' from the default option</p> <pre><code>&lt;select class="Form-group-item" v-model="user.corporation_id"&gt; &lt;option value="" disabled&gt;Corporatie&lt;/option&gt; &lt;option v-for="corporation in corporations" v-bind:value="corporation.id"&gt;{{ corporation.name }}&lt;/option&gt; &lt;/s...
Correct Usage of Entity Framework Generated Classes (DB First Approach) <p>I'm developing my first MVC5 website and it happens this is also the first time I'm using ET.</p> <p>I'm using Database First approach.</p> <p>For example, lets say these are my fields in Users table.</p> <pre><code>| Username | Email | Passw...
<p>You should not touch your entity framework generated code for such requirement. Instead you need to create a view model to contain fields which you want to get from user when registration. You can create a <code>RegisterViewModel</code>. Then to compare those properties, use <a href="https://msdn.microsoft.com/en-us...
ignored declarative Security in IBM WebShere application server <p>I have a spring MVC rest application that is deployed as a war file to IBM WebSphere application server v 8.5, i want to secure some of the rest api in this application, hence, i used the application web.xml and declare the security role i want, then i ...
<p>You should not include your context-root (LBS in your case) in the url-pattern. It is relative to your application context-root. The <code>/*</code> pattern protects all urls, but <strong>only in your application</strong>, not others. So if you just want to protect for example rest api, it is usually mapped to some...
static variables in multiple processes (Signals) <p>I have 2 processes running test.c. There is a signal handler in test.c which executes an execlp. In test.c, I have a static variable which needs to be only initialized once, and incremented each time before the execlp call. When either process reaches 99, they exit.</...
<p>Use Interprocess communication concepts (pipe, fifo, shared memory) here, <code>execlp</code> function overwrites memory of current program with new program. So when ever you call <code>execlp</code> gets called your program get refreshed and starts from begining and <code>static int i</code> is always 0.</p> <p>I ...
java collection result designing <p>I am developing a small utility for collection filtering. I have done the coding for that. What I am doing is iterating the original collection and find the filter matching and if any match is found then add the result to the new collection(result collection). And finally the result ...
<p>At first it's really bad practice modify original collection, because you can apply filter only once and you always should keep in mind that your original collection can be changed. It's highway to bugs.</p> <p>Also use Predicate instead of Filter or make Filter implements Predicate, its more flexible and convenien...
Is AtomicCmpExchange reliable on all platforms? <p>I can't find the implementation of <code>AtomicCmpExchange</code> (seems to be hidden), so I don't know what it does. </p> <p>Is <code>AtomicCmpExchange</code> reliable on all platforms? How is it implemented internally? Does it use something like a critical section?<...
<p><code>AtomicCmpExchange</code> is what is known as an <a href="http://docwiki.embarcadero.com/RADStudio/en/Delphi_Intrinsic_Routines" rel="nofollow"><em>intrinsic routine</em>, or a <em>standard function</em></a>. It is intrinsically known to the compiler and may or may not have a visible implementation. For example...
MongoDB query and calculating average for nested array elements <p>I have a collection <code>lanes</code> which has documents of following structure. Only the <code>dist</code> and <code>time</code> of new documents changes. I want to calculate average-speeds of all lanes grouped by <code>l_id</code>. </p> <pre><code>...
<pre><code>db.Test2.aggregate([ { $unwind: "$ab" }, { $unwind: "$ab.data" }, { $group:{ _id: "$ab.l_id", avgspeed: {$avg:{$divide:["$ab.data.dist","$ab.data.time"]}} } } ]); </code></pre>
Select a large number of ids from a Hive table <p>I have a large table with format similar to</p> <pre><code>+-----+------+------+ |ID |Cat |date | +-----+------+------+ |12 | A |201602| |14 | B |201601| |19 | A |201608| |12 | F |201605| |11 | G |201603| +-----+------+------+ </code></pre...
<p>Using a partitioned table things run fast. Once you partitioned the table add your ids into the where. You can also extract a subtable from the original one selecting all the rows which have their ids between the min and the max of you ids list.</p>
Django dateutil parse is changing the date to today's date <p>I am trying to use Django dateutil.pareser.parse() to change the date '2016:09:24 17:08:45' to '2016-09-24 17:08:45'. But when I use the following code:</p> <pre><code>the_timestamp = self.request.query_params.get('timestamp',0) # = '2016:09:24 17:08:45' th...
<p>You have the wrong date format. It should be:</p> <pre><code>2016-09-24 </code></pre> <p>not </p> <pre><code>2016:09:24 </code></pre>
How to call a variable inside main function from another program in python? <p>I have two python files first.py and second.py</p> <p>first.py looks like</p> <pre><code>def main(): #some computation first_variable=computation_result </code></pre> <p>second.py looks like</p> <pre><code>import first def main(): ...
<p>You should use function calls and return values instead of this. </p> <p>Return the computation_result from the function in the first file, and then store the result in the b variable in the second file.</p> <p>first.py</p> <pre><code>def main(): # computation return computation_result </code></pre> <p>s...
How do you align text on a Text Field? <p>I made a <code>TextField</code> using Libgdx scene2d and I want the text on the text field to appear on the center, so when the user type a string, the string will start at the center and not at the left. I also tried to set the cursor position but nothing is happening, is it b...
<p>You can try <code>textField.setAlignment(Align.center);</code>.</p> <blockquote> <p>setAlignment(int alignment)</p> <p>Sets text horizontal alignment (left, center or right).</p> </blockquote>
Typescript : Call instance method <p>I have an interface:</p> <pre><code>export interface ISearchService { search(terms: string): Observable&lt;any&gt;; } </code></pre> <p>I have two services implementing this interface:</p> <p>SearchMaleEmployeeService:</p> <pre><code>@Injectable() export class SearchMaleEmpl...
<p>Because you're using <code>useValue</code></p> <pre><code>{provide: 'ISearchService', useValue: SearchFemaleEmployeeService} </code></pre> <p>which just uses the <em>value you provide</em>, which is a class, which in JS is a function. You should instead use <code>useClass</code>, then Angular will create it for yo...
Why do my menu items activate a scroll function? <p>I used the 'Page scroll to id' plugin for Wordpress to set up a one scroll page where the menu items let you scroll through the section. I noticed the animation wasn't working, which had been the case for a few other websites I worked on in the past. Strange enough, u...
<p>Could be still stetting #id in the menu, try to check the Menu inside appearance.</p> <p>Other things you can do it's delete the tables of the plug-in in the DB. when you uninstall the plug-in form wp, the tables in the db still exits, it's difficult but cold be that. </p> <p>Also you can check if you have really ...
Open file with external Intent/Application <p>After creating a file in the app's <code>fileDirectory</code> I would like to open it with an external app like the Adobe Reader etc. To achive this I tried to use an <code>Intent</code> like in the code below.</p> <pre><code>ContextWrapper cw = new ContextWrapper(getAppli...
<p>Third-party apps do not have access to your app's portion of <a href="https://commonsware.com/blog/2014/04/07/storage-situation-internal-storage.html" rel="nofollow">internal storage</a>. Use something like <code>FileProvider</code> <a href="https://commonsware.com/blog/2016/03/16/how-publish-files-via-content-uri.h...
Using logical OR operator in condition <p>my code is comparing a strings "text" against two additional strings "redact" and "redact2" and replacing it with "REDACTED" if there is match. </p> <pre><code>puts "Enter your sentense" text = gets.downcase.chomp puts "Enter your 2 words to be reducted" redact = gets.downcas...
<blockquote> <p>Can someone please explain me why?</p> </blockquote> <p>Because <code>==</code> binds stronger, than <code>||</code>.</p> <p>Thus, your statement is actually interpreted as follows:</p> <pre><code>if (w == redact) || redact2 </code></pre> <p>not as you are expecting:</p> <pre><code>if w == (redac...
Swift: Execution was interrupted, reason: EXC_BAD_INSTRUCTION error <p>When I attempt this in Playground:</p> <pre><code>func StockEvolution(S_0:Double, _ down:Double, _ up:Double, _ totalsteps:Int, _ upsteps:Int) -&gt; Double // function being used in calcCall() { var S_t:Double = S_0 * pow(up, Double(upsteps)) *...
<p>The issue is with your nested <code>while</code> loops. The first time you loop through, <code>n</code> is set to <code>9</code>, which means that on the final pass through the nested loop you end up with <code>j == 9</code>, which clearly means <code>j + 1 == 10</code>. But you're trying to get <code>prices[j + 1] ...
Performing specific action when user clicks any HTML element <p>I am creating navigation buttons that will drop down sub-menu when clicked, using checkbox input. Whenever user clicks the label input is checked and menu drop's down, when clicking the label again, it is being collapsed back. </p> <p>But now i need to pe...
<p>If you are ok with javascript solution you can use this example:</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>$(document).click(function(e) { if (! ($('#down-nav-1'...
Rails Rspec Capybara Selenium JS create not showing after pressing submit <p>I am building a web shop, the functionality is already there, namely: in ONE screen there is a list of products and a list of ordered items. When in a product pressing order, this product then shows up immediately in this list. </p> <p>As you...
<p>Most likely cause is an error in one of your JS assets that's preventing the behavior you're expecting from being attached. Things can work fine in dev mode when the assets aren't concatenated (so an error in one file doesn't prevent the other files from being processed), but then fail in the test and production en...
Improving javascript code performance <p>Assume you have a webapp with a 1000000 user logins in an hour.</p> <p>and the following code get executed on each user login :</p> <pre><code>if (DevMode) { // make an Ajax call } else if (RealMode) { // make other Ajax call } else { // Do something else } </code...
<p>Assuming that <code>RealMode</code> is the 95% case (you haven't actually said whether it's <code>RealMode</code> or <code>else</code>) then: Well, yes, because you avoid doing a check that will be false 95% of the time.</p> <p>It won't <strong>matter</strong> that it's more efficient, though. Testing a variable fo...
React + Webpack - Invariant Violation Error in simple Hello World component <p>So far I have managed to finally figure out how to configure my webpack.config.js file to handle jsx files. here it is:</p> <pre><code>var HtmlWebpackPlugin = require('html-webpack-plugin'); var HtmlWebpackPluginConfig = new HtmlWebpackPlug...
<p>You are getting a bit confused about the different import types in ES6. When you <code>export default</code> a class or variable, you must import it without using braces. For example:</p> <p><strong>A.js</strong></p> <pre><code>class X { } export default X; </code></pre> <p><strong>B.js</strong></p> <pre><code...
PDF error - removing overlapped objects <p>I'm hand-rolling a PDF (don't ask why, it's a long story) and I am now trying to define a Form XObject.</p> <p>The page I'm working in is 8.5" x 11", moves the origin to the bottom-left, and converts to 96 dpi, so there's a line right at the top:</p> <pre><code>0.75 0 0 0.75...
<p>Most other readers give better diagnostics than Adobe Acrobat. <code>xpdf</code> for example:</p> <pre><code>Syntax Error (324732): Incorrect number of arguments in 'sc' command Syntax Error (2083): Bad block header in flate stream </code></pre> <p>The <code>sc</code> error can be fixed by inserting a <code>/Devic...
C# Include List<> with object to Json result <p>I have this Models:</p> <p>Agenda</p> <pre><code> public class Agenda { [Key] public int AgendaID { get; set; } public DateTime data { get; set; } public List&lt;Agendamento&gt; agentamentos { get; set; } public string status ...
<p>You are using eager load right? You need to include cliente from each agendamento loaded</p>
Regex to match only numbers in currency <p>I'm trying to get a VB regex to match only the numbers in a currency sequence without additional substitution lines if possible. It needs to look for a number with + on end $ at the start and return what's in the middle, minus any commas.</p> <p>Accordingly</p> <pre><code> $...
<p>Your regex is <code>\$(\d+(,?\d+)*)\+</code>. Group 1 is what you are looking for <br/> Check <a href="https://regex101.com/r/HQEMuC/2" rel="nofollow">here</a></p> <p>After retrieving results you should remove commas from it</p>
Select N items directly before a given ID <p>If I have a row for each of the alphanumerically ordered items (ids) below:</p> <pre><code>aa ab ac ba cc cf ff gh h4 ia </code></pre> <p>I would like to select the <strong>3 items directly prior</strong> to <code>cc</code>, which would be <code>ab</code>, <code>ac</code> ...
<p>You are very close:</p> <pre><code>SELECT * FROM things WHERE id &lt; 'cc' ORDER BY id DESC ------------^ LIMIT 3; </code></pre> <p>You need to sort the items in descending order to get the "biggest" ones before <code>'cc'</code>.</p> <p>Also, for three items you want <code>limit 3</code>. I assume the "2" is a ...
Schema-less in All layers <p>I have use case where schema of my entities keep on changing again and again. Based on that i have to change/add new business rules which is not scalable for me.</p> <p>I am trying to go schema-less by using JSON documents in <strong>my data , service and ui layer</strong>. </p> <p>I wan...
<p>Have you tried the Java API for JSON Processing? <a href="http://www.oracle.com/technetwork/articles/java/json-1973242.html" rel="nofollow">http://www.oracle.com/technetwork/articles/java/json-1973242.html</a></p> <p><a href="https://jcp.org/en/jsr/detail?id=353" rel="nofollow">https://jcp.org/en/jsr/detail?id=353<...
Evaluate String from database in taglib in Grails <p>I have a taglib method and I fetch an object from database with string expressions to evaluate. From the docs, it should be possible to do sth like this:</p> <pre><code>out &lt;&lt; "&lt;div id=\"${attrs.book.id}\"&gt;" </code></pre> <p>But when I try to do the sam...
<p>try this</p> <pre><code>def output = "" def objectFromDb = fetchObjectFromDb() def output += objectFromDb.getContent() // use toString() if needed out &lt;&lt; output </code></pre>
WPF DataContext works differently in seemingly identical situations <p>I have the following resources:</p> <pre><code>&lt;Window.Resources&gt; &lt;SolidColorBrush x:Key="b" Color="{Binding B}" /&gt; &lt;my:C x:Key="c" Prop="{Binding Source={StaticResource b}}" /&gt; &lt;my:C x:Key="d" Prop="{Binding A}" /&...
<p>Strange.</p> <p>my:C has obviously no DataContext and can therefore not bind directly to anything.</p> <p>Resources with DataContext do not inherit the resources owner's DataContext (Ellipses e and f)</p> <p>SolidColorBrush "b" derive form System.Windows.Freezable which has a protected Field/Property called Inher...
C++ Function does not take 2 arguments <p>I'm following a tutorial on creating a video game using C++. And I've got stuck on this step:</p> <pre><code>spriteBg -&gt; setAnchorPoint(0,0); </code></pre> <p>I've got an error of: Function does not take 2 arguments</p> <p>But anchor points are usually two digits pair (x,...
<p>Not sure what the problem is without the exact error message, but if you say it takes Vec2::ZERO maybe try:</p> <p><code>spriteBg -> setAnchorPoint(Vec2(0,0));</code></p>
ScrollToTop button displaying at the top when page is refreshed <p>I am trying to get my scrollToTop button to stop showing when at the top</p> <p>I have the button working, as in it fades in when scrolling down, and scrolls to the top when clicked, and then hides, but if I am the top of the page and hit refresh the b...
<p>You need to make sure its default setting is that it is not appearing, use CSS.</p> <p>The Javscript will then take care of the rest and override this when needed.</p> <pre><code>.scrollToTop { display:none; } </code></pre>
How would i loop this bit of code so that It will go to the start again? <p>I'm a new to python and i need a bit of help. I just need to know how would i loop this bit of code so that after it says "please try again..." it will then go onto "Do you want to roll or stick". Thanks in advance.</p> <pre><code>Roll = input...
<p>You can wrap up your code with <a href="https://wiki.python.org/moin/WhileLoop" rel="nofollow"><code>while</code></a> loop:</p> <pre><code>while True: Roll = input("Do you want to Roll or Stick?") if Roll.lower() == 'exit': break ... else: print("Please try again. Type 'exit' to exit...
How to Subtract fields in filemaker? <p>I have added a field11 total. It has to be the value field10 - field9 - field8 - field7. How to write the code and view result in field11? </p>
<p>Calculations need to be defined using FileMaker's field type = "calculation" under Manage Database, whether the desired result is a number or text or other.</p> <p><a href="http://www.filemaker.com/help/12/fmp/html/create_db.8.17.html" rel="nofollow">http://www.filemaker.com/help/12/fmp/html/create_db.8.17.html</a>...
Twilio iOS SDK fails with "400 Bad request" on outgoing call <p>Took the source code of example provided <a href="https://www.twilio.com/blog/2015/02/a-swift-adventure-building-basicphone-with-twilioclient.html" rel="nofollow">here</a>, converted to Swift 3 and applied my generated token of an upgraded Twilio account.<...
<p>If you are writing your own <strong><em>client</em></strong>, you need to set the HTTP Content-Type header to "<em>application/x-www-form-urlencoded</em>" for your requests.</p> <p><code>400 BAD REQUEST</code> means: the data given in the <code>POST</code> or <code>PUT</code> failed validation. Here are details in ...
html5 custom validation not working with angular <p>I am using this below form:</p> <pre><code>&lt;form name="signupForm" id="register-form" ng-submit="addUser(user)" method="POST"&gt; &lt;div class="row"&gt; &lt;input type="email" ng-model="user.email" id="reg_email" class="form-control" placeholder="Emai...
<p>I fixed it this way. Hope it helps some one.</p> <pre><code>auth.signup($scope.userData, successAuth, function (error) { $rootScope.error = error.error; if ($rootScope.error == "user already exists") { $scope.signupForm.reg_email.$setValidity("User already exists", false); } }); </code></pre> <...
Exclipse JavaFX SceneBuilder GridPane <p>i can't use GridPane in SceneBuilder (eclipse), when i try to insert GridPane in my project, the SceneBuilder quit without prompt any message.</p> <p>and that's what i find in the log file:</p> <h1># A fatal error has been detected by the Java Runtime Environment: # # EXCEPTIO...
<p>The problem has been solved by installing SceneBuiled 32bit.</p>
How do you get an INTEGER in a textfile mixed with Strings and Integer? <p>I'm trying to get an <code>int</code> value from a text file. This is my current read file algorithm:</p> <pre><code>if (q) { while ((ch = fgetc(q)) != EOF) { if(ch == ) printf("%c",ch); } } else { printf("F...
<p>Consider using fgets to read each line and sscanf to parse the line. This sscanf will fail on the lines that do not start with "Room Number:".</p> <pre><code>char line[100] = ""; int room = 0; if (q) { while (( fgets ( line, sizeof line, q))) { if( ( sscanf ( line, "Room Number:%d", &amp;room)) == ...
What does +@ mean as a method in ruby <p>I was reading some code and I saw something along the lines of </p> <pre><code>module M def +@ self end end </code></pre> <p>I was surprised that this was legal syntax, yet when I ran <code>ruby -c</code> on the file (to lint) it said it was valid. <code>-@</code> was ...
<p>Ruby contains a few unary operators, including <code>+</code>, <code>-</code>, <code>!</code>, <code>~</code>, <code>&amp;</code> and <code>*</code>. As with other operators you can also redefine these. For <code>~</code> and <code>!</code> you can simply just say <code>def ~</code> and <code>def !</code> as they do...
Yii2. dektrium/user. Custom controller action redirects to the login page <p><strong>Problem</strong></p> <p>Every custom action redirects back to the login page.</p> <p><strong>My code</strong></p> <p>I've extended my custom controller from the <code>dektrium\user\controllers\RegistrationController</code></p> <p>M...
<p>If you want change the access control rules you should change properly eg: in your site controller add plan to the rules accessible without authenctication</p> <pre><code>class SiteController extends Controller { /** * @inheritdoc */ public function behaviors() { return [ 'access' =&gt; [ ...
Angular2 final version: Injected Service method under unit test returning undefined <p>I am trying to write some unit-tests on a component that got some services injected into it, to load the data from server. Data is loaded in this component on OnInit() method. I am trying that service method returns some dummy data, ...
<ol> <li><p>You need to call <code>fixture.detectChanges()</code> for the <code>ngOnInit</code> to be called.</p> <pre><code>fixture = TestBed.createComponent(MyComponent); fixture.detectChanges(); </code></pre></li> <li><p><code>getCountries</code> returns a <code>Promise</code> so you need to <code>then</code> it, o...
Python String Extraction for football results <p>I have the following string:</p> <pre><code>"W-Leicester-3-0-H|W-Hull-2-0-A|L-Arsenal-0-3-A|L-Liverpool-1-2-H|D-Swansea-2-2-A" </code></pre> <p>What I would like to do is manipulate the string above so it returns the results of each game which is the first letter after...
<p>Try something like this:</p> <pre><code> string = "W-Leicester-3-0-H|W-Hull-2-0-A|L-Arsenal-0-3-A|L-Liverpool-1-2-H|D-Swansea-2-2-A" result = ''.join([s[0] for s in string.replace('||', '|').split('|')]) </code></pre>
How to display current variable of date to minDate using JQuery <p>I have a php variable for date that was from database that should be put in minDate. </p> <p>Example: </p> <p>Php Code </p> <pre><code>&lt;?php //Example variable in PHP that was from the database $get_frm_database = "2016-10-20"; ?&gt; </code></pr...
<p>Try to simply echoing it...</p> <pre><code>minDate: "&lt;?php echo $get_frm_database; ?&gt;", </code></pre>
i can't login to my magento backend <p>I installed magento 2.1.1 on a WAMP Server and the installation was successful. I was able to login to backend of the Magento but everything changed when i installed a theme. According to the documentation of the theme I have to create a new database in <code>phpmyadmin</code> and...
<p>If you have changed your database to another, then the user you originally created won't exist anymore for the Magento install to let you in.</p> <p>In this case, you're best off creating a new admin user.</p> <p>You can do this using the Magento commmand line tool:</p> <p><div class="snippet" data-lang="js" data...
Interpolate without having negative values in python <p>I've been trying to create a smooth line from these values but I can't have negative values in my result. So far all the methods I tried do give negative values. Would love some help.</p> <pre><code>import matplotlib.pyplot as plt from scipy.interpolate import Un...
<p>Spline fitting is known to overshoot. You seem to be looking for one of the so-called <em>monotonic</em> interpolators. For instance,</p> <pre><code>In [10]: from scipy.interpolate import pchip In [11]: pch = pchip(x, y) </code></pre> <p>produces</p> <pre><code>In [12]: xx = np.linspace(x[0], x[-1], 101) In [13...
"Incorrect syntax" when using a common table expression <pre><code>WITH list_dedup (Company, duplicate_count) AS ( SELECT *, ROW_NUMBER() OVER (PARTITION BY Company ORDER BY Email) AS 'RowNumber' FROM Travels ) </code></pre> <p><strong>Error</strong>:</p> <blockquote> <p>Msg 102...
<p>You are missing a final select for the common table expression (<strong>after</strong> the definition of the CTE):</p> <pre><code>WITH list_dedup (Company,duplicate_count) As ( select *, ROW_NUMBER() OVER (PARTITION BY Company ORDER by Email) As "RowNumber" From Travels ) <b>select * from list_dedup...
Open another conection in OracleDataReader loop the oracle session not close <p>I have a problem about session not close when make calling another connection under OracleDataReader loop code below</p> <pre><code> private ArrayList GetORA() { ArrayList arr = new ArrayList(); string conn...
<p>IF you want to close session you should finish you call <code>connection.Dispose();</code></p> <p><a href="http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/hol08/dotnet/getstarted-c/getstarted_c_otn.htm" rel="nofollow">http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/hol08/dotnet/getstarted-...
Launching activity on condition for loginactivity <p>I want to launch activity after login on 2 condition if user is active in Database entry i want to launch MainActivity.java if user is not active it should launch mobile verification screen i am using volley to make http calls and getting data from server here is my ...
<p>The problem is you are comparing two strings in a wrong way. You should edit </p> <pre><code>if(new String(status).equals("active") ) </code></pre> <p>to:</p> <pre><code>if(status.contentEquals("active")) </code></pre> <p>and you are done.</p>
Angular application works on Chrome but not Safari <p>My website works fine on Chrome but is broken on Apple Mobile Safari.</p> <p>I have troubleshot the situation and have found that it is the below line of code placed in side of my angular controller that is causing the problem. With out this code everything works f...
<p>you are using ECMA 2015 lambda notation, try to wrap this with babel and try it again, did you check the browsers compatibility status with ECMA Script 2015?</p>
SQL Sampling: one element from each bucket <p>Here is a simulation of the basic setup i have: each person can hold multiple possessions.<br> <b>Persons</b> table:</p> <pre><code>id name 1 Carl 2 Sam 3 Tom 4 Jack </code></pre> <p><b>Possessions</b> table:</p> <pre><code>possession personId car 2 shoes...
<p>Why don't you take random set of persons and join to posessions ranked by random. Something like below. Sorry if it contain any spelling error but I don't have DB to check it now:</p> <pre><code> select * from ( (select top 1 percent * from persons order by newid()) a inner join (select p.*, ROW_NUMB...
C++ code compiles but doesn't run <p>I am currently writing a Texas Hold'em code in order to learn more about c++ and gain experience. But I recently ran into a problem in which I have no idea what to do.My code compiles just fine without errors but once I make it run and it arrive at a specific function it just stops ...
<pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;stdlib.h&gt; #include &lt;ctime&gt; </code></pre> <p>Be consistent in what you do. Including <code>&lt;stdlib.h&gt;</code> and <code>&lt;ctime&gt;</code> looks strange. Either include <code>&lt;cstdlib&gt;</code> and <code>&lt;ctime&gt;</code>, ...
Exit sudoers view difference on apt-get update <p>I ran apt-get upgrade about 10 minutes ago to upgrade my Ubuntu 16.04 server. I asked me if I would like to keep my current Sudoers file or upgrade to the new one, it also had the option to view the differences between the two, so I decided to view the differences.</p> ...
<p>Turns out it's <kbd>ctrl</kbd>+<kbd>q</kbd>+<kbd>t</kbd>.</p> <p>Whoever thought of that is an idiot.</p>
Jquery cloned element is replacing himself <p>I have been getting some issue with cloning element, when I am cloning an element and add it to the DOM it work perfectly but when I am trying to clone a second one its replacing the first added clone, do you know where it could come from ? </p> <pre><code> var clone_coun...
<p>You clone your row only once.<br> If you're using before on a single element, it will move the elements.</p> <blockquote> <p>If an element selected this way is inserted into a single location elsewhere in the DOM, it will be moved before the target (not cloned):</p> </blockquote> <p>Read more: <a href="http://...
How to persist values of delegated fields in rails <p>I currently have the following models:</p> <p><strong>user.rb</strong></p> <pre><code> class User &lt; ApplicationRecord has_one :profile, dependent: :destroy before_create :build_profile end </code></pre> <p><strong>profile.rb</strong></p> <...
<p>Instead of delegate, which is normally reserved for exposing public methods that do not involve persistence, try adding the following line to your profile model:</p> <pre><code>accepts_nested_attributes_for :user #This will allow you to handle user attributes via a profile object </code></pre> <p>Also, in your <co...
iOS app crashes after deleting the last cell in section <p>So I've my app crashing everytime I try to delete the last cell of the section.</p> <p>Ex., if my section has 10 rows, I can delete them without any problem but the last one throws the following error:</p> <blockquote> <p>Terminating app due to uncaught exc...
<p>The problem is that <code>numberOfSections</code> returns different values before and after you delete rows, but <strong>you don't delete any sections</strong>. So you should either return a constant value in numberOfSections or call <code>deleteSections</code> in addition to <code>deleteRows</code></p> <p>The main...
User defined fields model in django <p>I want to allow my users to define custom properties.</p> <p>They are managing apartments so each customer manages the apartments in different way. I want to allow them to define some custom properties for they apartments.</p> <pre><code>class Unit(CommonInfo): version = In...
<p>I would reccomend the following solution:</p> <p>1.Create a "property" Model:</p> <pre><code>class Property(models.Model): property = models.CharField(max_length=140) value = models.CharField(max_length=140) def __str__(self): return self.property </code></pre> <p>2.To your Unit model, add a ...
statistical summary table in sklearn.linear_model.ridge? <p>In OLS form StatsModels, results.summary shows the summary of regression results (such as AIC, BIC, R-squared, ...). </p> <p>Is there any way to have this summary table in sklearn.linear_model.ridge? </p> <p>I do appreciate if someone guide me. Thank you.</p...
<p>As I know, there is no R(or Statsmodels)-like summary table in sklearn. (Please check <a href="http://stackoverflow.com/a/26326883/3054161">this answer</a>) </p> <p>Instead, if you need it, there is <a href="http://statsmodels.sourceforge.net/devel/generated/statsmodels.regression.linear_model.OLS.fit_regularized.h...
Adding custom overlay in map view <p>i'm new to iOS and my goal is to add custom overlay in map view using Swift 3 and MapKit. I've followed this <a href="http://stackoverflow.com/questions/9049790/add-inverted-circle-overlay-to-map-view">Add inverted circle overlay to map view</a>. Here is the code:</p> <pre><code>im...
<p>Solved it, just added reversing():</p> <pre><code>path.append(excludePath.reversing()) </code></pre> <p>Full function code:</p> <pre><code>override func draw(_ mapRect: MKMapRect, zoomScale: MKZoomScale, in context: CGContext) { let path = UIBezierPath(rect: CGRect(x: mapRect.origin.x, y: mapRect.origin.y, w...
Concatenating pandas DataFrames keeping only rows with matching values in a column? <p>I am trying to "merge-concatenate" two pandas DataFrames. Basically, I want to stack the two DataFrames, but only keep the rows from each DataFrame which matching values in the other DataFrame. So for example:</p> <pre><code>data1: ...
<p>How about this?</p> <pre><code>In [335]: cls = np.intersect1d(data1['class'], data2['class']) In [336]: cls Out[336]: array([4, 5], dtype=int64) In [337]: pd.concat([data1.ix[data1['class'].isin(cls)], data2.ix[data2['class'].isin(cls)]]) Out[337]: first_name last_name class 3 Alice Aoni 4 4 ...
Trying to split string with regex <p>I'm trying to split a string in Python using a regex pattern but its not working correctly.</p> <p>Example text:</p> <p><code>"The quick {brown fox} jumped over the {lazy} dog"</code></p> <p>Code:</p> <p><code>"The quick {brown fox} jumped over the {lazy} dog".split(r'({.*?}))</...
<p>You're calling the strings' split method, not re's</p> <pre><code>&gt;&gt;&gt; re.split(r'({.*?})', "The quick {brown fox} jumped over the {lazy} dog") ['The quick ', '{brown fox}', ' jumped over the ', '{lazy}', ' dog'] </code></pre>
Cron to detect low available memory <p>Hello I have a memory leak on my server which I finding it difficult to trace, apparently so is support. They told me I to try and write a cron to detect when my server is low on memory but I have no idea how to do this.</p> <p>I use PHP to build my apps on a VPS server with Cen...
<p>Quoting from <a href="https://cookbook.wdt.io/memory.html" rel="nofollow">https://cookbook.wdt.io/memory.html</a>:</p> <blockquote> <p><strong>free</strong> is a standard unix command that displays used and available memory. Used with the options -m it will output the values in megabytes. The last value in the li...
Convert all lowercase characters to uppercase and vice-versa <p>I am writing a C program to read characters one-by-one from standard input, convert all upper-case characters to lower-case and all lower-case characters to upper-case, and write the result to standard output. I also want to count how many characters I hav...
<p>Change the ternary to an if/else clause, and provide counters for each condition.</p> <pre><code>int changedToLower = 0; int changedToUpper = 0; for (i = 0; i &lt; count; i++) { char oldC = sentence[i]; if(islower(sentence[i])) { ch = toupper(sentence[i]) changeToUpper += (ch != oldC)? 1 : 0; ...
Error when clicking AlertDialog to setValue at Firebase database <p>I tried to select an option at AlertDialog but it shows an error. Below is the error:</p> <pre><code>10-17 00:54:44.765 25600-25600/com.example.jingwen.bluetoothlowenergy E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.jingwen.bluetoothlo...
<p>This likely has nothing to do with Firebase.</p> <p>As far as I can tell, mBTDevicesArrayList (definition and assignment not shown above) is an ArrayList of size zero, and you're passing a value of 1 to its get method,as indicated by the error message "java.lang.IndexOutOfBoundsException: Invalid index 1, size is 0...
npm ERR! enoent ENOENT: no such file or directory, open package.json <p>I'm new to Node so bear with me.</p> <p>I have a Node server which requires <code>ws</code> so I install it with:</p> <pre><code>$ npm install ws /private/var/www/html/WebRTC/SVC └─┬ ws@1.1.1 ├── options@0.0.6 └── ultron@1...
<p>When you type</p> <pre><code>npm run server.js </code></pre> <p>npm tries to find entry named <code>server.js</code> in the <code>scripts</code> section of your <code>package.json</code> file (see <a href="https://docs.npmjs.com/misc/scripts" rel="nofollow">npm docs on scripts </a> for details).</p> <p><code>pack...
what is type means <pre><code>STUFF((SELECT distinct ',' + QUOTENAME(c.Error_Code) FROM (SELECT Connection_type, Error_Code, Count FROM (SELECT Connection_Type, error_code, count(*) AS count, row_number() over(partition by Conne...
<p>It returns a value typed as XML.</p> <p>A common alternative that does not use this and just returns directly as string is below.</p> <pre><code>SELECT STUFF((SELECT ',' + QUOTENAME(c.Error_Code) FROM (VALUES('FOO &amp; BAR'), ('1 &lt; 4 ') ) c(Error_Code) ...
Find Max in List Using the Reduce Function <p>In Torbjörn Lager's 46 python exercises, number 26 is finding the max in a list using the reduce function. I know how to add and multiply using the reduce function but it doesn't make sense to me how you could use it to find the largest number. Does anyone know how to do ...
<p>Write a function that returns the larger of two numbers:</p> <pre><code>def larger(a, b): return a if a &gt; b else b </code></pre> <p>Then use it with <code>reduce</code>:</p> <pre><code>reduce(larger, [1, 2, 3, 4]) </code></pre> <p>Conveniently, Python already has a function like <code>larger</code> that's...
Call a function continuously after key is pressed in C <p>I want to be able to call my function that moves my propellers (OpenGL work) after I press the 'a' key. Here's what I have set up:</p> <pre><code>switch (key) { case 'a': startShip = 1; while (1 (&amp;&amp; startShip == 1)) { spi...
<p>Game loops work like this:</p> <pre><code>while (true) { get_input(); // get keyboard, mouse, and joystick input move_items(); // update the player position and all other items in the game, fire weapons, and update game state collision_detection(); // figure out what hit what and update game state...
Jekyll syntax highlighting with data variable <p>I'm working on a Jekyll page that shows a list of items with their <em>markdownified-syntax highlighted</em> code. I've a data file with content like this</p> <pre><code># myitems.yaml id: 'someID' updated: 'someDate' items: - item: id: "0001" content: " *Thi...
<p>solved by using the pipe instead of regular string quotes. </p> <pre><code>-item: id:"0001" content: | *This is italicized*, and so is _this_. **This is bold**, and so is __this__. &amp; Use ***italics and bold together*** if you ___have to___. ``` html &lt;script&gt;alert() some content&lt;/scrip...
SQL query that removes a row of data based on 2 columns <p>I have a common table expression query that returns this set of data:</p> <pre><code>Board_Name Method Source TicketCount Percentage IT Services NULL NULL 73 0.7 IT Services Call Call 6929...
<p>One way would be (<a href="http://rextester.com/VGJ55852" rel="nofollow">Demo</a>)</p> <pre><code> WHERE NOT 'Call' = ALL(SELECT ISNULL(Method,'') UNION SELECT ISNULL(Source,'')) </code></pre> <p>Or along similar lines (<a href="http://rextester.com/XTW38001" rel="nofollow">Demo</a>)...</p> <pre><code>WHERE 'Cal...
get data from a column then select whole row where the data belongs <p>for example this is my <code>JTable</code>:</p> <blockquote> <p>ID|NAME|AGE</p> <p>001|anna|18</p> <p>002|tony|25</p> </blockquote> <p>now i want that the user will enter the ID, then convert that ID into which row it belongs. now i'm ...
<p>Write a loop.</p> <ol> <li><p>You can use the <code>getRowCount()</code> method of the table to iterate through each row. </p></li> <li><p>Then you use the <code>getValueAt(...)</code> method to get the value of the ID in the row for the specific column. </p></li> <li><p>When you find a match you use the row index ...
Mirror grouped bars across the x-axis <p>This is cross-posted from the rstats subreddit. I have seen mirrored bars or grouped bars, but not mirrored AND grouped bars. The closest I have gotten is using "stacked," but it doesn't seem to work across the x-axis for negative values, while "dodge" offsets related bars that ...
<p>How about this?</p> <pre><code>library(ggplot2) library(tidyr) limits &lt;- aes(ymax = Data$mean + Data$sd, ymin = Data$mean - Data$sd) Data %&gt;% separate(treatment, c("Type", "Pos")) %&gt;% ggplot(aes(x = factor(group), y = mean, group = Type, fill = interaction(Pos, Type))) + geom_bar(stat = "identity...
Image is not displayed on wp_get_attachment_image_src, instead it returns an array <p>Hi i have a wordpress site and i am trying to display image using <strong>wp_get_attachment_image_src</strong> but it returns only array</p> <p>Below what i have tried with myself</p> <pre><code>`$get_story_image_src = wp_get_attach...
<p>Its correct <strong>wp_get_attachment_image_src</strong> always returns array .</p> <p>if you want to display image using this function you need to pass array indexes in the image tag .</p> <p>Try below code :</p> <pre><code>`$get_story_image_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post-&gt;ID...
How to get value of array by using the key from a string <p>I have an array with some keys and I want to get the array values according to the array keys where the keys are in a string.</p> <p>Example:</p> <pre><code>$arr = array( "COV" =&gt; "Comilla Victorians", "RK" =&gt; "Rajshaji Kings" ); ...
<p>You could try this:-</p> <pre><code>&lt;?php $arr = array( "COV" =&gt; "Comilla Victorians", "RK" =&gt; "Rajshaji Kings" ); $str = "COV-RK"; $values = explode("-", $str); // explode string to get keys actually echo $arr[$values[0]] . " VS " . $arr[$values[1]]; // print desired output </code></pre>
Javascript fill array with intermediate value <p>I'm trying to fill an array with missing intermediate data</p> <p>My data input is like this</p> <blockquote> <p>var data = [[5.23,7],[5.28,7],[5.32,8],[5.35,8]];</p> </blockquote> <p>I wanna fill the array with missing value but I need to respect this rule:</p> <o...
<p><code>Array.prototype.reduce()</code> is sometimes handy to extend the array. May be you can do as follows;</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>var data = [[5...