input
stringlengths
51
42.3k
output
stringlengths
18
55k
What is the size of the structure in this code below assuming that we have structure padding and size of int is 4 and size of double is 8 bytes <p>Can anyone please tell me how come the size of the structure shown below is 24 and not 20.</p> <pre><code>typedef struct { double d; // this would be 8 bytes char ...
<p>Size would be <code>24</code>. It is because <strong>the last member is padded with the number of bytes required so that the total size of the structure should be a multiple of the largest alignment</strong> of any structure member. </p> <p>So padding would be like </p> <pre><code>typedef struct { double d;...
Java program keeps throwing up an error while compiling <pre><code>EyeColour.java:27: error: cannot find symbol Scanner input = scanner(System.in); ^ symbol: method scanner(InputStream) location: class EyeColour 1 error </code></pre> <p>I keep getting this ^^ error when trying to compile ...
<p>You are missing the <code>new</code> keyword.<br> Try using this:</p> <pre><code>Scanner scanner = new Scanner(System.in); </code></pre>
I cant store image on firebase if dont connect with wifi? Android <p>I can store image with android phone on firebase, if I connected on WiFi, but if don't connected I can't save image.</p> <pre><code>error sending network request POST https://firebasestorage.googleapis.com/v0/b/pickapp-b9a6b.appspot.com/o?name=f34183...
<p>I'm honestly kind of amazed that you got a <code>405</code> back, since AFAIK, we (GCS) don't return a <code>405</code> (see <a href="https://cloud.google.com/storage/docs/json_api/v1/status-codes" rel="nofollow">GCS error codes</a>). Could this be an issue with a proxy or firewall preventing you from uploading, or ...
When jumping over a declaration, why is trivial destructor required? <p><code>goto</code> or <code>switch</code> can jump over a declaration-statement given that it has no initializer and the construction is trivial — and that the object is also trivially <strong>destructible</strong>.</p> <p>What's the rationale fo...
<p>The current wording is a result of <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2762.htm" rel="nofollow">N2762</a>. The paper gives the following rationale:</p> <blockquote> <p>6.7 stmt.dcl:</p> <p>&nbsp; &nbsp; Jumping over the definition of an automatic variable will pose the problem o...
Elastic Search: parse_exception: failed to parse search source. expected field name but got [START_OBJECT] <p>I'm new in <code>Elastic Search</code> and using ES in my application. When I run simple query on single table on ES then it working file.. But When I'm using nested query then it is not giving me proper result...
<p>Updated answer. Try this. </p> <pre><code>{ "fields" : "_source,_timestamp", "size" : 10, "from" : 0, "query" : { "bool" : { "should" : [{ "wildcard" : { "_all" : "*a*" } }, { "nes...
Whole and fraction to float/double? <p>If I have a signed long variable that holds the whole number part of a decimal and another long variable that holds the fraction part, how would I convert that to a float or double type?</p> <p>The fraction part is scaled to the 9th place.</p> <p>Example: signed long h = -5; lon...
<p>Since the <code>long int</code>, <code>h</code>, representing the fractional part is scaled by 1000,000,000 you just need to divide it by 1000000000 and correct for the sign in the event the integer portion of the pair is negative. That is you add the scaled fractional part when the base number is positive and subtr...
How can I return value from completion block to use it in other viewController? <p>I would like to retrieve a value from <code>queryCompletionBlock</code> and sent it to another <code>viewController</code>.</p> <p>Here is my code:</p> <pre><code>func KcalCloudKitData() { publicDatabase = container.publicCloudData...
<p>It is because the completion <strong>closure</strong> (block is term for Objective-C) was called after the task was finished: e.g. your </p> <pre><code>self.kcalUnitValid.append(...) </code></pre> <p>task is done later than the line</p> <pre><code>print(self.kcalUnitValid) </code></pre> <p>regardless it stands ...
How to solve Missing CURL extension on nginx server? <p>My site is a wordpress platform, hosted with AWS EC2. I have installed a plugin and it said "You'll need to contact your hosting provider and ask them to enable CURL for PHP.". </p> <p>I have checked on my server using "service apache2 status" and "service httpd ...
<p>It's not related with apache or nginx. You need to install the php libcurl package</p> <p>On deb systems you could do it with the following command:</p> <pre><code>sudo apt-get install php-curl </code></pre>
Using transform() and calc() in firefox <p>Am I missing something obvious, or does firefox not like using calc() inside transform:skewY() ?</p> <h1>The problem</h1> <p>the following transform works, no problem :</p> <pre><code>body article { postion:relative; top:50%; transform-origin:left; transform...
<p>There is <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=956573" rel="nofollow">Bug 956573 - calc() CSS function doesn't work with all data types (units) that it should, such as times</a> (from 2014 but still open) in the issue tracker. </p> <p>One comment (also from 2014) has a code snipped with the comment ...
Unable to use command line parser in opencv <p>I have the following code: </p> <pre><code>int main(int argc, char** argv) { cv::CommandLineParser parser(argc, argv, "{eyes||}{nose||}{mouth||}{help h||}"); if (parser.has("help")) { help(); return 0; } input_image_path = p...
<p>There are a couple of mistakes:</p> <ol> <li>you don't specify the positional arguments for <code>input_image_path</code> and <code>face_cascade_path</code> in the <code>parser</code> keys.</li> <li>to use non-positional arguments, you need to use <code>-arg=</code>, e.g.: <code>-eyes=/path/to/eyes.xml</code></li> ...
Completely load a link <p>I am trying to promote an advertiser and when the user clicks on the advertiser link, it redirects 5-6 times through different links (for tracking purposes) before reaching the advertiser's website.</p> <p>Is it possible to show some kind of loading icon on the page on which the user clicks o...
<p>Since it redirects to someone elses website, you cannot change the content of those websites to have a loading icon.</p> <p>You could load it in an iframe and when the iframe has not changed its location in, say, 5 seconds, show the iframe as the whole page and hide the loading icon. You can also set the target to ...
On deep water. add a div with js in a php printed line <p>Maybe I'm way off, but here we go. </p> <pre><code>print '&lt;li '.$class.'&gt;&lt;a id="flodet" href="index.php?artikelid='.$rad["id"].'"&gt;'.$rad["header"].'&lt;/a&gt; &lt;/li&gt;'; </code></pre> <p>This line print links to articles from a database. The cl...
<p>Here is a snippet to play around with. </p> <p>Few suggestions: </p> <ul> <li><code>'&lt;li '.$class.'&gt;</code> - this seems to be wrong ; use the attribute <code>class</code></li> <li>You could select the <code>li</code> using <code>ul &gt; li</code> if needed and can avoid setting class to each <code>li</code...
Calling Sass function from jquery <p>Earlier my question was:-</p> <p>I have the following code in my Sass file</p> <pre><code>.random { box-sizing: content-box; text-align: center; line-height: 1; &amp;:before { display: inline-block; margin-right: 0.2em; width: 0; he...
<p>Changing the style of <code>pseudo</code> elements are <strong>not</strong> possible because <code>:after</code> and <code>:before</code> are not part of the DOM technically. You need to find a work around or use additional classes to achieve this. </p>
JavaFX listView on-drag list items of type int[] ( Java Messsge:-1 ) <p>So i have quite a hard task of making my listview items dragable so i can change theyr index , items in listview are <strong>int[]</strong> so i use <code>CustomWeaponRecoilRowListCell&lt;T&gt; extends ListCell&lt;T&gt;</code> with <strong></stron...
<p>Ok i found out what the problem was , first of all <code>draggedIdx</code> was always <strong>-1</strong> for some reason there was no way for me to get correct index value from jewelsea's answer tryed multiple ways even with cached value , index tracking / value was null at point of dragDetected, so i decided to g...
Output scoped variable values within execution of batch/stored procedure TSQL <p>Is it possible to output a list of all current variable values within the execution of a stored procedure?</p> <p>For context, it would be nice to know what variable values are when a stored procedure throws an error to help troubleshooti...
<p>You are using local variable, which is not possible it out of it's scope. As <a href="https://technet.microsoft.com/en-us/library/ms187953(v=sql.105).aspx" rel="nofollow">TechNet</a> also mentioned it:</p> <blockquote> <p>The scope of a variable is the range of Transact-SQL statements that can reference the var...
Is a multi-demionsional array the same as a matrix? <p>I understand what an array and a matrix is. I want to learn how to create 3D graphics and I want to know if a multi-demionsional array is the same as a matrix.</p>
<p>There are several uses of the term "matrix". Normally however we say that a matrix is a 2-dimensional array of scalar (integer or floating point) values, with known dimensions, an entry for every position (no missing values allowed), and arranged such that the columns represent observations about or operations on th...
Using undefined CSS media queries <p>I was researching about CSS media queries best practices and found the <a href="http://foundation.zurb.com/sites/docs/v/5.5.3/media-queries.html" rel="nofollow">Foundation's definition</a>.</p> <p>As you can see, the first media query has no min/max-size definition:</p> <blockquot...
<p>Media queries are not only for breakpoints. You can specify the output medium like <code>screen</code>. In this case, only display screens are targeted. You can also target only <code>print</code> media, or media with specific orientation or resolution.</p> <p>See more information about media queries and media type...
My rest service does not work <p>I am trying to make a rest call but it does not work.</p> <p>My project explorer is;</p> <p><a href="http://i.stack.imgur.com/c8qea.png" rel="nofollow"><img src="http://i.stack.imgur.com/c8qea.png" alt="My project explorer is"></a></p> <p>My web.xml is;</p> <pre><code>&lt;?xml versi...
<p>Try to change your Servlet deployment code as given below. With this deployment all the @Path classes found in your web application will be available with the URL pattern /rest/*</p> <pre><code>&lt;servlet&gt; &lt;servlet-name&gt;javax.ws.rs.core.Application&lt;/servlet-name&gt; &lt;load-on-startup&gt;1&lt...
Hibernate generates invalid DDL (PostgreSQL 9.6) <p>I'm using Spring Boot JPA with no dialect configured in application.properties. In my output, I can see that Hibernate is generating the following DDL commands:</p> <pre><code>create table user ( id int8 not null, password varchar(255), username varchar(2...
<p>You can use the table name in quotes.<br> Here is one of the fine <a href="http://stackoverflow.com/questions/39698973/hibernate-with-primary-key-in-postgresql-with-camelcase-format/39703583#39703583">example</a> which I have solved. The answer contains everything that you need.</p>
How to debug exception from bootstrap grid.less and ClearScriptV8 <p>All of a sudden (so it seems) a perfectly working MVC5 with Bootstrap (LESS) solution refuses to run. When I attempt to run, it just gives me blank screen and the site never loads. </p> <p>When I run in debug mode, after about 90 seconds, it crashes ...
<p>The problem was with a plugin (<a href="https://github.com/nakupanda/bootstrap3-dialog" rel="nofollow">https://github.com/nakupanda/bootstrap3-dialog</a>). </p> <p>It had LESS and CSS files. </p> <p>While the CSS file only contained styles for the plugin itself, the LESS file contained the whole bootstrap LESS in...
Longest Common Suffix-Prefix <p>Is there an efficient algorithm to find the longest common suffix and prefix of two different strings? The alphabet size is unbounded. </p> <p>Formally, let string S = wa and T = bw, where a, b, w are substrings. How to find the longest such w, given S and T?</p>
<p>You can use Trie tree, it's very useful for common suffix</p>
How does the maxConcurrentOperationCount of the NSURLSession delegateQueue effects task concurency <p>I'am using AFNetworking 3.0 which uses <code>NSURLSessionDataTask</code> and also an operationQueue (property of the <code>AFURLSessionManager</code>), which is used as the delegateQueue for the <code>NSURLSession</cod...
<p>That queue is the delegate queue, so it should only affect delegate message delivery.</p> <p>When you create an <code>NSURLSession</code> you give it a configuration object of type <code>NSURLSessionConfiguration</code>.</p> <p><code>NSURLSessionConfiguration</code> includes a property <code>HTTPMaximumConnection...
Why can't local classes access variables from the enclosing scope? <p><a href="http://stackoverflow.com/a/3930239/560648">A local class cannot access local variables of the function in which it is defined</a>.</p> <p>Why is this? What is the reason for this rule in C++?</p>
<p>It's a reasonable question to ask, especially since some common languages, e.g. Python, allow this.</p> <p>However, think about this situation if references to locals were allowed and hypothetically this code could compile.</p> <pre><code>struct MyClass { virtual fetchValue() = 0; }; MyClass* somefunction(){ ...
What could be the better way here than to split the string in a loop? <p>I have a string:</p> <pre><code>FeatureName:Height-FeatureValue:1-vmin:1-max:20000-pricing-row-, FeatureName:Width-FeatureValue:1-vmin:1-max:20000-pricing-row-, FeatureName:ChannelCount-FeatureValue:23-vmin:234-max:0-pricing-row-, FeatureName:Hei...
<p>Splitting (ie parsing) this string by splitting it multiple times is not a bad solution.</p> <p>However if you want to use regex, start by splitting your input into individual lines by splitting on ",". Then for each line of your input, parse the line into its component pieces using this regex:</p> <pre><code>var ...
How to get inputs value using javascript <p>My script fetchs and insert some data from db and displays to the user then I decied to slightly change my code and add some functionality.For example what if any of textbox is empty so that I have added a java script file that controls this sitituation.Bu I cant get the valu...
<p>When selecting an element with</p> <pre><code>$('#last') </code></pre> <p>you are getting the entire element in return. With that, you can use the <code>val()</code> method to retrieve the elements value:</p> <pre><code>var name = $('#last').val(); </code></pre>
Date picker auto close after selecting the date is not working <p>I have developed a type-form where i am using datepicker but after selecting the date , datepicker auto is not working</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre...
<p>I don't see any references to the pickadate library's theme CSS files in your snippet. It's autoclosing for me once I added them</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"...
How to convert Uri image into Base64? <p>I have write code to convert image from file location into base64. I can easily convert image into base64 from absolute file location like: <strong>C:/Users/Java Engineer/Desktop/test/gallery/magar/Kanuglam.jpg</strong> , but I can not convert from location like<br> <a href="htt...
<p>Ok, try this </p> <pre><code>bitmap = getBitmapFromUrl(image_url); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); byte[] array = stream.getByteArray(); encoded_string = Base64.encodeToString(array, 0); </code></pre> <p>Method wo load image fro...
Not able to find Restivus after having added with meteor add nimble:restivus <p>I have a functioning Angular2-Meteor installation.</p> <p>On top of this, I have installed Restivus via the command </p> <pre><code>meteor add nimble:restivus </code></pre> <p>The installation does not show any problem.</p> <p>Following...
<p>To use Restivus, you don't import it as a module, you simply need to call <code>new Restivus(options)</code>. Restivus is only available in server code, so make sure you're in a <code>if (Meteor.isServer) {}</code> block or in a file under a /server directory.</p>
libgdx click area above target <p>I'm trying to make a simple main menu with clickable play and exit labels, but clickable area is always above labels. To click "play" label I need to click about 20 pixels above it.</p> <p>How can I align clickable area with labels?</p> <p>There is my MainMenuButton class</p> <pre><...
<p>I found a solution. I needed to update view port for the MainMenuButtons, so I created a new method </p> <pre><code>// in the MainMenuButtons class public void viewportUpdate(int width, int height) { gameViewport.update(width, height); } </code></pre> <p>and call if from the MainMenu class</p> <pre><code>@Ove...
BFS not returning a path <p>I am trying to implement BFS on a 2d array given the start point and end point. I tried giving my function two points on the grid, but it returns an empty array meaning that there is no path.</p> <p>Can someone please point where am I going wrong and if possible help me correct my error? Th...
<p>The first issue is that you're adding all the elements you remove from the queue to the path (I'm referring to the line containing <code>path.add(next);</code>).</p> <p>Instead, you should keep track of the parent node from which you visited each node. When you find the end node, you can trace back your steps to th...
SQL Server - Cyclic Cascade Path <p>Lets say I have two tables - <strong>User</strong> and <strong>Post</strong></p> <p>I introduced a customized Join table <strong>Vote</strong> to have a many-to-many relationship between <strong>User</strong> and <strong>Post</strong>.</p> <p>The tables have following structure:</p...
<p>You are looking for cascading foreign key relationships. For the first two:</p> <pre><code>alter table vote add constraint fk_vote_user foreign key (userid) references user(userid) on delete cascade; alter table vote add constraint fk_vote_post foreign key (postid) references post(postid) ...
Regexp for several URLs <p>I use this module in Django: <a href="https://github.com/ottoyiu/django-cors-headers" rel="nofollow">https://github.com/ottoyiu/django-cors-headers</a></p> <p>There is setting (CORS_URLS_REGEX) to allow CORS URLs which I cant configure.</p> <p>I need to combine in one regex:</p> <p>r'^/api...
<p>I think this should work:</p> <pre><code>r'^/api/general/(enterpriseinfo|availabletime)/$ </code></pre>
How is the .NET PointToClient function implemented? <p>My game requires that I call PointToClient every frame, and while this may not be causing any kind of bottleneck currently, I wanted to take a look at the source to see if I could improve the performance of the function. I know that most .NET functions have an awfu...
<p>The native method probably does it faster than you can with do with C#. If you really need speed, use DirectX or some gaming API.</p> <p>This put aside, in order to get the local coordinates (the client coordinates) of a point given in screen coordinates in respect to a control, you must subtract the screen coordin...
Using Data visualization to create artwork <p>I'm trying to create the visual of a tree by data, something like a data visualization art. My reference of the visual is <a href="http://www.openprocessing.org/sketch/5918" rel="nofollow">http://www.openprocessing.org/sketch/5918</a>, however it is created my random float ...
<blockquote> <p>Are there any libraries needed </p> </blockquote> <p>You don't need any libraries. You can simply load the csv file using the <code>loadTable()</code> function. More info is available in <a href="https://processing.org/reference/loadTable_.html" rel="nofollow">the reference</a>.</p> <blockquote> <...
What microdata should i use for purchase guide segment in category page? <p>I have many category pages and each category has many products and companies and one guide for users (user guide about category subject).</p> <p>What microdata should I use for purchase guide for each category page?</p> <p>If I use article, P...
<p>If you don't want show the Puplisher logo visible at the end of the article you can use </p> <pre><code>&lt;span itemprop="logo" itemscope itemtype="https://schema.org/ImageObject"&gt; &lt;meta itemprop="url" content="http://www.domain.com/logo.jpg"&gt; &lt;meta itemprop="width" content="600"&gt; &lt;meta it...
Unexpected output when printing directly to text video memory <p>I am developing a kernel in C and created something to print on screen on video memory. I expected that the first byte in video memory would be the character to print and the second byte tells the color. But my program has something different but it works...
<p>This should work. Each VGA cell is of 2 bytes long, First byte stores Character while the second byte stores the color. Also make sure you make marked the pointer volatile. To avoid any type of unexpected changes(or <strong>optimizations</strong>) made by the compiler on that local field.</p> <pre><code>void write_...
Merging Android Manifest <p>Hi I made an android game which uses googleadmob. I have decided to port it to amazon app store as well and use game circle. They both have their own android manifests so this creates an error when building. How can I combine the abmob manifest into the game circle one. Please advise as i do...
<p>Your merged manifest something look like this,</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="com.example.admobtest" android:versionName="1.0" android:versionCode="1"&gt; &lt;us...
Jquery ordering table rows <p>I'm using the following code to order table rows and it works pretty much as I need.</p> <pre><code>var $table=$('#Frm1'); var rows = $table.find('tr.grp').get(); rows.sort(function(a, b) { var keyA = $(a).attr('data-site'); var keyB = $(b).attr('data-site'); if (keyA &gt; key...
<p>If the attribute is there but has no value, the value you'll get from <code>attr</code> will be <code>""</code>. So just allow for that:</p> <pre><code>if (!keyA) return 1; if (!keyB) return -1; if (keyA &gt; keyB) return 1; if (keyA &lt; keyB) return -1; </code></pre> <p>Example:</p> <p><div class="snippet" data...
Is there analogue for dictionary in J? Or how to implement it <p>I mean datatype "dictionary". Like in python language. 'key':'value' storage.<br/> I've implemented it using complex numbers. Real part stands for 'key', imaginary - for 'value'.<br/></p> <pre><code>storage =: 10j7 5j6 16j5 8j4 4j3 2j2 1j1 get =: (1&amp;...
<p>Take a look at symbols implemented using the s: primitive and see if that suffices.</p> <p><a href="http://www.jsoftware.com/help/dictionary/dsco.htm" rel="nofollow">http://www.jsoftware.com/help/dictionary/dsco.htm</a></p>
Where is the error of my implementation of "Intersection of Two Linked Lists"? <p>I'm preparing algorithm test at Leet Code and here's the description for <a href="https://leetcode.com/problems/intersection-of-two-linked-lists/" rel="nofollow">N°160 Intersection of Two Linked Lists</a>:</p> <p>Write a program to find...
<p>The <code>Stack</code> data structure uses object <code>Integer</code> instead of primitive type <code>int</code>. So I need to change the comparison to</p> <pre><code>stackA.peek().equals(stackB.peek()) </code></pre> <p>And the submission is accepted this time.</p> <p>Now if you were interested in this algorithm...
changing has_key to in python 3 ipython notebook <p>i'm doing text mining on twitter with ipython notebook </p> <p>i use python 3 but this code uses python 2 <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-htm...
<p>Strings still need to be strings.</p> <pre><code>if 'retweeted_status' in status </code></pre>
IntelliJ TestNG Maven Test automation project structure <p>i'm thinking about test automation structure using selenium, intelliJ ide, testng and maven. What You think about below:</p> <p><a href="http://i.stack.imgur.com/j3tdK.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/j3tdK.jpg" alt="Selenium test structu...
<p>Too long for a comment:</p> <p>I would assume your helper class is goin to have common functions. Also, depending on the size of your modules you may want to create more sub-module folders. You can also add a commons folder which contains generic steps and methods.</p> <p>Now, if your modules are deployed complete...
how to break a long label in many lines in Extjs <p>so here is my problem i wanna put a label before a fieldset and the label text is very long.and i need to have this long text in three rows/line. i used width, minWidth, margins, etc but not working. Is there is another easy way to ix it? I hope you people understand ...
<p>Don't use a label. Use container and fill the <code>html</code> config.</p> <p>Detailed answer:</p> <p>The <code>label</code> component can only play out its strength <a href="http://docs.sencha.com/extjs/6.0.1/classic/Ext.form.Label.html#cfg-forId" rel="nofollow">if you connect it to a field that can be focused w...
find positive calendarDurations in matlab <p>AIM: I need to synchronize the animation of two plots in Matlab.</p> <p>PROBLEM: The data of the two plots has been acquired with a variable sample rate.</p> <p>SOLUTION: I converted the time-stamps of the two datasets in duration objects (relative to the beginning of the...
<p>You can use <a href="https://www.mathworks.com/help/matlab/ref/split.html" rel="nofollow"><strong><code>split</code></strong></a> function for this purpose.</p> <p>Use <code>is_past = split((d1-et),'time')&gt; 0;</code> instead of <code>is_past = (d1-et)&gt;0;</code> </p>
Shorthand if statement always returns 'false' instead of value assigned <p>I am trying to use the shorthand if statement in Javascript to find out if one of my arguments is a negative number, and if it is, I want to change it to a specific value. Here is my code:</p> <pre><code>var findDigit = function(num, nth){ nth ...
<p>You don't have to do anything else than placing the values:</p> <pre><code>nth = nth &lt; 0 ? -1: nth; </code></pre>
Element 'a' cannot be nested inside element 'iframe' <p>I am working a WebBowser project in Visual Studio 2015 that embeds a part of their functionality inside another website adding a html file. It runs without warnings using the Run Code snippet of stackoverflow but if I run it in Visual Studio 2015, it runs ok it bu...
<p>The <code>width</code> and <code>height</code> attributes do not take units (except <code>%</code>). Therefore:</p> <pre><code>... width="200" height="461" ... </code></pre> <p>For the second problem: The error is quite clear. You cannot have an <code>&lt;a&gt;</code> tag within an iframe. You are only allowed to ...
Using Java-script to write a certain function <p><a href="http://jsfiddle.net/cjLm77ek/" rel="nofollow">http://jsfiddle.net/cjLm77ek/</a></p> <p>In this example here, I want to add something to the java script code so that when I re-click the flip button again, it flips back to the original form. How should I do that?...
<p>Easiest one is to toggle a class:</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).ready(function() { $("#flip_content").click(function() { $("...
Can we create SOAP and REST Web Services in an single application <p>Can we create SOAP and REST Web Services in an single application. If "YES" then how to distinguish between them while performing testing </p>
<p>Applications usually expose either SOAP, or REST services. However, if you have both customers who prefer REST (e.g. for simplicity) and who prefer SOAP (e.g. because it is better supported by their integration tools and standards), it might be right to provide both SOAP and REST. Of course there is a drawback of hi...
How to change the CSS property of the DOM element with AngularJS <p>I created a function <code>validateCode()</code> and when a user clicks on the button <code>validateCode()</code> will trigger. </p> <p>I want to change the height of the <code>&lt;div class="loginForm"&gt; &lt;/div&gt;</code> when the button clicks.<...
<p>Here is a solution using <a href="https://docs.angularjs.org/api/ng/directive/ngClass" rel="nofollow">ngClass</a>:</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>angular...
make bouncing turtle with python <p>i am a beginner with python I wrote this code to make bouncing ball with turtle it works but have some erors like ball dissapering</p> <pre><code>import turtle turtle.shape("circle") xdir = 1 x = 1 y = 1 ydir = 1 while True: x = x + 3 * xdir y = y + 3 * ydir turtle.got...
<p>You need <code>window_width()/2</code> and <code>window_height()/2</code> to keep inside window.</p> <p>ie.</p> <pre><code>if x &gt;= turtle.window_width()/2: xdir = -1 if x &lt;= -turtle.window_width()/2: xdir = 1 if y &gt;= turtle.window_height()/2: ydir = -1 if y &lt;= -turtle.window_height()/2: ...
Copying SUMIF exact date +1d formula <p>I should be able to do this but my brain has stopped working again. I'm working on a google sheet at work. I want to copy a simple formula to the cells below, increasing the exact date by one day to the rows below. I put this formula in P2</p> <pre><code>=SUMIF(Zapv1SUP!$S$2:$S,...
<p>@Ron Rosenfeld's suggestions also works in Google Sheets i.e. in P3 put</p> <pre><code>=SUMIF(Zapv1SUP!$S$2:$S,DATE(2016, 10, 1)+rows($1:1),Zapv1SUP!$V$2:$V) </code></pre>
How to disable all but one button in a JPanel and enable them one after the other <p>I created a JPanel with 11 buttons (all in an array). Now I set actionListeners on those buttons, but I want only one button to be enabled initially, then after the actionListener on it is completed, the next button is enabled. Here is...
<p>If you want to sequentially enablebuttons I would use at least two fields, an <code>ArrayList&lt;JButton&gt;</code> filled with your buttons, and an <code>int buttonListIndex</code> int index field to tell the program which button is active. You can enable and disable buttons via <code>setEnabled(true)</code>. In th...
Migrate from monolithic Node.js application to microservices. Any advice? <p>We want/need to migrate from a monolithic Node.js application to microservices.</p> <p>Any advice (challenges, roadmap, resources)?</p>
<p>For a quick overview i recommend <a href="http://martinfowler.com/articles/microservices.html" rel="nofollow">Martin Fowler Blog</a>. It has the basic stuff, why you should do it, pros and cons.</p> <p>For a more long and detailed study i recommend <a href="http://shop.oreilly.com/product/0636920033158.do" rel="nof...
Is it normal that my simple canvas with requestAnimationFrame + drawimage uses about ~8-9% of cpu? <p><br> I'm testing HTML5 Canvas with a easy example to draw some isometric tiles. I'm using <code>requestAnimationFrame</code> method. However, I can see about 8% of CPU usage in Chrome task manager. </p> <p><strong>P...
<p>For speed the general rule is "Write at the lowest level available": Typescript adds overhead write the code in Javascript where you need speed. </p> <p>Don't use for( in ??) iterate with standard for loop, it is faster.</p> <p>Don't use apply, call the function directly, its a good 6 times quicker (and more on C...
Project Euler #2; Code Fails to Output Correct Answer <p>Question Given: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:</p> <p>1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...</p> <p>By considering the terms in the Fibonacci sequence ...
<p>The Problem Statement is (from <a href="https://projecteuler.net/index.php?section=problems&amp;id=002" rel="nofollow">here</a>):</p> <blockquote> <p>Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:</p> <p>1, 2, 3...
Webpack does not create output file (not using webpack-dev-server) <p>I am using webpack (NOT the dev-server, I know that doesn't output a file), and it is not creating a dist folder or output file.</p> <p>I've tried running it directly through <code>webpack</code> (installed globally) and <code>npm run build</code> w...
<p>Your webpack output path is absolute:</p> <pre><code>output: { path: path.join('/dist'), &lt;---- filename: '[name].bundle.js', }, </code></pre> <p>My guess is it's being generated in your root directory. <code>/dist</code> would mean from the root of your file system, not relative to your project director...
Saving firebase data to variable swift <p>so this has been something that I have been trying to work out for a while, both by myself and searching through stack overflow. I am using swift with firebase to record the amount of likes a certain "post" has. What I need to do, is set the amount of likes, which is a label, t...
<p>You can observe the down votes value so when it changes, your label is automatically updated.</p> <pre><code>ref.child("IssueLikes/Abortion/Downvotes").observeEventType(.Value, withBlock: { [weak self] snapshot in self?.un_2.text = snapshot.value as? String }) </code></pre>
How can i set watermark of photos on my website <p>Can I do it with CSS or HTML?</p> <p><a href="http://www.expocreek.com" rel="nofollow">http://www.expocreek.com</a></p>
<p>No, you can't do that in client side. It requires server side rules. Basic watermark you can set in client side, the user will see that watermark, but he can also download the original photo.</p>
Is there a benefit to calling a function within a function? <p>I'm following a tutorial on MDN for javascript and they add an onclick handler to a button and then call a function within a function:</p> <pre><code>myButton.onclick = function() { setUserName(); } </code></pre> <p>I tried assigning the event to the func...
<p>If the function doesn't care about the event object that gets passed as the first argument, no. It bloats the code, creates an extra object in memory and has no benefit.</p>
I am working on batch game and can't get my inventory to work. Code to the game below <p>The Current Weapon seems to work but when I go to the store in my game and buy new weapons it does not show them in the unequipped area of the inventory. If you need to see the rest of the code to the game just tell me</p> <pre><c...
<p>set /a var=value is an <strong>arithmetic</strong> assignment. The numerical value of the argument is assigned. <code>true</code> is likely undefined, so <code>p</code> will be assigned <code>0</code>. BTW <code>p</code> appears not to be initialised, so if no <code>set p=</code> is executed, it will remain unchange...
Getting custom colors and thresholds to work with D3 RelationshipGraph <p>Based on this example: <a href="https://cdn.rawgit.com/hkelly93/d3-relationshipGraph/master/examples/index.html" rel="nofollow">https://cdn.rawgit.com/hkelly93/d3-relationshipGraph/master/examples/index.html</a></p> <p>D3 should allow me to cre...
<p>This turned out to be a bug in the module itself. I notified the author and he fixed the way it sorts thresholds so it matches up with corresponding colors now.</p>
Find all common N-sized tuples in list of tuples <p>I have to create an an application that does the following (I have to parse the data only once and store them in a database):</p> <p>I am given K tuples (with K over 1000000) and each tuple is in the form of</p> <pre><code>(UUID, (tuple of N integers)) </code></pre>...
<p>It appears that you could put the tuples into the rows of a matrix and make a map from row numbers to UUIDs. Then it's feasible to store all of the tuples in a numpy array since the elements of the tuples are small. numpy has code capable of computing the intersections between rows of such an array. This code genera...
Creating a simple Clock in QT <p>I want to create a simple clock in my Qt program: QLabel which is updated once a second.</p> <p>QLabel name: label_clock</p> <p>My clock "script":</p> <pre><code>while (true) { QString time1 = QTime::currentTime().toString(); ui-&gt;label_clock-&gt;setText(time1); } </code></pr...
<p>You can use <a href="http://doc.qt.io/qt-5/qtimer.html" rel="nofollow">QTimer</a> for this. Try something like this:</p> <pre><code>QTimer *t = new QTimer(this); t-&gt;setInterval(1000); connect(t, &amp;QTimer::timeout, [&amp;]() { QString time1 = QTime::currentTime().toString(); ui-&gt;label_clock-&gt;setTex...
Asp.net web API with angularJS for an E-commerce website <p>I am a bachelor's undergraduate. For my third year computer project I am hoping to develop a e-commerce website using angularJs and asp.net web API as I have a basic understanding of it. But I have some of questions with my choice. </p> <p>1) For a E-commerce...
<p>1) Yes. Just as much as you could do any other major stack. Depends on how you implement it. E-commerce is a very generic term. There can be e-commerce web apps with 4 pages or 400 pages. These things really determine your tech stack.</p> <p>2) Yes. Just as much as you could do any other major stack.</p> <p>3) Yes...
android- crashing application while switching between activities <p><strong>I have edit the manifest file as well. and did everything i could do. still my code is crashing. please help me with this error..............................................................................................</strong></p> <p>Activ...
<p>All java classes have to be capitalized, welcomemessage is not and in the mainfest it needs an intent filter block as well, if you post the logcat I can help track down any other errors</p>
replacing on mouse selected area in emacs <p>This is something easily done in nedit, or komodo, but could not find how to do it in emacs.<br> I highlight an area of my code, using the mouse. Then I just want to do replace or regexp replace, on the area highlighted only.<br>Any ideas? A reference to elisp code which ena...
<p>Use the command <code>query-replace</code> (by default it is bound to <code>M-%</code>), or <code>M-x query-replace</code>. If a region is highlighted, it will only do replacements within that region.</p> <p>If you want to use a regexp, do <code>M-x replace-regexp</code> with a region highlighted, and you will have...
Gaussian blur algorithm <p>I'm trying to implement a gaussian blur algorithm, but my weight function is returning the wrong values</p> <pre><code>float gauss(int x, int y, float sigma) { float gauss = 100*exp(-(pow(x,2)+pow(y,2)) / (2*pow(sigma,2))) / (pow(sigma, 2)*2*3.14159); return gauss; } </code></pre> <...
<p>I think you are using sigma = 1.0, the example you're comparing has used sigma = 1.5?</p>
How to get current date in spring form of jsp page <p>Please i want to know how to get the current date in a form of jsp page using spring .Is there a jsp tag for that or maybe a library ? here is my code :</p> <pre><code> &lt;form:input path="date" value=" " /&gt; &lt;/form:form&gt; </code></pre> <p>What should...
<p>Try using below code</p> <pre><code>&lt;jsp:useBean id="now" class="java.util.Date" /&gt; </code></pre> <p>In case you want a particular format.</p> <pre><code>&lt;fmt:formatDate value="${now}" pattern="MM.dd.yyyy" var="formatted" /&gt; </code></pre>
See available space in all storage devices, mounted or unmounted, through a linux command? <p>I've seen that df -H --total gives me the total space available but only of <strong>mounted</strong> devices, and lsblk gives me the sizes of <strong>all</strong> storage devices, yet not how much space is available within the...
<p>The operation of <em>mounting</em> a medium makes the operating system <em>analyze</em> the file system. </p> <p>Before a medium is mounted, it exists as a block device and the only fact the OS might know about it might be the <em>capacity</em>. </p> <p>Other than that, it is just a stream of bytes not interpreted...
.NET CE 2.0 Data Access NullReferenceException when assigning DB fields to List(of T) <p>The code below grabs data based on a provided username and password in VS 2008. When I Check the <code>reader.FieldCount</code> it contains all of the fields it should contain. The issue I am having is at <code>results.Add</code>, ...
<p>You should use the keyword <code>New</code>:</p> <pre class="lang-vb prettyprint-override"><code>Dim results As New List(Of String) </code></pre>
How to read Json data using ng-repeat <p>I am working with Express 3 version of the NodeJs and have a SQL query which fetched the data from the database and then I applied JSON.Stringify and then JSON.PARSE function on the results obtained from the SQL query. </p> <p>My JSON data looks like something like this. result...
<p>This happens because your <code>myResult</code> variable is binded to the whole data returned from your server. Instead of doing this</p> <pre><code>$scope.myResult = response.jsonParse; </code></pre> <p>do</p> <pre><code>$scope.myResult = response.data.jsonParse; </code></pre>
how can I load a div into bootstrap modal <p>I know this is the basic question, but I'm not able to solve this. Please do help me.</p> <p>I'm trying to load the content of div on a click of a hyperlink into the bootstrap modal. How can I able to do this? </p> <p>Below is my code :</p> <pre><code>&lt;a id="myModalId"...
<p>U can use this function to load content in order by the clicked button link:</p> <p>Buttons:</p> <pre><code>&lt;a href="#myModalId" data-toggle="modal" data-content="d1"&gt;myLink1&lt;/a&gt; &lt;a href="#myModalId" data-toggle="modal" data-content="d2"&gt;myLink2&lt;/a&gt; </code></pre> <p>Modal:</p> <pre><code>...
How can I install mpmath as an external library for Blender? <p>I'm interested in trying out sympy with Blender (v2.76, Python 3.4.2 Console, Windows 8.1). I followed this <a href="http://blender.stackexchange.com/questions/15453/error-import-point3d-of-geometry-module-of-sympy0-7-5-in-blender2-71/15513#15513">answer</...
<p>You want to install mpmath into blenders python folder, the same as you have done for sympy.</p> <p>Your example of running pip was done in a system installed python that is setup to find the mpmath that you have installed in <code>c:\anaconda3\lib\site-packages</code></p> <p>Another option is to use the existing ...
Sudoku algorithm not backtracking properly <p>I'm making a Sudoku solver which tries every possible value in a square and backtracks if it doesn't lead to a solution. I believe I have a nearly-working algorithm, but it only has worked so far on rows 0, 2, and 3 of a 16-cell puzzle.</p> <pre><code>public boolean fillBo...
<p>The issue was that it didn't reset the space to 0 when the value was incorrect, so if it ever reached the max index and wasn't correct, it just left it. The below code works. Just waiting on another person in my group to deliver the box-checking method, but I will probably end up having to do that myself.</p> <pre>...
How can i get the value from table row? <p>This is the table form which i will select the row to edit by using Button Edit</p> <pre><code>$query = "SELECT * FROM tbl_document LIMIT $start, $end"; $result = mysqli_query($con,$query); echo "&lt;table border='1' width='300' height='160' align = center id='result'&gt;"; e...
<p>On your second form (your modal), I see no echo to display the value of your <strong>title</strong></p> <pre><code>&lt;form method="post" action="&lt;?php $_SERVER['PHP_SELF'];?&gt;"&gt; &lt;p&gt; &lt;label class="w3-label w3-text-black"&gt;&lt;strong&gt;Title:&lt;/strong&gt;&lt;/label&gt; &lt;input class="w3-input...
Group By after Union throw "must be reducible node" Exception <p>I need unoin two query and after union Group By that, but throw "must be reducible node" Exception. in following sample code are:</p> <pre><code>public class ForumPost { public int ForumPostId { get; set; } public string Message { get; set; } ...
<p>I guess this special case wasn't enabled, but when you take a look at the EntityFramework Core Roadmap, you'll see in the "Critical O/RM Features" the following entries: </p> <blockquote> <p>Critical O/RM features</p> <p>The things we think we need before we say EF Core is the recommended version of EF. Unti...
SparkContext Initialization Error: Scala <p>I am running spark using the following run command:</p> <pre><code>spark-submit --class "Pagecounts" --master local[*] target/scala-2.11/Pagecounts-assembly-0.1-SNAPSHOT.jar &lt;some_file_name&gt; </code></pre> <p>But I am getting the following initialization error:</p> <p...
<p>I think you cant local deploy this application like this because jar need spark environment to run spark application but here local[<em>] nothing so if you want to run application locally then simply set master local[</em>] in your SparkConf object like below</p> <pre><code>val conf = new SparkConf().setMaster("loc...
Please help me to find the mistake in query <p>Hye, </p> <p>I have table AddClient which have data like this</p> <pre><code> idClient NameClient Balance Date CL-MK Muhammad Kashif CL-MK 9000 2016-10-01 CL-MA Asim CL-MA 8000 2016-10-01 CL-MQ Qasim...
<p>You need to group both by ID and name of the client instead of grouping only by name:</p> <pre><code>SELECT idClient, NameClient, min(Balance) FROM AddClient GROUP BY idClient, NameClient </code></pre> <p>Additionally, it seems that the data type that you are using for balance is not a numeric type - that would ...
iOS Instrumentation: how to interpret Memory Allocations Template? <p>I am using Allocations Profiling template for an iOS Instrumentation. I created an extension to UIView class, that takes a snapshot for a view that is not added to the view hierarchy. I want to double check how much memory does my new method consume....
<p>A couple of thoughts:</p> <ol> <li><p>Be careful when filtering the results of the call tree. You could have accidentally pruned out the routine with which the profiler associated the memory. Try (a) selecting the range of the graph that has the allocation in question (to reduce the amount of noise in the results);...
Linker command failed with exit code 1 (Framework not found) <p>When I build my app it gives error:</p> <blockquote> <p>Linker command failed with exit code 1</p> </blockquote> <p>When I click on it to see the details, it says:</p> <blockquote> <p>Framework not found Cosmos</p> </blockquote> <p>I used to use co...
<p>Check "Project Setting"(Click on project name in files tree in Xcode) -> General -> Embedded Binaries. If there is "Cosmos" - delete it.</p> <p>UPD</p> <ol> <li>Try to find "import Cosmos" in source files, and delete it if it won't help</li> <li>Try to open pbxproj of you project. <code>Right click on project nam...
How to tell which files are being transpiled by Babel 6? <p>I have a project that is using <code>babel-register</code> to dynamically transpile ES6 source to ES5 when requiring that module in a Node 6.6 project. I've read that <a href="https://babeljs.io/docs/usage/require/" rel="nofollow"><code>babel-register</code> ...
<p>Because of this:</p> <pre><code>cucumberjs --compiler js:babel-core/register </code></pre> <p>...babel is invoked for both your test and regular source code. Keep in mind that in node, the only way to import JS is through <code>require</code>, so obviously <code>babel-register</code> will always be invoked. Of cou...
Sql Table join query <p>I have 3 tables in sql </p> <ol> <li>ProductMaster with column ProductName</li> <li>PurchaseData with column ProductName and Quantity</li> <li>SaleData with column ProductName and Quantity</li> </ol> <p>Please guide me to write query for table join to get the result as under</p> <pre><code>PR...
<p>Try to start with something like this:</p> <pre><code>SELECT [ProductMaster].[ProductName] ,[PurchaseData].[Quantity] AS [PurchasedQuantity] ,[SaleData].[Quantity] AS [SoldQuantity] ,[PurchaseData].[Quantity] - [SaleData].[Quantity] AS [ClosingStock] FROM [ProductMaster] LEFT OUTER ...
When submitting an ajax request, how can you "put the original request on hold" temporarily until a condition is met? <p>I am wanting to implement a recaptcha process that captures all ajax requests before they go through - the desired process would be as follows:</p> <ol> <li>User completes an action which is going t...
<p>Thank you @Loading and @guest271314 for your help in pointing me in the right direction that helped me get things figured out. I've pasted how I accomplished it below - perhaps it will be of help to someone else. Of course if anyone would like to weigh in on my implementation please do.</p> <pre><code>&lt;script sr...
Rails 5: Check returned enum value in controller <p>I am struggling to check returned enum value. In models/roles.rb I have enums:</p> <pre><code>class Role &lt; ApplicationRecord belongs_to :user, optional: true accepts_nested_attributes_for :user enum general: { seller: 1, buyer: 2, seller_buyer: 3}, _suffix:...
<p>Maybe you could just use the instance variable <code>@roles</code> that you've initialized</p> <pre><code>if @roles.any? { |role| role.deleter_dashboard? } flash.now[:error] = "You can do whatever want!" else flash.now[:error] = "Only view!" end </code></pre> <p>You should be able to <code>role.deleter_dashbo...
how to open whatsapp from iphone swift app <p>I am using webview for my swift app, and i have share on WhatsApp button in my website, which works fine on browser , but on iPhone app when i click on WhatsApp share button, nothing happens, i have also created a android app with same website and i added this code to my ap...
<p>For this you should use URL schemes.</p> <pre><code>let message = "Message" let urlWhats = "whatsapp://send?text=\(message)" if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed) { if let whatsappURL = NSURL(string: urlString) { if UIApplication.shared...
Javascript could not load <p>What am I doing wrong? Javascript is not working. There is link to jsfiddle and there it is working perfectly: <a href="http://jsfiddle.net/onazdce2/" rel="nofollow">http://jsfiddle.net/onazdce2/</a> .</p> <p>I would like to rewrite it somehow into my programs, but js seems not loaded.</p>...
<p>Solved: I must have both script references in head tag. Thanks everybody for advices.</p> <pre><code>&lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt; &lt;script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js" integrity="sha256-T0Vest3yCU7pafRw9r+settMBX6JkKN06dqBnpQ8d30=" crossorigin=...
selecting rows in a tuplelist in pandas <p>I have a list of tuples as below in python:</p> <pre><code> Index Value 0 (1,2,3) 1 (2,5,4) 2 (3,3,3) </code></pre> <p>How can I select rows from this in which the second value is less than or equal 2?</p> <p><strong><em>EDIT:...
<p>You could slice the <code>tuple</code> by using <code>apply</code>:</p> <pre><code>df[df['Value'].apply(lambda x: x[1] &lt;= 2)] </code></pre> <p><a href="http://i.stack.imgur.com/MZBwY.png" rel="nofollow"><img src="http://i.stack.imgur.com/MZBwY.png" alt="Image"></a></p> <hr> <p>Seems, it was a list of tuples a...
(SWIFT 3) parent child context crash core data (libc++abi.dylib: terminating with uncaught exception of type NSException (Recorded Frame) ) <p>I'm trying to save messages on the background queue and push them to the main queue by using two contexts a parent and a child. but my app keeps crashing. I used apples docs, no...
<p>Ok so there are two problems you have.</p> <p>The first is that you haven't set the parent context. If you don't do this nothing will be propagated to your main managed context</p> <p>The second is that you are not changing the private managed context in it's own block. In the same way that your normal managed con...
iPhone VPN to track usage <p>Hi StackOverflow community.</p> <p>I am beginning a new project and was wondering if I could get some insight on VPNs and iPhones.</p> <p>I want to create a VPN so that I can route all of my network traffic through it from my iPhone. I also hope to log each request that was routed through...
<p>This is actually not a programming, but a network question. So you might rather post a question over at <a href="http://serverfault.com">serverfault</a>.</p> <p>You need a VPN server that in best case, has a fixed IP. From your iPhone you connect to this VPN via the external IP. If you don't have a fixed one, you'd...
Add a delay before playing an audio using Android MediaPlayer <p>I want to play 5 audio's at a go but with different time delays. Like (a.mp3 with a time delay of 2 sec, b.mp3 = 4 sec etc) but i dont know how to do it.</p>
<p>You can use handler.</p> <pre><code>Handler handler = new Handler(); final static int DELAY = 1000; // one second public void playAudioWithDelay(){ handler.postDelayed(new Runnable(){ //your code start with delay in one second after calling this method }, DELAY); handler.postDelayed(new Runnable(){ /...
How to permute in Prolog the elements of a list composed of sub-list and atoms <p>Let us consider lists such as <code>L=[[7,3,4],9,[4,5],[1,3,5],4]</code> where components could be lists or atoms. How to produce this type of permutation results:</p> <pre><code>R = [[7, 3, 4], 9, [4, 5], [1, 3, 5], 4] R = [[7, 4, 3], ...
<p>The following modification should do:</p> <pre><code>permutation(X,X). permutation(L,[T|Q]) :- dif(L,[T|Q]), select(T,L,L1), permutation(L1,Q). allperm(L,R) :- maplist(permutation,L,R). </code></pre> <p>We extend the “identity” permutation to any Prolog term (first clause of <code>permutation</c...
Can you access an array through a cin input that has the same name as the array? <pre><code>int a[5]= { 1, 2, 3 ,4 , 5}; char letter; cin &gt;&gt; letter; </code></pre> <p>If I input a, which is the name of my array, is it possible to retrieve a value from array a by using letter as the array name instead of a. Ex: ...
<p>No, it is not supported by design. If you are keen to go ahead, you might consider to use a <code>std::map</code>.</p>
login form in angular.js <p>I was trying to implement login form by authenticating the credentials from data stored in json file. But i'm getting error like only first case is working.It's just a demo application trying to learn the concepts: this is my controller:</p> <pre><code>var app = angular.module('myApp', [])...
<pre><code>$http.get('roles.json').then(function(res){ sample = res.data; console.log(sample); var isMatched = false; angular.forEach(sample, function(val) { if($scope.uName==val.userName &amp;&amp; $scope.password==val.password) { isMatched = true; return false; // To stop th...
What's the best way to store API secrets and encryption keys? <p>I am using environment variables to store API secrets and data encryption keys. I wonder is environment variables are the most secure way to store such data ? If hacker get into my server, can he access environment vars ?</p>
<p>It depends on the platform, and it is probably somewhat opinionated, but in general I think environment variables are a good way to store secrets in many scenarios.</p> <p>If for example your application is vulnerable to SQL injection, local file inclusion or some other application level vulnerability, any secret s...
How to generate tags in R <p>I need to fill out the 'z' variable. </p> <pre><code>a b z 1 100 1 2 500 1 3 450 2 4 200 3 5 152 3 6 200 3 </code></pre> <p>Thanks a lot.</p>
<p>How about</p> <pre><code>s &lt;- 0 k &lt;- 1 df$z &lt;- 0 for (i in 1:nrow(df)) { s &lt;- s + df$b[i] if (s &gt; 600) { s &lt;- s - 600 k &lt;- k + 1 } df$z[i] &lt;- k } </code></pre> <p>with the new df </p> <pre><code> df a b z 1 1 100 1 2 2 500 1 3 3 650 2 4 4 1 3 5 5 1 3 6 6 6 3 </code></...
How to force error branch in jasmine-node test <p>I'm testing the controller logic behind API endpoints in my node server with jasmine-node. Here is what this controller logic typically looks like:</p> <pre><code>var getSummary = function(req, res) { var playerId = req.params.playerId; db.players.getAccountSummar...
<p>It depends on your tests. If you only want to unit test, spies are the way to go. You can just stub your db response. Be aware that in this case the database is not called though. It's just simulated. </p> <pre><code>const db = require('./yourDbModel'); spyOn(db.players, 'getAccountSummary').and.callFake(function(i...
fixed point decimal printf output <p>I have my LCD working on my TM4C123 and I have printf working.</p> <p>I'm trying to make the input from the left column look like the output from the right column.</p> <p>What I tried was to extract each digit from the integer and then print each one out and then put the decimal s...
<p>This doesn't use your data structure or types, but can be readily adapted to match.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; int main(void) { int values[] = { 0, 4, -5, 78, -254, 999, -1000, 1234, -5678, -9999, +9999, 10000, -10000 }; enum { NUM_VALUES = s...
Exclude a subfolder only for Github with .gitignore <p>I have a project which is pushed to both of Github and Bitbucket repos:</p> <pre><code>git push github master git push bitbucket master </code></pre> <p>Github is public, Bitbucket is private repo.</p> <p>My problem is I use this repo to develop a side project i...
<p>For your side project inside which later will be a completely standalone one, you should reference your super project as a dependency.</p> <p>This means go ahead and create the new repository and push it to private remote. Then you've got at least 3 ways to include your public library:</p> <ol> <li><p>Use a depend...
Segmentation fault for a particular value <p>I wrote a code which first takes dimensions(<code>n X m</code>) of a matrix as input, and then its elements which are <code>0</code>s and <code>1</code>s. Now I am trying to build a graph(adjacency list representation) using this matrix such that all <code>1</code>s are conn...
<p><strong>Problem</strong></p> <p>Your adjacency list is an array, instead of a list or a vector: </p> <pre><code>list&lt;int&gt; *adjlist; </code></pre> <p>You initialize it in the constructor on the base of the argument v: </p> <pre><code>adjlist=new list&lt;int&gt; [v]; </code></pre> <p>So when constru...
explicitly setting style sheet in python pyqt4? <p>In pyqt standard way for setting style sheet is like this <br><br> <code>MainWindow.setStyleSheet(_fromUtf8("/*\n" "gridline-color: rgb(85, 170, 255);\n" "QToolTip\n" "{\n" " border: 1px solid #76797C;\n" " background-color: rgb(90, 102, 117);;\n" " color: whi...
<p>There are currently only two main ways to set a stylesheet. The first is to use the <code>setStyleSheet</code> method:</p> <pre><code>widget.setStyleSheet(""" QToolTip { border: 1px solid #76797C; background-color: rgb(90, 102, 117); color: white; padding: 5px; opacity: 2...