Tutorial by Examples: l

Symbol is a new primitive type in ES6. Symbols are used mainly as property keys, and one of its main characteristics is that they are unique, even if they have the same description. This means they will never have a name clash with any other property key that is a symbol or string. const MY_PROP_KE...
Let's assume that we want to remove 2 upvotes from all the articles of the author with id 51. Doing this only with Python would execute N queries (N being the number of articles in the queryset): for article in Article.objects.filter(author_id=51): article.upvotes -= 2 article.save() ...
// You need a writable database to update a row final SQLiteDatabase database = openHelper.getWritableDatabase(); // Create a ContentValues instance which contains the up to date data for each column // Unlike when inserting data you need to specify the value for the PRIMARY KEY column as well ...
Orders Table CustomerIdProductIdQuantityPrice12510013220014150021450356700 To check for customers who have ordered both - ProductID 2 and 3, HAVING can be used select customerId from orders where productID in (2,3) group by customerId having count(distinct productID) = 2 Return value:...
package main import ( "fmt" "io/ioutil" ) func main() { files, err := ioutil.ReadDir(".") if err != nil { panic(err) } fmt.Println("Folders in the current directory:") for _, fileInfo := range files { ...
You need to create a new local copy of the repository with the command git svn clone SVN_REPO_ROOT_URL [DEST_FOLDER_PATH] -T TRUNK_REPO_PATH -t TAGS_REPO_PATH -b BRANCHES_REPO_PATH If your SVN repository follows the standard layout (trunk, branches, tags folders) you can save some typing: git svn...
The equivalent to git pull is the command git svn rebase This retrieves all the changes from the SVN repository and applies them on top of your local commits in your current branch. You can also use the command git svn fetch to retrieve the changes from the SVN repository and bring them to ...
The command git svn dcommit will create a SVN revision for each of your local git commits. As with SVN, your local git history must be in sync with the latest changes in the SVN repository, so if the command fails, try performing a git svn rebase first.
Just use your local git repository as a normal git repo, with the normal git commands: git add FILE and git checkout -- FILE To stage/unstage a file git commit To save your changes. Those commits will be local and will not be "pushed" to the SVN repo, just like in a normal git reposito...
git does not recognice the concept of folders, it just works with files and their filepaths. This means git does not track empty folders. SVN, however, does. Using git-svn means that, by default, any change you do involving empty folders with git will not be propagated to SVN. Using the --rmdir fl...
This simple CUDA program demonstrates how to write a function that will execute on the GPU (aka "device"). The CPU, or "host", creates CUDA threads by calling special functions called "kernels". CUDA programs are C++ programs with additional syntax. To see how it works...
Go to File -> Settings -> Editor -> Colors & Fonts -> Android Logcat Change the colors as you need: Choose the appropriate color:
Some basic types and classes in Java are fundamentally mutable. For example, all array types are mutable, and so are classes like java.util.Data. This can be awkward in situations where an immutable type is mandated. One way to deal with this is to create an immutable wrapper for the mutable type...
static int Sum(int a, int b) { return a + b; } static int Multiplication(int a, int b) { return a * b; } static void Main(string[] args) { Func<int, int, int> method = Sum; // method points to the Sum method // that retuns 1 int variable and takes 2 int vari...
An anonymous method can be assigned wherever a delegate is expected: Func<int, int> square = delegate (int x) { return x * x; } Lambda expressions can be used to express the same thing: Func<int, int> square = x => x * x; In either case, we can now invoke the method stored ins...
An immutable object is an object whose state cannot be changed. An immutable class is a class whose instances are immutable by design, and implementation. The Java class which is most commonly presented as an example of immutability is java.lang.String. The following is a stereotypical example: ...
You can let I18n handle pluralization for you, just use count argument. You need to set up your locale file like this: # config/locales/en.yml en: online_users: one: "1 user is online" other: "%{count} users are online" And then use the key you just created by ...
In most cases, you may want to set I18n locale. One might want to set the locale for the current session, the current user, or based on a URL parameter This is easily achievable by implementing a before_action in one of your controllers, or in ApplicationController to have it in all of your controll...
<?xml version="1.0" encoding="utf-8" ?> <Employees> <Employee> <EmpId>1</EmpId> <Name>Sam</Name> <Sex>Male</Sex> <Phone Type="Home">423-555-0124</Phone> <Phone Type="Work&quot...
# this method can be anything and anywhere as long as it is accessible for connection @pyqtSlot() def run_on_complete(): pass # An object containing methods you want to run in a thread class Worker(QObject): complete = pyqtSignal() @pyqtSlot() def a_method_to_run...

Page 224 of 861