Tutorial by Examples: app

The apply and call methods in every function allow it to provide a custom value for this. function print() { console.log(this.toPrint); } print.apply({ toPrint: "Foo" }); // >> "Foo" print.call({ toPrint: "Foo" }); // >> "Foo" You mig...
With Gson, you can read JSON dataset and map them to a custom class MyClass. Since Gson is not serializable, each executor needs its own Gson object. Also, MyClass must be serializable in order to pass it between executors. Note that the file(s) that is offered as a json file is not a typical JSON...
A reference to an option &Option<T> cannot be unwrapped if the type T is not copyable. The solution is to change the option to &Option<&T> using as_ref(). Rust forbids transferring of ownership of objects while the objects are borrowed. When the Option itself is borrowed (&a...
The most important AppWidgetProvider callback is onUpdate(). It is called everytime an appwidget is added. public class ExampleAppWidgetProvider extends AppWidgetProvider { public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final int N = a...
Consumable Managed Products are products that can be bought multiple times such as in-game currency, game lives, power-ups, etc. In this example, we are going to implement 4 different consumable managed products "item1", "item2", "item3", "item4". Steps in...
1) Form Request Validation You may create a "form request" which can hold the authorization logic, validation rules, and error messages for a particular request in your application. The make:request Artisan CLI command generates the class and places it in the app/Http/Requests director...
public class MainApplication extends Application { private static Context context; //application context private Handler mainThreadHandler; private Toast toast; public Handler getMainThreadHandler() { if (mainThreadHandler == null) { mainThreadHand...
Download the Datastax PHP driver for Apache Cassandra from the Git project site, and follow the installation instructions. We will be using the "users" table from the KillrVideo app and the Datastax PHP driver. Once you have Cassandra up and running, create the following keyspace and tabl...
Tuples are useful to swap values between 2 (or more) variables without using temporary variables. Example with 2 variables Given 2 variables var a = "Marty McFly" var b = "Emmett Brown" we can easily swap the values (a, b) = (b, a) Result: print(a) // "Emmett Bro...
Rails is shipped by default with ActiveRecord, an ORM (Object Relational Mapping) derived from the pattern with the same name. As an ORM, it is built to handle relational-mapping, and more precisely by handling SQL requests for you, hence the limitation to SQL databases only. However, you can stil...
This example demonstrates how to place 3 buttons in total with 2 buttons being in the first row. Then a wrap occurs, so the last button is in a new row. The constraints are simple strings, in this case "wrap" while placing the component. public class ShowMigLayout { // Create the ...
In many Excel applications, the VBA code takes actions directed at the workbook in which it's contained. You save that workbook with a ".xlsm" extension and the VBA macros only focus on the worksheets and data within. However, there are often times when you need to combine or merge data fr...
One can clear the user data of a specific app using adb: adb shell pm clear <package> This is the same as to browse the settings on the phone, select the app and press on the clear data button. pm invokes the package manager on the device clear deletes all data associated with a packag...
As discussed in the introduction, the gradle wrapper functionality works because a jar is downloaded into the project to be used when the gradlew command is run. However this may not get committed and after the next time the project is checked out, gradlew will fail to run with the error: Error: C...
Gradle has the ability to add a wrapper to projects. This wrapper alleviates the need for all users or continuous integration systems to have Gradle installed. It also prevents version issues where there is some incompatibility between the version the project uses and that which users have installed...
From Apple documentation: Use the CTCallCenter class to obtain a list of current cellular calls, and to respond to state changes for calls such as from a dialing state to a connected state. Such state changes are known as cellular call events. The purpose of CTCallCenter is to give the develop...
mount is used to mount another application (basically rack application) or rails engines to be used within the current application syntax: mount SomeRackApp, at: "some_route" Now you can access above mounted application using route helper some_rack_app_path or some_rack_app_url. But ...
Don't put comments after mappings, it will break things. Use :map <F6> to see what is mapped to <F6> and in which mode. Use :verbose map <F6> to also see where it was last mapped. :map and :map! are too generic. Use :n[nore]map for normal mode mappings, :i[nore]map for insert ...
A basic AppComponent that depends on a single AppModule to provide application-wide singleton objects. @Singleton @Component(modules = AppModule.class) public interface AppComponent { void inject(App app); Context provideContext(); Gson provideGson(); } A module to use to...
Dim sites() As String = {"Stack Overflow", "Super User", "Ask Ubuntu", "Hardware Recommendations"} Dim query = From x In sites Select x.Length ' result = 14, 10, 10, 24 Query...

Page 7 of 33