Tutorial by Examples: ti

Numpy installation through pypi (the default package index used by pip) generally fails on Windows computers. The easiest way to install on Windows is by using precompiled binaries. One source for precompiled wheels of many packages is Christopher Gohkle's site. Choose a version according to your ...
Django uses migrations to propagate changes you make to your models to your database. Most of the time django can generate them for you. To create a migration, run: $ django-admin makemigrations <app_name> This will create a migration file in the migration submodule of app_name. The first...
Sometimes, migrations generated by Django are not sufficient. This is especially true when you want to make data migrations. For instance, let's you have such model: class Article(models.Model): title = models.CharField(max_length=70) This model already have existing data and now you want ...
m := make(map[string][]int) Accessing a non-existent key will return a nil slice as a value. Since nil slices act like zero length slices when used with append or other built-in functions you do not normally need to check to see if a key exists: // m["key1"] == nil && len(m[&qu...
Python uses the C3 linearization algorithm to determine the order in which to resolve class attributes, including methods. This is known as the Method Resolution Order (MRO). Here's a simple example: class Foo(object): foo = 'attr foo of Foo' class Bar(object): foo = 'attr foo o...
Relative positioning moves the element in relation to where it would have been in normal flow .Offset properties: top left right bottom are used to indicate how far to move the element from where it would have been in normal flow. .relpos{ position:relative; top:20px; left:3...
When absolute positioning is used the box of the desired element is taken out of the Normal Flow and it no longer affects the position of the other elements on the page. Offset properties: top left right bottom specify the element should appear in relation to its next non-static containing ...
Sometimes it's not a good practice expose an internal collection since it can lead to a malicious code vulnerability due to it's mutable characteristic. In order to provide "read-only" collections java provides its unmodifiable versions. An unmodifiable collection is often a copy of a mod...
Prerequisites nodejs To install the latest stable release of sails with the command-line tool issue following command: $ sudo npm install sails -g Depending on your OS you might not need to use sudo.
In Rails, you find yourself looking at controllers, views, and models for your database. To reduce the need for heavy configuration, Rails implements rules to ease up working with the application. You may define your own rules but for the beginning (and for later on) it's a good idea to stick to co...
By default, the various Collection types are not thread-safe. However, it's fairly easy to make a collection thread-safe. List<String> threadSafeList = Collections.synchronizedList(new ArrayList<String>()); Set<String> threadSafeSet = Collections.synchronizedSet(new HashSet<S...
Given the following history, imagine you make a change that you want to squash into the commit bbb2222 A second commit: $ git log --oneline --decorate ccc3333 (HEAD -> master) A third commit bbb2222 A second commit aaa1111 A first commit 9999999 Initial commit Once you've made your change...
Now that the routes are set up, we need some way to actually change routes. This example will show how to change routes using the template, but it is possible to change routes in TypeScript. Here is one example (without binding): <a routerLink="/home">Home</a> If the user...
NOTE: This example is based on the 3.0.0.-beta.2 release of the @angular/router. At the time of writing, this is the latest version of the router. To use the router, define routes in a new TypeScript file like such //app.routes.ts import {provideRouter} from '@angular/router'; import {Home} ...
def my_mix(name,valid=true, *opt) puts name puts valid puts opt end Call as follows: my_mix('me') # 'me' # true # [] my_mix('me', false) # 'me' # false # [] my_mix('me', true, 5, 7) # 'me' # true # [5,7]
To generate a controller (for example Posts), navigate to your project directory from a command line or terminal, and run: $ rails generate controller Posts You can shorten this code by replacing generate with g, for example: $ rails g controller Posts If you open up the newly generated app/...
Python uses indentation to define control and loop constructs. This contributes to Python's readability, however, it requires the programmer to pay close attention to the use of whitespace. Thus, editor miscalibration could result in code that behaves in unexpected ways. Python uses the colon symbo...
You can initialize a constant by using the const keyword. const foo = 100; const bar = false; const person = { name: "John" }; const fun = function () = { /* ... */ }; const arrowFun = () => /* ... */ ; Important You must declare and initialize a constant in the same statement....
A one-liner that helps granting or revoking vulnerable permissions. granting adb shell pm grant <sample.package.id> android.permission.<PERMISSION_NAME> revoking adb shell pm revoke <sample.package.id> android.permission.<PERMISSION_NAME> Granting all run...
This command print all relevant application data: version code version name granted permissions (Android API 23+) etc.. adb shell dumpsys package <your.package.id>

Page 59 of 505