How to force Sequential Javascript Execution?

Well, setTimeout, per its definition, will not hold up the thread. This is desirable, because if it did, it’d freeze the entire UI for the time it was waiting. if you really need to use setTimeout, then you should be using callback functions: function myfunction() { longfunctionfirst(shortfunctionsecond); } function longfunctionfirst(callback) { setTimeout(function() { alert(‘first function … Read more

Adding delay between execution of two following lines

You can use gcd to do this without having to create another method // ObjC NSTimeInterval delayInSeconds = 2.0; dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ NSLog(@”Do some work”); }); // Swift DispatchQueue.main.asyncAfter(deadline: .now() + 2) { print(“Do some work) } You should still ask yourself “do I really need to add … Read more

Can I pass an argument to a VBScript (vbs file launched with cscript)?

You can use WScript.Arguments to access the arguments passed to your script. Calling the script: cscript.exe test.vbs “C:\temp\” Inside your script: Set File = FSO.OpenTextFile(WScript.Arguments(0) &”\test.txt”, 2, True) Don’t forget to check if there actually has been an argument passed to your script. You can do so by checking the Count property: if WScript.Arguments.Count = … Read more

Gradle to execute Java class (without modifying build.gradle)

There is no direct equivalent to mvn exec:java in gradle, you need to either apply the application plugin or have a JavaExec task. application plugin Activate the plugin: plugins { id ‘application’ … } Configure it as follows: application { mainClassName = project.hasProperty(“mainClass”) ? project.getProperty(“mainClass”) : “NULL” } On the command line, write $ gradle … Read more

Asynchronous vs synchronous execution. What is the difference?

When you execute something synchronously, you wait for it to finish before moving on to another task. When you execute something asynchronously, you can move on to another task before it finishes. In the context of operating systems, this corresponds to executing a process or task on a “thread.” A thread is a series of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)