input
stringlengths
51
42.3k
output
stringlengths
18
55k
"Authorization has been denied for this request" in production environment only <p>I'm using WebAPI and Owin with the following authentication setup. Locally, I can register, get a token, and make API requests that have the [Authorize] annotation on them. In production, I can register <strong>and get a token</strong>, ...
<p>Ah! The login call was using the LOCAL api, while the rest of the routes were using the production api. Fixing that solved my problem.</p>
Spring integration kafka how to handle error when produce to kafka <p>While using int-kafka:outbound-channel-adapter to produce to kafka, there seems no error-channel available. In this case how to handle message failed to produce to kafka after reties times?</p> <p>Any error that could cause produce to kafka failure....
<p>Please, follow answers to this question <a href="http://stackoverflow.com/questions/39915579/exception-handling-in-int-jpaupdating-outbound-gateway">exception handling in int-jpa:updating-outbound-gateway</a>. </p> <p>Since you have there <code>&lt;polled&gt;</code>, you can specify <code>error-channel</code> and h...
Wrapping a #include directive for a standard C++ header in extern "C" { ... }? <p>I recently saw this block at the beginning of a <code>.h</code> file.</p> <pre><code>#ifdef __cplusplus extern "C" { #include &lt;cstddef&gt; #include &lt;cstdint&gt; #else #include &lt;stddef.h&gt; #include &lt;stdint.h&gt; #e...
<p>Based on the "If ...def" statement in that header file, the </p> <p>"if" block : "if you use the particular header file in C++" </p> <p>"else" block : "if you use the particular header file not in C++, could be C"</p> <p>if you do not wrap the headers in "extern C" in the "if" block(which is meant for C++), the "...
How to ignore dashes or hyphens in JS comparisons <p>I want to compare two input values on a page. One input value is always entered with hyphens as spaces. ie "first-value" The other input value is never entered with hyphens as spaces. ie "first value"</p> <p>"first-test" == "first test" this views them as different....
<p>Dashes may come in more varieties thank you'd expect. Especially if people copy/paste their input from MS Word and the likes. For example, would you consider - or ‐ or ‑ or ‒ or – or — or ― all to be dashes? (they're all different unicode characters)</p> <p>If the parts that you care about are only alph...
How to show both markers on Google Maps? <p>I have a maps activity that displays an origin and a destination location (Point A and Point B). However, when the origin and destination locations are inputted. Only the Origin is displayed initially. You would have to zoom out to see the destination on the map. How can I sh...
<p>You need to set up a LatLng bounds to fit all of your points (in this case, just two) within the Map's camera. Take this code for example:</p> <pre><code>final LatLngBounds.Builder builder = new LatLngBounds.Builder(); builder.include(markerA.getPosition()); // this is a LatLng value builder.include(markerB.getPosi...
Time Complexity of a recursive Reverse String <p>I want to find the Time complexity in Big O of the following code:</p> <pre><code>ReverseString(S,x,y) if x &lt; y swap(S,x,y) return ReverseString(S,x+1,y-1) </code></pre> <p>The equation I got was </p> <pre><code>T(1) = 1 T(n) = 3 + T(n+1)+ T(n-1) </code></p...
<p>Assuming that x and y are pointers to string ends, then your equation is wrong. This is a simple, single recursion, but you've assumed double. Also, there is the serious problem of making T(n) depend on T(n+1); you really don't want to go <em>up</em> in subscripts without a guaranteed, finite bounded decrease.</p>...
Open a file in linux machine on a Mac Text Editor <p>I have problem with my <strong>FTP client</strong>, so that's not an option. </p> <hr> <p>I SSH into my Ubuntu server, and tried to open up a file with my Mac Text editor application such <strong>Text Edit</strong>, or <strong>Sublime Text</strong>. </p> <p>Is the...
<p>Try using sshfs. Mount the Linux drive on your system and then you will be able to use the folders like there were local. This will allow you to open the file. </p>
Is it possible to create an auto scaling Elastic Beanstalk without a load balancer? <p>We have an application which consists of an API and many microservices. The API writes to queues from which the microservices are listening. We currently have 25 microservices - none of which need load balancers. At the cost of nearl...
<p>You need to make a worker tier in Elastic Beanstalk. So no loadbalancer would be needed. This page describes it in detail. </p> <p><a href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features-managing-env-tiers.html" rel="nofollow">http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-feature...
Responsive banner image for all resolutions <p>I am trying to have a banner image, spanning 100% width of the screen An example of what I want to achieve is found here:</p> <p><a href="http://www.aha.io/roadmapping/where-aha-fits" rel="nofollow">http://www.aha.io/roadmapping/where-aha-fits</a></p> <p>Look at it in fu...
<p>This would be a good case to use Media Queries.The code below targets specific widths in a mobile-first pattern. This way the style for #background depends on the width of the device.</p> <pre><code>#background { background: url(http://snowdebts.com/images/banner-thin.png); background-position: center; backgr...
Transition from tableView to detailView passing Firebase data <p>I have a current app which displays articles in a tableview like so: </p> <p><img src="http://i.stack.imgur.com/VqHtv.jpg" alt="TableView"></p> <p>The data is displayed correctly, however, when I tap each cell, it does not populate with the correspondin...
<p>I assume the code you are providing is the one for your detail controller.</p> <p>Seems like you don't give parameter to <code>Data.dataService.fetchData</code>, you're probably returning a 'room' independently of the detail you're in. I recommend you to read some documentation or tutorials about how to pass data b...
How to upgrade openssl 0.9.8 to 1.0.2 with mod_ssl in Apache 2.2.9 <p>I am asked to recompile <code>mo_ssl</code> with openssl 1.0.2 in SuseSE11SP3. However, I am a newbie to Suse, but know a little bit of linux. </p> <ul> <li>OS : Suse SE11SP3 </li> <li>Openssl : 0.9.8j &lt;-which comes with original Suse linux</li> ...
<p>Due to Alvits's help, I could write this answer in stackoverflow for the first time. </p> <p><strong>!! Kudos to Alvits !!</strong></p> <p>My original task was that I need to install different version of openssl in local direcotry which is different from system openssl. But I like to make mod_ssl which is linked ...
C# WPF Prism ViewModelLocator in different Class Libraries/Projects <p>is there a way for the Prism ViewModelLocator to autowire the views and viewmodels from different class library beside just the WPF project?</p> <p>Currently my WPF MainWindow.xaml is in a Views folder in the WPF project and is auto wired to link w...
<p>Yes. Either change the ViewModelLoctor convention to fit your needs, or use the ViewModelLocationProvider.Register method to specify which VM should be used for a view.</p> <p><a href="http://brianlagunas.com/getting-started-prisms-new-viewmodellocator/" rel="nofollow">http://brianlagunas.com/getting-started-prisms...
Aggregate/project sub-document as top-level document in mongo <p>After a few aggregation steps (pipeline steps) in one of my collections, I'm ending up with the following result:</p> <pre><code>{ "_id" : ObjectId("574e7722bffe901713d383bb"), "eventname" : "Ball Passed", "command" : { "_id" : Object...
<p>As you have guessed, <code>$project</code> allows you to do that:</p> <pre><code>db.col.aggregate([ { $project : { _id: "$command._id", name: "$command.name", strike: "$command.strike", duration: "$command.duration" } } ]).pretty() </code></pre> <p>I inserted your pre...
drawLayer:inContext not displaying drawing <p>I'm trying to draw a blue circle inside a <em>UIView</em> subclass on Xcode 8, Swift 3. Inside a Cocoa Touch file that I'm using as the class for a <em>View</em> object in the <em>Storyboard</em>, I wrote the following code, but the circle is not displayed:</p> <pre><code>...
<p>I was working on your question and this are my results, first of all you need to get you CurrentGraphicsContent, if you don't do this, you can't draw anything, so try with this code</p> <pre><code>override func draw(_ rect: CGRect) { super.draw(rect) if let ctx = UIGraphicsGetCurrentContext() { ctx...
Trying to scan values with scanf within a loop. Requires secondary input to print the first input <p>I'm having trouble with scanf (and before anyone mentions it, I have to use it. I can't use <code>getchar()</code>, <code>fgets()</code>, and various other things). In my code below, I need to add (or subtract) two real...
<p>Various problems</p> <ol> <li><p>The trailing space <code>"%lf "</code> obliges <code>scanf()</code> to detect following non-white-space after the number, delaying <code>scanf()</code> return. <a href="http://stackoverflow.com/questions/39968870/trying-to-scan-values-with-scanf-within-a-loop-requires-secondary-in...
How can i get 2 classes by id inside the same function <p>I need to target two div elements and toggle their classes simultanouesly.</p> <p>I understand that I can get multiple divs "by ID" by using <code>.querySelectorAll</code></p> <p>but when I get to <code>.classlist.toggle ("NewClassName");</code> how can I targ...
<p>You can create a single javascript function that sets appropriate classes on each element. Since you have only two elements it is not too complex.</p> <p>HTML</p> <pre><code>&lt;div id="container"&gt; &lt;div id="lefty" onclick="toggle('lefty', 'righty')"&gt;Lefty&lt;/div&gt; &lt;div id="righty" onclick="togg...
How do I go to a specific page in React based on a URL param <p>As an example when entering <code>http://localhost:3000/ui/?goto=/ui/entity/e2</code> in the browser I'd like to go to the Entity component e2.</p> <p>This is my router:</p> <pre><code>&lt;Route path="/ui/" component={App}&gt; &lt;IndexRoute comp...
<p>You should use <code>browserHistory</code></p> <pre><code>import { browserHistory } from 'react-router'; ... if (gotoUrl) { browserHistory.push(gotoUrl) } </code></pre> <p>Let me know if this works</p>
Two select query at a time python <p>I want to calculate distance between two points. For that for each point in one table i have to calculate distance with all the other point in another table in same database. I am using python for that but I am not able to execute two query at a time. </p> <pre><code>import mysql.c...
<p>One trick you could use here would be to cross join the two tables together:</p> <pre><code>SELECT t1.longitude, t1.latitude, t2.geo_coordinates_latitude, t2.geo_coordinates_longitude FROM ( SELECT longitude, latitude FROM roadData LIMIT 5 ) t1 CROSS JOIN ( SELECT geo_coordinate...
Access local variable in another function without using global <p>I need to match the value of multiple <code>textareas</code> to the properties of an object. It should only be a match if :</p> <ol> <li>the value of the <code>textarea</code> being used is equal to the person's name contained in the object <strong>and<...
<p>Given that your employee IDs don't seem to be unique, I'd suggest you store all the people in an array, then in your <code>suggest()</code> function you can search through the array to check for a match (click <em>Run code snippet</em> to try it out):</p> <p><div class="snippet" data-lang="js" data-hide="false" dat...
How to choose a file and download it in ASP.NET MVC <p>I'm trying to let user choose a xls file and generate a new xls file based on it for the user to download. My question is, should I use two actionresults in my Controller? One gets the file path and the other generates the new file and send it back to my View. Or I...
<p>That is entirely up to you. If you intend to store the original file somewhere, then process it later and return the derivative file, then it would make sense to use two action methods, one to upload and one to process/download. On the other hand, if it's a fairly small and quickly processed file, it might make sens...
How to enable multicore processing with sklearn LogisticRegression? <p>Sklearn's LogisticRegression model refuses to run in parallel. I set n_jobs=-1, and also tried n_jobs=4. No luck -- only one core is engaged. I've run other sklearn models in parallel, e.g., RandomForestClassifier and XGBoostClassifier.</p> <p>I'm ...
<p>From the doco for <code>LogisticRegresssion</code> it looks like the <code>n_jobs</code> parameter is only used for separate cross-validation folds (unlike the case for <code>RandomForestClassifier</code> where the individual trees are computed in parallel). </p> <blockquote> <p>n_jobs : int, default: 1</p> ...
Running Hadoop jar command through Java <p>I want to run this command in linux through java code. I am writing a java code to run all hadoop commands instead of typing one by one. </p> <p><code>hadoop jar WordCount.jar WordCount input/wordcount.txt output</code></p> <p>I tried <strong>Runtime.getRuntime().exec(comma...
<p>try hadoop jar WordCount.jar ur_pacjage_name.WordCount input/wordcount.txt output</p>
Assiging Random Values to an Array in C <pre><code> #include &lt;conio.h&gt; #include &lt;time.h&gt; int i = 1; int main() { int nums[20]; srand(time(NULL)); while(i &lt; 20){ nums[i] = rand()% 10; i++; } printf("%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%...
<pre><code>nums[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] </code></pre> <p>is equivalent to</p> <pre><code>nums[20] </code></pre> <p>due to the funny <a href="https://en.wikipedia.org/wiki/Comma_operator" rel="nofollow"><code>,</code>-operator</a>.</p> <p>Try enumerating elements like this (starting with ...
Woocommerce add to cart ajax and mini-cart <p>I need to re-populate mini-cart when product added via ajax add to cart. I manage to update cart quantity with filter woocommerce_add_to_cart_fragments like this:</p> <pre><code>add_filter( 'woocommerce_add_to_cart_fragments', function($fragments) { ob_start(); ?&...
<p>Ok so I just realized that I can use woocommerce_add_to_cart_fragments filter 2 times, like so:</p> <pre><code>add_filter( 'woocommerce_add_to_cart_fragments', function($fragments) { ob_start(); ?&gt; &lt;div class="cart-contents"&gt; &lt;?php echo WC()-&gt;cart-&gt;get_cart_contents_count(); ...
Error consume JSON with JS <p>I have a JS problem with Java using Spring. I made some WebServices and PHP is running smoothly, but I need to access them using JS. I've tried everything, still is not calling my service</p> <p>Below my code in Java</p> <pre><code>@Controller @RequestMapping("/map") public class MapRest...
<p>Remove the first slash from the method <code>@Path</code> annotation:</p> <pre><code>@Controller @RequestMapping("/map") public class MapRest { @Autowired private MapService mapService; @RequestMapping(value = "searchCarByUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public Resp...
Mutate a lead or lag column for certain rows in r <p>I have a forecast that doesn't quite align with the moving holidays. I am trying to find a quick fix:</p> <p>Here is the structure of my data frame:</p> <pre><code>df1: Date City Visitors WKN WKN_2015 Holiday 2016-11-06 New York 4000...
<p>You are interest in only three weeks per year and you can calculate the lag value in the "Thanksgiving" row. I don't think <code>dplyr</code> is needed to do it.</p> <pre><code>df1$New_Visitors &lt;- df1$Visitors # copy Visitors ind &lt;- which(df1$Holiday == "Thanksgiving") # get number of "Thanksgivi...
Can't set CALayer's border color <p>I'm trying to customize the appearance of a UIButton, like this: </p> <pre><code>@IBOutlet weak var button: UIButton! override func viewDidLoad() { super.viewDidLoad() button.layer.cornerRadius = button.frame.size.width / 2 button.layer.borderColor = UIColor.cyan.cgCol...
<p>The problem is that you are running this code too soon (in <code>viewDidLoad</code>). Your <code>cornerRadius</code> calculation depends upon <code>calculateButton.frame</code>, but its value is not known at this time. Move your code into <code>viewDidLayoutSubviews</code> and I think you will find that it works as ...
How to make crosstab in PostgreSQL? <p>CREATE TEMPORARY TABLE</p> <pre><code>CREATE TEMP TABLE pivot( gid SERIAL, zoom smallint NOT NULL, day timestamp with time zone NOT NULL, point integer NOT NULL ); </code></pre> <p>INSERT DATA</p> <pre><code>INSERT INTO pivot(zoom, day, point) VALUES(6,'2015-10-01',21); INSERT ...
<p>Thanks to @Abelisto suggestion about <code>timestamptz</code>, this works:</p> <pre><code>SELECT * FROM crosstab( 'SELECT zoom, day, point FROM pivot ORDER BY 1,2' ,$$VALUES ('2015-10-01'::timestamptz), ('2015-10-02')$$) AS ct ("zoom" smallint, "2015-10-01" integer, "2015-10-02" inte...
Deprecation warning in moment js <p>I need help I'm getting a warning on my code that has a value provided is not in a recognized ISO format. and I change my variable today with moment function and still it doesn't work.</p> <p>Here's the warning error </p> <blockquote> <p>Deprecation warning: value provided is not...
<p>Check out all their awesome documentation!</p> <p>Here is where they discuss the <a href="http://momentjs.com/docs/#/parsing/string/" rel="nofollow">Warning Message</a>.</p> <h2>String + Format</h2> <blockquote> <p>Warning: Browser support for parsing strings is inconsistent. Because there is no specification o...
Which is the intended bit (not byte) order in internet RFC packet diagrams <p>I am parsing ICMPv6 datagrams on my home wired network, and can't find an explicit mention of the bit-ordering convention in the specific RFC. </p> <p>Multi-byte fields are network order, but what about bits within a byte?</p> <p>Machines a...
<p>As pointed out in a previous comment (thanks ron-maupin), <a href="https://tools.ietf.org/html/rfc1700" rel="nofollow">RFC1700</a> tells one that the messages (covering internet protocols) are depicted with most significant bits on the left.</p> <pre><code>Whenever an octet represents a numeric quantity the left mo...
My program doesn't seem to follow through my If statements <pre><code> //Declarations double height; double weight; double BMI; int Const; //Reading User Input //HEIGHT Console.WriteLine("Please enter the person's height in inches: "); h...
<p>If you are checking between a range 5 and 120 it should be as follows, because <code>height &lt; 5 &amp;&amp; height &gt; 120</code> will return false.</p> <pre><code>if (height &gt; 5 &amp;&amp; height &lt; 120) { Console.WriteLine("The height entered must be between 5” and 120” inclusive."); } </code>...
variable in bat file not being read <p>I have a .bat file which contains the following command:</p> <pre><code>set /p Param=&lt;foo.ext START "test" /wait "C:\Program Files\blabla\bla.exe" -flag1 -flag2 %Param% </code></pre> <p>Param is the file to be opened by bla.exe. When I run the .bat, bla.exe opens, but it does...
<p>get rid of the &lt; in the first line.</p> <p>P.S: I am a bot for J03L's chat rooms, i just need 20 rep to be able to be given the permissions.</p>
How would improve this O(n^2 ) string manipulation solution? <p>Write a function that takes in an input of a string and returns the count of tuples. Tuples in the form (x,y) where x = index of 'a', y = index of 'b' and x &lt; y.</p> <p>Examples: For “aab” the answer is two For "ababab" the answer is six</p> <p>I...
<p>The idea is to store the amount of 'a's that we have behind the <strong>ith</strong> position in the string.</p> <pre><code>int main() { string ss; ss = "ababab"; int NumberOfAs = 0; //The amount of A that we have encountered int Answer = 0; //The sum of the possible tuples int StringLen ...
Best path to have a masters degree in computer science? (Canada, Quebec) <p>I was wondering what could be the best path to be a have a computer science master's degree as I want to be a game developer, I'm currently in grade 10 and I'm taking advanced math and science, getting fairly good grades but I dont know what I ...
<p>I think a degree in Computer Science is very valuable, but because it is in such high demand right now, it may be a better option to do a few internships while in college and get hired by a company right after you get your BS. A masters would be useful, however, if you plan on getting a job as a "senior software eng...
AngularJS - Passing variable to controller <p>I need to send a parameter to the controller</p> <pre><code>function config($routeProvider, $locationProvider) { $routeProvider .when('/url-1', { parameter: 1 }) .when('/url-2', { parameter: 2 }) .othe...
<p>This would be good way to define route, suppose if you have 100 routes then the rout definition would get increased to that number. Rather that multiple routes have single generic route.</p> <p>And assign a controller to the route where you can access $routeParams API to get parameters available in route.</p> <p>C...
Scrapy Xpath with text() contains <p>I'm using scrapy, and I'm trying to look for a span that contains a specific text. I have:</p> <pre><code>response.selector.xpath('//*[@class="ParamText"]/span/node()') </code></pre> <p>which returns:</p> <pre><code>&lt;Selector xpath='//*[@class="ParamText"]/span/text()' data=u'...
<p><code>contains()</code> can not evaluate multiple nodes at once :</p> <pre><code>/span[contains(text(),"STODOLINK")] </code></pre> <p>So, in case there are multiple text nodes within the <code>span</code>, and <code>"STODOLINK"</code> isn't located in <em>the first text node child of the <code>span</code></em>, th...
POST method does not display but GET method does <p>My <code>POST</code> method does not display on the webpage, but my <code>GET</code> method does even though I haven't create a method with it in my global.js. Does the <code>GET</code> method come with <code>POST</code>? I want my <code>POST</code> to display not <co...
<p>Your GET method is work because you used onclick with <code>location.href</code> method .That will always redirected with GET method so it can display your output ! But to work with <code>POST method in ajax</code> you need to remove onclick method and append return data to body element . </p> <p><strong>Button.php...
Add values in Array based on other multiple values then regroup <p>I have this data:</p> <pre><code>var data = [ [1, "San Miguel National Central High School", "School", 1], [1, "San Miguel Central Elementary School", "School", 2], [2, "Medrano's Rice Mill and Warehouse", "Warehouse", 3], [1, "Unknown", "Resid...
<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 input = [ [1, "San Miguel National Central High School", "School", 1], [1, "San Miguel Central Elementary School", "Scho...
IFS and INDEX/ MATCH EXCEL COUNTERPART IN SQL QUERY <p>My table looks like this</p> <pre><code>NAME BRAND REFERENCE COMMENTS &lt;-Expected output ------------------------------------------------- Gu Skirt 101128 Pants Cci Pants 101127 Pants Cha Skirt...
<p>You can use common table expressions to break down the problem which can help with maintaining the code.</p> <p>I didn't use lag/lead because you only have two rows in the pair, so numbering the rows and joining the table to itself felt quicker and easier to follow.</p> <p>Here's the code I've used to answer and t...
Python - KeyboardInterrupt or RuntimeError implementation <p>New to python and programming. I have a program consist of several classes, module and functions. the program runs from a main class which calls several modules and function</p> <p>My question is how to implement keyboardinterrupt if the user wants to termin...
<p>You could do something like :</p> <pre><code>try: ... except KeyboardInterrupt: Do something </code></pre>
Check if the first letter of each element of an array is capital using filter method. But I keep getting the whole array <pre><code>// JavaScript Document "use strict"; var testArray =["beau","Diane","morgan","Brittany"]; function checkCapital(value,index,array) { if(value!==value.charAt(0).toLowerCase()) retur...
<p>The <code>filter()</code> method depends on the <code>return</code> statement of the callback, which if returns <code>true</code> then <code>filter()</code> will include the current value to the array it will return. Just remove your <code>if</code> statement and put the condition on the <code>return</code> statemen...
In Handsontable How do you save records with specific ids each row? <p>I have this set of records object-array like for example.. </p> <p><code>[{firstname:'John',lastname:'Smith'},{firstname:'Jimmy',lastname:'Morre'}]</code></p> <p>What I want to do is to enable Saving feature of Handsontable. My problem is I can't ...
<p>I am not sure to understand what you want.</p> <p>But in this <a href="http://jsfiddle.net/am5dmmbt/" rel="nofollow">JSFiddle</a> you can see how to get the property of your data ;)</p> <pre><code>var datas = hot.getData() $.each(datas, function(rowIndex, row) { console.log('The row id is ' + rowIndex); $.ea...
php url string converts "&section=" to "§ion", which does not yield cURL response <p>I save a php string as $url = "<a href="http://example.com/index.php?q=board/ajax_" rel="nofollow">http://example.com/index.php?q=board/ajax_</a><strong>call&amp;section</strong>=get_messages";</p> <p>The url when printed to screen ...
<h1>Your Problem</h1> <p>The problem is that <code>&amp;sect</code> is interpreted by the browser as the <a href="https://dev.w3.org/html5/html-author/charref" rel="nofollow">HTML entity</a> for <code>§</code>.<sup>*</sup> So, <code>&amp;section</code> displays as <code>§ion</code>.</p> <h1>The Solution</h1> <p>If...
Best Way to Implement an Intro Sequence? Swift <p>I'm trying to add an intro sequence to my code so that if it's the first time the app is opened, the user can enter some basic information (which I can then store in UserDefaults).</p> <p>The way that I was thinking of doing this is by having a variable called <code>is...
<p>You can achieve it easily. This is code which I have used for it.</p> <p><strong>Step 1</strong> First create a file called UserDefaultManager.swift</p> <pre><code>import UIKit // User Defaults Manager Constants let kIsFirstTimeLaunch = "IsFirstTimeLaunch" class UserDefaultsManager: NSObject { // MARK: Setter M...
Getting SignalR IConnectionManager GetHubContext working in Startup.cs in aspnet core <p>I can't seem to the following code working. All I'm doing is in <code>ConfigureServies</code> calling <code>_serviceProvider.GetService&lt;IConnectionManager&gt;();</code> and saving it in a static field and trying to use it later ...
<p>1st thing is to realize this version of SignalR isn't shipping, it's just alpha. The problem you're having is because you're building 2 service providers and they're not talking to each other. You call <code>BuildServiceProvider()</code> instead of injecting the <code>IConnectionManager</code> into your Configure me...
How to load the embeded video only after some click-event was triggered. jQuery <p>What I have now satisfies me in terms of an overall effect: Click on "show me", it displays an YT Video, when clicked once again - vid will hide etc. BUT even when site is loaded in the first place (and YT video is hidden) - all of its (...
<p>Try something like this:</p> <p>HTML:</p> <pre><code>&lt;div class="#"&gt; &lt;a href="#" id="show_me"&gt;&lt;i class="icon fa-angle-down"&gt;&lt;/i&gt;Show Me&lt;/a&gt; &lt;div id="i_frame"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>JS:</p> <pre><code>$(document).ready(function(){ $("#show_me").c...
How to resolve scala.MatchError when creating a Data Frame <p>I have text file which has complex structured row. I am using customer converter which converts the given string(line) to Pojo class(countryInfo). After converting, I am building DF. The POJO class has a field which is a List of Custome Type(GlobalizedPlayTi...
<p>OK - to cut the long discussion short, here's a working solution. Basically you had two separate issues here:</p> <ol> <li><p>You expected Spark to be able to parse an arbitrary Java class into a DataFrame - that is not the case, Spark can only parse specific types, which are generally: Scala collections; Primitive...
Using loops within CSV export - Ruby <p>I'm trying to DRY up my code and wondering if many people have experience with CSV's and ruby.</p> <p>My code is below. It works just... Its awful. </p> <p>I'm wondering if anyone has any ideas on how I could do the following:</p> <p>1 - How could I use a loop rather than expl...
<p>How's this?</p> <pre><code>... job.employer.account_type, 'null', 'null', *1.upto(10).flat_map {|i| jq = job.job_questions[i] [jq[:question], jq[:knockout], jq[:correct_answer]] } ... </code></pre>
c++ parsing data from file I/O <p>I am writing code to 1. read in from a file via command line argument, 2. parse through each line of data (string) and 3. split the data into 4 substrings.</p> <p>say I have game.txt</p> <pre><code>3 overwatch|hanzo|junkrat|reinhart league of legends|vayne|ezreal|master yi starcraft|...
<p>You can use <a href="http://www.cplusplus.com/reference/fstream/ifstream/" rel="nofollow">ifstream</a> to read first number and <a href="http://en.cppreference.com/w/cpp/io/basic_istream/getline" rel="nofollow">lines</a> from file. For getting data from the any line, you can use <a href="http://www.cplusplus.com/ref...
STM32 SPI hardware and strict aliasing warnings <p>I've seen that the subject has been discussed in many other questions, but I can't quite find the answer for my particular case.</p> <p>I am working with a STM32F0 microcontroller. The top of the SPI reception/transmit FIFO are accessible by a memory access. This part...
<p>I would suggest creating two specific pointers for the job. You can create them during initialisation or statically so you don't have to create them each time.</p> <pre><code>static uint8_t * const DR_Byte = (uint8_t * const)&amp;_handle-&gt;Instance-&gt;DR; static uint16_t * const DR_Word = (uint16_t * const)&amp;...
When I click Element A, I want to change text of Element B <p>The idea is that when I click on h1.question, the string in h1.answer will change to the string in h1.question's data-text-swap. For example, if I click "What is wrong with you?", I should see the answer "Nothing" at h1.answer.</p> <p>I've tried using .text...
<p>you are binding the click handler on all h1 with class 'question', so if you just reference the clicked element dynamically, you end up with a (almost) one-liner:</p> <pre><code>$('h1.question').on('click', function() { $('h1.answer').text($(this).attr('data-text-swap')); }); </code></pre> <p>no need to write ...
Updating List<> used in xaml and reload frame <p>So i have an XML file that i load data into a List&lt;> from. That means that i have a main list that contains all the data i need.</p> <p>From that list i the create variable "sub" lists that i then will use to present data, as needed.</p> <p>My main window (as for no...
<p>One simple way to solve this problem would be to enable the <code>NavigationCacheMode</code> for Page1.</p> <p>This caches the state of page1 and shows the old state when reopening the page. Just remember that you cannot empty the cache once the page is initialized. Also the <code>NavigationCacheMode</code> must be...
How do I make powershell stop showing this message whenever I push <p>How do I make powershell stop showing the below message:</p> <blockquote> <p>github --credentials get: github: command not found</p> </blockquote> <p>This occurs whenever I try to <code>ssh</code> for <code>git push</code> or <code>git pull</code...
<p>Check you git remote -v: it you see https, it is not an ssh url.<br> Make sure push or pull are using an ssh url with:</p> <pre><code>git remote set-url origin git@github.com:username/repo.git </code></pre> <p>If you are using https, Git will try and use a credential helper: see if <code>git config -l | grep cred<...
why does the c value gets repeated in the given code? <p>1.This is my code to convert binary to decimal but its not working.The c value gets repeated for some reasons.</p> <pre><code>/** * Created by Ranjan Yadav on 11.10.2016. */ public class BinaryToDecimal { public static void main(String[] args) { ja...
<p>You were <strong>increasing n by 1</strong> and <strong>dividing binary by 10 raised to n</strong> at same time. Due to this, you were not able to fetch the unit's digit of binary number after 1st iteration. To solve this issue, you need to get binary modulo 10 (not 10 raised to n) in each iteration and also keep th...
Is there a simple method to get properties for all keys in javascript object? <p>So I've created this JS code to get a map where every word in a string is the key and the amount of times that word appears is the value.</p> <pre><code>var txtArray = txtVar.split(" "); var txtMap = {}; for (var i = 0; i&lt;txtArray.leng...
<p>It's probably an adequate approach to do as you're currently doing, then sorting/slicing those results when you're done:</p> <pre><code>var allWords = Object.keys(txtMap); var tenMostFrequent = allWords .sort((a, b) =&gt; txtMap[b] - txtMap[a]) .slice(0, 10); var longestWords = allWords .sort((a, b) =&gt; b.l...
Ruby 100 doors returning 100 nil <p>I'm solving the <a href="https://www.rosettacode.org/wiki/100_doors" rel="nofollow">'100 doors' problem from Rosetta Code</a> in Ruby. Briefly,</p> <ul> <li>there are 100 doors, all closed, designated 1 to 100</li> <li>100 passes are made, designated 1 to 100</li> <li>on the ith pas...
<p>That's what your <code>if</code> clauses return. Just add a return value explicitly.</p> <pre><code>until visit_number == 100 do door_array = door_array.map.with_index { |door_status, door_index| if (door_index + 1) % (visit_number + 1) == 0 if door_status == "closed" door_status = "open" ...
User input within functions, can I make it 'global'? <p>The best way I can phrase this question = <em>'Can I use a 'programmer' defined function to grab user input, and then use that input within another user defined function?'</em></p> <p>Background info:</p> <pre><code> 1. Python 3.x please 2. I understand f...
<p>Declare the variable <code>global</code> inside the function</p> <pre><code>&gt;&gt;&gt; def func(max_input): global list1 list1=[] for i in range(max_input): list1.append(input('enter item and press enter')) return list1 #Optional </code></pre> <p><strong>Output</st...
Why are constants not defined when using p5.js in instance mode? <p>I'm probably missing something very obvious here. I can use p5.js in global mode and use constants for textAlign with no problem, e.g. CENTER.</p> <p>Here is global mode code where it works fine:</p> <pre><code>function setup() { var canvas = creat...
<p>In global mode, all the P5.js functions <strong>and variables</strong> are added to the global namespace. In instance mode, all the P5.js functions <strong>and variables</strong> are added to the variable passed into the sketch function (in your case, your <code>p</code> variable).</p> <p>To use the <code>CENTER</c...
AngularJS cannot insert data to phpMyadmin (mySql) <p>I'm new for AngularJS but it seems like I can't insert any data to my database. I have followed few instructions but seem likes it doesn't work. When I click on submit button, nothing happen and no data has inserted to my database. Please help.</p> <p>Thanks a lot ...
<p>Turn on error reporting or take a look at server log. You are obviously missing a comma in <code>INSERT</code> statement between <code>fName</code> and <code>lName</code>.</p>
SQLite: How to combine SQL of order limit with left join queries <p>I have a record of A, B, C and D.</p> <p>My SQL1 <code>SELECT * FROM main_table order by main_table.date desc limit 2</code> returns A and B.</p> <p>My SQL2 <code>SELECT * FROM main_table left join sub_table using (key) where sub_table._id is not nul...
<p>If I read correctly, then a <code>UNION</code> might be what you have in mind:</p> <pre><code>SELECT * FROM (SELECT * FROM main_table LEFT JOIN sub_table USING (key) ORDER BY date DESC LIMIT 2) UNION SELECT * FROM main_table LEFT JOIN sub_table USING (key) WHERE sub_table._id IS NOT NULL </code></pre...
Type of expression is ambiguous without more context in Swift 3 <p>I am trying to learn Swift and am going through a tutorial on push notifications.</p> <pre><code>let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge , .Sound], categories: nil) </code></pre> <p>Is giving me the error</p> <blockquote> ...
<p>Look at the documentation for <code>UIUserNotificationSettings</code>. Its signature has changed in Swift 3 as has the values for the types.</p> <p>You need:</p> <pre><code>let settings = UIUserNotificationSettings(types: [.alert, .badge , .sound], categories: nil) </code></pre> <p>Of course if you are only suppo...
:hover not working on div, working on other parts of page <p>My hover class is not working on my button div however it is working on other parts of my webpage including ones using the absolute position. </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="s...
<p>Please check : why do you have in your <code>.designCard</code> attr <code>z-index: -1</code>. This causes that your body element is <code>higher</code> then your card and because of this your hover is never "called"</p>
How to extract digits from a sentence in java? <pre><code>[{"id":1475280000,"high":0.01384629,"low":0.01155011,"area":13251.43990321,"quoteVolume":1073925.2309893,"averagevolume":0.01233925},{"id":1475366400,"high":0.0139987,"low":0.0119,"area":7535.00823446,"quoteVolume":573093.11152305,"averagevolume":0.01314796}] </...
<p>You can deserialize the json object wrapping the values in a Java object using jackson fasterxml and ObjectMapper:</p> <pre class="lang-java prettyprint-override"><code>class Values{ //With getters and setters int id; double area; double averageVolume; //Rest of the values in the json string } </code></pr...
Unexpected value when counting the number of words in a textbox <pre><code>$scope.cal = function (){ var totalItems = stringSplit($scope.eatables); $scope.value = totalItems; if(totalItems == 0){ $scope.message = "Please enter something"; }else if(totalItems &lt;= 3){ $scope.message = "E...
<p>How about this?</p> <pre><code>function stringSplit(string){ var array = string.split(" "); var x = array.length; return (array[i] === "" || array[i] === null || array[i] === undefined) ? 0 : x; //Check whether first element is empty }; </code></pre>
Fetch words in a sentence <p>I have string - <code>My name is "foo bar" I live in New York</code></p> <p>Now I want to split it to an array but words in double quotes should be considered as one.</p> <p>I have tried <code>input.split(' ')</code> but need some help how to handle strings inside double quotes.</p> <p>I...
<p>Something along the lines of</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 str = 'My name is "foo bar" I live in New York'; console.log(str.split(/ |(".*?")/).filt...
Make an object that behaves like a slice <p>How can we make a class represent itself as a slice when appropriate?</p> <p>This didn't work:</p> <pre><code>class MyThing(object): def __init__(self, start, stop, otherstuff): self.start = start self.stop = stop self.otherstuff = otherstuff ...
<p>TLDR: It's impossible to make custom classes replace <code>slice</code> for builtins types such as <code>list</code> and <code>tuple</code>.</p> <hr> <p>The <code>__index__</code> method exists purely to provide an <em>index</em>, which is by definition an integer in python (see <a href="https://docs.python.org/3....
After uprading to SupportMapFragment do you need a new google api map key? <p>My release build doesn't recognize my v2 google map api key. It works fine with a debug package name and corresponding debug key. I know the key and package name have to match. Is a new key required when upgrading to SupportMapFragment ?<...
<p>There no relation between key and SupportMapFragment. Generate SHA for release key store and generate new API key from that. Then use that new API key within the app.</p>
any logs/steps to debug azure stream analytics job available? <p>Referring to the below link <a href="https://blogs.msdn.microsoft.com/streamanalytics/2016/04/18/troubleshooting-azure-stream-analytics-jobs-on-new-portal-2/" rel="nofollow">https://blogs.msdn.microsoft.com/streamanalytics/2016/04/18/troubleshooting-azure...
<p>When using the classic portal, go to the Stream Analytics Job , tabpage "Dashboard" and look for the link to "Operation Logs" near the bottom right.</p> <p>In the new portal, go to the Stream Analytics Job and open the Activity log (second item of the menu, just below "Overview")</p>
Access Storyboard from embedded project <p>I have got two projects <strong>ProjectA</strong> and <strong>ProjectB</strong>, where <strong>ProjectA</strong> is the main project and <strong>ProjectB</strong> is embedded into <strong>ProjectA</strong>.</p> <p>When I try to access the storyboard of <strong>ProjectB</stron...
<p>Try to save "Storyboard B" into Project A. Simply drag the storyboard into the Projact A's folder. Make sure to set in the App's overview the right storyboard as main.</p> <hr> <p>If this don't work, try to save the storyboard within the Finder, copy the storyboard from Project B and paste it into Project A>base.l...
Calling an instance method using autowired bean <p>I have three classes (Class <strong>A</strong>, Class <strong>B</strong>, Class <strong>C</strong>) in my application. </p> <p>I'm a spring beginner. Trying to inject a bean of Class <strong>B</strong> to use in Class <strong>A</strong> using <code>@Autowired</code> a...
<p>Spring singleton is defined as "per container per bean"</p> <p>If you want singleton per spring container below is what needs to be done in your bean definition</p> <pre><code>&lt;bean id="myBean" class="MyBean"/&gt; </code></pre> <p>If you want the singleton per entire application and not per container, then I b...
Why does $(this) work differently depending on how callback is created? <p>I'm trying to display a table and cause certain actions to take place if the user clicks on a cell in the table. My Javascript (using jquery-3.1.1.min) looks like this:</p> <pre><code> $(function() { function tdHeader(key) { ...
<p>jQuery calls the callback you pass to <code>click</code> in the context of the element the event belongs to. So for <code>$(".mytable-cell").click(clickHandler);</code> the <code>clickHandler</code> is called in the context of the given DOM element.</p> <p>For <code>$(".mytable-cell").click(function() {clickHandler...
Login into laravel 5.2 from other domain <p>I have a project with <strong>laravel 5.2</strong>. There is <strong>another system in .net</strong>. What I want is to get <strong>login into laravel 5.2 from .net system</strong>. For that, I'm <strong>making ajax call</strong> from .net app to laravel app. But laravel app ...
<p>If you need to send more information with javascript try this</p> <pre><code> jQuery.support.cors = true; $.ajax({ url: 'http://192.168.1.78/myproject/login', type: 'POST', dataType: dataType, data: data, crossDomain: true, cotentType: YOUR_CONTENT_TYPE, ...
Recycle-view inflating different row :- Getting exception while binding the data <p><br> I am working on the <code>Recyceview</code> with different item inflation. When i am <strong>NOT</strong> binding the data on <code>onBindViewHolder</code> method of <code>RecycleView</code> than it Does not crash..<br> But when i ...
<p>The reason is<code>onCreateViewHolder(ViewGroup parent, int viewType)</code>. The parameter is view type but not position. Using <code>int listViewItemType = getItemViewType(viewType)</code> is incorrect because <code>position</code> should be passed to <code>getItemViewType</code>.</p> <p>In short, you should use ...
Querying with joins & filters in Mongoose <p>I'm new to Mongodb &amp; using it in web application that I'm building using MEAN stack. My goal is to query two tables by joining them and applying a filter condition on them. For eg: I have two tables - Bike-BikeID,Registration No.,Make,Model &amp; Appointment - Appointmen...
<p>You were almost there, you just needed the right <strong><a href="https://docs.mongodb.com/manual/reference/operator/aggregation/match/" rel="nofollow"><code>$match</code></a></strong> query which follows:</p> <pre><code>ubBike.aggregate([ { "$match": { "cust": req.query._id } }, { "$lookup": { ...
Order by same as where in condtion <p>How can i order records same as <code>where I.ItemCode in ()</code> sequence</p> <p><strong>(sort by order of values in a select statement in clause)</strong></p> <p><strong>Query</strong> </p> <pre><code>SELECT I.ItemCode,I.ItemName,UM.Name As Unit, SUM(CASE WHEN Rs.Rest...
<p>You need to explicitly hard code the ordering in <code>Order by</code> no other way </p> <pre><code>Order by Case ItemCode when 355 then 0 when 365 then 1 when 360 then 2 when 275 then 3 .. wh...
Changing Scale of Sprite with SKAction.scale <p>Trying to have the scale of the sprite 'PlayButton' continue to scale up and down to hint to the user to touch it. Can't seem to get it working. </p> <p>This is the Menu Class:</p> <pre><code>import SpriteKit class MenuScene: SKScene { let ScalePBup = SKAction.scaleX(...
<p>In <strong>MenuScene</strong> remove the code:</p> <pre><code>run(SKAction.repeatForever(SKAction.sequence([ SKAction.run(ScalePBup, onChildWithName: "playButton"), SKAction.run(ScalePBdown, onChildWithName: "playButton") ]) )) </code></pre> <p>in <strong>class PlayButton</strong> add:<...
Source of event (SCREEN_ON) <p>I have such problem: My application subscribed on the Intent.SCREEN_ON event, but in some cases it make wrong effect. How I can detect - SCREEN_ON has been caused by button (user has pressed the power button), or any other (alarm, incoming call, notification from whatsapp)? Is it possible...
<p>No. It's not possible.</p> <p>At the heart of every broadcasts is an <code>Intent</code>. If such feat is possible then we should see the required information somewhere within them.</p> <p>But if you take a look at <code>Intent</code>'s soucre, these are the only fields defined:</p> <pre><code> private String ...
error when implementing eccjs library <p>I am trying to implement this <code>ecc</code> library of NodeJS, <a href="https://github.com/jpillora/eccjs" rel="nofollow">https://github.com/jpillora/eccjs</a>.</p> <p>The file that I am trying to run is,</p> <pre><code>https://github.com/jpillora/eccjs/blob/gh-pages/exampl...
<p>You need to import the <code>generate</code> method from where its coming from in the js file. </p> <p>Add an import statement to the to of the file pointing to the module supporting this generate method. </p> <p>Looking at the file, this is currently commented out: </p> <pre><code>// var ecc = require('../dist/0...
Convert if else structure into switch case in swift <p>I am pretty new in programming, I am trying to convert this if else structure into Switch cases in Swift language, i appreciate your help, thanks.</p> <p>here is my code</p> <pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { ...
<p>Something like this:</p> <pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if (segue.identifier == "ShowDefinition") { if let destinationViewController = segue.destinationViewController as? EnglishViewController { if let definition = sender as? String {...
Convert LINQ with Model To Array <p>I'm trying to create a LINQ to get the records in Personnel table that exist in Users table. Here's the tutorial I'm currently following: <a href="http://docs.telerik.com/data-access/feature-reference/api/linq-guide/data-access-tasks-querying-model-convert-result-to-array" rel="nofol...
<p>Contains is awaiting for UserModel instance to be passed, that's why you get error. Just use .Any() instead:</p> <pre><code>var matches = from p in db.PERSONNEL_MSTR where userList.Any(u=&gt; u.ID == p.EMP_ID) select p; </code></pre> <p>What it does here is: If p.EMP_ID is found inside user...
npm ionic install error in node.js <p>I'm quite upset by the day. Give me best solution.</p> <p>Your environment has been set up for using Node.js 0.10.38 (x64) and npm.</p> <pre><code>C:\Users\ASAR-KSS&gt;npm install -g ionic npm ERR! network getaddrinfo ENOTFOUND npm ERR! network This is most likely not a problem w...
<p>Update npm to the <a href="https://docs.npmjs.com/getting-started/installing-node" rel="nofollow">latest version</a>. Try again. Seems that it can't find the package, or you're using an outdated npm version. </p> <p>If that doesn't work, check whether you're sitting behind a proxy or make sure you've not configured...
How to minimize the Size of Xamarin android app <p>How to i minimize the size of a Xamarin android app.Unlike the android studio version,Xamarin apps tend to take more space. I would be glad for the help. thanks</p>
<p>Xamarin apps take more space only in Debug mode, if you try build your application in Release mode then linker deletes all unnecessary libraries from build.</p>
Best way to make fixed div to bottom or top depending on the position? Example inside <p>I'm in trouble. What a best way to make left block fixed like that <a href="http://gph.is/2e2oh46" rel="nofollow">http://gph.is/2e2oh46</a></p> <p>My current code</p> <pre><code>var lastSt = 0; var windowHeight = $(window).height...
<p>There are a lot of examples arround the WWW.</p> <p>Please visit this page <a href="https://css-tricks.com/scrollfollow-sidebar/" rel="nofollow">https://css-tricks.com/scrollfollow-sidebar/</a></p>
generate document and then zip with php <p>I have an issue. I have an index.php with several checkboxes. Every checkbox represents a piece of code. I am trying to create some generating tool. For example: if I select four checkboxes, I want that four specific parts of code to generate in one php file, then zip it and ...
<p>Copied from comments:</p> <p>Read the files yourself using <code>file_get_contents</code>, concatenate using <code>+</code>, write to zip with <code>ZipArchive::addFromString</code>.</p>
Laravel not sending from address <p>I want to send Email to my Email when a user views a page.<br> I done it successfully.</p> <p>My code looks like this:</p> <pre><code>Route::any('contact_us/send', function() { return Mail::send('contactus.send', ['name' =&gt; 'Advaith'], function($message) { $name = $_...
<p>This problem is not a Laravel issue. You said in a comment, that it is written that you sent the email to yourself. This is due to the fact that gmail does not allow to use random from addresses, to prevent spamming. </p> <p>You have to register alternate addresses before you can use them as your "from address" , o...
White border on both sides of the image <p><p>I'm trying to load my my image to a custom view but after loading im getting withite border on both sides.</p><a href="http://i.stack.imgur.com/1NWXs.png" rel="nofollow"><img src="http://i.stack.imgur.com/1NWXs.png" alt="enter image description here"></a></p> <p>My custom ...
<p>It is not exactly a white border, the image you are setting in your custom view is not of exactly the same size as your <code>MyCanvas</code> view. You will need to scale or crop your image if you want it to take up all the space without leaving any empty spaces around.</p> <p>Try adding <code>android:scaleType="fi...
Object oriented jQuery/JavaScript <h3>Description</h3> <p>All of my jQuery code works well on my website and I don't have any issues. However, I think that it would be a good idea to rewrite all the code in a more object oriented manner, so that it's reusable.</p> <p>As I don't have any experience in jQuery/JavaScrip...
<p>This question is a bit broad. That said, I'll share the approach I use.</p> <p><strong>Note</strong> I got this from <a href="http://ejohn.org/blog/simple-javascript-inheritance/" rel="nofollow">John Resig's Simple JavaScript Inheritance</a></p> <p>See also <a href="http://blog.buymeasoda.com/understanding-john-re...
C++ second counter <p>I have created a function which counts seconds, after the choice of a user. It all works, but can it be done smarter and more efficient? Because it seems very heavy and slow. Is there a lib that solves this problem? Or how can we get around it?</p> <p>Here is my code:</p> <pre><code>#include &lt...
<p>You can measure time using the library <code>&lt;chrono&gt;</code> (since <code>c++11</code>) <br></p> <p>Example:</p> <pre><code>#include &lt;iostream&gt; #include &lt;chrono&gt; using namespace std; using namespace chrono; int main() { auto start = high_resolution_clock::now(); // your code here a...
angular2 select disable first element <p>I have a select component like this: </p> <pre><code>&lt;select name="typeSelection" materialize="material_select" [(ngModel)]="trainingplan.type" &gt; &lt;option [ngValue] = "null" disabled selected&gt;Please choose a type&lt;/option&gt; &lt;option [ngValue]="type...
<p>Your <code>trainingplan.type</code> would need to be set to <code>null</code> but as far as I know <code>[ngValue]</code> with null will only work after the next update.</p> <p>You would need to choose a different value for the first option and set <code>trainingplan.type</code> to this value. You can remove the <c...
My second spinner adapter not updated after my first spinner position has changed <p>I have two spinner, the first spinner is related to the second spinner.</p> <p>I'm using JSON to fill the adapter for both of them.</p> <p>When i start the activity, both of adapter is already filled with a correct data(the first and...
<p>It's solved, the problem is because i put the JSONObject and JSONArray into the same variable "result".</p> <p>So here's the right code :</p> <pre><code>spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected (AdapterView &lt; ? &gt; parent, View vi...
Ruby .ceil and .floor <p>I'm new to Ruby and I'm trying to figure out how <code>ceil</code> and <code>floor</code> works as I get different answers when a fraction or a decimal number is used (similar value). Below is what I have tried:</p> <pre><code>puts 8/3.ceil == 2 puts 8/3.floor == 2 puts 2.67.ceil == 2 puts 2.6...
<p>Everything is returned correctly.</p> <pre><code>puts 8/3.ceil == 2 #=&gt; true, because 8/3 returns an Integer, 2 puts 8/3.floor == 2 #=&gt; true, because 8/3 returns an Integer, 2 puts 2.67.ceil == 2 #=&gt; false, because 2.67.ceil is 3 puts 2.67.floor == 2 #=&gt; true, because true :) </code></pre> <p>To make t...
AngularJS drop-down with ability to type value <p>We're using AngularJS v1.5.8 in our application. I am looking for a way to display drop down but also allow to type new value. I've checked this <a href="http://stackoverflow.com/questions/4430262/manually-type-in-a-value-in-a-select-drop-down-html-list">Manually type i...
<p>Try this. We use our version of this, but it's very close to <a href="https://github.com/angular-ui/ui-select2" rel="nofollow" title="this solution">this solution.</a></p>
Regex for matching string, contains only number and count must be 2 min values <p>Is there any regex for validating length of a number string for 2 consecutive digits or number </p> <p>Example : </p> <pre><code>"12541256442545245215" = Count (20) "125412564425452452"= Count (18) </code></pre> <p>Need a regex to chec...
<p>You can use this regex:</p> <pre><code>^[0-9.]{18}(?:[0-9.]{2})?$ </code></pre> <p>About this regex:</p> <pre><code>^ # start [0-9.]{18} # match digit or DOT 18 times (?: # start non-capturing group [0-9.]{2} # match digit or DOT 2 times )? # end non-capturing group, ? makes thi...
How to auto-increase the height of a FAQ with 2 Main Themes? <p>I have a FAQ in my site with 2 MAIN THEMES..</p> <p>I create a jsfiddle here: <a href="https://jsfiddle.net/kuwr2vhn/" rel="nofollow">https://jsfiddle.net/kuwr2vhn/</a></p> <p>MY ISSUE:</p> <p>FAQ B - is working OK - but FAQ A - isn't.</p> <p>Both FAQ ...
<p>You are doing it wrong. It won't be dynamic because your answer is also a li and doesn't have its own parent. Here's way of making it dynamic.</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 prettyp...
Array of objects and instance of object in each row in C# <p>In an array of objects, why do we have to initialize each object in the array?.... see when an array of a class is made why should i instantiate all the members of the array. is it not kind of pointless or repetetive to again instantiate it again. yes it was...
<p>An array is simply a collection of references.</p> <p>For example, the following snippet:</p> <pre><code>Label[] labels = new Label[5]; </code></pre> <p>Declares an array of five <code>Label</code> references. It doesn't actually create the labels themselves. Those five references point to nothing. It's the sa...
Blue "Default" line in a listview - where is it coming from? <p>Can someone please explain to me, what does this line mean, where is it coming from and how do I take it away? Thanks. <a href="http://i.stack.imgur.com/YqoZo.png" rel="nofollow"><img src="http://i.stack.imgur.com/YqoZo.png" alt="enter image description h...
<p>The item you have added does not belong to a <code>Group</code>, and so is added to the default group.</p> <p>By defining a list of groups for your <code>ListView</code>, you can control what group each item comes under.</p> <p>You can modify these values in the Form Builder or in code. Try setting your <code>Lis...
iterating array on refresh <p>How could I go about writing a snippet, that could iterate through array on refresh? Say I have an array with banner links, and I'd like the banner to change to next one when refreshed. There is a lot of solutions to make it random, but I want it to loop through array in order, and go to ...
<p>Use <a href="https://developer.mozilla.org/en/docs/Web/API/Window/localStorage" rel="nofollow"><code>localStorage</code></a> like so:</p> <pre><code>var banner = new Array(); banner[0] = "http://placehold.it/728x90?text=one"; banner[1] = "http://placehold.it/728x90?text=two"; banner[2] = "http://placehold.it/728x90...
MVC: Serve file with http header <p>I am trying to follow <a href="https://documentation.onesignal.com/docs/web-push-sdk-setup-https#section-can-manifest-json-onesignalsdkworker-js-and-onesignalsdkupdaterworker-js-be-served-from-a-subfolder-of-my-site-" rel="nofollow">this</a> guide and store files in a sub-folder. </p...
<p>You can use in your controller's action : </p> <pre><code>this.Response.Headers.Add("Service-Worker-Allowed","/"); </code></pre> <p>Hope this help :-)</p> <p>Edit : A better way to do this is to create an action filter to automatically add this header : </p> <pre><code>public class WorkerAllowedAttribute : Acti...
checking number modulo 1 <p>I saw the following: <code>if (n % 1 || n &lt; 2) ...</code> in some <a href="https://gist.github.com/ehsanamini/d6f3c3709841a2dab94fda4758d07e8f" rel="nofollow" title="github gist">code</a>.</p> <p>The question is what good is the test <code>n % 1</code>? I presume it is (false)0 for all n...
<p>in javascript all numbers are <code>float</code>s so <code>n%1</code> returns remainder of <code>n/1</code> so it returns the fractional part of <code>n</code> something like <code>n-floor(n)</code> for positive <code>n</code>. So:</p> <pre><code>if (n % 1 || n &lt; 2) </code></pre> <p>should select all fractional...
No benefit of using AsParallel in C#? <p>Here is my sample project:</p> <pre><code> Console.WriteLine("Elapsed time in milliseconds:"); swSingle.Start(); var numbers2 = Enumerable.Range(0, 100000000); var singleResult = numbers2 .Where(i =&gt; i % 2 == 0) .ToArra...
<p>It simply takes more time to make your code run in parallel (create a task, schedule and run it) than the advantage you gain by executing that code in parallel.</p> <p>That said, this makes very clear not every piece of code benefits of running in parallel. You can only use it on substantial code segment with a hig...