Tutorial by Examples: adv

Pagination p = new Pagination(10); Timeline fiveSecondsWonder = new Timeline(new KeyFrame(Duration.seconds(5), event -> { int pos = (p.getCurrentPageIndex()+1) % p.getPageCount(); p.setCurrentPageIndex(pos); })); fiveSecondsWonder.setCycleCount(Timeline.INDEFINITE); fiveSecondsWon...
println! (and its sibling, print!) provides a convenient mechanism for producing and printing text that contains dynamic data, similar to the printf family of functions found in many other languages. Its first argument is a format string, which dictates how the other arguments should be printed as t...
If you don't want to add Unix commands to your PATH on Windows, you can download a standalone SSH client like PuTTY. Download PuTTY here, then follow the instructions below to get a build machine. Call meteor admin get-machine <os-architecture> --json Copy and save the private key from the...
Git lets you use non-git commands and full sh shell syntax in your aliases if you prefix them with !. In your ~/.gitconfig file: [alias] temp = !git add -A && git commit -m "Temp" The fact that full shell syntax is available in these prefixed aliases also means you can us...
First we need to install composer. Steps to install composer Install Composer. curl -sS https://getcomposer.org/installer | php Now change directory: sudo mv composer.phar /usr/local/bin/composer Check composer working composer Now Composer installed. There two ways to install Yii2 adv...
Even just reading the value of a pointer that was freed (i.e. without trying to dereference the pointer) is undefined behavior(UB), e.g. char *p = malloc(5); free(p); if (p == NULL) /* NOTE: even without dereferencing, this may have UB */ { } Quoting ISO/IEC 9899:2011, section 6.2.4 §2: ...
The module cmath includes additional functions to use complex numbers. import cmath This module can calculate the phase of a complex number, in radians: z = 2+3j # A complex number cmath.phase(z) # 0.982793723247329 It allows the conversion between the cartesian (rectangular) and polar repr...
A model can provide a lot more information than just the data about an object. Let's see an example and break it down into what it is useful for: from django.db import models from django.urls import reverse from django.utils.encoding import python_2_unicode_compatible @python_2_unicode_compati...
Given the model: class MyModel(models.Model): name = models.CharField(max_length=10) model_num = models.IntegerField() flag = models.NullBooleanField(default=False) We can use Q objects to create AND , OR conditions in your lookup query. For example, say we want all objects that ...
add_filter('template_include', 'custom_function'); function custom_function($template){ /* * This example is a little more advanced. * It will check to see if $template contains our post-type in the path. * If it does, the theme contains a high level templat...
A common question is how to juxtapose (combine) physically separate geographical regions on the same map, such as in the case of a choropleth describing all 50 American states (The mainland with Alaska and Hawaii juxtaposed). Creating an attractive 50 state map is simple when leveraging Google Maps...
Sometimes what you want to do is just too complex for a filter or a simple_tag. Fow this you will need to create a compilation function and a renderer. In this example we will create a template tag verbose_name with the following syntax: ExampleDescription{% verbose_name obj %}Verbose name of a mo...
import std.format; void main() { string s = "Name Surname 18"; string name, surname; int age; formattedRead(s, "%s %s %s", &name, &surname, &age); // %s selects a format based on the corresponding argument's type } Official documentatio...
You have a local vagrant box that you want to upload to Amazon AWS. First, you need to create a .box file: vagrant package --base my-virtual-machine This step should take a while depending on the size of your image. Then, you need to get the .vmdk image from the .box file: gunzip -S .box packag...
Large fluent assertions do become harder to read, but when combined with classes that have good implementations of ToString(), they can generate very useful error messages. [Test] public void AdvancedContraintsGiveUsefulErrorMessages() { Assert.That(actualCollection, Has .Count.Equa...
Once you have both your server-side logging running, and your client side development tools, you can start looking at Meteor specific extensions like the Meteor Chrome DevTools Extension. This lets you actually observe server logging in the client! Because the database is everywhere. As is logging. ...
Using raw values directly from the accelerometer sensor to move or rotate a GameObject can cause problems such as jerky movements or vibrations. It is recommended to smooth out the values before using them. In fact, values from the accelerometer sensor should always be smoothed out before use. This ...
This is a copy of the advanced function snippet from the Powershell ISE. Basically this is a template for many of the things you can use with advanced functions in Powershell. Key points to note: get-help integration - the beginning of the function contains a comment block that is set up to be ...
This example shows how a function can accept pipelined input, and iterate efficiently. Note, that the begin and end structures of the function are optional when pipelining, but that process is required when using ValueFromPipeline or ValueFromPipelineByPropertyName. function Write-FromPipeline{ ...
This is an example of something that would have been straight up impossible with labels. If you execute the same label multiple times at the same time and they rely on variables that are being defined within them, they very likely interfere and cause unexpected behavior. Here is how to do it with f...

Page 1 of 4