input
stringlengths
51
42.3k
output
stringlengths
18
55k
Stubbing Google Maps/Places iOS SDK calls for unit testing <p>I'm trying to stub my Google Places calls using a local <code>json</code> file. Using Charles proxy, I find that the Google Maps SDK uses the url <code>https://www.googleapis.com</code>. So, I try to stub like:</p> <pre><code>stub(isHost("https://www.goog...
<p>Answer given here: (I was using the incorrect host name, should use simply "www.googleapis.com")</p> <p><a href="https://github.com/AliSoftware/OHHTTPStubs/issues/219" rel="nofollow">https://github.com/AliSoftware/OHHTTPStubs/issues/219</a></p>
Sylius : Catchable Fatal Error: Argument 1 passed to ShopBundle\Controller\HomepageController::__construct() <p>I'm trying to override the <code>HomepageController:indexAction</code> from SyliusShopBundle to pass some data to the <code>index.html.twig</code> but an exception keep appearing:</p> <blockquote> <p>Catch...
<p>You need to pass the templating engine as an argument in your service definition, something along those lines :</p> <pre><code>services: app.custom_homepage_controller: class: AppBundle\Controller\CustomHomepageController arguments: - "@templating" </code></pre>
Interactions (stats) in matlab <p>I was wondering if there was a function which can give me all interactions given an input of vectors.</p> <p>for example:</p> <p>If I had three vectors a,b,c. Their values are:</p> <pre><code>a = [1,9,3] b = [4,3,2] c = [6,5,7] </code></pre> <p>then I can get back a matrix with:</p...
<p>The needed computation doesn't have an inbuilt function but you can always write your own:</p> <pre><code>%% Define the vectors a = [1,9,3]; b = [4,3,2]; c = [6,5,7]; %% test function pairWiseAppend(a,b,c) %% Define the function function customVector = pairWiseAppend(a,b,c) %multiply and generate new vectors ...
Converter Java calendar to Persian calendar <p>I know this question asked by another user and I see all of the posts about this question. I need a library that convert all Java Calendar to Persian calendar like year , month, day and day of week, day of month ... including giving me all the days of one week (Persian wee...
<p>you can see this links...<a href="https://github.com/mohamad-amin/PersianMaterialDateTimePicker" rel="nofollow">PersianMaterialDateTimePicker </a> and <a href="https://github.com/ebraminio/DroidPersianCalendar" rel="nofollow">Android Persian Calendar</a> this are two open source app which i think could help you</p>
Task manager for Android and Profiler for SmartWatches (AndroidWear) <p>Is there any app or way like task manager where I can close individual apps on a smartwatch (Android wear) ? Also if there is any way to measure cpu, memory, and battery consumption of individual apps on Android wear ? </p> <p>For task manager, I ...
<p>This question may be more suited in <a href="http://superuser.com/">superuser.com</a> instead of stackoverflow.</p> <p>Anyways, if you're looking for an app, you can try this <a href="https://play.google.com/store/apps/details?id=rocketstartups.weartaskmanager&amp;hl=en" rel="nofollow">Task Manager For Android Wear...
regular expression for double consonants <p>I have a problem writing regular expression. I want to write a regular expression that replaces all double consonants with a single consonant. Please help me to write such a rule in only one line. Thanks in advance. </p>
<p>Since you did not specify the language, I'm going to go ahead and assume Javascript.</p> <p>This should get you started:</p> <p><code>console.log('babble bubble http htttp www'.replace(/([^aeiou\.,\/=?:\d&amp;\s!@#$%^*();\\|&lt;&gt;"'_+-])\1{1}/gi, "$1"));</code></p> <p>See more here:</p> <p><a href="http://rege...
Multipart upload initiated with putObject is aborted (AWS Javascript SDK) <p>I'm using the AWS JS Javascript SDK in the browser and trying to upload user selected large files to the user's designated folder on S3.</p> <p>I use the putObject method to upload files to S3. The user is authenticated with a temporary token...
<p>the problem was "No access to ETag property on response. Check CORS configuration". Solved it with adding "ETag" in bucket CORS configuration.</p>
jQuery prop function is not working <p>HTML code:</p> <pre><code> &lt;ul class="expander-list" id="category"&gt; &lt;li&gt; &lt;div class="radio" style="padding-left:0px"&gt; &lt;label&gt; &lt;input type="checkbox" id="all" name="filter" class="checkbox0" value="all"&gt; ...
<p>In your code, <code>this.checked</code> refers to the state of the box you've clicked -- the one that fired the <code>change()</code> event. So <code>this.checked</code> will be <code>true</code> if you checked a checkbox and <code>false</code> if you unchecked a checkbox. Here's a demonstration:</p> <p><div class=...
Thread 1: signal SIGABRT Login Button Causes App to Crash <p>Currently trying to finish up making the login and registration form for my app. Registration works like how I want it to, but after working on the login screen I get the Thread 1: signal SIGABRT message on my AppDelegate.</p> <p><a href="https://i.stack.img...
<p>Here is the probable reason from the crash log.</p> <ul> <li>Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key emailTxt.' * First throw call stack: ( 0 CoreFoundation 0x000000010c05634b</li> </ul> <p>Yo...
Converting a list of dictionaries to models <p>I have a <code>List</code> containing a <code>Dictionary&lt;string, string&gt;</code> that represents lines from a database from multiple joined tables. I have tried all sorts of LINQ approaches but I always hit a wall where LINQ just doesn't allow certain operations on th...
<p>Anonymous type projection initializer should be a simple name or member access. So you need to add an explicit name like below:</p> <pre><code>data.GroupBy(x =&gt; new {S = x["dataKey"] }) </code></pre>
queryBuilder create sql with innerJoin <p>i can't to do true query from 2 tables.</p> <pre><code> /** * Order * * @ORM\Table(name="order_work") * @ORM\Entity(repositoryClass="AppBundle\Repository\OrderWorkRepository") */ class OrderWork { /** * @var int * * @ORM\Column(name="id", type="intege...
<p>You have to make a query with a join, which is possible with the querybuilder but i like to use DQL.</p> <pre><code>public function findOrdersOnClientName($searchTerm) { return $this-&gt;getEntityManager()-&gt;createQuery( 'SELECT o, c FROM AppBundle:OrderWork o JOIN o.client c WHERE c....
How do I obtain a cross product with multiple tables? <p>I am trying to obtain a cross product between two lists. I can see that the problem is that it's trying to append <code>(CP2 T1 T2)</code> with <code>(CP2 T1 T3)</code>. I have thought of other ways, such as <code>(CP2 (CP2 T1 T2) ...)</code>, but again, the elli...
<p>It can be done with one of the for loops also ( <a href="http://docs.racket-lang.org/reference/for.html" rel="nofollow">http://docs.racket-lang.org/reference/for.html</a> ): </p> <pre><code>(define (myproduct l1 l2) (for*/list ((i l1)(j l2)) (list i j))) (myproduct '(1 2 3) '(a b c)) </code></pre> <p>Ouput:...
AngularJS expandable table with aligned columns <p>With every example I can find of an expandable table using ng-repeat, the expanded row is "separate" content, such as an independent table inside the detail row. I have done many expandable tables using these methods, something like </p> <pre><code>&lt;tr ng-repeat-s...
<p>You can achieve this using ng-repeat-start and ng-repeat-end. The key difference is that your detail objects need to be children of the parent objects, not children of the same object.</p> <pre><code>&lt;tbody&gt; &lt;tr ng-repeat-start="parent in vm.parents"&gt; &lt;tr class="parent-entry"&gt; &lt;!-- cell...
Button under recyclerview is not visible <p>I'm progrmming app with <code>RecyclerView</code> and bottom buttons. <code>RecyclerView</code> is filling by images, that I got from the server. Top bar is fixed</p> <p><a href="http://joxi.ru/KAxee4XTEMpPr8" rel="nofollow">http://joxi.ru/KAxee4XTEMpPr8</a></p> <p><strong...
<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:tools="http://schemas.android.com/tools"&gt; &lt;RelativeLayout android:id="@+id/h...
How to include value within he file= string of a write.xlsx command <p>I'm struggling with finding out how to get a vlaue to resolve within speech marks. In the blow example, the is a load of other code logic between the setting of outputfolder and the write.xlsx line. Any suggestions?</p> <pre><code>client_name &lt;...
<p>Use <code>paste0(outputfolder, "/", client_name, "_", project_name, ".xlsx")</code></p>
how to change an old commit to become a fixup commit <p>I have list of commits:</p> <pre><code>1a First commit 2b Second commit 3c Third commit 4d fixup! First Commit 5e fixup! Second Commit 6f fixup! Third Commit HEAD 6f </code></pre> <p>I want to be able to change a commit in the past to become a fixup, and in som...
<ul> <li><p>If you want to keep these commits marked as <code>fixup!</code>:</p> <p>Use <code>git rebase -i</code> and change <code>pick 3c Third commit</code> to <code>reword 3c Third commit</code>. You will also need to restore the order and operations of the commits marked with <code>fixup!</code> if <code>autosqua...
How to return percentage in PostgreSQL? <p>CREATE TEMPORARY TABLE</p> <pre><code>CREATE TEMP TABLE percentage( gid SERIAL, zoom smallint NOT NULL, x smallint NOT NULL, y smallint NOT NULL ); </code></pre> <p>INSERT DATA</p> <pre><code>INSERT INTO percentage(zoom, x, y) VALUES (0,5,20), (0,5,21), (0,5,21), (...
<p>If am not wrong you are looking for this </p> <pre><code>SELECT zoom,x,y, amount, ( amount / Cast(Sum(amount) OVER(partition BY zoom) AS FLOAT) ) * 100 as amt_percentage FROM (SELECT zoom,x, y, Count(*) AS amount FROM percentage GROUP BY zoom,x,y) a </code></pre> ...
how to add two numbers input like one + two and output should be three in java? <p>Today I went one interview, interviewer ask me this question, I tried with StringBuffer but he not convinced please tell how I will do approach. </p>
<p>Am not telling this is the right answer, but maybe the HR just wanted to check your creativity applied to java language..</p> <p>something like:</p> <pre><code>public class Test { public static void main(String[] args) { System.out.println(Number.values()[Number.One.getNumber() + Number.Two.getNumber()...
Getting error:No adapter attached; skipping layout in recyclerview <p>I tried to fetch the json values from url and shows in listview with adapter in recylerview. but the listview is empty and getting this error 'No adapter attached; skipping layout'. When I tried with the below code its working</p> <pre><code>for (in...
<p>The issue is exactly like it sounds, an adapter is not being attached when it needs it. You don't attach it until <code>onPostExecute</code>. Just attach it right from the beginning:</p> <pre><code>mRecyclerView = (RecyclerView) findViewById(R.id.recycleView); mRecyclerView.setLayoutManager(new LinearLayoutManager(...
Angular 2 Final Release cannot find name module - moduleId: module.id <p>I just upgraded to the Angular 2 Final Release from RC 4 and I am now getting an error <code>cannot find name 'module'</code> on my code:</p> <pre><code>@Component({ selector: 'dashboard', moduleId: module.id, templateUrl: 'dashboard....
<p>Edit after updated question:</p> <p>Your HTML template is incorrect, you have a self-closing span element like this:</p> <p><code>&lt;span class="icon-external-link" /&gt;</code> </p> <p>which is not allowed in HTML. </p> <p>Change it to <code>&lt;span class="icon-external-link"&gt;&lt;/span&gt;</code></p> <hr>...
Error: double free or corruption (out): 0x00007fffffffddf0 *** <p>I am playing around with hierarchical objects and pointers and have written a base class Circle, then two classes Cylinder and Sphere that both derive from Circle. When I run the program I get the error: double free or corruption (out): 0x00007fffffffddf...
<p>You're allocating your cylinder and sphere on the stack, then calling delete on pointers to them. This will destroy your objects twice. Once when you call delete, and once when they go out of scope (main ends).</p> <p>Don't call delete on objects that you didn't create with new. Especially don't call delete on the ...
How can I get access to StackOverflow data? <p>I need to create reports around tag usage and unanswered posts. What're the different mechanisms available to access this data?</p>
<p>There are mainly 3 options:</p> <p>1) Use <a href="https://data.stackexchange.com/" rel="nofollow">SEDE</a> (Stack Exchange Data Explorer), which allows you to easily query the data. You can download the queried rows, however it does not allow you to run queries locally and can only be used manually.</p> <p>2) Use...
How can I remove night time points from GPS track data in R? <p>I have some tracking that looks like the sample below. I would like to be able to remove the rows that occur before 06:00 and after 18:00 i.e. the night time values. </p> <pre><code>tracks &lt;- read.table(text = " 05/04/2015 16:04, 53.3854 ...
<p>You can do this by first extracting the hours and minutes from <code>V1</code> and then use this to subset rows of <code>track</code>:</p> <pre><code>hm &lt;- strftime(as.POSIXct(tracks$V1, format="%m/%d/%Y %H:%M"), "%H:%M") tracks &lt;- tracks["06:00" &lt; hm &amp; hm &lt; "18:00",] ## ...
On Touch Method SurfaceView Android doesn't work <p>I created a SurfaceView (you can see it in the following) and started in from my Main Activity. I overwrote the onTouchEvent method in the SurfaceView and the problem is that the data I want to have logged with Log.d isn't logged, I don't get any Message... Does anyon...
<p>Try changing "getApplicationContext()" to "this" in following part of code:</p> <pre><code>setContentView(new MainGamePanel(getApplicationContext())); </code></pre> <p>to</p> <pre><code>setContentView(new MainGamePanel(this)); </code></pre>
How can I get value from label text field which is dynamically changes JavaFX <pre><code>&lt;Label fx:id="lblLibrarianId" layoutX="82.0" layoutY="14.0" prefHeight="24.0" prefWidth="212.0" text="$librarianId" /&gt; </code></pre> <p>I have a controller name <code>LibraryController</code>. I set label value text to <cod...
<p>In your controller, create your label object, and call getText() you'll need to use the @FXML to associate that object with the fx:id in your .fxml file</p> <p>ex.</p> <pre><code>public class LibraryController{ @FXML public Label lblLibrarianId; public String librarianID; final FXMLLoader fxmlLoad...
yes or no loop (TypeError: 'NoneType' object is not iterable) error <p>I'm trying to implement a yes / no / retry, but I am getting this error: 'NoneType' object is not iterable. I assume the issue is the function (def izberiEkipo() is not returning what it's suppose to.</p> <pre><code>def izberiEkipo(): m = se...
<p>Your assumption is correct: as given, your upper function returns nothing. You've disabled the loop with a <strong>False</strong> entry condition: it won't run at all. The only <strong>return</strong> in the function is inside that loop.</p> <p>Thus, all that routine does is to create two sets of a single charact...
How to use SELECT INTO in a plpgsql PROCEDURE? <p>I'm trying to use <a href="https://www.postgresql.org/docs/9.2/static/sql-selectinto.html" rel="nofollow">SELECT INTO</a> in a plpgsql procedure.</p> <pre><code>CREATE OR REPLACE FUNCTION reset_data() RETURNS void AS $$ BEGIN DROP TABLE IF EXISTS experiment; SELECT * I...
<p>It's discouraged to use <code>select into</code> to create a table based on a select statement.</p> <p>It is recommended to use the (standard compliant) <a href="https://www.postgresql.org/docs/current/static/sql-createtableas.html" rel="nofollow"><code>create table as</code></a>.</p> <p>The documentation for <cod...
SQL Query with one column and multiple LIKEs <p>I got a table with a column which contains content like Driver||Helper||Garden. I want to export this table to a new system, where I have diffrent columns for each user Skill (as it should be).</p> <p>Question: How can I get this kind of information in a nice SQL export....
<p>You need to split the string. So,it will divide Driver|Helper|Garden to separate Driver, Helper and Garder columns. </p> <p>This function is absent in mysql. You have to create it your own. Check this link: <a href="https://blog.fedecarg.com/2009/02/22/mysql-split-string-function/" rel="nofollow">https://blog.fedec...
Racket - Building the built-in member function <p>I like writing code to the same thing that built-in functions do. It is always a great exercise for me.</p> <p>In racket there is a bult-in function called "member" which checks if a certain element is inside a list. If true, the function returns the rest/cdr o the lis...
<p>There are some issues with your code. As a first observation you have switched the contract so that the list comes first instead of last. </p> <p>It also seem that you are checking if one of the elements is the empty list and not the list itself. Thus your <code>member</code> would terminate with <code>#f</code> in...
How to configure git-diff so that long line not wrap around? <p>I sometimes have long line of code in git repo (e.g. a json config file), and <code>git diff</code> will generate output like below.</p> <p><img src="https://www.dropbox.com/s/71o88x38fgmwhlb/git-diff-config-multi-lines.png?dl=1" alt="long line"></p> <p>...
<p>It's your terminal or pager program that wraps the lines, not <code>git diff</code>. Try redirecting the output of <code>git diff</code> into a file and open it with an editor that allows to control wrapping - you will see that the lines are not actually wrapped. </p> <p>You can try this:</p> <pre><code>git diff|c...
find a date range from min and max date field <p>I am trying to find the earliest instance of a date for a unique ID (unique ID has multiple rows of data with different dates) and then filter that result to find the data between years 2005 and 2010 using a subquery. I keep getting 'Incorrect syntax near the keyword 'gr...
<p>If I understood you correctly, you can use:</p> <pre><code>WITH CTE AS ( SELECT custnum, Field2, Field3, Field4, Field5, Field1 = MIN(Date_Field) OVER(PARTITION BY custnum) FROM dbo.table1 ) SELECT * FROM CTE WHERE Field1 BETWEEN '20050101' AND '2...
Migrating from log4j-1.2 to slf4j with log4j-2.6 binding <p>I am trying to migrate an existing project from direct log4j to slf4j with log4j binding. Also I am upgrading the the version of log4j from 1.2 to 2.6</p> <p>Some of the common code change are :-</p> <p>1.</p> <pre><code>import org.apache.log4j.Logger; . . ...
<p>First, I am not really sure why you are switching to the SLF4J API since the Log4j 2 API supports everything SLF4J does and much more. In my own code I have found that switching only requires changing the imports and LoggerFactory to LogManager.</p> <p>Configurator is a class in Log4j 1 that is used to configure Lo...
How do you validate an email field in angular 2 using model driven form <p>How do you validate an email field in angular 2 using model driven form, this is what I have so far.</p> <p><em>This is my form component</em></p> <pre><code>export class signinComponent { signinform: FormGroup; constructor(public fb: ...
<p>Validation method:</p> <pre><code>authEmailValidation( control: FormControl ): {[s:string]:boolean} { let pattern = /^(([^&lt;&gt;()\[\]\\.,;:\s@"]+(\.[^&lt;&gt;()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; if ( !pattern.tes...
visual studio 2015 find and replace not working <p>After Windows 10 auto installed the Anniversary Update, along with installing Visual Studio 2015 Update 3 (using Visual Studio Enterprise Edition), any time I try to use the Find in Files, or Replace in Files window has a scrambled UI, and no am unable to click / use a...
<p>The issue seems to have fixed itself with the Oct 12 windows update. From looking at the descriptions of the 'Cumulative Update for Windows 10 Version 1607 for x64-based Systems (<a href="https://support.microsoft.com/en-us/kb/3194798" rel="nofollow">KB3194798</a>)'. Unable to duplicate this issue anymore</p>
Why is arithmetic + preferred over textual one? <p>If I run</p> <pre><code>select '1' + '1' </code></pre> <p>the result is 11, since I have added a text to another one.</p> <p>If I run</p> <pre><code>select 1 + '1' </code></pre> <p>the result is 2. I assume the arithmetic operator is chosen over the concatenator b...
<p>What you're running into is a matter of <a href="https://msdn.microsoft.com/en-us/library/ms190309.aspx" rel="nofollow">data type precedence</a>. SQL Server looks to character data types <strong>after</strong> numerics. So regardless of the ordering of your operands (<code>1 + '1'</code> vs <code>'1' + 1</code>), it...
Git: Branch of Branch is not fully Rendering CSS <p>I am new to Git. For my project, I have a branch called staging which is a branch off of master. I created a new branch called salesforce_update off of the staging branch. When I am on the staging branch, everything runs and renders well. When I switch over to the sal...
<p>If you are using a task runner to compile your assets you may run into issues when switching branches with it running. Make sure to restart your task runner after switching.</p>
Get Post title in span tag <p>i want to get the wordpress title post to a span tag.</p> <p>i use the code below with the_title() in span tags:</p> <pre><code>&lt;?php echo '&lt;div&gt; &lt;img src="image.jpg"/&gt; &lt;h2&gt;&lt;span&gt;'.the_title().'&lt;/span&gt; &lt;/h2&gt;&lt;/div&gt;'; ?&gt; </code></pre> <p>but...
<p>I would advice changing this </p> <pre><code>&lt;?php echo '&lt;div&gt; &lt;img src="image.jpg"/&gt; &lt;h2&gt;&lt;span&gt;'.the_title().'&lt;/span&gt; &lt;/h2&gt;&lt;/div&gt;'; ?&gt; </code></pre> <p>to something like this </p> <pre><code>&lt;div&gt; &lt;img src="image.jpg"/&gt; &lt;h2&gt; &lt;?php the_t...
Subcomponents dagger2 implementation <p>i'm trying to apply MVP concepts using dagger2 following <a href="https://github.com/googlesamples/android-architecture/tree/todo-mvp-dagger/" rel="nofollow">this</a> Google repo on Github i have multiple fragments splash screen i have created the first splash screen fragment us...
<p>To be honest, It's really hard to find out your problem because some pieces of your puzzle is missing, but I guess this might help:</p> <p>add this to your DataRepoComponent:</p> <pre><code>@Singleton @Provides DataRepo provideDataRepo(){ return new DataRepo(); } </code></pre> <p>by the way, I think looking a...
NSLog output no where to be found, Xcode8 <p>I'm trying to use NSLog statements to figure out the execution flow of my app, so I have one in main.m right after autoreleasepool:</p> <pre><code>@autoreleasepool { NSLog(@"app started"); //added breakpoint here, but debugger stopped at next line BOOL runningTests ...
<p>the NSlog is executed but is hidden among lots of other console debug outputs to solve this issue:</p> <pre><code>In Xcode8: Product -&gt; Scheme -&gt; Edit Scheme -&gt; Run -&gt; Arguments -&gt; Environment Variables </code></pre> <p>add <code>OS_ACTIVITY_MODE</code> and check it, but don't add any value.</p>
NLog - Variable Update (at runtime) <p>Trying to update a variable at runtime with NLog on a vb.net (asp.net) application and doesn't appear to be working.</p> <pre class="lang-xml prettyprint-override"><code>&lt;nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-in...
<p>Instead of </p> <pre class="lang-vb prettyprint-override"><code>GlobalDiagnosticsContext.Set("Line", "myLine")` </code></pre> <p>use </p> <pre class="lang-vb prettyprint-override"><code>LogManager.Configuration.Variables("line") = "myLine" </code></pre> <p>Although the GlobalDiagnosticsContext and variables use ...
What is the priceRange parameter for Google Structured Data Reviews <p>I am trying to determine what are the acceptable values for the <code>priceRange</code> parameter. </p> <p><strong>On Google I see $$$ and thats it</strong></p> <p>Can someone explain if I should be using <code>$$$</code> literally or a decimal am...
<p>It seems there is no "standard" for this, and probably is born out of the rating system for Restaurants.</p> <p>It seems the convention is:</p> <blockquote> <ul> <li>$ = Inexpensive, usually $10 and under</li> <li>$$ = Moderately expensive, usually between $10-$25 </li> <li>$$$ = Expensive, usually between...
ERROR ITMS-90685: "CFBundleIdentifier Collision. There is more than one bundle" <p>When I am try to submit my app to app store I am getting the error </p> <pre><code>ERROR ITMS-90685: "CFBundleIdentifier Collision. There is more than one bundle with the CFBundleIdentifier value com.companyname.projectNam...
<p>Have you got an App Extension in your app? I had this error because of Cocoapods embedded frameworks inside App Extension folder.</p> <p>You need to remove build phase <code>'[CP] Embed Pods Frameworks'</code> from Extension target.</p> <p>I wrote such ruby script for that:</p> <pre><code># remove.rb require 'xco...
How can I convert these ASCI codes to Unicode? <p>jslint appears to complain here:</p> <pre><code>Unexpected '\' before 'X'. Priv.SELECTOR = /^(@|#|\.)([\x20-\x7e]+)$/; </code></pre> <p>Perhaps if I used Unicode things would work?</p>
<p>It seems that <code>\uXXXX</code> notation is recognized by jslint as valid. Use</p> <pre><code>Priv.SELECTOR = /^([@#.])([\u0020-\u007e]+)$/; </code></pre> <p>or</p> <pre><code>Priv.SELECTOR = new RegExp("^([@#.])([\\u0020-\\u007e]+)$"); </code></pre> <p>Note that the backslashes must be doubled inside a <code>...
Is a compound index needed for querying on one field and using another for sorting? <p>In MongoDB, let's say I have the following query:</p> <pre><code>db.things.find({ name: 'some string' }).sort({ age: -1 }) </code></pre> <p>I know that having an index for <code>age</code> will help performance, but do I create the...
<p>Create a compound index. Mongo DB's documentation goes into more detail here:</p> <p><a href="https://docs.mongodb.com/manual/tutorial/sort-results-with-indexes/" rel="nofollow">https://docs.mongodb.com/manual/tutorial/sort-results-with-indexes/</a></p> <p>From that page:</p> <blockquote> <p>The following oper...
Checking if another window is closed c++ <p>I'm developing an application that checks open windows on a user computer on Windows (just like the Task Manager)</p> <p>I used <strong>EnumWindows</strong> to list all the active window and it works, now i want to create a function that write a message on the console when a...
<p>The easiest solution is to use <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd373889.aspx" rel="nofollow">WinEvents</a>, by registering for <code>EVENT_OBJECT_DESTROY</code> events. The code is fairly straight forward:</p> <pre><code>#include &lt;windows.h&gt; namespace { HWINEVENTHOOK g_W...
Tests: check if tuple is returned <p>I am writing a test which checks response from gen_server. The response itself is either <code>{profile, SomeProfileFromGenServer}</code> or <code>{error, ErrorResponse}</code></p> <p>So I wanted to write a test which does:</p> <pre><code>Profile = mygenserver:get_profile(), ?asse...
<p>You can use <code>?assertMatch</code>, with the first argument being a pattern:</p> <pre><code>?assertMatch({profile, _}, Profile) </code></pre>
SFINAE does not work as expected <p>I am reading <a href="http://baptiste-wicht.com/posts/2015/03/named-optional-template-parameters-compile-time.html" rel="nofollow">this article</a> and find this piece of code using <code>SFINAE</code> very interesting:</p> <pre><code>template&lt;typename D, typename T2, typename......
<p>SFINAE occurs in immediate context, here your condition doesn't depend of <code>T</code> so it is a hard failure, your code should be something like:</p> <pre><code>template &lt;typename T&gt; class A&lt;T, typename enable_if&lt;condition&lt;T&gt;::value&gt;::type&gt; { }; </code></pre>
Fast optimization of "pathological" convex function <p>I have a simple convex problem I am trying to speed up the solution of. I am solving the argmin (<em>theta</em>) of</p> <p><img src="http://latex.codecogs.com/gif.latex?-%5Csum_%7Bt%3D1%7D%5E%7BT%7D%5Clog%281%20&plus;%20%5Cboldsymbol%7B%5Ctheta%27%7D%20%5Cboldsymb...
<p>I believe the issue is that it is possible for <code>theta</code> to be such that the <code>log</code> argument becomes negative. It seems that you have identified this issue, and have <code>goalfun</code> return the tuple <code>(100,100*ones(N))</code> in this case, apparently, as a heuristic attempt to suggest the...
working with DOM end events <p>I have a small problem. If I have a form with few inputs[type="text"] and div's around them (plus and minus)... how to increment and dicrement input without creating variables, classes and ids for every tag? someone said I can use arrays but I don't know how to do it... </p> <p>the examp...
<p>you can simply use var child= document.getElementById("child"); child.value++; or child.value--;</p>
Cannot figure out REGEX java <p>I am trying to write a REGEX which can get string between two words. Here is the code,</p> <pre><code>Pattern MY_PATTERN = Pattern.compile("/\\x22(.*?)/\\x22"); Matcher m = MY_PATTERN.matcher("sasaa \\x22 kjhkjhk \\x22,sasas"); while (m.find()) { String s = m.group(1); System.o...
<blockquote> <p>Pattern.compile("\\\\x22(.*?)\\\\x22");</p> </blockquote> <p>You must escape backslash in Patterns with another backslash. Since backslash must be already escaped with another backslash in any Java string in the first place (like you did in the input string), you must have 4 of them in total.</p>
Create semi transparent uibutton with solid white text <p>I am trying to create button similar to following: <a href="https://i.stack.imgur.com/c66iW.png" rel="nofollow"><img src="https://i.stack.imgur.com/c66iW.png" alt="enter image description here"></a></p> <p>I have tried to give alpha with white text color but I ...
<p>What you need to do is set the alpha of the button to the point that you want. So for example this would have a semi-transparent background and white text color:</p> <pre><code>button.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 0.1) button.textColor = .white button.attributedPlaceholder = NSAttribut...
Extension methods for EntityTypeConfiguration and <datatype>PropertyConfiguration <p>With Entity Framework I might have a configuration that looks like:</p> <pre><code>internal class MyDbContext : DbContext { .... protected override void OnModelCreating(DbModelBuilder mb) { builder.Entity&lt;MyEntity&gt;()...
<p>After a little playing around, I realized I don't need to execute/compile any of it, I just need to chain the parameters together in the correct sequence.</p> <pre><code> public static EntityTypeConfiguration&lt;TEntityType&gt; Property&lt;TEntityType&gt;( this EntityTypeConfiguration&lt;TEntityType&gt; ...
Why does my object move in the wrong direction <p>I have a made a simple program which is meant to move a ball left and right horizontally within a canvas. The user will use the left and right keys to move the ball accordingly by 5 pixels a time. If the x coordinate of the ball is less than 40 or more than 240 then it...
<p>According to the <a href="http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.move-method" rel="nofollow">Tkinter Canvas documentation</a>, the second argument to the <code>move</code> method, <code>dx</code>, is an offset. Try calling it like</p> <pre><code>game_area.move(ball, -5, 4) </code></pre> <p>Then yo...
How can I update the highscore of a game with a database without reloading the page? <p>I made a JS snake <a href="http://msolonko.net/snake" rel="nofollow">game</a> using HTML5 canvas. If the user loses the game, the score is sent to the database using AJAX. The PHP script compares it to the current value and saves it...
<p>I think to specify the url in the $.ajax call</p> <pre><code>$.ajax({ url: "test.html", cache: false, success: function(html){ $("#results").append(html); } </code></pre> <p>});</p> <p>Take a look at this link:</p> <p><a href="http://stackoverflow.com/questions/9436534/ajax-tutorial-for-post-and-get">AJA...
Bootstrap col-md-4 to col-sm-6 <p>I have seen this question: <a href="http://stackoverflow.com/questions/29926617/boostrap-3-col-md-4-to-col-sm-6-or-grid-of-3x2-to-2x3">Boostrap 3 - col-md-4 to col-sm-6, or grid of 3x2 to 2x3</a></p> <p>But it hasn't worked for me.</p> <p>This is my HTML:</p> <p><div class="snippet"...
<p>Bootstrap uses floats to organize its column divs. If a column div is a different height it won't be able to float all the way to the left. In your example it looks like the first and second service divs are taller than the 3rd. This is causing the second row to not be able to float left all the way. The fix for...
Transform a factor into a matrix of 2 columns in R <p>I have a column of continuous values that goes from 0 to 21600 approximately. </p> <p>I am trying to get this data binned in ranges of 100 and get the frequencies of them, e.g: [0,100) - 35, [100,200) - 57, and so on.</p> <p>What I am doing is this:</p> <p>binned...
<p>There are a few ways to do this. But first, what you want is a data.frame (or even better a data.table or a tbl) since you are now dealing with things of different types. The counts are numbers and the ranges are factors.</p> <p>To count easily, use <code>table</code> and from there put it into a data.frame</p> <p...
Drop Foreign Key not working when Key_name does not match Column_name <p>When I run:</p> <pre><code>ALTER TABLE `example` DROP FOREIGN KEY `example_configs_user_email_foreign`; </code></pre> <p>It runs without error however, the foreign key is not dropped. When I look at the table indexes it still shows:</p> <pre><c...
<pre><code>create schema test8484a; use test8484a; create table sometable ( id int auto_increment primary key, user_email varchar(255) not null COLLATE utf8_unicode_ci NOT NULL, key `keyname8282`(user_email) )engine=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; CREATE TABLE `example` ( `id` int(10)...
cropper is not a function on is not a function <p>I'm trying to make use of <a href="https://github.com/fengyuanchen/cropper" rel="nofollow">cropper plugin by fengyuanchen</a> but meeting quite an impossible error</p> <p>I constantly get into <code>Uncaught TypeError: canvas.cropper</code> is not a function even thoug...
<p>From the jQuery docs:</p> <blockquote> <p>Attach an event handler function for one or more events to the selected elements.</p> </blockquote> <p>Now, <code>canvas</code> after <code>var canvas=$('#image-display canvas')[0];</code> is not a selected element. It's the first property of the selected element. <code>...
Distinguish between days in Spiral graph <p>so is there any idea for how to do this ,Please ? Thanks in advance.</p> <p>here's my <a href="https://www.dropbox.com/s/ni5aperr0yeertv/All_smry.csv?dl=0" rel="nofollow">data</a> for almost 5weeks</p> <pre><code>head(All.smry) Source: local data frame [6 x 7] Groups: day [...
<p>Try to remove <code>coord_polar()</code> to have a better understanding of what happens.</p> <p>You can either add diagonal lines between your existing colored diagonal bars, a bit like I said in my firt comment. This requires some tweaking but it should work.</p> <p>Another solution is to act directly on the colo...
Restrict Special Characters in HTML & AngularJs <pre><code> ` ~ ! @ # $ % ^ &amp; * ( ) _ + = { } | [ ] \ : ' ; " &lt; &gt; ? , . / </code></pre> <p>I want to restrict the above mentioned special characters and numbers in the input text field. I used the</p> <pre><code>ng-pattern="/^[a-zA-Z ]*$/" </code></pre> <p>to...
<p><strong>Updates:</strong></p> <p>I think $parsers is the best options here. See the updated code and plunker.</p> <p>Controller</p> <pre><code>angular.module('ngPatternExample', []) .controller('ExampleController', ['$scope', function($scope) { $scope.regex = /^[^`~!@#$%\^&amp;*()_+={}|[\]\\:';"&lt;&gt;?,./...
How to call Java method which returns String from C using JNI? <p>Is there a way to call a java method, which returns a <code>String</code> in C?<br> For <code>Integer</code> it works like that: </p> <pre><code>JNIEXPORT jint JNICALL Java_Client_getAgeC(JNIEnv *env, jobject callingObject, jobject employeeObject) { jc...
<p>Below is an example of JNI code calling a method returning a string. Hope this helps.</p> <pre><code>int EXT_REF Java_JNITest_CallJava( JNIEnv* i_pjenv, jobject i_jobject ) { jclass jcSystem; jmethodID jmidGetProperty; LPWSTR wszPropName = L"java.version"; jcSystem = i_pjenv-&g...
How to remove 'selected' attribute from item in ModelChoiceField? <p>ModelChoiceField adds attribute <code>selected</code> in HTML, if object from choices list has FK to parent object.</p> <p>How\where can I remove this 'selected' attribute in order to get just list of choices? Want to mention, that I need to remove j...
<p>I don't know would it work or not, but an idea would be clear for you. </p> <p>So, i found source of <code>Select</code> widget that sets your <code>selected</code> property in html. It's <a href="https://docs.djangoproject.com/en/1.10/_modules/django/forms/widgets/#Select" rel="nofollow">here</a>, just search for ...
Explain this Code? <p>So I know that this code takes a random 10 number array and puts it in order from lowest to highest. How does it do it though? Can you explain what the loops, the buffers and the I's and J's?</p> <pre><code>import java.util.Arrays; public class Divisible { public static void main(String[] args)...
<p>It's bubble sort. See <a href="https://en.wikibooks.org/wiki/Algorithm_Implementation/Sorting/Bubble_sort" rel="nofollow">https://en.wikibooks.org/wiki/Algorithm_Implementation/Sorting/Bubble_sort</a> for explanation.</p>
Inject a p namespace attribute using spring annotations <p>I have a bean defined similar to below in my spring.xml. I am converting all my beans into annotation based. How can I inject the attributes in the below listed bean?</p> <pre><code>&lt;bean id = "dataPropDao" class = "com.service.ref.DataPropD...
<p>"p" namespace is used to set bean properties using setters. Equivalent of your code in Java config would be similar to:</p> <pre><code>@Configuration class MyConfig { @Bean DataPropDaoImpl dataPropDao(DataSource datasource) { DataPropDaoImpl dao = new DataPropDaoImpl(); dao.setDataSource(d...
Product multiple columns by a single column in a dataframe <p>My datas as follows:</p> <pre><code>datas6=structure(list(Exp = c("BA", "CI", "CE", "DE"), Var1 = c(0L, 0L, 0L, 0L), Var2 = c(0L, 0L, 1L, 0L), Var3 = c(0L, 1L, 1L, 0L ), Var4 = c(1L, 1L, 1L, 1L), Freq = c("6", "2", "7", "5")), .Names = c("Exp", "Var1", "V...
<p>We can do this by</p> <pre><code>datas6[2:5] &lt;- datas6[2:5] * as.numeric(datas6[,6]) datas6[2:5] # Var1 Var2 Var3 Var4 #1 0 0 0 6 #2 0 0 2 2 #3 0 7 7 7 #4 0 0 0 5 </code></pre>
Going through a object with a variable <p>I guess I didnt really know how to ask this question for me to find an answer. </p> <p>So I have three variables that are going to make this function do what it has to</p> <pre><code> function gatherDataForGeographic(ele) { var $this = $(ele) var $main_titl...
<p>You can use dynamic properties in JS using the bracket syntax, not the dot syntax:</p> <pre><code>reportAreas[type] </code></pre> <p>That will resolve to <code>reportAreas['whateverString']</code> and is equivalent to <code>reportAreas.whateverString</code>- <code>reportAreas.type</code> however, is a literal chec...
Write a program in C to apply Luhn's algorithm for credit card validation <p>I am completely new to C (and all forms of programing...) and following the CS50 class this year. I'm having a really hard time with writing a simple program that uses Luhn's algorithm to test the validity of credit card numbers. </p> <p>I ne...
<p>Your answer is a out of order pastiche with sections that don't follow logically from the previous.</p> <p>Specific issues:</p> <p>This logic:</p> <pre><code>if (count != 13 || count != 15 || count != 16) </code></pre> <p>invalidates every card, the <strong>or</strong>s (||) should be <strong>and</strong>s (&amp...
Getting @section from multiple views in your layout <p>I have the following code in my master.blade layout:</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-html lang-html prettyprint-override"><code>&lt;div id="w...
<p>Include login-popup.blade.php in every page. You can do that by:</p> <p><code>@include('login-popup')</code></p>
Why does implicit UNNEST not work as the docs say it should? <p>According to the <a href="https://cloud.google.com/bigquery/sql-reference/query-syntax#unnest" rel="nofollow">BigQuery docs</a>:</p> <blockquote> <p>In implicit unnesting, array_path must resolve to an ARRAY and the UNNEST keyword is optional.</p> ...
<p>I filed an (internal) bug against our documentation to clarify this section based on your feedback so hopefully we can have it fixed soon.</p> <p>This section of the <a href="https://cloud.google.com/bigquery/sql-reference/migrating-from-legacy-sql#removing_repetition_with_flatten" rel="nofollow">migration guide</a...
convert coordinates into binary image python <p>I made a GUI in which I can load an image from disk and convert the mouse motion ( drawing the contours ) into coordinates. Now I need to convert the coordinates into a binary image and I don't know how. Here is my code:</p> <pre><code>from Tkinter import * from tkFileD...
<p>Your issue is that you are creating a new empty array at each mouse event with the line <code>a = np.zeros(shape=(h,w))</code> in mouseevent. To fix that you should have <code>a</code> declared in the <code>__init__</code> as an attribute (ie <code>self.a = np.zeros(shape=(h,w))</code>) so that you can acces and upd...
Perl: Split CSV at given string and use specific string as file name <p>So I have several large CSV files with several columns and rows (6000 odd rows and +-60 columns each) that I would like to split into seperate CSV files at a given string (number of lines between string differs), where each file is to be named the ...
<p>First of all, your line:</p> <pre><code>open (INPUT, "&gt;", "$input_file") </code></pre> <p>Looks like it's opening a file for <strong>WRITING</strong> -- you wanted to read it, right?</p> <p>If you're really dealing with a true CSV file, you may want to explore <code>Text::CSV</code> instead of splitting just ...
How two recursion function in program works? <p>I am learning Recursion and understand single recursion like Factorial . I am facing problem to understand how two recursive function works ? I am trying to understand this code :</p> <pre><code>def countdown(n,m): if n == 0: # this is the base case return ...
<p>You are confuse because you are visualizing two recursion with single stack , You have to know that Every recursion function store values its own stack , It means if you have two recursion there will be two stack , if you have three recursion there would be three stack. </p> <p>Now back to the question , I have wri...
(Python) How to find the index of the maximum value of a list? <p>The instructions for the program: To create an empty list and fill it with 20 random integers between 1-500 inclusive, print the list on a single line, and print the maximum value of that list on a separate line. The max value function cannot be used.</p...
<p>Lists have a <code>.index</code> method. That should fit the bill.</p> <pre><code>&gt;&gt;&gt; ["a","b","c"].index("b") 1 </code></pre>
How to find uses-feature in APK? <p>I know I can use </p> <pre><code>aapt d permissions foo.apk </code></pre> <p>to find out which permissions a certain APK needs. But how can I check which <code>&lt;uses-feature&gt;</code> tags were used?</p>
<p><code>aapt dump badging</code> will list <code>&lt;uses-feature&gt;</code> as part of its output:</p> <pre><code>feature-group: label='' uses-feature: name='android.hardware.camera' uses-feature-not-required: name='android.hardware.camera.autofocus' uses-feature-not-required: name='android.hardware.camera.fro...
Spawn A Player when player pass y coordnat <p>I'm working on a plugin. I want to spawn a player when a player come a y coordinates(Fall Down). I tried scheluder (some resources says) but i didn't do it how can do it?</p> <p>Thanks For Answers</p>
<p>You can use an event handler for the PlayerMoveEvent, and then check if the Y coordinate is less than your threshold, and if it is, teleport them to spawn with the Entity#teleport(Location) method.</p>
BigQuery standart SQL - how to calculate 2 timestamp2 difference in minutes <p>I'm using BigQuery standart SQL and i need to find the difference between 2 timestamps, in minutes.</p> <p>For example:</p> <p>Timestamp1 = '2016-10-10 09:40:00' | Timestamp2 = '2016-10-10 09:50:00' </p> <p>I want to return the differen...
<p>check for <a href="https://cloud.google.com/bigquery/sql-reference/functions-and-operators#regexp_contains" rel="nofollow">TIMESTAMP_DIFF</a> function </p> <pre><code>SELECT TIMESTAMP "2016-10-10 09:50:00" as first_timestamp, TIMESTAMP "2016-10-10 09:40:00" as second_timestamp, TIMESTAMP_DIFF(TIMESTAMP "2016-...
My Mutex is not working <pre><code> private static bool Created; private static System.Threading.Mutex PaintGuard = new System.Threading.Mutex(false, "MonkeysUncleBob", out Created); //Function that is attached to each pages "LayoutUpdated" call. private async void AnyPageLayoutUpdated(object sender, ob...
<p><code>await</code> is not compatible with <code>Mutex</code>. You can use an async-compatible mutex like <code>SemaphoreSlim</code> or the <a href="https://github.com/StephenCleary/AsyncEx.Coordination" rel="nofollow"><code>AsyncLock</code> that I have as part of my AsyncEx library</a>.</p> <p>However, if you need ...
Create a Pivot style table in SQL <p>I'm not sure how to get what I'm trying to do across in the title, any help there would be appreciated.</p> <p>Here's the problem:</p> <p>I've got a large data set, currently more than 108k rows with 5 columns. I'm trying to display it in a particular way so that it will look simi...
<p>SQL CLI tools are not really designed for neat presentation of data. You will probably find that it is more trouble than it is worth to try to do this in SQL. For a quick solution, I would look into using <a href="https://www.r-project.org/" rel="nofollow">R</a> to format the data. </p>
NullPointerException while calling findViewById method from Main Activity in app using ViewPager <p>I tried to write app using ViewPager and I want to add a listener to TextView in my app. Adding listener in Fragment code is simple, but how can I create it in MainActivity without getting NullPointerException ?</p> <p>...
<p>There is no view by the id txt_frag1 in you activity_main layout.Because of this you are getting a NPE.First add a textview with the same in activity_main xml and then access it in java.</p>
Bluebird.resolve(jQuery.ajax) Warning promise rejected with non-error [object Object] <p>Problem: when passing jQuery.ajax to Promise.resolve in Bluebird.js, it throws a warning when the request fails.</p> <p>Is this the correct behavior? For some reason that I couldn't find, Bluebird does not emit this warning when ...
<blockquote> <p>After digging a little bit, I find that it is simply a difference of the two different builds of Bluebird. The unminified build emits warnings, but the minified build does not. Is there a reason for this?</p> </blockquote> <p>This is done because the unminified version is considered the "debug" v...
Canvas DrawLine Is Invisible <p>I am trying to draw a single line in Android using canvas </p> <p><strong>My class :</strong></p> <pre><code>public class LineDrawer extends View { public LineDrawer(Context context) { super(context); } @Override protected void onDraw(Canvas canvas) { ...
<p><code>lineDrawer</code> is created but not added anywhere. Just creating a view is not enough, you need to add it to the current displayed views to be taken into account and drawn. You have two options:</p> <ul> <li><p>Add it to your XML layout. You will have to add the following constructor to your custom view.</p...
gitlab runner The requested URL returned error: 403 <p>I'm currently using gitlab.com (not local installation) with their multi-runner for CI integration. This works great on one of my projects but fails for another.</p> <p>I'm using 2012R2 for my host with MSBuild version 14.0.23107.0. I know the error below shows ...
<p>This looks like you need to add add a <code>cd</code> command to print current directory to your before_script. Then go fix permissions to access the parent of that folder. If you installed your gitlab runner to c:\glrunner, it's probably c:\glrunner\builds permission you need to fix.</p> <p>Second problem is you ...
Fixed Header Scrolling Issue <p>I'm creating a fixed nav so when the user scrolls and hits the top of the nav the nav is position:fixed to the top of the screen.</p> <p>It's more a query than anything else because when the variable 'navOffset' is inside the scroll function the header jitters, but when outside the func...
<p>Try this. I changed var navOffset = $("nav").position(); <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>(function(){ $(document).on("scroll", function(){ ...
Using Javascript I want a button to show or hide a div by changing the css <p>Using JavaScript, I want a button to show or hide a div by changing the CSS.</p> <p>HTML:</p> <pre><code>&lt;div id="bottomContainer"&gt; &lt;div id="count" class="count"&gt;...&lt;/div&gt; &lt;div id="visualizations&gt;...&lt;/div&...
<p>Yes, a number of ways. With vanilla JS, you would do something like:</p> <pre><code>document.getElementById('myButtonId').addEventListener('click', function () { document.getElementById('bottomContainer').style.display = "none"; } </code></pre> <p>This is just one of a few ways. You could also make a css rul...
Disable scroll zoom on mapbox <p>I'm trying to disable scroll zoom on a mapbox map, but it is not working. Can anyone let me know what's wrong with my code? The error I get is "Uncaught TypeError: Cannot read property 'disable' of undefined" </p> <pre><code>&lt;script&gt; L.mapbox.accessToken = 'pk.token'; var...
<p>This is a mapbox.js / leaflet map, not mapbox-gl-js, so the difference is in Leaflet the scroll zoom control is called <code>scrollWheelZoom</code> not <code>scrollZoom</code>. If you replace the last line of your script with the following it should work. <a href="http://jsfiddle.net/x5j669zj/" rel="nofollow">http:/...
cannot install python using brew <p>Trying to install python using the following command:</p> <p><code>brew install python</code></p> <p>But unfortunately I am getting the following error:</p> <pre><code>&gt;brew install python ==&gt; Downloading https://homebrew.bintray.com/bottles/python-2.7.12_2.el_capitan. Alrea...
<p>The error message says you don’t have permission to write under <code>/usr/local/lib/python2.7/site-packages/pkg_resources</code>.</p> <p>The following steps should work:</p> <ol> <li><p>Remove your broken Python install:</p> <pre><code>brew uninstall python </code></pre></li> <li><p>Ensure you own that directo...
Location for public files in angular2 app <p>I'm using ng serve to serve my angular 2 sample application. I created the sample application using the angular command line interface (CLI). I want to have a few jpg images in my angular application (company logo, etc...). However, I can't seem to find any folder which is p...
<p>Using the latest <code>angular-cli</code> all static files go into the <code>assets</code> folder under: <code>/src/assets</code>.</p> <p><a href="https://github.com/angular/angular-cli#project-assets" rel="nofollow">https://github.com/angular/angular-cli#project-assets</a></p> <p>The folder name can be changed i...
Get UserId of Facebook user <p>I have a snippet where I allow a user on my MVC Asp.net Site to publish a POST. It works fine.</p> <p>What I need is when the POST is published and a facebook user clicks on it (There is a url action that takes you to mywebsite if the user clicks on it) . How would I get the userId or so...
<p>If the user did not authorize your App, there is no way to know. If he authorized your App, you can get his id with <code>FB.getLoginStatus</code>, for example.</p>
Toggle open/close sliding panel <p>I have been working on a project and its almost functioning perfectly however I have one more hurdle.</p> <pre><code>$(document).ready(function() { $("a.shareTab").each(function(index, item) { $(this).on("click", function() { $('.sharepanel' + $(item).data("panel")).animate({ '...
<p>One way would be to hide all of the panels once a panel is clicked and then reopen the desired panel.</p> <pre><code>$(document).ready(function() { $("a.shareTab").each(function(index, item) { $(this).on("click", function() { $('.sharePanel').hide(); $('.sharepanel' + $(item).data("panel")).animate(...
Hide Y-axis labels when data is not displayed in Chart.js <p>I have a Chart.js bar graph displaying two sets of data: Total SQL Queries and Slow SQL Queries. I have Y-axis labels for each respective set of data. The graph can be seen below:</p> <p><a href="https://i.stack.imgur.com/yAKX2.png" rel="nofollow"><img src="...
<p>You can add a callback function to legends onClick:</p> <pre><code>var options = { animation: false, scales: { yAxes: [{ position: "left", ticks: { beginAtZero: true }, scaleLabel: { d...
c lang - different array length by pointer <p>I have problem with my own function for get array length. Code:</p> <pre><code>#include &lt;stdio.h&gt; int main() { int a[] = {5,4,1,2,1}; //len -&gt; 6!! FAIL! WHY? //int a[] = {5,4,1,2}; //len -&gt; 4 OK! int len = 0; int *p = a; while(*p != '\0'){ ...
<p>It fails because there's no <code>0</code> at the end of your array. It's not added automatically, you need to do it explicitly. As a result, you accessed outside the array, which results in undefined behavior. The fact that one of your tests seemed to work was purely luck, you can't depend on it.</p> <pre><code>in...
IEnumerable not not, but returning null reference exception on iteration (C#) <p>I have an IEnumerable that I run a foreach on. It's throwing a null reference exception in certain cases on the foreach line, it says </p> <blockquote> <p>ienumerable threw an exception of type 'System.NullReferenceException</p> </block...
<p>Iterators can do just about anything when iterated, including throw exceptions. So basically, you need to know what the source is. For example, this is a non-null iterator that throw in the same way:</p> <pre><code>var customers = new [] { new Customer { Name = "abc" }, new Customer { }, new Customer { ...
Python or Numpy Approach to MATLAB's "cellfun" <p>Is there a python or numpy approach similar to MATLABs "cellfun"? I want to apply a function to an object which is a MATLAB cell array with ~300k cells of different lengths. </p> <p>A very simple example:</p> <pre><code>&gt;&gt;&gt; xx = [(4,2), (1,2,3)] &gt;&gt;&gt;...
<p>The most readable/maintainable approach will probably be to use a <a href="https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions" rel="nofollow">list comprehension</a>:</p> <pre><code>yy = [ np.exp(xxi) for xxi in xx ] </code></pre> <p>That relies on <code>numpy.exp</code> to implicitly conver...
IllegalArgumentException when using FXML <p>I've been following along the TornadoFX guide for using FXML (<a href="https://github.com/edvin/tornadofx/wiki/FXML" rel="nofollow">https://github.com/edvin/tornadofx/wiki/FXML</a>), but am getting a error: </p> <pre><code>java.lang.IllegalArgumentException: FXML not found f...
<p>Short answer first: Put the file in <strong>src/main/resources/ui/view/BoardView.fxml</strong> and don't supply a path parameter to the <strong>fxml()</strong> call.</p> <p>If you are using Maven, it will not copy fxml files in <strong>src/main/java</strong> to the target directory by default, so even if you have t...
Thymeleaf Loop Until a Number <p>I make a search and get response from server with Thymeleaf. This holds the number of results:</p> <pre><code>${response.count} </code></pre> <p>I want to make an iteration like that:</p> <pre><code>for (int i = 1; i &lt;= response.count; i++) { if (response.page == i) { ...
<p>This works for me:</p> <pre><code>&lt;th:block th:each="i: ${#numbers.sequence(0, response.count - 1)}"&gt; &lt;button th:if="${response.page == i}" class="active"&gt;Dummy&lt;/button&gt; &lt;button th:unless="${response.page == i}"&gt;Dummy&lt;/button&gt; &lt;/th:block&gt; </code></pre>
Ansible apt module - "unsupported parameter for module: “name" <p>Ansible version 2.1.2.0 (homebrew, macOS - having removed any previous versions)</p> <pre><code>ansible myserver -m apt -a “name=backup2l,state=present” --ask-pass </code></pre> <p>returns this error:</p> <pre><code>myserver | FAILED! =&gt; { ...
<p>ansible arguments are seperated by spaces like a command line, not a function call. </p> <p>Try:</p> <pre><code>ansible myserver -m apt -a “name=backup2l state=present” --ask-pass </code></pre>
window.location does not get updated <p>I have a Javascript function as shown below for my HTML form. I am getting the <code>window.location.href</code> as source. Then I am removing two unwanted querystring parmaeters from that. This part works fine (as can be seen from first and second alert screenshots).</p> <p>But...
<p>This is a function I whipped up right now:</p> <pre><code>function redirectOnBadArgs(badargs) { var i, j, newloc, args, segs, isbad, redirect; redirect = false; newloc = location.href.split("?"); if (newloc.length === 2) { args = newloc[1].split("&amp;"); i = 0; while (i &lt; args.len...
Parse comma separated string into rows <p>I have a User Table, which has a role column. Each user can have multiple roles (or none) and for ease of use, I used a comma separated list to store the roles.</p> <pre><code>USERNAME ROLE ---------------------- bob role1,role2 sally role2 </code></pre> <p>Now,...
<p>You can speed it up by using instr and substr (rather than regexp versions), or speed it up A LOT if the input is CLOB and you use the dbms_lob versions of instr and substr. </p> <p>You can create a materialized view with <code>on commit refresh fast</code> (at the cost of making transactions on the base table a bi...
How can I add an if else conditional statement to this function? <p>How can a modify this function so if the user enters less than 2500 cubic ft the price is equal to 0?</p> <pre><code>function updateCombustibleMaterialFireFee(cubicft) { var price = 42; if (cubicft &gt; 5000) { price += (cubicft-5000)/...
<pre><code>function updateCombustibleMaterialFireFee(cubicft) { var price = 42; if (cubicft &lt; 2500) { price = 0; } else if (cubicft &gt; 5000) { price += (cubicft - 5000) / 1000 * 22; } // Change the parameters to the correct fee code, fee schedule, etc. // updateFee(fcod...
Need help converting from ASCII to binary <p>I'm very new to C, so I don't know much about it. Pointers are something I still haven't learned... I need to show a single character in decimal and binary. In decimals its easy but I can't get it to binary in any way... I get the ASCII number and compare it's module with 2 ...
<p>Your code had some errors in the <code>while</code> condition:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; #define MAXIMO 8 int main( void ) { char caracter; int aux, resto[MAXIMO], contador, decimal, numero; printf( "Digite um UNICO caracter: " ); caracter = getchar(); // I used getc...