This example displays a transaction for an image view with only two images.(can use more images as well one after the other for the first and second layer positions after each transaction as a loop)
add a image array to res/values/arrays.xml
<resources>
<array
name=&...
It is common for an AsyncTask to require a reference to the Activity that called it.
If the AsyncTask is an inner class of the Activity, then you can reference it and any member variables/methods directly.
If, however, the AsyncTask is not an inner class of the Activity, you will need to pass an A...
If your team is following a rebase-based workflow, it may be a advantageous to setup git so that each newly created branch will perform a rebase operation, instead of a merge operation, during a git pull.
To setup every new branch to automatically rebase, add the following to your .gitconfig or .gi...
std::optional<float> divide(float a, float b) {
if (b!=0.f) return a/b;
return {};
}
Here we return either the fraction a/b, but if it is not defined (would be infinity) we instead return the empty optional.
A more complex case:
template<class Range, class Pred>
auto find_if...
You can quit GHCi simply with :q or :quit
ghci> :q
Leaving GHCi.
ghci> :quit
Leaving GHCi.
Alternatively, the shortcut CTRL+D (Cmd+D for OSX) has the same effect as :q.
Launch mode defines the behaviour of new or existing activity in the task.
There are possible launch modes:
standard
singleTop
singleTask
singleInstance
It should be defined in android manifest in <activity/> element as android:launchMode attribute.
<activity
android:launchM...
A string can be written to a file with an instance of the File class.
file = File.new('tmp.txt', 'w')
file.write("NaNaNaNa\n")
file.write('Batman!\n')
file.close
The File class also offers a shorthand for the new and close operations with the open method.
File.open('tmp.txt', 'w') ...
You can create instance of objects in one of two ways:
(java.awt.Point. 0 1)
;;=> => #object[java.awt.Point 0x3776d535 "java.awt.Point[x=0,y=1]"]
Or
(new java.awt.Point 0 1)
;;=> => #object[java.awt.Point 0x3776d535 "java.awt.Point[x=0,y=1]"]
You can call static methods like this:
(System/currentTimeMillis)
;;=> 1469493415265
Or pass in arguments, like this:
(System/setProperty "foo" "42")
;;=> nil
(System/getProperty "foo")
;;=> "42"
You can call a Clojure function from Java code by looking up the function and invoking it:
IFn times = Clojure.var("clojure.core", "*");
times.invoke(2, 2);
This looks up the * function from the clojure.core namespace and invokes it with the arguments 2 & 2.
The macro() function allows you to add new functionality to Illuminate\Support\Collection objects
Usage:
Collection::macro("macro_name", function ($parameters) {
// Your macro
});
For example:
Collection::macro('uppercase', function () {
return $this->map(function ($i...
The permutation method, when called with a block yields a two dimensional array consisting of all ordered sequences of a collection of numbers.
If this method is called without a block, it will return an enumerator. To convert to an array, call the to_a method.
ExampleResult[1,2,3].permutation#<...
DatabaseTransactions trait allows databases to rollback all the change during the tests. If you want to rollback multiple databases , you need to set $connectionsToTransact properties
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ExampleTest extends TestCase
{
use Databas...
Messages can be sent from JavaScript using the following code
window.webkit.messageHandlers.{NAME}.postMessage()
Here how to create a script message handler to handle the messages:
class NotificationScriptMessageHandler: NSObject, WKScriptMessageHandler {
func userContentController(userCon...
function processGoogleDriveFolders() {
var arrayAllFolderNames,continuationToken,folders,foldersFromToken,thisFolder;//Declare variable names
arrayAllFolderNames = [];//Create an empty array and assign it to this variable name
folders = DriveApp.getFolders();//Get all folders from ...
function processGoogleDriveFiles() {
var arrayAllFileNames,continuationToken,files,filesFromToken,fileIterator,thisFile;//Declare variable names
arrayAllFileNames = [];//Create an empty array and assign it to this variable name
files = DriveApp.getFiles();//Get all files from Googl...
At its most basic level, Unit Testing in any language provides assertions against some known or expected output.
function assert( outcome, description ) {
var passFail = outcome ? 'pass' : 'fail';
console.log(passFail, ': ', description);
return outcome;
};
The popular assertio...
Elm allows the definition of custom infix operators.
Infix operators are defined using parenthesis around the name of a function.
Consider this example of infix operator for construction Tuples 1 => True -- (1, True):
(=>) : a -> b -> ( a, b )
(=>) a b =
( a, b )
Most of t...