Tutorial by Examples: c

static and templates folder in the apps may should also contain a folder with the name of app ex. blog this is a convention used to prevent namespace pollution, so we reference the files like /blog/base.html rather than /base.html which provides more clarity about the file we are referencing and pre...
The coordinate systems of Matplotlib come very handy when trying to annotate the plots you make. Sometimes you would like to position text relatively to your data, like when trying to label a specific point. Other times you would maybe like to add a text on top of the figure. This can easily be achi...
In order for a program to react to a certain signal, other than using default action, custom signal handler can be installed using sigaction. sigaction receives three arguments - signal to act on, pointer to sigaction_t structure which, if not NULL, is describing new behaviour and pointer to sigacti...
SELECT DATE('2003-12-31 01:02:03'); The output will be: 2003-12-31
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
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
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....
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 ...
If everything whas been set up correctly, the following snippet will show a window titled "SFML works!" with a green circle: #include <SFML/Graphics.hpp> int main() { sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!"); sf::CircleShape shape(100.f...
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...

Page 385 of 826