Pass correct “this” context to setTimeout callback? [duplicate]

Pass correct “this” context to setTimeout callback? [duplicate]

This question already has an answer here: How to access the correct `this` inside a callback? 6 answers How do I pass context into setTimeout? I want t

How to concatenate twice with the C preprocessor and expand a macro as in “arg ## _ ## MACRO”?

How to concatenate twice with the C preprocessor and expand a macro as in “arg ## _ ## MACRO”?

I am trying to write a program where the names of some functions are dependent on the value of a certain macro variable with a macro like this:#define VARIABLE 3#define NAME(fun) fun ## _ ## VARIABLEint NAME(some_function)(int a);Unfortunat

How to get the Android device's primary e-mail address

How to get the Android device's primary e-mail address

How do you get the Android's primary e-mail address (or a list of e-mail addresses)?It's my understanding that on OS 2.0+ there's support for multiple e-mail addresses, but below 2.0 you can only have one e-mail address per device. 1:The

Find the min/max element of an Array in JavaScript

Find the min/max element of an Array in JavaScript

How can I easily obtain the min or max element of a JavaScript Array?Example Psuedocode:let array = [100, 0, 50]array.min() //=> 0array.max() //=> 100 1:How about augmenting the built-in Array object to use Math.max/Math.min instead:Arra

Command not found error in Bash variable assignment

Command not found error in Bash variable assignment

I have this script called test.sh:#!/bin/bashSTR = "Hello World"echo $STRwhen I run sh test.sh I get this:test.sh: line 2: STR: command not foundWhat am I doing wrong? I look at extremely basic/beginners bash scripting tutorials online and

Dynamically select data frame columns using $ and a vector of column names

Dynamically select data frame columns using $ and a vector of column names

I wish to order a data frame based on different columns, one at a turn. I have a character vector with the relevant column names on which the order should be based:parameter <- c("market_value_LOCAL", "ep", "book_price", "sales_price", "div

Aren't promises just callbacks?

Aren't promises just callbacks?

I've been developing JavaScript for a few years and I don't understand the fuss about promises at all.It seems like all I do is change:api(function(result){ api2(function(result2){ api3(function(result3){ // do work

What are the best JVM settings for Eclipse? [closed]

What are the best JVM settings for Eclipse? [closed]

What are the best JVM settings you have found for running Eclipse? 1:It is that time of year again: "eclipse.ini take 3" the settings strike back! Eclipse Helios 3.6 and 3.6.x settingsalt text http://www.eclipse.org/home/promotions/frie

What is an IndexOutOfRangeException / ArgumentOutOfRangeException and how do I fix it?

What is an IndexOutOfRangeException / ArgumentOutOfRangeException and how do I fix it?

I have some code and when it executes, it throws a IndexOutOfRangeException, saying, Index was outside the bounds of the array.What does this mean, and what can I do about it?Depending on classes used it can also be ArgumentOutOfRangeExce

Swift - 'Bool' is not a subtype of 'Void'?

Swift - 'Bool' is not a subtype of 'Void'?

I'm getting the following error: 'Bool' is not a subtype of 'Void'performBlock takes a void closure with no argument, and method itself has a single argument, so I should be able to use the following syntax for my closure. Why am i getting

Fragment getArguments() returns null

Fragment getArguments() returns null

I have a Fragment which has a TabHost as the root layout as follows... The code to create / update each Fragment for the tab content is as follows...private void updateTab(String ta

Mathematical expression in axis label

Mathematical expression in axis label

In R, I use expression(theta[l]) so that the label of my plot axis is that same as $\theta_l$ from LaTeX. For esthetic reasons, I'd rather like to display $\theta_\ell$. Can you help me?EDITBefore, I didplot(1:10, 1:10, xlab=expression(thet

Why does the ld linker allow multiple class definitions with the same methods?

Why does the ld linker allow multiple class definitions with the same methods?

Consider this file, first.cpp, containing a class definition and use:#include struct Foo{ Foo(){ std::cout and another, second.cpp, containing a conflicting class definition:#include struct Foo{ Foo(); ~Foo();};Foo::~Foo(){ std::co

Array of functions in Swift

Array of functions in Swift

How can I store an array of functions to callback later in an array like in JavaScript? Any and AnyObject type cannot hold functions with different types of method signatures. 1:You can use an enum to put various functions into the Array

How do I read a delimited file with strings/numbers with Octave?

How do I read a delimited file with strings/numbers with Octave?

I am trying to read a text file containing digits and strings using Octave. The file format is something like this:A B Ca 10 100b 20 200c 30 300d 40 400e 50 500but the delimiter can be space, tab, comma or semicolon. The textread function w

c array - warning: format not a string literal

c array - warning: format not a string literal

I'm attempting to learn C and already I've run into an issue. I assume its trivial but I need to know it. I have written:#include #include int main() { char str_a[20]; strcpy(str_a, "Hello, world!\n"); printf(str_a);}Once I attempt

Meaning of Three dot (…) in PHP

Meaning of Three dot (…) in PHP

What is the meaning of Three dot (...) in PHP ?While I am installing Magento 2 in my Sever I got an error. Investigate the code and found that there is a Three dot (...), which is producing the error. I mentioned the code belowreturn new $t

prevent typing non ascii characters in a textbox

prevent typing non ascii characters in a textbox

Since I think people have encounter it lots of time before I did and there may be some standart solution.. Can anybody give any hint direction how to prevent a user from typing non ascii characters in a textbox. 1:I personally find tinke

U-Boot hangs while loading kernel?

U-Boot hangs while loading kernel?

I am working on Freescale board imx50evk. I have built the uboot.bin and uImage using LTIB (linux target image builder). At the U-Boot prompt I enter the bootm addr command, and then it hangs after showing the message "Loading Kernel..." >

Implementing pipe in C

Implementing pipe in C

I am trying to implement pipe in C. eg - $ ls | wc | wcI have written the following code - #include#include#include void run_cmd(char *cmd, int* fd_in, int* fd_out){ int c = fork(); if (c==0) { if (fd_in != NULL) {

C# check if you have passed arguments or not

C# check if you have passed arguments or not

I have this code:public static void Main(string[] args){ if (string.IsNullOrEmpty(args[0])) // Warning : Index was out of the bounds of the array { ComputeNoParam cptern = new ComputeNoParam(); cptern.ComputeWi

Converting an Ant fileset to multiple apply args

Converting an Ant fileset to multiple apply args

I have some files:dir/foo.txtdir/bar.txtdir/foobar.txtIn an Ant apply task, I want to pass the list of files as arguments: This works fine, but what if I want to pick the list of files

When does JVM decide to reuse old lambda?

When does JVM decide to reuse old lambda?

Consider the following code fragment:public static Object o = new Object();public static Callable x1() { Object x = o; return () -> x;}public static Callable x2() { return () -> o;}Method x2() will always return the same lamba obje

How to get the index of a value in a vector using for_each?

How to get the index of a value in a vector using for_each?

I have the following code (compiler: MSVC++ 10):std::vector data;data.push_back(1.0f);data.push_back(1.0f);data.push_back(2.0f);// lambda expressionstd::for_each(data.begin(), data.end(), [](int value) { // Can I get here index of the v

No non-missing arguments warning when using min or max in reshape2

No non-missing arguments warning when using min or max in reshape2

I get the following warning when I use min or max in the dcast function from the reshape2 package. What is it telling me? I can't find anything that explains the warning message and I'm a bit confused about why I get it when I use max but n