Tutorial by Examples: app

The following code snippet shows how to open the Google Play Store Listing of your app in a safe way. Usually you want to use it when asking the user to leave a review for your app. private void openPlayStore() { String packageName = getPackageName(); Intent playStoreIntent = new Intent(I...
Write the following command in your terminal: adb install [-rtsdg] <file> Note that you have to pass a file that is on your computer and not on your device. If you append -r at the end, then any existing conflicting apks will be overwritten. Otherwise, the command will quit with an error....
Write the following command in your terminal to uninstall an app with a provided package name: adb uninstall <packagename>
After creating a new model or modifying existing models, you will need to generate migrations for your changes and then apply the migrations to the specified database. This can be done by using the Django's built-in migrations system. Using the manage.py utility when in the project root directory: ...
A custom extraction can be written by implementing the unapply method and returning a value of type Option: class Foo(val x: String) object Foo { def unapply(foo: Foo): Option[String] = Some(foo.x) } new Foo("42") match { case Foo(x) => x } // "42" The retur...
Unshift Use .unshift to add one or more items in the beginning of an array. For example: var array = [3, 4, 5, 6]; array.unshift(1, 2); array results in: [1, 2, 3, 4, 5, 6] Push Further .push is used to add items after the last currently existent item. For example: var array = [1, 2, 3...
A popular form of data analysis is split-apply-combine, in which you split your data into groups, apply some sort of processing on each group, and then combine the results. Let's consider a data analysis where we want to obtain the two cars with the best miles per gallon (mpg) for each cylinder cou...
It's a bad idea to hard code paths in your application. One should always use relative urls so that your code can work seamlessly across different machines. The best way to set this up is to define a variable like this import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) Then use th...
connection.Execute(@"some Query with @a,@b,@c", new {a=somevalueOfa,b=somevalueOfb,c=somevalueOfc});
To apply a function to every item in an array, use array_map(). This will return a new array. $array = array(1,2,3,4,5); //each array item is iterated over and gets stored in the function parameter. $newArray = array_map(function($item) { return $item + 1; }, $array); $newArray now is a...
The virtualenvwrapper utility simplifies working with virtual environments and is especially useful if you are dealing with many virtual environments/projects. Instead of having to deal with the virtual environment directories yourself, virtualenvwrapper manages them for you, by storing all virtual...
Pojo Model public class Model { private String firstName; private String lastName; private int age; /* Getters and setters not shown for brevity */ } Example: String to Object Model outputObject = objectMapper.readValue( "{\"firstName\":\"J...
To change the default stack order positioned elements (position property set to relative, absolute or fixed), use the z-index property. The higher the z-index, the higher up in the stacking context (on the z-axis) it is placed. Example In the example below, a z-index value of 3 puts green on to...
Now that the routes are defined, we need to let our application know about the routes. To do this, bootstrap the provider we exported in the previous example. Find your bootstrap configuration (should be in main.ts, but your mileage may vary). //main.ts import {bootstrap} from '@angular/platfo...
This command print all relevant application data: version code version name granted permissions (Android API 23+) etc.. adb shell dumpsys package <your.package.id>
Many C interfaces such as SDL2 have their own deletion functions. This means that you cannot use smart pointers directly: std::unique_ptr<SDL_Surface> a; // won't work, UNSAFE! Instead, you need to define your own deleter. The examples here use the SDL_Surface structure which should be fre...
Install gunicorn pip install gunicorn From django project folder (same folder where manage.py resides), run the following command to run current django project with gunicorn gunicorn [projectname].wsgi:application -b 127.0.0.1:[port number] You can use the --env option to set the pat...
After following the instructions above and installing Leiningen, start a new project by running: lein new <project-name> This will setup a Clojure project with the default Leiningen template within the <project-name> folder. There are several templates for Leiningen, which affect the...
Introduction In this minimalist example, using pytest we're going to test that indeed our Hello World app does return "Hello, World!" with an HTTP OK status code of 200, when hit with a GET request on the URL / First let's install pytest into our virtualenv pip install pytest And jus...
map is a function in functional programming which given a list and a function, returns a new list with the function applied to each item in that list. In Elixir, the map/2 function is in the Enum module. iex> Enum.map([1, 2, 3, 4], fn(x) -> x + 1 end) [2, 3, 4, 5] Using the alternative c...

Page 3 of 33