Tutorial by Examples: e

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...
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...
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 ...
Matplotlib includes the image module for image manipulation import matplotlib.image as mpimg import matplotlib.pyplot as plt Images are read from file (.png only) with the imread function: img = mpimg.imread('my_image.png') and they are rendered by the imshow function: plt.imshow(img) L...
As a developer, you frequently find yourself dealing with strings that are not created by your own code. These will often be supplied by third party libraries, external systems, or even end users. Validating strings of unclear provenance is considered to be one of the hallmarks of defensive program...
module.exports.routes = { 'GET /foo': 'FooController.index', 'GET /foo/new': 'FooController.new', 'POST /foo/create': 'FooController.create', 'GET /foo/:id/edit': 'FooController.edit', 'PUT /foo/:id/update': 'FooController.update', 'GET /foo/:id': 'FooController.show', ...
module.exports.routes = { '/foo': '/bar', 'GET /google': 'http://www.google.com' };

Page 549 of 1191