Tutorial by Examples: er

The android:process field defines the name of the process where the service is to run. Normally, all components of an application run in the default process created for the application. However, a component can override the default with its own process attribute, allowing you to spread your applicat...
Given the model: class MyModel(models.Model): name = models.CharField(max_length=10) model_num = models.IntegerField() flag = models.NullBooleanField(default=False) We can use Q objects to create AND , OR conditions in your lookup query. For example, say we want all objects that ...
Django manger is an interface through which the django model queries the database. The objects field used in most django queries is actually the default manager created for us by django (this is only created if we don't define custom managers). Why would we define a custom manager/queryset? To avo...
Filters are a special type of function that can modify how something is printed out to the page, or can be used to filter an array, or a ng-repeat action. You can create a filter by calling the app.filter() method, passing it a name and a function. See the examples below for details on syntax. Fo...
To run a container interactively, pass in the -it options: $ docker run -it ubuntu:14.04 bash root@8ef2356d919a:/# echo hi hi root@8ef2356d919a:/# -i keeps STDIN open, while -t allocates a pseudo-TTY.
Node Version Manager, otherwise known as nvm, is a bash script that simplifies the management of multiple Node.js versions. To install nvm, use the provided install script: $ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh | bash For windows there is a nvm-windows p...
In some cases you may want to wrap a synchronous operation inside a promise to prevent repetition in code branches. Take this example: if (result) { // if we already have a result processResult(result); // process it } else { fetchResult().then(processResult); } The synchronous and async...
When you want to use user generated content in the SQL, it with done with parameters. For example for searching user with the name aminadav you should do: var username = 'aminadav'; var querystring = 'SELECT name, email from users where name = ?'; connection.query(querystring, [username], functi...
You send the query as a string and in response callback with the answer is received. The callback gives you error, array of rows and fields. Each row contains all the column of the returned table. Here is a snippet for the following explanation. connection.query('SELECT name,email from users', fu...
You can use a RecyclerView.ItemDecoration to put extra margins around each item in a RecyclerView. This can in some cases clean up both your adapter implementation and your item view XML. public class MyItemDecoration extends RecyclerView.ItemDecoration { private final int extraMargin; ...
The most "popular" way of reversing a string in JavaScript is the following code fragment, which is quite common: function reverseString(str) { return str.split('').reverse().join(''); } reverseString('string'); // "gnirts" However, this will work only so long as ...
You can archive different Textsizes inside a Textview with a Span TextView textView = (TextView) findViewById(R.id.textView); Spannable span = new SpannableString(textView.getText()); span.setSpan(new RelativeSizeSpan(0.8f), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(span)...
There are several ways to create an Observable in RxJava. The most powerful way is to use the Observable.create method. But it's also the most complicated way. So you must avoid using it, as much as possible. Emitting an exiting value If you already have a value, you can use Observable.just to emi...
Create a class which extends Service class and in overridden method onBind return your local binder instance: public class LocalService extends Service { // Binder given to clients private final IBinder mBinder = new LocalBinder(); /** * Class used for the client Binder. Bec...
Describe your service access interface through .aidl file: // IRemoteService.aidl package com.example.android; // Declare any non-default types here with import statements /** Example service interface */ interface IRemoteService { /** Request the process ID of this service, to do evil...
SharedPreferences Manager (Singleton) class to read and write all types of data. import android.content.Context; import android.content.SharedPreferences; import android.util.Log; import com.google.gson.Gson; import java.lang.reflect.Type; /** * Singleton Class for accessing SharedPref...
A request for the top 10 most recently active StackOverflow posts using the Stack Exchange API. package main import ( "encoding/json" "fmt" "net/http" "net/url" ) const apiURL = "https://api.stackexchange.com/2.2/posts?" ...
Executing code after 1.5 seconds: Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { //The code you want to run after the time is up } }, 1500); //the time you want to delay in milliseconds Executing code repeatedly every...
__FUNCTION__ returns only the name of the function whereas __METHOD__ returns the name of the class along with the name of the function: <?php class trick { public function doit() { echo __FUNCTION__; } public function doitagain() { echo __METHOD_...
__CLASS__ magic constant returns the same result as get_class() function called without parameters and they both return the name of the class where it was defined (i.e. where you wrote the function call/constant name ). In contrast, get_class($this) and get_called_class() functions call, will both ...

Page 56 of 417