input
stringlengths
51
42.3k
output
stringlengths
18
55k
PCA in Python: scikit-learn vs numpy approach <p>I have 4 classes of images (72 .png files for each class) and I am carrying out PCA on them, in order to find the two components that show most variance on the data. Here's the code:</p> <pre><code>data_list = [] for file in fileList: # fileList contains the name of th...
<p>I think you may have got your matrix multiplication the wrong way around. Does it work if you do something like <code>X_t = standX.dot(matrix_w)</code> ?</p>
How to add a "select file" button that saves an image in a mongodb collection for a meteor project <p>I've made a form for a project I'm working on and in it there's the tipical text inputs: "First Name", "Last Name", "Address" etc, etc... but there's a problem I'm facing and it's due to my lack of knowledge in Meteor ...
<p>There are 2 packkages on atmosphere you could use</p> <p><a href="https://atmospherejs.com/vsivsi/file-collection" rel="nofollow">https://atmospherejs.com/vsivsi/file-collection</a></p> <p><a href="https://atmospherejs.com/jalik/ufs" rel="nofollow">https://atmospherejs.com/jalik/ufs</a></p> <p>I have used the fir...
Property '' does not exist on type 'Object'. Observable subscribe <p>I have just started with Angular2 and I've got an issue I cannot really understand.</p> <p>I have some mock data created as such:</p> <pre><code>export const WORKFLOW_DATA: Object = { "testDataArray" : [ { key: "1", name: "D...
<p>Typescript expects <code>WORKFLOW_DATA</code> to be <code>Object</code> here:</p> <pre><code>.subscribe( WORKFLOW_DATA =&gt; {} ) </code></pre> <p>because you told it so:</p> <pre><code> getWorkflowForEditor(): Observable&lt;Object&gt; </code></pre> <p>But <code>Object</code> doesn't have <code>testDataArray</c...
How to initialize over a 100 QLabel in an efficient way <p>I want to have the ability to update over 100 labels, so I was going to put them in an array like this:</p> <pre><code>voltage_label_array[0] = this-&gt;ui-&gt;Voltage_0; voltage_label_array[1] = this-&gt;ui-&gt;Voltage_1; voltage_label_array[...] = this-&gt;u...
<p>If you need to do this, something is horribly wrong with your design. But it is possible.</p> <p>Assuming your labels are named <code>Voltage_0</code> to <code>Voltage_99</code>:</p> <pre><code>for(int i = 0; i &lt; 100; ++i) { auto ptr = this-&gt;findChild&lt;QLabel*&gt;(QString("Voltage_%1").arg(i)); vol...
C++ - SFML When using textEntered I can't get the backspace key to delete last character of the string <p>I am trying to create a text box a user an input data into, it is going fine , however, whenever I try to set up the backspace key to delete the last character of the string, it doesn't seem to work even though cou...
<p>Nevermind, its not that hard, you're going to feel weird after what i'm going to say ^^</p> <pre><code>if (event.type == sf::Event::TextEntered) { if (event.text.unicode == 8) if (sentence.getSize())//If the string doesn't have any char, don't do anything sentence.erase(sentence.getSize() - ...
Chrome Browser becomes laggy after an onClick event <p>I am developing a parallax solution for my website which gets the mouse position every time the user moves the cursor. The problem that I ran into was that when I click anywhere on the document, the browser becomes laggy and jittery. I am able to log the position o...
<p>I made a test CopePen to understand the problem...<br> Since no code was provided.</p> <p>While playing with it (I really had fun!), I found these things that should be considered.</p> <ol> <li>Reduce the unnecessary calculations.</li> <li>Limit decimals passed to <code>translate()</code>.</li> <li>Disable mouse e...
How to create external source maps so can use the Chrome debugger in Vscode / Typescript for the browser using Gulp <p>I wish to use Gulp to build my very simple Typescript project <em>running in the browser</em>. Using <code>gulp-typescript</code> it appears to add modules.export into the generated js files, so I then...
<p>Does your "Launch Chrome" actually start up chrome and find your localhost? I don't see a url option there. I started with that same example code you linked to and it didn't work for me as is, I added some options I found elsewhere and it works. Here's my "launch"</p> <pre><code> { "name": "Chrome : L...
max OSX EI Cap why there are two php.ini files? <p>For the mac os shipped php5.5, i find there are two php.ini files, one is in /etc/php.ini, the other is in /usr/local/etc/php/5.5</p> <p>I tried phpinfo(), it points to the one in /etc/php.ini However, when i use php --ini, it shows the one in the /usr/local/etc/php/5...
<p>When you call php from the CLI you can specify the path to your desired ini file with the -c flag. Any php run by your server uses the ini specified in your server configuration. If you're just looking to make sure they're both looking at the same ini file probably easiest to just tell your CLI calls to php to use t...
how to know which css and js files have been applied to an element <p>Suppose I inspect the navbar in a web page in google chrome. How do I know which CSS and js files are being applied to that navbar?</p>
<p>In the Chrome dev tools you can see what CSS is applied to an element under the "Computed" tab. Scroll down to the attribute such as "font-size" and expand the attribute to see the where the style is set. <a href="https://developers.google.com/web/tools/chrome-devtools/inspect-styles/" rel="nofollow">https://develop...
Optim() taking too long when trying to maximize GARCH(1,1) <p>I have been trying to build my own GARCH(1,1) model. However the solvers I have used so far have either failed to return the optimized parameters or taking way too long to optimize (maybe not converging?). So far I have tried optim() (with Nelder-Mead &amp; ...
<p>I would suggest re visiting your model, when I ask the function to print the parameters e.g.</p> <pre><code>garch_likelihood &lt;- function(asset,fixed=c(FALSE,FALSE,FALSE)) { pars &lt;- fixed function(p) { print(p) ...} </code></pre> <p>Parameters look like in the right range as follows.</...
How can I get type safety for returned functions in TypeScript? <p>This TypeScript compiles fine:</p> <pre><code>abstract class Animal { /* Any extension of Animal MUST have a function which returns another function that has exactly the signature (string): void */ abstract getPlayBehavior(): (toy:...
<blockquote> <p>I am expecting an error because the Cat class definitely does not implement the abstract Animal class properly</p> </blockquote> <p>Because of type compatability. A function (say <code>foo</code>) that doesn't take any parameter is assignable to a function (say <code>bar</code>) that does take a para...
std::map::operator[] <p>I was doing a simple map program but ended up with this question. The c++ doc says this:</p> <p><em>Access element If k matches the key of an element in the container, the function returns a reference to its mapped value. If k does not match the key of any element in the container, the function...
<p>The statement of "using its default constructor" is confusing. More precisely, for <a href="http://en.cppreference.com/w/cpp/container/map/operator_at" rel="nofollow">std::map::operator[]</a>, if the key does not exist, the inserted value will be <a href="http://en.cppreference.com/w/cpp/language/value_initializatio...
SQL Server 2016 JSON in existing column <p>I have been banging my head against the wall, for something that is probably fairly obvious, but no amount of googling has provided me with the answer, or hint that I need. Hopefully the geniuses here can help me :)</p> <p>I have a table that looks a bit like this:</p> <p><a...
<p>Here is one way using <a href="https://msdn.microsoft.com/en-in/library/dn921885.aspx" rel="nofollow"><strong><code>OPENJSON</code></strong></a> to extract the <code>ID</code> from your <code>JSON</code></p> <pre><code>SELECT id FROM Yourtable CROSS apply Openjson([register_sale_products]) WITH (id varchar(500) '...
Handling SIGTSTP signals in C <p>I came across this example code in my studies:</p> <pre><code>#include &lt;signal.h&gt; #include &lt;stdio.h&gt; #include &lt;string.h&gt; char* nums[5] = {"One", "Two", "Three", "Four", "Five"}; char number[6]; void handler(int n) { printf(" %s\n", number); } int main() { s...
<p>To answer the two actual questions you had, the program continues running because your signal handler returns, and nothing you have written in your signal handler causes your program to terminate, so your program continues as normal. If you want your program to terminate, you'd need to call <code>_exit()</code> or <...
Protractor - Ignore Synchronisation flag <p>I have started doing a POC on Protractor as our e2e automation testing tool. Our application is designed in angular which makes it a perfect fit.</p> <p>However, I need to login via google which is a non-angular website and therefore at the start of my test I state</p> <blo...
<p>Few things to fix:</p> <ul> <li>wait for the "click" to go through</li> <li>use <code>browser.get()</code> on the Angular Page</li> </ul> <p>Here are the modifications:</p> <pre><code>signin.click().then(function () { browser.ignoreSynchronization = false; browser.get(tdurl); browser.waitForAngular();...
What does <function at ...> mean <p>Here's the code:</p> <pre><code>def my_func(f, arg): return f(arg) print((lambda x: 2*x*x, (5))) &gt;&gt;&gt;(&lt;function &lt;lambda&gt; at 0x10207b9d8&gt;, 5) </code></pre> <p>How to solve the error, and can some please explain in a clear language what exactly that error mean...
<p>There is no error; you simply supplied two arguments to <code>print</code>, the <code>lambda x: 2*x*x</code> and <code>5</code>. You're not calling your anonymous function rather, just passing it to <code>print</code>.</p> <p><code>print</code> will then call the objects <code>__str__</code> method which returns wh...
Converting If statement to a loop <p>I am working on a practice problem where we are to input a list into a function argument, that will represent a tic tac toe board, and return the outcome of the board. That is, X wins, O wins, Draw, or None (null string).</p> <p>I have it solved, but I was wondering if there is a w...
<p>First up, there are only <em>eight</em> ways to win at TicTacToe. You have nine compare-and-return statements so one is superfluous. In fact, on further examination, you check <code>00, 11, 22</code> <em>three</em> times (cases 3, 6 and 9) and totally <em>miss</em> the <code>02, 11, 20</code> case.</p> <p>In terms ...
Use a list to conditionally fill a new column based on values in multiple columns <p>I am trying to populate a new column within a pandas dataframe by using values from several columns. The original columns are either <code>0</code> or '1' with exactly a single <code>1</code> per series. The new column would correspond...
<p>I can think of a few ways, mostly involving <code>argmax</code> or <code>idxmax</code>, to get either an ndarray or a Series which we can use to fill the column.</p> <p>We could drop down to <code>numpy</code>, find the maximum locations (where the 1s are) and use those to index into an array version of new_col:</p...
For loop - Magic number program <p>What changes should I make so that the user of this code can guess at the amount of magic numbers they choose, with three different chances to guess at each magic number? I am also confused on what to change so that the magic number can change once the user guesses the magic number co...
<p>I'm not sure what your first question is, but for this question "I am also confused on what to change so that the magic number can change once the user guesses the magic number correctly", you should edit the variable <code>magic</code> inside the first <code>for loop</code> so the magic number changes after the use...
Java safe return type container <p>I am a c++ developer by day, and I am used to the convention of const return types. I am aware that there is no facility similar to this in java.</p> <p>I have a specific situation and was wondering the best immutable collection for my task. In C++ I would just use std::vector.</p> ...
<p>If you can live with the boxing cost, a <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#unmodifiableList-java.util.List-" rel="nofollow"><code>Collections.unmodifiableList()</code></a> or <a href="http://google.github.io/guava/releases/19.0/api/docs/com/google/common/collect/ImmutableLis...
How to register JS object via Electron? <p>I'm new on Node.js and Electron.</p> <p>I already developed a Web View Application via CefSharp.WinForm.</p> <p>When I used CefSharp, I added <code>window.AppViewport</code> object like this.</p> <pre><code>chromeBrowser.RegisterAsyncJsObject("AppViewport", new AppViewport(...
<p>You need to define a <code>global</code> object on your <code>Main</code> process,</p> <pre><code>global.yourSharedObj = {some_prop: true}; </code></pre> <p>and with Electron's Remote API, you can access that object in <code>Renderer</code> with something like this:</p> <pre><code>var remote = require('electron')...
how's the input word2vec get fine-tuned when training CNN <p>When I read the paper "Convolutional Neural Networks for Sentence Classification"-Yoon Kim-New York University, I noticed that the paper implemented the "CNN-non-static" model--A model with pre-trained vectors from word2vec,and all words— including the unkn...
<p>The word embeddings are weights of the neural network, and can therefore be updated during backpropagation.</p> <p>E.g. <a href="http://sebastianruder.com/word-embeddings-1/" rel="nofollow">http://sebastianruder.com/word-embeddings-1/</a> :</p> <blockquote> <p>Naturally, every feed-forward neural network that ta...
If multiple classes have a static variable in common, are they shared (within the same scope?) <p>I have the following example code:</p> <pre><code>class A { public: static int a; }; int A::a = 0; class B { public: static A a1; }; A B::a1; class C { public: static A a1; }; A C::a1...
<p>The <a href="http://en.cppreference.com/w/cpp/language/static">static members</a> belong to class, it has nothing to do with objects. </p> <blockquote> <p>Static members of a class are not associated with the objects of the class: they are independent objects with static storage duration or regular functions defi...
The `or` operator on dict.keys() <p>As I've been unable to find any documentation on this, so I'll ask here. </p> <p>As shown in the code below, I found that the <code>or</code> operator (<code>|</code>), worked as such:</p> <pre><code>a = {"a": 1,"b": 2, 2: 3} b = {"d": 10, "e": 11, 11: 12} keys = a.keys() | b.keys...
<p>The <a href="https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects">Python 3 Documentation</a> notes that the <code>dict.keys</code> method is set-like and implements <a href="https://docs.python.org/3/library/collections.abc.html#collections.abc.Set"><code>collections.abc.Set</code></a>.</p> <p>N...
What is the file extension when creating Binary files <p>I am just trying to learn to write to Binary files. When we create text files we normally give the extension .txt. The same way, what should be the file extension for Binary files created using C#.</p> <p>Which are the contexts that demands us to write to a bina...
<p>Absolutely anything you want, or even nothing at all.</p> <p>Just make sure you're consistent, and it helps not to use an extension already in wide use such as .doc or .pdf</p> <p>Microsoft once advised using long extensions of the form <code>.company-program-format</code> [1] since you can have extensions longer ...
On android, how to abort geocoder.getFromLocation <p>A am using the code bellow to get the adress of my lat/lon</p> <pre><code>Geocoder geocoder = new Geocoder(this, Locale.getDefault()); List&lt;Address&gt; addresses = geocoder.getFromLocation(lat, lng, 1); </code></pre> <p>The method getFromLocation is bloking. I a...
<p>Check out the Android documentation for <a href="https://developer.android.com/training/location/display-address.html" rel="nofollow">Displaying a Location Address</a>. </p> <p>Here you create an IntentService, which runs on a worker thread and finishes itself after the <code>onHandleIntent()</code> has completed. ...
nginx reverse proxy fails for post/get requests <p>I'm trying to set up a reverse proxy using nginx for a nodejs application. My node application currently runs on port 8005 of the example.com server. Running the application and going to example.com:8005 the application works perfect. But When I tried to set up nginx m...
<p>There got to be some way to tell nginx about whichever app you are using.</p> <p>So for that, either you can prefix all the apis with say test<code>(location /test/api_uri</code>), and then catch all the urls with prefix /test and proxy_pass them to node, or if there is some specific pattern in your urk, you can ca...
How to disable content selection in mobile browser <p>I'm trying to include a command to disable content in mobile browser. Initially i tried to insert this code in the body of the blog:</p> <pre><code> &lt;body expr:class='&amp;quot;loading&amp;quot; + data:blog.mobileClass'&gt; </code></pre> <p>And this code in the...
<p>Is <code>expr:class='&amp;quot;loading&amp;quot; + data:blog.mobileClass'</code> what applies the <code>mobile</code> class you're trying to target? If so, your selector is a little off. </p> <p><code>.mobile body</code> is looking for a <code>.mobile</code> with a <code>body</code> inside it. What you want is <cod...
What does "Load Playlist started" mean in Visual Studio? <p>When I load my solution into Visual Studio, I get the following in the Output window:</p> <pre><code>------ Load Playlist started ------ ========== Load Playlist finished (0:00:00.0030077) ========== </code></pre> <p><a href="https://i.stack.imgur.com/CNCRV....
<p>Starting with Visual Studio 2012 Update 2 you can create a Playlist in the Test Explorer that consists of a subset of your existing unit tests. (Before VS2012 Update 2 you could only use Traits to sort of group them together.)</p> <p>A Playlist is essentially needed when you only want to run specific unit tests tha...
How to create this type of view in ionic? <p>I tried below code</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.halfOval { background-color: #a0C580; width: 400px; ...
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div style=" background-color: #19cb8d; width: 100%; height: 130px; margin: 0px auto 0px; border-radius: 200px/ 5...
python array data structure <p>is there a data structure in python that is equivalent to array in cpp? one that some elements are initialized and some are not? for example, in python list: [1,2,3], elements have to be sequentially filled in cpp array can be a[0] == 0, a<a href="https://i.stack.imgur.com/G7MBe.png" rel=...
<p>Perhaps this answer here on StackOverflow may be what you are looking for?</p> <p><a href="https://stackoverflow.com/questions/10617045/how-to-create-a-fix-size-list-in-python">How to create a fix size list in python?</a></p>
pandas Dataframe columns doing algorithm <p>I have a dataframe like this:</p> <pre><code>df = pd.DataFrame({ 'A': ['a', 'a', 'a', 'a', 'a'], 'lon1': [128.0, 135.0, 125.0, 123.0, 136.0], 'lon2': [128.0, 135.0, 139.0, 142.0, 121.0], 'lat1': [38.0, 32.0, 38.0, 38.0, 38.0], 'lat2': [31.0, 32.0, 35.0, 3...
<p>It seems like you are trying to apply function <code>angle(...)</code> to every row of your dataframe.</p> <p>First it is necessary to cast all your string-typed numbers into float so as to calculate.</p> <pre><code>df1.loc[:, "lon1"] = df1.loc[:, "lon1"].astype("float") df1.loc[:, "lon2"] = df1.loc[:, "lon2"].ast...
SQL- The multi-part identifier could not be bound <p><a href="https://i.stack.imgur.com/pG5LJ.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/pG5LJ.jpg" alt="enter image description here"></a></p> <p>While executing the following query, I am getting the Multi Part Identifier could not be bound error. Kindly he...
<p>Try this</p> <pre><code>SELECT C.CustomerID, C.LastName, A.ArtistID, A.LastName FROM CUSTOMER as C, ARTIST as A WHERE CUSTOMER_ARTIST_INT.CustomerID=C.CustomerID AND CUSTOMER_ARTIST_INT.A=ARTIST.ArtistID </code></pre>
How can I access a file that I have created externally? AKA where is the file? <p>I'm in the process of trying to create a backup/restore (export/import) process for an SQLite Database App.</p> <p>Although I appear to have created and populated the file (OK I now know that I have). I cannot see the file in DDMS nor in...
<p>The file becomes visible in Windows explorer after disconnecting and re-connecting the USB cable. I'm not sure if this how MTP is meant to work or it could perhaps be due to ADB as per this snippet:-</p> <blockquote> <p>However, if you’ve ever attempted to unlock your device such as to install a new ROM or ro...
Python format() without {} <p>I am working on python 3.6 64 bit.</p> <p>Here is my code:</p> <pre><code>days = "Mon Tue Wed Thu Fri Sat Sun" print("Here are the days",format(days)) </code></pre> <p>The output I got is </p> <p>Here are the days Mon Tue Wed Thu Fri Sat Sun</p> <p>I didn't add "{}" in my string. Als...
<p>I think you're thinking what's happening is similar to:</p> <pre><code>print("Here are the days {}".format(days)) </code></pre> <p>However, what's actually happening is that you're passing in multiple arguments to print(). If you look at the <a href="https://docs.python.org/3/library/functions.html#print" rel="nof...
How To use Database as a variable with blade template in laravel? <p>i'm new in laravel, i have some problem to make database as variable to be shown on blade template, example i want to get any data from database :</p> <pre><code>{{$get = DB::table('perangkat')-&gt;get()}} </code></pre> <p>then:</p> <pre><code>@for...
<p>Write database related stuff in model or controller in a method and pass that value to view. It will be very neat and clear</p> <pre><code>public function getData(){ $get = DB::table('perangkat')-&gt;get(); return view('myblade', ['data' =&gt; $get]); } </code></pre> <p>In your view</p> <pre><code>@fore...
How rotate a Landscape Image to Portrait in Android OpenCV 3 <p>This code rotate a image from Landscape to Portrait, but I can't do it in Android. What is the equivalent code?</p> <pre><code>import cv2 import numpy img = cv2.imread('original.png') h, w = img.shape[:2] img2 = numpy.zeros((w, h, 3), numpy.uint8) cv2...
<p>I assume you have your image as OpenCV Mat in Android (you can load an image by using the <code>Imgcodecs.imread()</code> method).</p> <p>Then you can just do it like this:</p> <pre><code>Mat src = Imgcodecs.imread("path/to/file"); // initialize this with your image from file Core.flip(src.t(), src, 1); // this w...
Python code to return total count of no. of positions in which items are differing at same index <p>A=[1,2,3,4,5,6,7,8,9] B=[1,2,3,7,4,6,5,8,9]</p> <p>I have to compare these two lists and return the count of no. of location in which items are differing using one line python code.</p> <p>For example: the output shou...
<pre><code>count = sum(a != b for a, b in zip(A, B)) print(count) </code></pre> <p>or just <code>print sum(a != b for a, b in zip(A, B))</code></p> <p>you can check about <a href="https://bradmontgomery.net/blog/pythons-zip-map-and-lambda/" rel="nofollow">zip/lambda/map here</a>, those tools are very powerfull and im...
Special characters and json_encode <p>I'm trying to pull some information from a mysql database and then json encode it. I'm running into problems with special characters. I'll pull the info from the database containing the special characters, but then when I use the PHP json_encode function, it fails to encode and re...
<blockquote> <p>Try adding the <code>ENT_QUOTES</code> flag to <code>htmlspecialchars()</code>. It will take care of both single and double quotes for you like so:</p> </blockquote> <pre><code> &lt;?php while($r = $db-&gt;fetch($result)){ $r[] = array_map( 'utf8_encode', ...
How to work with iframes in Chrome DevTools? <p>I'd like to point the developer tools at a specific <code>iframe</code> within a document. In Firefox, there is a <a href="https://developer.mozilla.org/en-US/docs/Tools/Working_with_iframes" rel="nofollow">button</a> in the toolbar. In Chrome, I found this:</p> <p><a hr...
<p>One possible workaround is to enable the still-in-development <a href="http://www.chromium.org/developers/design-documents/oop-iframes" rel="nofollow">Out-of-process iframes (OOPIF)</a> using <code>chrome://flags/#enable-site-per-process</code> flag:</p> <ul> <li>A new devtools floating window will open when an ifr...
sbcl Common Lisp incf warning <p>I was following a tutorial on lisp and they did the following code </p> <pre><code>(set 'x 11) (incf x 10) </code></pre> <p>and interpreter gave the following error:</p> <pre><code>; in: INCF X ; (SETQ X #:NEW671) ; ; caught WARNING: ; undefined variable: X ; ; compilation un...
<p>This is indeed how you are meant to increment <code>x</code>, or at least one way of doing so. However it is not how you are meant to bind <code>x</code>. In CL you need to establish a binding for a name before you use it, and you don't do that by just assigning to it. So, for instance, this code (in a fresh CL i...
How do I find the location of Python module sources while I can not import it? <p>The answer in <a href="http://stackoverflow.com/questions/269795/how-do-i-find-the-location-of-python-module-sources">How do I find the location of Python module sources?</a> says just import it and print its <code>__file__</code>. But my...
<p>Try:</p> <pre><code>import imp imp.find_module('cv2') </code></pre>
Division in Ruby, error <p>it's my first day learning Ruby. I'm trying to write a Ruby program that asks the user for the cost of a meal and then what percentage they would like to tip and then does the calculation and prints out the result. I wrote the following:</p> <pre><code>puts "How much did your meal cost?" co...
<pre><code>ip_calculator.rb:7:in `&lt;main&gt;': undefined method `/' for "20\n":String (NoMethodError) </code></pre> <blockquote> <p>I have no idea what this message means</p> </blockquote> <p>Let's break it down:</p> <ul> <li><code>ip_calculator.rb</code> the file the error occured in</li> <li><code>7</code> the...
Perl Syntax help <p>I am new in perl and Can anyone explain me below command to understand what is purpose of using $t[1]-- and timelocal(1,1,1,reverse @t).</p> <p>Below command used to convert timestamp into epoch format. but please explain me use of this command $t[1]-- and timelocal(1,1,1,reverse @t).</p> <pre><c...
<p>An example is in order:</p> <pre><code>perl -MTime::Local=timelocal -e ' @t = split(/[-\/]/, $ARGV[0]); $t[1]--; print timelocal(1,1,1,reverse @t); ' "2016-10-18" </code></pre> <p>Will print out an epoch date (seconds since Jan 1, 1970)</p> <pre><code>1476766861 </code></pre> <p>Having a look at the ...
Make chrome put table header at the top of each page for long printed table <p>I have a really long table that when printed, spans several pages.</p> <p>Currently, when printing the table, the header row only appears at the very top of the table and not at the top of each page.</p> <p>How can I make the browser (spec...
<p>Use <code>&lt;thead&gt;</code> tag. This is used to group header content in an HTML table. When printing a large table that spans multiple pages, these elements can enable the table header and footer to be printed at the top and bottom of each page.</p> <p>Try this,</p> <pre><code>&lt;table&gt; &lt;!--header--&g...
tester program for my subclass java <p>Output: Write algorithms and programs to create a BetterRectangle sub-class - refer to E9.10 on page 459 in the text. Provide a BetterRectangle sub-class that extends the Rectangle class of the standard Java library by adding methods to compute the area and perimeter of the rectan...
<p>A Tester Class is really just there to let you test your code. The most straightforward way is to define another class, where in the main method, you run a few cases to make sure your newly-added methods are correct. For example:</p> <pre><code>public class BetterRectangleTester { public static void main(String...
How to get the total internal storage of device <p>I am trying to get the total internal storage of the device like user storage with device storage. i am able to get the internal device storage using this code.</p> <pre><code>final File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath(...
<pre><code> public static String getAvailableInternalMemorySize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return bytesToHuman(availableBlocks * ...
Replace values in factor based on frequency of levels <p>Here is a data frame:</p> <pre><code>vegetables &lt;- c("carrots", "carrots", "carrots", "carrots", "carrots") animals &lt;- c("cats", "dogs", "dogs", "fish", "cats") df &lt;- data.frame(vegetables, animals) </code></pre> <p>Looks like:</p> <pre><code>&gt; df ...
<p>Not sure if the levels of variable are important, if not, you could do the following with <code>stringsAsFactors=FALSE</code> as option in <code>data.frame</code></p> <pre><code>vegetables &lt;- c("carrots", "carrots", "carrots", "carrots", "carrots") animals &lt;- c("cats", "dogs", "dogs", "fish", "cats") DF ...
Backbone view - Cross component communication <pre><code>var BaseView = Backbone.View.extends({ }); var ComponentView = BaseView.extends({ }); var ChildView1 = ComponentView.extends({ }); var ChileView2 = ComponentView.extends({ }); </code></pre> <p>I want to a have cross component communication between <code>ChildVie...
<p>In Backbone, I prefer using some sort of publish/subscribe event pattern to communicate between views. In it's most simplest form, your code will look something like the following:</p> <pre><code>/* Create an Event Aggregator for our Pub/Sub */ var eventAggregator = _.extend({}, Backbone.Events); /* Pass that Even...
HttpClient handshake stuck forever <pre><code>public HttpResponseBean get(String url, Map&lt;String, String&gt; headers) throws Exception { logger.debug("Sending get request..."); HttpClient httpClient = null; try { int timeout = 30 * 1000; // 30 seconds RequestConfig re...
<blockquote> <p>Is there a way out of this? I am using httpclient 4.4.1</p> </blockquote> <p>Here's the <a href="https://issues.apache.org/jira/browse/HTTPCLIENT-1478" rel="nofollow">associated bug on the Apache site</a>. It looks like people have had problems with the 4.4.1 version:</p> <blockquote> <p>I had th...
Stop Laravel from loading new URL and let angular handle it <p>So, I have a single page angular app that is opened when I navigate to a URL. If I use the links, moving around within the app is fine - new URLs load just fine. However, if I enter a new URL in the browser URL window and hit enter, the back end framework -...
<p>If I understand your question correctly, you don't want Laravel handles it because the routes is defined in javascript, not in server side. If that's the case, you can simply solve it by using wildcard.</p> <p>Let's say in your laravel's routes you have this line to load your app, views, javascripts etc:</p> <pre>...
Links not working with angular ui-router <p>So I've set up ui-router and I had it working a few minutes ago, sort of, it would display the template with content loaded from another html file, but none of the links would work. Now nothing is working: the template shows up but the content is not pulled in and none of th...
<p>You are mistake the state URL</p> <p>your code <code>&lt;li&gt;&lt;a href="#/about.html"&gt;about&lt;/a&gt;&lt;/li&gt;</code></p> <p>You can access the state by URL from browser, but referencing other section of the app is a <strong>bad practice</strong> though it still works</p> <p><code>&lt;li&gt;&lt;a href="#/...
Bower not installing locally but to my appdata folder on Windows <p>I have this bower.json:</p> <pre><code>{ "name": "project", "version": "0.1.0", "private": true, "dependencies": { "requirejs": "2.1.17", } } </code></pre> <p>When running <code>bower install bower.json</code> it installs it somewhere e...
<p>For anyone having the same issue please note that it should always be <code>bower install</code>.</p> <p>To run the local bower.json add config:</p> <pre><code>bower install --config.directory=mylocalfolder --config.cwd=drive:/..../folder </code></pre> <p>Available configs are described at <a href="https://github...
Replace String values with value in Hash Map in Java <p>I have created a hash map that contains my Key Value pairs to utilize in replacing user input with the value corresponding to the respective key. For exp i have multiple Strings like</p> <pre><code> String pattern = "a+b"; String pattern = "C__a_plus_b+d" Stri...
<p>With Java 8 streams it should be something like:</p> <pre><code>String result = String.join( "+", Arrays.asList(pattern.split("\\+")) .stream() .map((String s) -&gt; vals.get(s)) .collect(Collectors.toList()) ); </code></pre>
ng-view doesn't show in angularjs <p>i want to make route with angularjs. but when i run my app, ng-view doesnt show anything. i'm new in angularjs.</p> <p>index :</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;CRUD&lt;/title&gt; &lt;/head&gt; &lt;body ng-App="myAPP"&gt; &...
<p>You have not closed the <code>js/angular-route.js</code> tag</p> <pre><code> &lt;script src="js/angular.js"&gt;&lt;/script&gt; &lt;script src="js/angular-route.js"&gt;&lt;/script&gt; &lt;script src="js/app.js"&gt;&lt;/script&gt; </code></pre> <p><strong><a href="https://plnkr.co/edit/yllShhhuH1wimgSCqrF7?p=pr...
Maintain object visbility on height increase <p>How to fix object visibility on height scroll.</p> <p>I have the following code below which grows height of the div based on user scroll. When you scroll down the spider image become invisible. </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="...
<p>Try moving the spider outside of its parent div and giving it a fixed position in the bottom corner; it should stay there regardless of scrolling. (You may need to tweak the behavior of the scroll/web line to look right.)</p>
Two model Popup in bootstrap webpage <p>enter image description here</p> <p><a href="https://i.stack.imgur.com/udH0L.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/udH0L.jpg" alt="![SignIn popup"></a></p> <p><a href="https://i.stack.imgur.com/IrxSa.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/IrxS...
<p>remove the # from the selector:</p> <pre><code>function launch_modal(id) { $('.modal').not(id).modal('hide'); $(id).modal('show'); } </code></pre>
Android HttpURLConnection, load only first 4066 symbol, and breaks request <p>The problem is that I do not get a full result. And only some part, that is not part of the sales, and the first 4066 characters.The problem is the same, IOException not seem to be caused by</p> <pre><code>private class GetContent extends As...
<p>Your read logic should be something like this:</p> <pre><code>InputStream in = mConnection.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(in, enconding)); int ch; StringBuilder sb = new StringBuilder(); while ((ch=reader.read()) &gt; 0) { sb.append((...
Upgrade Apache Spark version from 1.6 to 2.0 <p>Currently I have Spark version 1.6.2 installed.</p> <p>I want to upgrade the Spark version to the newest 2.0.1. How do I do this without losing the existing configurations? </p> <p>Any help would be appreciated.</p>
<p>If its maven or sbt application you simply change dependency version of spark and also migrate your code according to 2.0 so you will not lose you configurations. and for spark binary you can take backup of config folder.</p>
SQLAlchemy ORM update value by checking if other table value in list <p>I have a Kanji (Japanese characters) list which looks like:</p> <pre><code>kanji_n3 = ['政', '議', '民', '連'] # But then with 367 Kanji </code></pre> <p>and I have 2 tables: <code>TableKanji</code> and <code>TableMisc</code>. <code>TableMis...
<p>Seems like that your intention is to make an update on joined tables. Not all databases support this.</p> <p>First of all you should use <a href="http://stackoverflow.com/questions/8603088/sqlalchemy-in-clause"><code>in_</code></a> method instead of <code>in</code> operator.</p> <p>You can make select first and th...
PDO, $_GET, and SELECTing from MySQL Database <p>So I'm working on a PHP Pastebin-esque project on my freetime to learn PHP and server management, and I've run into a LOT of issues, and I haven't been able to solve them. I decided to restart from sratch on my own with the information I've gathered so far, and threw thi...
<p>Try this;</p> <p>connection.php</p> <pre><code>try{ $db = new PDO('mysql:host=localhost;dbname=database_name;charset=utf8mb4', 'database_username', 'database_password'); $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db-&gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, false); } catch (PDOException $...
String and 2 letters <p>Hello I am a student and my question in better detail is this.</p> <blockquote> <p>Given a string and two letters (c1 and c2), return a count of the number of times "axb" occurs in the string, where x is any character. For example, given the string "antiaircraft" and the letters 'a' and 't', ...
<p>Just iterate once and keep track, and if you happen to find the first character then do a lookahead:</p> <pre><code>public int countAxA(String s, char one, char two) { char[] cs = s.toCharArray(); int count = 0; for (int i = 0; i &lt; cs.length - 2; i++) { //don't need to go beyond 3rd last char ...
Cannot get Relay to make GraphQL Call over the network <p>I am new to Relay, and I am having problems making it work with a GraphQL server. </p> <p>I have adapted the <a href="https://facebook.github.io/relay/" rel="nofollow">Tea</a> sample from the relay homepage to the SWAPI relay service. I cloned <a href="https://...
<p>According to section 5.1 of <a href="https://facebook.github.io/relay/graphql/objectidentification.htm#sec-Fields" rel="nofollow">this document</a>, the "Relay Object Identification Specification":</p> <blockquote> <p>Relay‐compliant servers may expose root fields that are not plural identifying root fields; th...
Integrate Magento API V2 to ASP.NET <p>I want to Integrate Magento API V2 which is installed in my localhost and call the V2 API in ASP.NET Visual Studio 2015</p>
<p>To Integrate Magento API V2 in ASP.NET you can use Web Service with SOAP protocol. SOAP is a W3C submitted note (as of May 2000) that uses standards based technologies (XML for data description and HTTP for transport) to encode and transmit application data.</p> <p><a href="https://msdn.microsoft.com/en-us/library/...
How to turn EditText to editable text-file like NotePad <p><strong>Hi</strong></p> <p>My problem is, that when I have a blank screen with <code>ScrollView</code> and <code>EditText</code>. I wanted my app to allow user to write what ever and where ever he/she wants, <strong>BUT</strong> when I ran the app, you were on...
<p>In your XML you need <code>android:gravity="top|start"</code> on your EditText.</p> <p>If you want to do it in Java code then it's: <code>myEditText.setGravity(Gravity.TOP | Gravity.START);</code></p>
String replace method issue in java <p>My problem is to replace only the last occurrence of a character in the string with another character. When I used the String.replace(char1, char2), it replaces all the occurrences of the character in the string.</p> <p>For example, I have an address string like </p> <p><code>St...
<p>You should use <code>String.replaceAll</code> which use regex</p> <pre><code>str = str.replaceAll (",$", "."); </code></pre> <p>The <code>$</code> mean the end of the String</p>
Cannot read property 'emit' of undefined error using React/Socket.IO <p>I'm trying to build a basic chat app using React and Socket.Io based on the React tutorial <a href="https://facebook.github.io/react/docs/tutorial.html" rel="nofollow">https://facebook.github.io/react/docs/tutorial.html</a> but keep getting an erro...
<p>The call to <code>this.socket.emit('message', comment)</code> is at the wrong place neither this.socket nor comment is defined in your <code>CommentForm</code> Component.</p> <p>You have to call <code>this.socket.emit('message', comment)</code> in the <code>handleCommentSubmit</code> Method in the <code>CommentBox<...
Sed command keeps on throwing error "Unrecognized Command" <p>I'm having trouble on executing sed command. I would like to know first if sed command is really working on ksh script. I'm using putty as my tool to execute ksh script. </p> <p>If it really works, my command that I am using is <code>sed -e [^a-zA-Z0-9] &lt...
<p>Yours is not a valid <code>sed</code> script. The problem is exacerbated by the lack of quoting.</p> <p>Without quotes, the shell attempts to expand the expression <code>[^a-zA-Z0-9]</code> to a list of matching file names. If you have files named, say, <code>,</code> and <code>?</code> in the current directory, ...
Gridview row doesn't save on Modification <p>I have a <code>gridview</code> in which I insert one row for the first time and save it. Till this it works properly as expected.</p> <p>But when I see the saved data, and wanted to modify/Add one more data, I get error as</p> <blockquote> <p>Column 'EXP_TYPE_ID' does no...
<p>Here as per discussed in a comments, <code>EXP_TYPE_ID</code> does not in exist as column.</p> <p>So change it: </p> <pre><code>newRow["EXP_TYPE_ID"] = Convert.ToString(e.Record["EXP_TYPE"]); </code></pre> <p>To </p> <pre><code>newRow["EXP_TYPE"] = Convert.ToString(e.Record["EXP_TYPE"]); </code></pre>
ERROR 1111 (HY000): Invalid use of group function in MySQL Cluster 7.3 <pre><code>select count(*) from student group by branch </code></pre> <p>This query is perfectly working for me,and i got the output like this. </p> <pre> +----------+ | count(*) | +----------+ | 32 | | 27 | | 50 | | 52 | ...
<p>You can't nest aggregate functions. You need to use a subquery.</p> <pre><code>SELECT MAX(c) FROM (SELECT COUNT(*) AS c FROM student GROUP BY branch) AS t1 </code></pre>
javascript attempting to set element display to none after page load echos 'none' <p>When typing the following into a browser url bar once a page has been displayed, I would expect the referenced element to be hidden. However, what actually happens is the contents of the window is cleared and the word "none" is echoed ...
<p>Which browser and version are you use?</p> <p>According to Mozilla, the function you mentioned is disabled on Firefox version 40 and later.</p> <p><a href="https://developer.mozilla.org/en/docs/Tools/Browser_Console" rel="nofollow">Browser Console - Firefox Developer Tools | MDN</a></p> <blockquote> <p>NB: The ...
Flickering effect when hovering title. Title over opacity background <p>Having this html:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Image hover&lt;/title&gt; &lt;meta charset="UTF-8"&gt; &lt;meta name="viewport" content="width=device-width"&gt; &lt;style&gt; .g...
<p>You can try the following snippet, I changed some of the <code>display:block</code> to <code>opacity:1</code>, and added a z-index property to the <code>.title</code></p> <p>Also I moved your css, got rid of the body, meta etc tags for the purpose of this snippet</p> <p><div class="snippet" data-lang="js" data-hid...
gzip decompression issue on OSX with TIdHTTP and TIdCompressorZLib <p>I'm trying to fetch a page with gzip compression enabled, using <code>TIdHTTP</code> and <code>TIdCompressorZLib</code>. On Windows, the code works fine and the data is decompressed. But the exact same code on OSX is returning garbage data that looks...
<p>You are <em>manually</em> setting the <code>TIdHTTP.Request.AcceptEncoding</code> property to tell the webserver that it is OK to send a compressed response <strong>even if <code>TIdCompressorZLib</code> is not actually ready to handle it</strong>. In your case, the <code>TIdCompressorZLib.IsReady</code> property i...
Android app . fetching data from database <p>I am a new Android app developer and need some help. I want to develop a simple login app just for understanding the working. Using sqlite we can create tables and insert records in our application , but how to keep the table centralised for username and password so that a...
<p>Are you aware of the backend and frontend? sqlitedatabase doesnot stores the universal data which is available for all the users. the database you are talking about needs to be stored in the server side or what people also say backend. that is the "centralised part" you are talking about. read about frontend and bac...
Osmdroid maps not loading on my device <p>I have an Alcatel One Touch 7040, when i test my sample of osmdroid on it, the maps don't render. I have tested on other devices, the maps are rendering in them properly, only on this device they are not. I thought my device memory was low so I deleted some apps from my device,...
<p>What API level is the device? It could be a permissions issues. Sometimes android also mounts <code>Environment.getExternalStorageDir()</code> as read only, which is wrong. One of these days I'm going to fix this with a work around.</p> <p>Does the example application provided by osmdroid work? Not only do you have...
AWS : Play Custom Sound When Push Messages are received <p>I have implemented Amazon Web Service(AWS) for notification messages in my app, I am able to send message from Amazon SNS Server successfully.</p> <p>Now i want to implement <strong>default/custom</strong> sound, when any messages are received from AWS.</p> <...
<p>Try as bellow</p> <p>Please make sure to change the JSON according to your need</p> <pre><code>{ "aps" : { "category" : "NEW_MESSAGE_CATEGORY" "alert" : { "body" : "Acme message received from Johnny Appleseed", "action-loc-key" : "VIEW" }, "badge" : 3, "sound" : "chime.aiff" }, ...
Bash function comment extraction from sourced file <p>I have a bash script with functions I have sourced from a random file, that I no longer retain the original path.</p> <pre><code>#!/bin/bash my_awesome_function() { #- Usage: my_awesome_function &lt;key&gt; &lt;to&gt; &lt;success&gt; echo "I'm doing something...
<p>Try:</p> <pre><code>my_awesome_function() { [ "$1" = "--help" ] &amp;&amp; { echo 'Usage: my_awesome_function &lt;key&gt; &lt;to&gt; &lt;success&gt;' return } echo "I'm doing something great." } </code></pre> <p>Example:</p> <pre class="lang-none prettyprint-override"><code>$ my_awesome_function ...
Inapp purchases disappear on android ionic app <p>I'm trying to implement inapp purchases with the plugin <code>cordova-plugin-inapppurchase</code> The products load, but after the products are loaded the products doesn't show. </p> <p>What's my mistake?</p> <p>This is my code: </p> <pre><code>&lt;h3 class="inapp_te...
<p>You are just loading product that's why its not appearing.</p> <p>you have to print it to show as below.</p> <pre><code>&lt;h3 class="inapp_textw" ng-repeat="product in products" ng-click="buy(product.productId)"&gt;{{product}}&lt;/h3&gt; </code></pre>
angular without dependencies is not working <p>I just started angular js and l started with the basic declaration of a module without services and factories. It was working well before adding services and factories. Now after adding services and factories its not working anymore.</p> <p>The first declaration that is n...
<p>You are redeclaring the module 'root' instead of adding a new module 'services', since you´ve again added 'services' to your to the dependencies. You don´t have to redeclare 'root' in the new module, since it should be standalone and portable. Check out the module documentation: <a href="https://docs.angularjs.org...
Cannot add asset: Process : Task node [2] has no task type <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!-- origin at X=0...
<p>It seems that you have an invalid process definition. Try to use validation in the Designer to see all the errors you need to fix.</p>
Is calling $scope.$digest within $scope.$on fundamentally incorrect? <p>I have inherited some AngularJS code, and I know very little about it (the code and Angular both). The code that I inherited contains several places where <code>$scope.$digest</code> is called within a <code>$scope.$on</code> method within a contro...
<p><a href="https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$on" rel="nofollow"><code>$scope.$on</code></a> gets called in response to <a href="https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$broadcast" rel="nofollow"><code>$scope.$broadcast</code></a> or <a href="https://docs.angularjs.org/api/ng/type...
Angular 2: How to use Observable filter <p>I have a service that calls the API like this:</p> <pre><code>return this._http .post(appSettings.apiUrl + 'SomeController/SomeAction', params, {withCredentials: true, headers: this.headers}) .timeoutWith(appSettings.maxTimeHttpCalls, Observable.defer(() =&gt;...
<p>Whether <code>filter()</code> should be before or after <code>map()</code> depends on what you want to do.</p> <p>I guess in your case <code>map()</code> should go before <code>filter()</code> because you want to first decode data from JSON and then filter it. The way you have it now won't return anything if the co...
How to calculate the timer while items at added runtime in tabcontrol <p>we have test the automation teascase.so i have added tabcotrol and using the button click event to add the 40 tabitem at Runtime.In our requirement how to calculate the timer at while adding the tabitem. </p>
<p>A simple way to solve it is to compare the time before and after.</p> <pre><code>DateTime now = DateTime.Now; // When you start. for (int i = 0; i &lt; 40; i++) { // Your logic for adding the tab here... AddTab(); } TimeSpan elapsed = DateTime.Now - now; //When you're done. Console.WriteLine(elapsed.TotalMi...
c# Base64 Encoding Decoding wrong result <p>I need to create a hash-signature in c#. </p> <p>The pseudo-code example that i need to implement in my c# code: </p> <pre><code>Signatur(Request) = new String(encodeBase64URLCompatible(HMAC-SHA-256(getBytes(Z, "UTF-8"), decodeBase64URLCompatible(getBytes(S, "UTF-8")))), "U...
<p>You're assuming that your key was originally text encoded with UTF-8 - but it looks like it wasn't. You should keep logically binary data <em>as</em> binary data - you don't need your <code>Base64Encode</code> and <code>Base64Decode</code> methods at all. Instead, your <code>HmacSha256</code> method should take a <c...
String to template type via Object.factory(...) <p>Can a string be converted to a template parameter, or alternatively, is there an idiomatic D way to achieve the concept of passing deserialized classes as class/function template parameters.</p> <p>The concept is based on <a href="http://cqrs.nu/tutorial/cs/02-domain-...
<p>You cannot use runtime values as template parameters. But you have options:</p> <ol> <li><p>Cast it to IEvent and let the event initiate <code>apply</code> with an overloaded function. (<a href="https://en.wikipedia.org/wiki/Visitor_pattern" rel="nofollow">Visitor pattern</a>)</p> <pre><code>class UserCreated : IE...
Installer framework on Ubuntu <p>I'm trying to create an installer for a C++ program on Ubuntu. One requisite is that once something is installed if the installer is run again, it will remove the old version and re-install the new one.</p> <p>I've tried the Qt Installer Framework, which was very easy to set up but doe...
<p>If you don't want to use the distributions' package manager:</p> <ul> <li><p>Write a shell script that copies the files using <code>install</code> (as @MD XF sugessted).</p></li> <li><p>Write a <code>Makefile</code> (<a href="https://www.gnu.org/software/make/" rel="nofollow">https://www.gnu.org/software/make/</a>)...
How to set "CheckBoxes" to checked from treeview using javascript? <p>I'm using kendo mvvm frameworks. I would like to check certain checkbox with an array contain the checkbox value. Example </p> <pre><code>var checkboxValue=["a","c"] [x]a [ ]b [x]c </code></pre>
<p>Try this:</p> <pre><code>var values = ["A", "C"]; var setTreeViewValues = function(values) { var tv = $("#treeview").data("kendoTreeView"); tv.dataItems().forEach(function(dataItem) { if (values.indexOf(dataItem.text) &gt; -1) { dataItem.set("checked", true); } }); }; setT...
What is the impact of async action method on IIS? <p>I need help in understanding how async action method can improve performance of IIS (and eventually my application).</p> <p><strong>First I tried to create Server Unavailable (503) with following code and setup</strong></p> <ul> <li>Application Queue Length: 10</li...
<p>Defining an async action method <strong>does not affect how many requests IIS can serve of the same type</strong>. You are correct when you say that the thread itself is released during the Task.Delay call, but the <em>request</em> is still there in the queue. </p> <p>You would see a difference only if you sent a f...
Get notification when added / updated any single contact in phone book in android <p>I want to sync contact whenever new contact added or updated. don't want to sync any specific time. </p>
<p>You can add ContentObserver with service this will notify you on contact data changes. Just register contact uri with ContentObserver Ref -<a href="https://developer.android.com/reference/android/database/ContentObserver.html" rel="nofollow">https://developer.android.com/reference/android/database/ContentObserver.ht...
session not created exception for chrome in Protractor <p>I get below error when try to run Protractor test against chrome.</p> <p>My conf.ts</p> <pre><code>import {Config} from 'protractor' export let config: Config = { framework: 'jasmine', // capabilities: { browserName: 'chrome'}, multiCapabilities: ...
<p>I don't have enough rep yet to leave a comment under Sudharsan's answer but the location of the config file he is telling you to modify is actually at </p> <pre><code>node_modules/protractor/node_modules/webdriver-manager/config.json </code></pre> <p>It's not the protractor tsconfig but the webdriver-manager <code...
HTML5 input - pattern with required="true" attribute still allows form submission <p>I have text box as below</p> <pre><code>&lt;input type="text" name="country_code" pattern="[A-Za-z0-9|]{1,50}" title="Three letter country code" required="true"&gt; </code></pre> <p>When I submit the form without entering any value i...
<p>Your syntax is wrong. Only <code>required</code> is required.</p> <pre><code>&lt;input type="text" name="country_code" pattern="[A-Za-z0-9|]{1,50}" title="Three letter country code" required&gt; </code></pre> <p>It's actually <code>required="required"</code> but you can ommit the second one and use the shorthand i...
StringBuilder returning list of strings + a NewLine at the end when copying to clipboard? <p>I have a loop which is appending a new line every time it loops. By the time it finishes, and I copy to clipboard the <code>StringBuilder.ToString()</code> and I paste it in notepad, the blinking cursor remains on a new line be...
<p>I see that the string you copy to the clipboard ends with a new line. Of course this new line is pasted and thus your cursor is on the new line.</p> <p>Somehow you have to get rid of this new line. The method to do this depends on your precise specifications:</p> <blockquote> <p>If the string is copied to the cl...
Get child name from Firebase? <p>If I have something like:</p> <pre><code>child name: "value" </code></pre> <p>How can I get the childname? I know its possible to get the value, but what about the other?</p>
<p>Yes! The child name in this situation is the "KEY" of that value. So use the reference object and simple called getKey() on it.</p> <pre><code>String name = ref.getKey(); </code></pre>
Andorid - Big Picture Style image not showing properly <p>Image in big picture style not showing in proper way. From top and bottom it cuts.</p> <p>Here is code to generate notification:</p> <pre><code>private void notificationWithImage(String url, String msg, int smallLogo) { try { Bitmap icon1 = BitmapF...
<p>The thing that you want can be done perfectly by the use RemoteView in Notification &amp; then Apply customView in Builder. </p> <p>This is a template code to use RemoteViews : - </p> <pre><code> RemoteViews remoteViews = new RemoteViews(getApplicationContext().getPackageName(), R.layout.notification_layout); No...
how do I calculate a rolling idxmax <p>consider the <code>pd.Series</code> <code>s</code></p> <pre><code>import pandas as pd import numpy as np np.random.seed([3,1415]) s = pd.Series(np.random.randint(0, 10, 10), list('abcdefghij')) s a 0 b 2 c 7 d 3 e 8 f 7 g 0 h 6 i 8 j 6 dtype: int64...
<p>There is no simple way to do that, because the argument that is passed to the rolling-applied function is a plain numpy array, not a pandas Series, so it doesn't know about the index. Moreover, the rolling functions must return a float result, so they can't directly return the index values if they're not floats.</p...
Generate JSON file using JavaScript code <p>I'm new to Web Development and just created a simple form in HTML and using some JavaScript I can submit the form by HTTP Post. I wanted to know whether there is a way to generate a JSON file with JSoN objects in it and then upload it to a JSON based database like firebase? T...
<p><strong>Short answer:</strong> yes, just use var <code>json = JSON.stringify(array);</code></p> <p><strong>Long answer:</strong> You need an array, or better: an object array. If you assign keys it will be much easier to work on serverside. However just stringify the array and you are done.</p>
Python/Math Find Previous Value in Fibonacci Sequence with a Function/Equation <p>This is slightly less code related...<br> I am making a function that calculates a Fibonacci number backwards. </p> <p>Not just print it backwards but do the math itself backwards.<br> I did a little research using Phi and phi... </p>...
<pre><code> def FingFactorial(n): if n == 1: return 1 else: res = n * FingFactorial(n-1) return res n=int(input("Factorial Of : ")) print("Factorial Of",n,"Is :",FingFactorial(n-1)) </code></pre> <p>this code may give your desired result .. :) <a href="http://blog.iamovi.me/function-...
combine two element in an array perl <p>I want to compare two sequences using <code>standalone blastn</code>. </p> <p>But before I can do that I have to cut the sequence into 1020nt of each fragment. If the last fragment is less than 1020nt, i have to merge (the sequence) in the last fragment with sequence in the prev...
<p>You need to remove the last cut and append it to the second-to-last cut using the <code>.=</code> concatenation operator:</p> <p>Here is a simplified example:</p> <pre><code>#!/usr/bin/env perl use warnings; use strict; my $total_length = 100; my $chop_length = 14; my @letters = qw( A C G T ); my $long_string ...
How to make "ld" link in 32bit mode? <p>I've got assembly source file under ubuntu 64bit version. I wish to compile a 32bit version.</p> <pre><code>$ cat 1.s .code32 .text .globl _start _start: movl $2,%ebx movl $1,%eax int $0x80 $ as 1.s $ readelf -h 1.o ELF 头: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 0...
<p>Just change your output ELF format with the <code>-melf_i386</code> flag:</p> <pre><code>ld 1.o -o my -melf_i386 </code></pre>
How to convert large UTF-8 encoded char* string to CStringW (UTF-16)? <p>I have a problem with converting a UTF-8 encoded string to a UTF-16 encoded <code>CStringW</code>.</p> <p>Here is my source code:</p> <pre><code>CStringW ConvertUTF8ToUTF16( __in const CHAR * pszTextUTF8 ) { _wsetlocale( LC_ALL, L"Korean" );...
<p>The code in the question is stock full of bugs, somewhere in the order of 1 bug per 1-2 lines of code.</p> <p>Here is a short summary:</p> <pre><code>_wsetlocale( LC_ALL, L"Korean" ); </code></pre> <p>Changing a global setting in a conversion function is unexpected, and will break code calling that. It's not even...