Tutorial by Examples

SELECT DATE('2003-12-31 01:02:03'); The output will be: 2003-12-31
Least squares is a standard approach to problems with more equations than unknowns, also known as overdetermined systems. Consider the four equations: x0 + 2 * x1 + x2 = 4 x0 + x1 + 2 * x2 = 3 2 * x0 + x1 + x2 = 5 x0 + x1 + x2 = 4 We can express this as a matrix multiplication A * x = b: A ...
When rendering a form 'by hand', it can be useful to know if there are fields left to render or not. The function isRendered() from the FormView class returns true if there are still fields left to be rendered to the template. This snippet prints <h3>Extra fields</h3> if there are fiel...
Group Concat is used in MySQL to get concatenated values of expressions with more than one result per column. Meaning, there are many rows to be selected back for one column such as Name(1):Score(*) NameScoreAdamA+AdamA-AdamBAdamC+BillD-JohnA- SELECT Name, GROUP_CONCAT(Score ORDER BY Score desc SE...
CREATE TABLE foo ( ... name CHARACTER SET utf8mb4 ... );
Vital to using character sets is to tell the MySQL-server what encoding the client's bytes are. Here is one way: SET NAMES utf8mb4; Each language (PHP, Python, Java, ...) has its own way the it usually preferable to SET NAMES. For example: SET NAMES utf8mb4, together with a column declared CH...
There are dozens of character sets with hundreds of collations. (A given collation belongs to only one character set.) See the output of SHOW COLLATION;. There are usually only 4 CHARACTER SETs that matter: ascii -- basic 7-bit codes. latin1 -- ascii, plus most characters needed for Western Eur...
Use git revert to revert existing commits, especially when those commits have been pushed to a remote repository. It records some new commits to reverse the effect of some earlier commits, which you can push safely without rewriting history. Don't use git push --force unless you wish to bring down ...
You can rename branch in local repository using this command: git branch -m old_name new_name
Getting zsh zsh is available on many UNIX-like platforms via their built-in package management systems. On the Debian and Ubuntu Linux distributions, zsh is available in the default package repositories and can be installed using: $ sudo apt-get install zsh # or, on newer Ubuntu distributions $ ...
You can obtain the url for an existing remote by using the command git remote get-url <name> By default, this will be git remote get-url origin
When you created your own Models in a app, they still need to be registered in order to become available in the admin pages. This is done in the admin submodule. If your app was created using manage.py startapp, an admin.py file should already lay in you app module. Otherwise create it. #myapp/a...
Javassist is a bytecode instrumentation library that allows you to modify bytecode injecting Java code that will be converted to bytecode by Javassist and added to the instrumented class/method at runtime. Lets write the first transformer that actually take an hypothetical class "com.my.to.be....
There are several packages that allow the output of data structures in form of HTML or LaTeX tables. They mostly differ in flexibility. Here I use the packages: knitr xtable pander For HTML documents --- title: "Printing Tables" author: "Martin Schmelzer" date: &quot...
C++ thrives on what is known as a Regular type (or at least Pseudo-Regular). A Regular type is a type that can be constructed and assigned-to and assigned-from via copy or move, can be destroyed, and can be compared equal-to. It can also be constructed from no arguments. Finally, it also has supp...
Mockito offers a one-size-fits-all mehtod to create mocks of (non-final) classes and interfaces. Dependency mock = Mockito.mock(Dependency.class); This creates a mock instance of Dependency regardless of whether Dependency is a interface or class. It is then possible to stub method calls to tha...
While a simple mock returns null (or defaults for primitives) to every call, it is possible to change that behaviour. Dependency mock = Mockito.mock(Dependency.class, new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { ...
The following example illustrates how to use CullingGroups to get notifications according to the distance reference point. This script has been simplified for brevity and uses several performance heavy methods. using UnityEngine; using System.Linq; public class CullingGroupBehaviour : Mono...
Following script illustrates how to receive events according to visibility to a set camera. This script uses several performance heavy methods for brevity. using UnityEngine; using System.Linq; public class CullingGroupCameraBehaviour : MonoBehaviour { CullingGroup localCullingGroup;...
You can add bounding distances on top of culling point radius. They are in a manner additional trigger conditions outside the culling points' main radius, like "close", "far" or "very far". cullingGroup.SetBoundingDistances(new float[] { 0f, 10f, 100f}); Bounding ...

Page 620 of 1336