input
stringlengths
51
42.3k
output
stringlengths
18
55k
Creating a dictionary in python by combining two .csv files <p>I am trying to create a dictionary in python by combining data from two .csv files, by matching the first column of the two files. This is what I have so far </p> <pre><code>import csv with open('a.csv', 'r') as my_file1 : rows1 = list(csv.reader(my_...
<p>You're creating a new dictionary on every iteration of your <code>for</code>, so only the update from the last iteration is kept, others have been thrown away.</p> <p>You can solve this by moving the dictionary setup outside the <code>for</code>:</p> <pre><code>new_dict = {} for i in range(10): ... </code></pr...
Given known origin and destination latitude/longitude, how can I create its bounding box? <p>Origin Latitude/longitude: 39.50000000,-84.78000000</p> <p>Destination Latitude/longitude: 28.42000000,-81.31000000</p> <p>How can I draw its bounding box?</p> <p>The correct bounding box is:</p> <pre><code>+-----1 | / | ...
<p>you can use fitbounds</p> <pre><code>&lt;body&gt; ..... &lt;div id='your_map_id' style='height : 300px; width: 300px;'&gt;&lt;/div&gt; &lt;body&gt; &lt;style&gt; var mapDiv = document.getElementById('your_map_id'); var map = new google.maps.Map(mapDiv, { mapTypeId: google.maps.MapTypeId...
Swift3 Xcode8 - iOS app User profile data update and display in Profile Screen view <p>First post and coding since 2 weeks, please be indulgent. Learning in the making.</p> <p>It saves the users details correctly in Firebase under its own UID. My problem is that once the user logs out and log back in, the second party...
<p>Sorry for the silence. I was away from my laptop. These are my suggestions.</p> <ol> <li><p>Get rid of the data node; it seems rather redundant. You can simply add other nodes under the root node i.e. <em>appname</em>.</p></li> <li><p>Refractor your <code>viewDidLoad</code>; because its rather convoluted. Put the f...
Rails 5: partial view with condition and locals <p>I'm a bit lost in creating "New campaign" button if user has particular role.</p> <p>In models/roles.rb I have:</p> <pre><code>class Role &lt; ApplicationRecord belongs_to :user, optional: true accepts_nested_attributes_for :user enum general: { seller: 1, buy...
<p>As far as I know you can't render the form with locals from the controller. Is there any reason why you would want to use a local? - these are normally used when rendering partials to pass local variables from one view to the partial, for purposes of reuse. for example...</p> <pre><code>&lt;%= render partial: 'form...
Dealing with NA in numeric vector and using transform <p>I came up with a very hacky way of dealing with an issue I faced when combining two columns, but there must be a better/more efficient way to do what I did. Any suggestions for an R novice would be much appreciated. </p> <p>I have two columns, one with code and ...
<p>You can use the <code>ifelse</code> function:</p> <pre><code>transform(df, code_location = ifelse(is.na(code), as.character(location), paste(code, location))) </code></pre> <p>Note that <code>df$location</code> is a factor, so it needs to be...
Python: printing result of multiple inputs <p>I'm pretty new to python programming, but i'm trying to write a program that goes as follows:</p> <p>First: the program asks the user for a fixed number. Then: the user can input as many numbers as he wants, until he writes "stop". (this is not really where i'm having trou...
<pre><code>input_list = [] sum = 0 while True: user_input = int(input('Enter the number')) if user_input != 'stop' input_list.append(user_input) elif user_input == 'stop': break; for i in input_list: sum += i print(sum) </code></pre>
Jquery multiple file upload issue <p>I'm using Jquery File Upload plugin, to upload files, here is method which gets files from server and generates HTML and inserts in into an element: </p> <pre><code> getFilesToHolders:function (id,tablesName) { //attachecedFiles is a container for the generated html ...
<p>The problem was with asynchronicity, <code>done</code> function was firing asynchronously so my getFile function was in the "queue" , the fix was just to place <code>attachedFiles.html('');</code> inside getFile function, so it will erase everything and start over, populating the div;</p>
How to get distance triggers working in argon.js and AFrame? <p>I'm trying to add distance triggers to an object in my ar-scene, following the <a href="https://github.com/argonjs/argon-aframe" rel="nofollow">code snippet</a> on the project's github page.</p> <p>The following gives me errors in Argon.</p> <p><code>&l...
<p>(This all assumes you are using argon.js and argon-aframe.js from <a href="http://argonjs.io" rel="nofollow">http://argonjs.io</a>)</p> <p>The "event" attribute of your trigger needs to be the name of an event you want to generate, not code to execute. The attributes of the components (like trigger) specify paramet...
How to extend a website with a calculated column? <p>I actually don't know what I could search for, so I need advice in technology. So what do I want?</p> <p>Imagine you are visiting a website and you see a table/div combination like this:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="tru...
<p>To adjust a page that way you need to modify it using <a href="https://developer.mozilla.org/en-US/docs/Glossary/JavaScript" rel="nofollow">JavaScript</a>.</p> <p>Regarding your example, to add the sum after the price and quantity you could have a script like this:</p> <pre class="lang-js prettyprint-override"><co...
What does defining a function with in the __init__ constructor in python mean? <p>I have just seen the following code and would like to know what the function within the <code>__init__</code> function means</p> <pre><code>def __init__(self): def program(percept): return raw_input('Percept=%s; action? ' % ...
<p>This code</p> <pre><code>class Foo: def __init__(self): def program(percept): return raw_input('Percept=%s; action? ' % percept) self.program = program </code></pre> <p>AFAIK, is actually the exact same as this since <code>self.program = program</code>. </p> <pre><code>class Foo: ...
Why reinterpret_cast fails while memcpy works? <p>I'm writing some socket code and based on some params I'm using either IPv4 or IPv6. For that I have a code like this:</p> <pre><code>struct sockaddr final_addr; ... struct sockaddr_in6 addr6; ... memcpy(&amp;final_addr, &amp;addr6, size); ... bind(fd, &amp;final_addr...
<p>If in the first version of the code <code>size</code> is <code>sizeof(addr6)</code> (as you stated in the comments), then the first version of the code uses <code>memcpy</code> to copy <code>sizeof(struct sockaddr_in6)</code> bytes of data.</p> <p>The second version of the code uses regular <code>struct sockaddr</c...
Inner join multiple tables get name instead of id <p>I have 4 tables</p> <pre><code>Table incidences-employees --------------------------- idIncidenceEmployee PK idEmployee FK (employee.idemployee) idMasterIncidence FK (incidence-master.idIncidence) createdby FK (user-employee.idMongoUser) authorizedBy FK (user-employ...
<p>incidences-employees.* is giving you all the fields from that table, which include the two IDs. One approach is to do two more joins, joining the employee table to the incidences table where employee.idemployee = incidences-employee.createdby and authorizedby. </p> <p>Then instead of using .*, you reference each ...
How To Change Pycharms Default Testing Skeleton From Unittest Format to Pytest? <p>I'm trying to change from Unittest to PyTests. After changing the default test runner from Unittests to py.test under Python integration Tools I'm still getting the Unittest skeleton when creating a new test:</p> <p>Instead of this:</p...
<p>In my case, the best solution I came up with was creating a new template. I called it <code>Python Test</code> and the template is as follows.</p> <pre><code># -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals import pytest def test(): pass </code></pre> <p>This speeds up enough...
adding tuples to a list in an if loop (python) <p>I'm working in python with symbulate for a probability course and running some simulations. </p> <p>Setup: Two teams, A and B, are playing in a “best of n” game championship series, where n is an odd number. For this example, n=7, and the probability team A wins an...
<p>So you're looking to store the results of each test? Why not store them in a <code>list</code>?</p> <pre><code>test1_results = [] for x in range(0,10000): test1 = test[x] # check if first element in sequence of game outcomes is a win for team A if test1[0] == 1: # or '1' if you're expecting string ...
How can I display the results of a javascript function <p>I have an HTML link which is playing a sound through a javascript function.</p> <pre><code>&lt;a style="width:20%;" href="javascript:playArSound();"&gt;Listen&lt;/a&gt; </code></pre> <p>I would like to find out the value of href after the javascript has been p...
<p>You need to use <code>getAttribute()</code> method to get the value of any attribute of element.Try the below code.</p> <pre><code>document.getElementsByTagName("a").getAttribute('href') </code></pre>
Select All checkbox in table header is causing issues <hr> <p>I have a table which contains a 'Select All' checkbox as the first column in the header row.</p> <p>The problem is column headers make perfectly sense when they represent the data type of their columns but the content of this th is just a checkbox with a "...
<p>I'm having a hard time understanding how 'Select All' is a valid heading. The heading is meant to provide context for the data in the associated cells. Used properly, a screenreader will read out the heading as you navigate into the column/row. </p> <p>If someone navigates from a cell in the second column into a ce...
gulp.series() doesn't run tasks <p>I can't figure out why <code>gulp.series()</code> is not firing in my callback function. </p> <p>I'm trying to grab a string from a user input with <code>gulp-prompt</code> and invoke a build and deployment function with <code>gulp.series()</code>. My tasks within <code>gulp.series()...
<p>Calling <code>gulp.series('task1', 'task2')</code> does <strong>not</strong> run <code>task1</code> and <code>task2</code>. All it does is return a new function. Only once you call <strong>that</strong> function are the tasks actually executed.</p> <p>That means in your case you need to do the following:</p> <pre>...
changing file content - is this a bug in g++ 4.7.2 or am I doing it wrong? <p>While writing some code to update a position in a binary file I noticed something strange. Consider this example code:</p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;string&gt; using namespace std; int main()...
<blockquote> <p>Now I wonder, is this a bug in the old g++</p> </blockquote> <p>No, there is no bug in g++ in this regard.</p> <blockquote> <p>or am I doing it wrong</p> </blockquote> <p>Yes. This is explained in the <a href="http://stackoverflow.com/questions/17536570/reading-and-writing-to-the-same-file-using-...
git lfs bfg: after that, resolve conflicts how? <p>We have a repository in which we committed PDF snapshots of reports. I want to try out git lfs, see if it improves the quality of life.</p> <p>I followed the procedures here (<a href="https://github.com/rtyley/bfg-repo-cleaner/releases" rel="nofollow">https://github.c...
<blockquote> <p>I think I'll probably just make a clean clone of the remote and go on from there.</p> </blockquote> <p>Right, this is the most important step after using any tool, be it BFG, filter-branch etc. which rewrites history (and usually in doing-so is removing unwanted files referenced in that history). BF...
Ruby regex eliminate new line until . or ? or capital letter <p>I'd like to do the following with my strings: </p> <pre><code>line1= "You have a house\nnext to the corner." </code></pre> <p>Eliminate <code>\n</code> if the sentence doesn't finish in new line after dot or question mark or capital letter, so the desire...
<p>You are nearly there. You need to a) escape both <code>?</code> and <code>.</code> and b) remove quotation marks around <code>\n</code> in the expression:</p> <pre><code>line1= "You have a house\nnext to the corner.\nYes?\nNo." line1.gsub!(/(?&lt;!\?|\.)\s*\n\s*/, " ") #⇒ "You have a house next to the corner.\nYe...
Swift Memory Management <p>I am developing an app in Swift and I am coming from non-arc Objective-C background. I ran into memory issues. So, I implemented <code>deinit</code> in my ViewControllers. None of them got called. Some code example:</p> <pre><code>@objc protocol ServerDelegate { @objc optional func onUpd...
<p>There is a system cache for images per the documentation of <a href="https://developer.apple.com/reference/uikit/uiimage/1624146-init" rel="nofollow"><code>UIImage.init(named:)</code></a>; you cannot manually flush it but Apple's design intention is that you wouldn't ever get any benefit from doing so if you could â...
awk print overwrite strings <p>I have a problem using awk in the terminal. I need to move many files in a group from the actual directory to another one and I have the list of the necessary files in a text file, as:</p> <p>filename.txt </p> <pre><code>file1 file2 file3 ... </code></pre> <p>I usually digit:</p> <pr...
<p>Your input file contains carriage returns (<code>\r</code> aka <code>control-M</code>). Run <code>dos2unix</code> on it before running a UNIX tool on it.</p> <p>idk what you're using paste for though, and you should not be using awk for this at all anyway, it's just a job for a simple shell script, e.g. remove the ...
Grid.MVC Sorting Bug <p>Grid.MVC sorting not working as expected. For example I have a column with a number value and also date values. The screen shots provided show only the Total Premium sort not working right, but the same thing happens on the Effective Date Column as well. Is there something additional I need to d...
<p>Thanks Santi for the comment. </p> <p>The type for the model was being formatted to a string to show a certain format before it got to the grid. Removed the string formatting and put the formatting up at the grid to allow sorting on the proper type and still show formatting. New grid below with the additional .F...
how to display title of websites in node.js <p>I want to get title of different site. like this.</p> <pre><code>localhost:1234/index/?url=google.com&amp;url=www.yahoo.com/&amp;url=twitter.com </code></pre> <p>if i got to this url it crawl on all the mention site in the url and display title of website.</p> <pre><cod...
<pre><code> var Urls = 'localhost:1234/index/?url=google.com&amp;url=www.yahoo.com/&amp;url=twitter.com'; // remove all special characters like '/' '&amp;' and '=' Urls = Urls.replace(/\&amp;/g, '').replace(/\//g, '').replace(/\=/g, ''); // split it based on url Urls = Urls.split('url'); //delet...
Open Youtube Video With Image on iPhone Safari HTML Page <p>Could someone please help me to figure out how to use a placeholder image to open a youtube video on mobile so that if the user clicks the image on the html page in safari on iphone, the video automatically plays fullscreen (note: on iphone the video would aut...
<p>Does the normal syntax below give you some sort of issue? It looks ok on my emulator... :</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body&gt; &lt;p&gt;&lt;a href="https://www.youtube.com/embed/ALqFFeU-Wp8"&gt;Full Screen&lt;/a&gt;&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
How to execute a line in a definition only once <p>So basically, I defined a variable in the beginning of a function and then i called it in a while loop. The problem is that inside the function I change the variable from True to False based on a condition. I want the variable to remain False. But since the definition ...
<p>Perhaps you can just made the variable a member of the object. Something like this:</p> <pre><code>class LaserClass(): def __init__(self, pic, pos = (0,0)): self.original_image = pic self.position = Vector2D(*pos) self.rotateDone = False def update(self): 'some code here' ...
Kubernetes 1.4 secret file permission not working <p>running K8s 1.4 with minikube on mac. I have the following in my replication controller yaml:<br> </p> <pre><code>volumes: - name: secret-volume secret: secretName: config-ssh-key-secret items: - key: "id_rsa" path: ./id_rsa...
<p>The .ssh directory has links to the actual files. Following the link shows the actual files have the correct permissions (read only for id_rsa). </p> <p>I validated the ssh setup would actually work by <code>exec</code>ing into a container generated from that replication controller and doing a git clone via ssh to ...
svn commandline options to check in all files and not open the gui <p>Tortoise svn commandline tool is there a switch or an argument to check All files and to suppress the gui. I am working on source control automation.</p> <pre><code>TortoiseProc.exe /command:commit /path:"C:\SVN" /url:"http://mysvnserver/trunk" /clo...
<p>As Ken White alluded to in his comment, TortoiseSVN is not designed to be automated in a completely "silent" fashion. If that's your requirement, you should use <code>svn.exe</code> (which is installed with TortoiseSVN as an optional component, or you can get it standalone).</p> <p>If there's a module/library for t...
Parsing JSON with Bash JQ Issue <p>Using bash JQ parser, Im trying parse the fields from a cURL <code>JSON</code> response.</p> <p>In file <code>'a.json'</code> has 4 'hash' values and <code>'b.json'</code> has 5 'hash' values. Based on the assumption that my results will be similar to <code>"a.json"</code> I wrote a ...
<p>You can get all the values with this:</p> <pre><code>jq -r '.info.file.hashes[] | .value' *.json </code></pre> <p>Suppose you need only the values where name == "B"</p> <pre><code>jq -r '.info.file.hashes[] | select(.name == "B") | .value' </code></pre> <p>Suppose you need only the values where name == "B" <em>o...
How to copy current state of master branch into another branch? <p>Have tried the accepted answer on this page here: <a href="http://stackoverflow.com/questions/3672073/how-to-merge-the-current-branch-into-another-branch">How to merge the current branch into another branch</a></p> <p>But the problem is, the master do...
<p>For marking specific points in history, you should use <strong><em><a href="https://git-scm.com/book/en/v2/Git-Basics-Tagging" rel="nofollow">tags</a></em></strong>, not "abandoned" branches.</p>
CardView Xamarin Android <p>I try to make CardView</p> <p>I have this code for Adapter:</p> <pre><code> using System; using System.Collections.ObjectModel; using System.Collections.Specialized; using Android.Support.V7.Widget; using Android.Views; namespace NavDrawer.Adapters { public class RecyclerAdapter&lt;T...
<p>mate.</p> <p>In your SponsorsList layout, do you have the RecyclerView view?</p> <pre><code> &lt;android.support.v7.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="wrap_content" android:clipToPadding="false" andro...
Correct workflow when using parent NSManagedObjectContext <p>I'm using a chain of <code>NSManagedObjectContext</code> to represent a hierarchy of views and actions that can be rolled back/cancelled. This is one example: Let's say I have the following structure:</p> <ul> <li>Client list (Main NSManagedObjectContext)</l...
<p>Using all these nested child contexts is almost certainly the wrong approach. For the most part you only want the one main context while on the main thread, however if you have a whole bunch of changes that only make sense when done and saved together then you can use a temporary child context for that. When you sav...
How to catch a PermissionDenied(403) from Django with Ajax? <p>So im trying to handle a GET request with AJAX instead of Django so I can display a simple pop-up/modal with jQuery when a 403 Forbidden (Given by Django) is raised, however im not sure how to continue right now.</p> <p>This is my Javasscript that handles ...
<p>You should be able to see HTTP errors in the <code>error</code> handler:</p> <pre><code>$.ajax({ ... error: function (xhr, ajaxOptions, thrownError) { if(xhr.status==403) { alert(...); } } } </code></pre> <p>You will always see the 403 in the console as that's the HTTP respo...
How to check that fscanf() returns valid string in C? <p>I have a C / fscanf() question. FULL DISCLAIMER: I am CS student, working on an assignment. My code works, but the graders will compile our submissions with using the GCC "all errors and warnings" option:</p> <pre><code>gcc -Wall yourCodeHere.c </code></pre> ...
<p><code>string</code> in your code is a pointer rather than an array. There is no memory allocated for <code>fscanf</code> to copy the characters into. Changing it to a character array will work as would <code>string = malloc(X);</code> where X is the number of bytes you want to allocate. Remember that you'll need ...
Mock Kotlin class in Java unit test <p>I have this Java test with Mockito:</p> <pre><code>public class PersistentNodeDeserializerTests { @Test public void userInfoPersistentNodeDeserializer() { PersistentNode node = mock(PersistentNode.class); when(node.stringChild("username")).thenReturn("cli...
<p>this library may solve your issue <a href="https://github.com/nhaarman/mockito-kotlin" rel="nofollow">https://github.com/nhaarman/mockito-kotlin</a></p> <p>EDIT: sorry, didn't realize you were using a Java test. If it's an option, try writing your test in kotlin too</p>
Pick file from Custom gallery of Audio and Video files <p>I have created a <code>Gallery Activity</code> which contains list of audio and video files located on SD Card. I have another activity through which I want to pick files from <code>Gallery Activity</code> using <code>Intent</code>. I have added following <code>...
<p>To return a result from an activity started by <code>startActivityForResult()</code>, call <code>setResult()</code>, supplying the <code>Intent</code> containing the "result". Usually, this is immediately followed by a call to <code>finish()</code>, so control returns to the activity that had called <code>startActiv...
RxSwift PublishSubject is being disposed <p>I bind Button pressed to <code>PublishSubject</code> in a router like so:</p> <pre><code>hambugerButton .rx_tap .bindTo(router.openMenu) .addDisposableTo(disposeBag) </code></pre> <p>In my Router:</p> <pre><code>let openMenu = PublishSubject&lt;Void&gt;() //... op...
<p>If the view controller which owns the <code>hamburgerButton</code> is being deallocated, and thus the <code>hamburgerButton</code> is also being deallocated, why wouldn't you want the binding to <code>router.openMenu</code> to also be deallocated? Maybe it's not clear what your view controller hierarchy is from you...
Dagger2, providing Retrofit instances with different APIs same time <p>In my project I use Retrofit and trying to use Dagger for injecting dependencies. I also have 2 Retrofit services with different APIs. I need to use 2 different APIs with different baseUrls at the same time. I stucked here, and dont know what to do ...
<p>You just use the <code>@Inject</code> annotation along with the <code>@Named()</code> annotation, like so:</p> <pre><code>@Inject @Named("provideRetrofit") Retrofit mRetrofit; @Inject @Named("provideRetrofit2") Retrofit mRetrofit2; </code></pre> <p>Or you could even inject the Retrofit services directly:</p> <pre...
parse csv using lua script <p>I have a csv file that has data like this: </p> <pre><code>+12345678901,08:00:00,12:00:00,1111100,35703,test.domain.net +12345678901,,,0000000,212,test.domain.net </code></pre> <p>I'm trying to write lua code that will loop through each line, and create an array of values like this: </p>...
<p>It seems that you just need to group the digits and <code>:</code> inside a <code>[...]</code>:</p> <pre><code>match("(%+%d+),([%d:]*),([%d:]*),(%d*),(%d*),(.*)") ^ ^^^^^^ ^^^^^^ </code></pre> <p>Now, the <code>[%d:]*</code> matches zero or more digits or <code>:</code> symbols. Your pattern ...
Join with <= in the On clause in Google bigquery <p>I want to execute a query with <code>join</code> in Google <code>bigquery</code> that has '&lt;=' instead of '=' in it's on clause:</p> <pre><code>select s.count_value as count_value,s.total as total,sum(p.total) as accumulated from stats s join stats p on p.rn...
<p>You should enable Standard SQL to do such JOINs<br> See <a href="https://cloud.google.com/bigquery/sql-reference/enabling-standard-sql" rel="nofollow">Enabling Standard SQL</a> </p> <p>in CLI - just add the --use_legacy_sql=false flag to your command line statement.</p>
How to calculate how many bacteria in each group are resistant to an antibiotic <p>I am attempting to count instances of resistance to 1 or 1+ antibiotics under certain conditions. Here is an example of what what my spreadsheet looks like:</p> <p><a href="http://i.stack.imgur.com/AXnLg.jpg" rel="nofollow"><img src="ht...
<p>Create a new column for "Resistance Count" and use <code>=COUNTIF(B2:D2,"&gt;=1")</code> for cell E2 and fill down. Then you can filter the table by Type or Resistance Count. Use <code>SUBTOTAL</code> to count the filtered rows.</p>
What is the difference between // and .// in XPath? <p>When I execute these XPath expression on Chrome Developer Tools' console over google.com, I got the same results</p> <ul> <li><p><code>$x("(.//*[@id='gs_lc0'])")</code></p></li> <li><p><code>$x("(//*[@id='gs_lc0'])")</code></p></li> </ul> <p>What is the usage of ...
<p>In XPath, <code>//</code> and <code>.//</code> are both syntactic abbreviations:</p> <ul> <li><code>//</code> is short for <code>/descendant-or-self::node()/</code></li> <li><code>.//</code> is short for <code>self::node()/descendant-or-self::node()/</code></li> </ul> <p>The <code>descendant-or-self</code> axis co...
Component does not get updated after calling `this.forceUpdate();` <p>I am using <a href="https://facebook.github.io/react-native/docs/direct-manipulation.html" rel="nofollow">direct manipulation</a> to change the color of a view, every time a specific event occurs.</p> <p>My render function:</p> <pre><code> render(...
<p>I found the issue. I need to update the background color using the <code>setNativeProps</code>.</p> <pre><code>onSlideChangeHandle(index) { this._view.setNativeProps({ style: { backgroundColor: 'red' } }); } </code></pre>
AngularJS/JSON: Refer to array member by value instead of index? <p>I have JSON data in the format of:</p> <pre><code>[ { "name": "partnerCodePrefix", "val": "12345", "inherit": true }, { "name": "partnerCode", "val": "AAAAAnnnnnnnnnnnnnnn", "inherit": false } ] </code></pre> <p>Currently, I am acc...
<p>I think that you can have a function that takes the value has the parameter and returns the index of the array when the name is equal to the parameter like </p> <p>mob.mobData[ returnIndex(str)].Val</p>
Stream Lining a long code <p>I have below codes running through multiple command buttons. Just wanted to know if there is any method to stream line. Each button works in a flow having certain characteristics. I am sure there are ways to cutoff excess junk. </p> <pre><code>Private Sub CommandButton1_Click() ActiveSheet...
<p>There a lot of ways to shorten your code:</p> <p>1) Start off with Kyle's comment and reduce your select statements.</p> <p>2) If you are looking to <em>visually</em> unclutter your code, make better use of white space.</p> <p>3) In commandbutton4, commandbutton7, you unprotect the same sheet twice. </p> <p>Othe...
efficiently replace values from a column to another column Pandas DataFrame <p>I have a Pandas DataFrame like the following one: </p> <pre><code> col1 col2 col3 1 0.2 0.3 0.3 2 0.2 0.3 0.3 3 0 0.4 0.4 4 0 0 0.3 5 0 0 0 6 0.1 0.4 0.4 </code></pre> <p>I want to replace the <code>co...
<p>Using <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html" rel="nofollow"><code>np.where</code></a> is faster. Using a similar pattern as you used with <code>replace</code>:</p> <pre><code>df['col1'] = np.where(df['col1'] == 0, df['col2'], df['col1']) df['col1'] = np.where(df['col1'] == 0...
How to embed CDATA in Mulesoft <p>I'm trying to embed a literal CDATA value in a Mulesoft flow and cannot figure out how to do so.</p> <p>My desired output (in an HTTP request body) is:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"...
<p>I would try:</p> <pre><code>sXML: "&lt;queryxml&gt; .... &lt;/queryxml&gt;" as :cdata </code></pre> <p>See <a href="https://docs.mulesoft.com/mule-user-guide/v/3.8/dataweave-formats#custom-types-2" rel="nofollow">https://docs.mulesoft.com/mule-user-guide/v/3.8/dataweave-formats#custom-types-2</a> for more informat...
SAS PROC SQL - issue with Left join on two character variables <pre><code> DataSet: Test1 Name Type Length Format Informat RowID Numeric 8 6. 6. COL2 Character 6 $6. $6. COL3 Numeric 8 NUMERIC12....
<p><code>14.14.50</code> ne <code>14:14:50</code></p> <p>Fix your formats, or use INPUT to make them both a number.</p>
ksoap2 stringArray for php Request <p>How to make such a request?</p> <pre><code>&lt;SOAP-ENV:Body&gt; &lt;ns1:CurrencySyncDelete&gt; &lt;Row xsi:type="ns2:Map"&gt; &lt;item&gt; &lt;key xsi:type="xsd:string"&gt;ID&lt;/key&gt; &lt;value xsi:type="xsd:int"&gt;999&l...
<p>I decided the problem with the help of marshaling <a href="http://read.pudn.com/downloads143/sourcecode/mobile/j2me/625948/branches/2_1_0_AttributePatch_1473145/ksoap2/ksoap2/src/org/ksoap2/serialization/MarshalHashtable.java__.htm" rel="nofollow">http://read.pudn.com/downloads143/sourcecode/mobile/j2me/625948/bran...
Website layout for mobile looks fine on emulator but not on actual mobile device <p>I just started learning html/css/javascript and decided to throw together a website for practice. I now know that a lot of the approaches I took in creating this website are seen as bad practice, which is why I will not continue to do t...
<p>Try adding this meta tag to your pages, in the &lt;head&gt; element:</p> <pre><code>&lt;meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /&gt; </code></pre> <p>I had this issue with Bootstrap awhile ago and then found this nifty answer online. I also would recom...
Can't find Google Play Services in components in Xamarin Android project <p>I am trying to add the Google Play Services component to my Xamarin application because I need to integrate google maps api into the application. When I try to search Google play services in components I can't find Google Play Services. I see o...
<p>You can use NuGet to download <a href="https://www.nuget.org/packages/Xamarin.GooglePlayServices.Maps/" rel="nofollow">Google Play Services Maps</a> to your project.</p> <p><a href="https://www.nuget.org/packages/Xamarin.GooglePlayServices.Maps/" rel="nofollow">https://www.nuget.org/packages/Xamarin.GooglePlayServi...
Where is year at 2:54 the speaker is referring to? <p>In <a href="https://www.youtube.com/watch?v=k0Uv7jX--W4" rel="nofollow">this tutorial</a>, at <code>2:54</code> minute - the speaker is saying:</p> <blockquote> <p>Now, in the last example with IPO pub year, we were using an expression that resolves to a value fo...
<p>You should be able solve your question yourself:</p> <blockquote> <p>Now, in the <strong>last example</strong> with IPO pub year, we were using an expression that resolves to a value for a scalar. In that case, it's a year. In this case our scalar as we saw earlier resolves to a document.</p> </blockquote> <p>Th...
How can I modify a javascript event in a PDF file programmatically? <p>My PDF file has an event attached to a button. I need to be able to modify that event programmatically. I tried this way using iTextSharp, but it didn't change the javascript in the new file:</p> <p>var pdfReader = new PdfReader(originalPdfDocument...
<p>I found that it works if, instead of changing the XML directly, I change the DomDocument and mark the XFA as changed. Below is the corrected code:</p> <pre><code>var pdfReader = new PdfReader(originalPdfDocumentPath); pdfReader.RemoveUsageRights(); var pdfStamper = new PdfStamper(pdfReader, new FileStream(newPdfD...
Oracle SQL Developer how to copy multiple procedures from one server to another <p><a href="http://i.stack.imgur.com/7QjSI.png" rel="nofollow"><img src="http://i.stack.imgur.com/7QjSI.png" alt="enter image description here"></a>What is the best way to copy procedures from one server to another I dont want to copy and p...
<p>'Best' - no way to answer without knowing more about what you want.</p> <p>You can drag and drop a procedure or procedures from one database connection to another and we'll copy them over. V4.1.5 or v4.2.</p> <p>In all other versions you can use Tools > Database > Copy and select your PL/SQL and target database an...
JDBC - varbinary(max) out parameter of stored procedure is truncated to 8000 bytes <p>I'm using Spring Data JPA 1.10.2 with jTds 1.3.1 to call a stored procedure. </p> <p>The stored procedure has an out parameter, <code>@data</code> of type varbinary(max). <code>@data</code> contains about ~10,000 bytes. </p> <p>Her...
<p>Use Microsoft's JDBC driver and specify the output parameter type as a <code>Blob</code>:</p> <pre><code>@Entity @NamedStoredProcedureQuery(name = "User.getUser", procedureName = "User.pTest", parameters = { @StoredProcedureParameter(mode = ParameterMode.OUT, name = "data", type = Blob.class), @St...
How does OracleRefereceCursor get data from database? <p>Let's say I have a stored procedure in Oracle db which has a ref cursor output parameter.</p> <p>From .Net using ODP.Net I am trying to get the data from the DB as below (I have taken this from <a href="http://www.oracle.com/technetwork/articles/dotnet/williams-...
<p>The amount of data fetched in each roundtrip to the database is controlled by the Fetchsize which is a certain number of bytes. I forget the default size. You can control this by setting FetchSize to a multiple of Rowsize. ODP.NET will cache the data until it needs to fetch more.</p>
How get permission on WatchFace <p>I have a application on Android Wear. App comprises only WatchFace. How I can get permission without activity? Permission added into manifest.</p>
<p>Go to Settings -> Permissions -> Select your app -> Turn on the permissions you have put in your manifest file</p>
jQuery-AJAX: How to disable a button on table row only when a condition is met <p>I'm trying to disable a button only when a certain condition is met. The buttons are generated dynamically and they have a dynamic ID as well. These buttons are on a table and they appear on each row. (2 buttons per row and one of those t...
<p>I've figured out how to accomplish what I needed. the if statement wasn't going to work because it will take every element with the same class and disable or enable it if the condition was met. Also, if/else cannot be used as is inside append.</p> <p>In order to make it work, I added used a <strong>ternary conditio...
Transactions dependency between rest services <p>We are converting our application to support SOA, mainly into restful services. I have the services developed, however I am now concerned about how to rollback the transaction of service 1 if service 2 fails.</p> <p>I have a page made of three services. If any of the se...
<p><strong>tl;dr</strong>: use compensation actions and idempotence</p> <p>In more detail:</p> <p>SOA and REST are architectural styles. This also means that when moving from a monolith to SOA and moving from distributed transactions to REST as well as moving from RPC (RMI, etc.) to REST, you have to rethink transact...
Karma cannot load Angular 2 Component <p>My Karma cannont load angular 2 component. Drop this error: </p> <pre><code>[web-server] :404 : /base/src/client/app/container/container.component </code></pre> <p>i do everything with angular 2 testing tutorial (i only modified path in karma) So problem must be in path. but i...
<p>I recently came across this same issue and I came to the conclusion that SystemJS is responsible for default extensions (should be 'js'). Make sure that your ng2 app folder is properly connected with your systemjs.config file.</p> <pre><code>(function (global) { System.config({ paths: { // paths serve a...
Distinguishing between 0 and null in OR statement in Javascript <p>I have below code in my function, I want to assign a value to the variable newValue.</p> <p><code>var newValue = fieldValue || originalValue || masterValue;</code></p> <p>Here if I have the originalValue = 0, the java script treats it as false/null an...
<p>Yes but it gets a bit complicated (<em>using the ternary operator</em>).</p> <pre><code>var newValue = fieldValue || (originalValue || originalValue===0) ? originalValue : masterValue; </code></pre> <p>(<em>this assumes you want to 0 to be assigned even when in <code>fieldValue</code></em>)</p>
heightForHeaderInSection only called once <p>Coding in Swift 3. Have a tableView with custom cells and header.</p> <p>I have a tableView with custom cells and headers. The headers have two (2) labels in them and have dynamic cell heights since the labels may be long. My problem is the first time the tableView and s...
<p>You should return <code>header</code> instead of <code>header.contentView</code> from <code>tableView: viewForHeaderInSection:</code> method:</p> <pre><code>override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -&gt; UIView? { let header = tableView.dequeueReusableCell(... ... ...
JavaScript function is not defined in external .js file in IE only <p>I use an external JavaScript file (.js) in a classic ASP program. I added a new function 'isFutureDate(dt)' to this file. The new function works fine when using Chrome browser to access the web page. When using IE 11, it showed the error of "isFutur...
<p>Hi Below are the root cause</p> <p>1) check the order of the Js file. it should be in correct order.</p> <p>2) If you are using multiple Js file. Use bundling because some browser have limitation of calling concurrent HTTP Call. if the limit exceeds it will stop rendering the script</p> <p>3) It should be the cac...
Dynamically how to set value to selected of select dropdown in angularjs depending upon value stored in array of objects <pre><code>I have multiple records which are stored in </code></pre> <p>$scope.myQuality</p> <p>variable currently in in below attached plnkr but that data will be coming from rest api. Currently ...
<p>Just remove the track by from your ng-options, plnkr below:</p> <p><a href="https://plnkr.co/edit/olbqvp2GiTTqr1JUyeSq?p=preview" rel="nofollow">https://plnkr.co/edit/olbqvp2GiTTqr1JUyeSq?p=preview</a></p> <pre><code>ng-options="option.value as option.text for option in items" </code></pre>
Display N/A if formula value is zero <p>I have the below formula, and I am trying to add "if 0 then show N/A" but it's not working properly.</p> <pre><code>Local StringVar x := ToText({SMPLODC.LCSCHD}, "0"); Local NumberVar c := (ToNumber(LEFT(x, 1)) + 1) * 10; x := RIGHT(x, 6); Local NumberVar y := ToNumber(ToText(c,...
<p>An easy way to do this is to right click the formula field, select <em>Format Editor -> Common -> Display String:</em> and enter the following code:</p> <pre><code>If {@YourFormulaNameHere} = "0" Then "N/A" Else Cstr({@YourFormulaNameHere}) </code></pre>
Spring Integration Kafka Consumer Listener not Receiving messages <p>According to the documentation provided <a href="http://docs.spring.io/spring-kafka/docs/1.1.1.RELEASE/reference/html/_reference.html" rel="nofollow">here</a>, I am trying on a POC to get messages into a listener as mentioned in the the <a href="http:...
<p>You have to add <code>@EnableKafka</code> alongside with the <code>@Configuration</code>.</p> <p>Will <a href="https://github.com/spring-projects/spring-kafka/issues/189" rel="nofollow">add</a> some description soon.</p> <p>Meanwhile:</p> <pre><code>@Configuration @EnableKafka public class KafkaConsumerConfig { <...
How to make JavaScript indexOf() not detect substring <p>Here are two if conditions with different checks:</p> <p>CASE 1: </p> <pre><code>if(plan_name.indexOf("T1")&gt;=0 &amp;&amp; plan_name.indexOf("FLEX")&gt;=0 &amp;&amp; plan_name.indexOf("Non-VAE")&gt;=0) { //do something } </code></pre> <p>followed by (in ...
<p>One solution is split it apart and see if the string matches in the array</p> <pre><code>var str = "iOS 7.7 - RC - T1 - Non-FLEX, Non-VAE"; var parts = str.split(/[\s,]/g); console.log("FLEX", parts.indexOf("FLEX")!==-1); console.log("Non-FLEX", parts.indexOf("Non-FLEX")!==-1); </code></pre>
Polymer 1.x: How to get paper-dialog-scrollable to render and behave when not direct child of paper-dialog <p><a href="http://jsbin.com/lifamasowe/1/edit?html,output" rel="nofollow">This jsBin demos correct implementation of <code>paper-dialog-scrollable</code></a>.</p> <p><a href="http://jsbin.com/fapivoqako/1/edit?h...
<p>The <a href="https://elements.polymer-project.org/elements/paper-dialog-scrollable" rel="nofollow">docs for <code>paper-dialog-scrollable</code></a> state:</p> <blockquote> <p>If <code>paper-dialog-scrollable</code> is not a direct child of the element implementing <code>Polymer.PaperDialogBehavior</code>, rememb...
Node partial require/import <p>I am following a MS tutorials on node and trying to require part of the module only. When i execute the code i get a syntax error though VS code editor seems to import properly in intellisense. Please assist</p> <p>Index.js</p> <pre><code>'use strict'; const { doSomething } = require(...
<p>Get rid of the brackets around <code>doSomething</code>. Those brackets would be used if you were using an <code>import</code> statement.</p> <pre><code>import { member } from "module-name"; </code></pre> <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import" rel="nofollo...
Typescript interface type with optional keys of different types and strictNullChecks <p>I am trying to create the following interface in typescript:</p> <pre><code>type MoveSpeed = "min" | "road" | "full"; interface Interval { min?: number, max?: number } interface CreepPlan { [partName: string] : Interval; ...
<p>You stated that all properties on <code>CreepPlan</code> have <code>Interval</code>-type values when you wrote:</p> <pre><code>interface CreepPlan { [partName: string] : Interval; } </code></pre> <p>i.e., any and every string-index-accessible property of <code>CreepPlan</code> will be an <code>Interval</code>. T...
Requesting the most recent version of an entity in CRM <p>I'm updating an entity using the <a href="https://msdn.microsoft.com/en-us/library/gg328198(v=crm.5).aspx" rel="nofollow">Organization Service</a>:</p> <pre><code> _organizationService.Update(contact); </code></pre> <p>I then would like to immediately query...
<p><a href="https://msdn.microsoft.com/en-us/library/gg695819(v=crm.7).aspx" rel="nofollow">XrmServiceContext</a> takes in organization service as a parameter which is cached. </p> <p>Use clear changes <code>_xrmServiceContext.ClearChanges();</code></p> <p>Or alternatively you could new up another <a href="https://ms...
How to set valueAxes title as variable from JSON in amCharts? <p>I would like to change the valueAxes title from a hardcoded string to a value from a JSON property via dataprovider.</p> <p>thanks </p>
<p>You can use the <code>init</code> event to set your valueAxes title then call <code>validateNow(true)</code> (or <code>validateData()</code>). Here's a contrived example:</p> <pre><code>var chart = AmCharts.makeChart("chartdiv", { "type": "serial", "theme": "light", "dataProvider": [{ "valueAxisTitle": "N...
I only want to update one MySQL row with PHP <p>I am working on a page that I need to be able to update single records from my MySQL database using PHP. Can someone please help me? When I try to update one record all my other records are updated.</p> <pre><code> &lt;form action="" method="post"&gt; &lt;input ty...
<p>First of all stop using <code>mysql_*</code> its deprecated and closed in PHP 7. You can use <code>mysqli_*</code> or <code>PDO</code>.</p> <p>Whats wrong with your query:</p> <p>This is very important, if you not use <code>WHERE CLAUSE</code> in your <code>UPDATE STATEMENT</code> than it will update the all rows....
Waiting for multiple async operations in Nightwatch.js <p>I am attempting to test multiple sites for section headers being in the correct order. Of course everything is asynchronous in Nightwatch, including getting text from an element. The following code leads to the timeout never being called.</p> <pre><code>client....
<p>I'm using <code>async</code> library for such cases <a href="https://github.com/caolan/async" rel="nofollow">https://github.com/caolan/async</a> Docs: <a href="https://github.com/caolan/async/blob/v1.5.2/README.md" rel="nofollow">https://github.com/caolan/async/blob/v1.5.2/README.md</a></p> <pre><code>var async = r...
Javascript: pass method of object as pointer <p>Here is my code: </p> <pre><code>function active_area(width, t_width, height) { this.width = width; this.height = height; this.t_width = t_width; //width of toolbar this.dotes = 20; this.gridStep = this.width/this.dotes; this.active_layer = -1;...
<p>You need to bind it</p> <pre><code>this.addButton(10, 10, 'Zoom out', this.zoomOut.bind(this)); this.addButton(10, 50, 'Zoom in', this.zoomIn.bind(this)); this.addButton(30, 30, 'Add layer', this.addLayer.bind(this)); </code></pre>
C# How to read items into an array <p>I can't figure out how can I read items from the text file and put them into an int array. My objective is to count what is the average grade. To do so, I need to read the number which tells me how many grades does 1 student have, and then using that amount, read the grades themsel...
<p>After your clarification, it seems that you want to take:</p> <pre><code>Smith;John;XYZ;4;2;4;6;8 </code></pre> <p>And retrieve the array of <code>[2,4,6,8]</code> so you can get the average from that.</p> <p>If you can't do what I mention in my comment, then here's a workaround. Since the number of grades is irr...
Clearing All Hidden Cells in a Range <p>Very simple question. I keep getting error messages and excel crashing. What is wrong with my code:</p> <pre><code>Sub Clear() Dim c As Range For Each c In ActiveSheet.Range("HeatPump1").Cells If c.EntireRow.Hidden = True Then c.Clear End If Next c End Sub </...
<p>Which line is throwing an error? Do you have a range named "HeatPump1" in the active sheet when the code is running?</p> <p>On a side note, c.EntireRow.Hidden is a boolean value, so you don't need to check if it is true. You can simply write:</p> <pre><code> If c.EntireRow.Hidden Then </code></pre>
Why can't class variables be used in __init__ keyword arg? <p>I can't find any documentation on when exactly a class can reference itself. In the following it will fail. This is because the class has been created but not initialized until after <code>__init__</code>'s first line, correct?</p> <pre><code>class A(object...
<p>Python scripts are interpreted as you go. So when the interpreter enters <code>__init__()</code> the class variable <code>A</code> isn't defined yet (you are inside it), same with <code>self</code> (that is a different parameter and only available in function body).</p> <p>However anything in that class is interpre...
Angular2 POST Web api 404 Not Found <p>I'm building an Angular2 service to log certain events, stored in ILog objects, and send them to an API to be stored in a database.</p> <p>My log service is pretty straightforward:</p> <pre><code>import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; i...
<p>Its because you cant post an atomic value directly to your method as json. You could turn it into an object and then post it as a corresponding object or post it as form uri encoded which also works. This is a limitation of asp.net's web api. </p> <p>There are some other similar questions all with similar answers. ...
Aggregate messages without List <p>I'm using spring integration and I need to pack group of messages by 10k. I don't want to store it into List since later 10k could became much bigger and persistent storage is also not my choice. I just want that several threads send messages into single thread where I can count them ...
<p>You can reach the task with the <code>QueueChannel</code>. Any threads can send messages to it concurrently. On the other side you should just configure <code>PollingConsumer</code> with the <code>fixed-delay</code> poller - single-threaded, as you requested. I mean that poller with the <code>fixed-delay</code> and ...
Support for .NET 4.6.2 in Azure Web Job <p>I tried deploying an Azure Web App built against .NET Framework 4.6.2 and it seems to work fine. However, within the same app, if I deploy a web job built against .NET 4.6.2, then it does not work. I get the following error:</p> <pre><code>[10/06/2016 19:42:25 &gt; b29283: SY...
<p>I created a console application using .NET Framework v4.6.2 and publish it as WebJob, and same issue appears on my side, the execution fails. So I guess that currently Azure WebJob does not support .NET Framework v4.6.2. As a workaround, you could try to modify <a href="https://msdn.microsoft.com/en-us/library/w4att...
Using CustomCredentialsAuthProvider in JsonServiceClient <p>I try to implement my own custom CredentialsAuthProvider. The server seems to work fine with the following implementation:</p> <pre><code>public class MyCustomCredentialsAuthProvider : CredentialsAuthProvider { public override bool TryAuthenticate(IServic...
<p><a href="https://github.com/ServiceStack/ServiceStack/blob/501ad4c5b5f077956d94c4254d981b8e4e548381/src/ServiceStack/Auth/CredentialsAuthProvider.cs#L28" rel="nofollow">CredentialsAuthProvider.Name</a> just provides typed access to the <a href="https://github.com/ServiceStack/ServiceStack/blob/501ad4c5b5f077956d94c4...
How do I store only the folder names as an array and not the while path (C#) <p>So I know how to store the full path but not just the end folder names, for example I've already got an array but is there any method to remove certain characters from all arrays or just get folder names from a path?</p> <p>Edit: string[] ...
<p>This works.</p> <pre><code>string[] allFolders = Directory.EnumerateDirectories(directory) .Select(d =&gt; new DirectoryInfo(d).Name).ToArray(); </code></pre> <p>This also works. Difference is we are using <code>List&lt;string&gt;</code> instead of <code>string[]</code></p> <pre><code>List&lt;string&g...
Aggregate in R taking way too long <p>I'm trying to count the unique values of x across groups y. </p> <p>This is the function:</p> <pre><code>aggregate(x~y,z[which(z$grp==0),],function(x) length(unique(x))) </code></pre> <p>This is taking way too long (~6 hours and not done yet). I don't want to stop processing as ...
<p>Here you go:</p> <pre><code>library(data.table) setDT(z) # to convert to data.table in place z[grp == 0, uniqueN(x), by = y] # y V1 #1: 1 2 #2: 3 1 </code></pre>
Finding clusters in a python list <p>I have a sorted python list which looks like:</p> <pre><code>myList = [1,2,3,7,8,9,12,13,14,15] </code></pre> <p>The consecutive elements with difference 1 form the cluster. I need to dig these clusters out.</p> <p>In the above example the clusters would be <code>1,2,3</code>; <c...
<p>There are many approaches to do this. One is to create a new list to map the break-points where new group starts and create the nested list based on the break points.</p> <p><strong>Approach 1:</strong></p> <pre><code>my_list = [1,2,3,7,8,9,12,13,14,15] start, new_list = 0, [] for i in range(len(my_list) - 1): ...
How to add files to android emulator <p>I am using the cordova filePicker plugin (MFilechooser), I see the filechooser from emulator (cordova emulate android). However, I don't know how to transfer a file from my PC to the emulator directory so I can select it.</p> <p>Can you please give me some suggestion on how to ...
<p>You can use <strong>adb</strong> comand line utility from Android SDK.<br/> Example of command:<br/> adb push /local/path/to/file/on/pc /path/to/file/in/emulator</p> <p>Substitute appropriate paths in example above.</p>
Why my redux-saga is async <p>In my React-Native app I write a user log in component which send username and hash to server, compare hash with hash in database and return a result. I implemented that <code>using redux-saga</code>:</p> <pre><code>function* fetchUser(action) { try { const user = yield call(Api.fet...
<p>You are not returning the promise from the fetchUser function. It should be</p> <pre><code>fetchUser(action) { const url = `${apiUrls.LOGIN_URL}`; return fetch(url, 'POST', action.user) .then(response =&gt; response.json()) .then(res =&gt; res) } </code></pre>
akka.net is there a a way to get or create actor <p>For my actor hierarchy, I do not know all the actors I need until I process the data through a few actors, so I'm looking for a way to either return an existing ActorRef or create a new action. This is what I would like the code below to either create an actor if one...
<p>You can check if current actor has a child with provided name by using <code>Context.Child(actorName)</code> method. It will return actor ref of the target actor if it exists or <code>ActorRefs.Nobody</code> if there is no such actor.</p> <p>Code in your case could look like:</p> <pre><code>var child = Context.C...
Store CLLocation Manager Values in Device swift <p>I'm building an app that sends (every x seconds) to an API the location values with some extra values (session, ID, etc) that is working nice (see here <a href="http://stackoverflow.com/questions/39757134/update-cllocation-manager-on-another-method">Update CLLocation M...
<p>If you want to store a some of non-sensitive values (such as a password), I suggest to use <a href="https://developer.apple.com/reference/foundation/userdefaults" rel="nofollow">NSUserDefaults</a>, you can easily use it like a dictionary:</p> <p><em>Note: Swift 2 Code.</em></p> <p>For example:</p> <pre><code> ...
Django user permission inside template <p>I created a custom auth permission in django via admin site, and i added that permission to a user (not a group), now i want to ask if the request user in a template has it but nothing works.It's not a duplicate, i already checked similar questions and none of this work:</p> <...
<p>django in template it uses the variable perms for the permissions of the logged in user so you can use inside template</p> <pre><code>{% if perms.auth.add_something %} {{do_smth}} {% endif %} </code></pre> <p>from the django documentation <a href="https://docs.djangoproject.com/el/1.10/topics/auth/default/#topic...
creating subset (using a col of data frame) using for loop and finding unique values of another column <p>I am new to R and am stuck up solving a problem. Could anyone point out where I have gone wrong I have the following data*</p> <pre><code> Score TestID 1536 2 16000 18000 1 15 7 ...
<p>EDIT: Your issue is that when you write the result of your for loop into the "final" matrix, you don't specify which row of the matrix to write the results to. To fix this, I create a "counter" variable, and set it equal to 0 before your for loop, then add 1 to it for each iteration of the loop. The counter indica...
Laravel - check if other people are using my API and who <p>I have an API and I'm not sure if other services are using it too. I don't want other people to use my server resources and I would like to check that.</p> <ol> <li>Assuming I have a method in a controller, how I can check who accesses this method where the r...
<p>Each request has a <code>Host</code> header you can use that to know which domain is using your service.</p> <p>if you want to only allow your domain to access the service then edit the <code>CORS</code> settings. I'm assuming you are using <a href="https://github.com/barryvdh/laravel-cors" rel="nofollow">barryvdh ...
Divide every value in the rows by the corresponding value in the column head in r <p>I need to divide values in the rows by the corresponding values in the column head and then get the sum of each row</p> <p>I have this data as a csv file:</p> <pre><code>df &lt;- read.table(text = "Year 2 3 4 5 6 7 ...
<p>One approach, using <code>dplyr</code> just to clean up the code, is to use <code>apply</code> and convert the column names to numeric. Note that, because you changed the row.names to a column ("YEAR") we need to handle those separately. Here, I do it by removing that column with <code>df[ ,-1]</code> then adding it...
Unexpected behaviour in python multiprocessing <p>I'm trying to understand the following odd behavior observed using the <code>python mutiprocessing</code>.</p> <p>Sample testClass: import os import multiprocessing </p> <pre><code>class testClass(multiprocessing.Process): def __del__(self): ...
<p>You can wrap your expensive initialization inside a context manager:</p> <pre><code>def run(self): with expensive_initialization() as initialized_object: do_some_logic_here(initialized_object) </code></pre> <p>You will have a chance to properly initialize your object before calling <code>do_some_logic_...
How can I write a query to show details of customers with duplicate names? <p>I have been looking around for quite a bit and cannot seem to find a solution that fits what I need.</p> <p>I have a table with many, many customers and the issue is that there are many, many duplicates in this table.</p> <p>I have been abl...
<p>Use window functions:</p> <pre><code>SELECT c.* FROM (SELECT c.*, COUNT(*) OVER (PARTITION BY NAME) as cnt FROM DEV.ALL_CUSTOMER c ) c WHERE cnt &gt; 1 ORDER BY NAME; </code></pre> <p>This will give you the rows that are duplicated on <code>NAME</code>.</p>
Get query parameters in React, Typescript <p>I have a component that looks like this:</p> <pre><code>class MyView extends React.Component&lt;{}, {}&gt; { render() { console.log((this.props as any).params); // prints empty object return ( &lt;div&gt;Sample&lt;/div&gt; ); } } ...
<p>You need to define the types for the props and state and then put them instead of the <code>{}</code>.<br> It's not clear where you want to get the "URL query params", so I'll just take them from the <code>window.location</code> object:</p> <pre><code>interface MyViewProperties { params: string; } interface My...
How to auto wrap function call in try / catch? <p>I have a lot of getter functions like this:</p> <pre><code>get_property_a(default=None): try: self.data.get("field_1")[0].get("a") except Exception as e: return default get_property_b(default=None): try: self.data.get("field_2")[0].get("b") exce...
<p>You <em>can</em> do this by writing your own decorator:</p> <pre><code>import functools def silent_exec(default=None): def decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): try: return func(*args, **kwargs): except Exception: ...
Arduino function variable value changes between function calls <p>I have three functions, each calls the next and passes some values. Strangely, in second function where I make multiple calls to third function, one of the values changes between the calls. And this variable is for sure local. Am I missing Something?</p>...
<p>Either you're passing some pointers around or functionC is doing some funky stuff with memory. Other than those two options, there's no real reason I can see why a value in a variable would simply change like in your example.</p>
see RAM usage in R-studio before crash? <p>I am switching from Python to R for some projects, and I have a hard time understanding the RAM management in R - R-Studio.</p> <p>I have the following two simple questions</p> <ul> <li><p>can we see how much RAM is being used by R at the moment? Just like in Spyder one can ...
<p>Check <code>gc()</code> to check how much memory is being used.</p> <p>And I think R uses all the memory available. However, you can also set the memory limit by <code>memory.limit(size=)</code>. </p> <p>Moreover, I would recommend using <a href="https://mran.microsoft.com/open/" rel="nofollow">Microsoft R Open...
Why is the height of li larger than the height of the image inside it? <p>On hovering a top level li element of my navigation bar,</p> <p><a href="http://i.stack.imgur.com/a9dSC.png" rel="nofollow">I see that small space beneath the image inside the li element</a></p> <p>This bugs me when I don't define a background ...
<p>It's because images are inline elements, to fix this add <code>display: block;</code> to the image then use <code>margin: 0 auto;</code> to center it inside the <code>li</code>.</p>