Tutorial by Examples: er

The spacing should be even and uniform throughout. Improper indentation can cause an IndentationError or cause the program to do something unexpected. The following example raises an IndentationError: a = 7 if a > 5: print "foo" else: print "bar" print "done&qu...
This method gets the user agent and parses it to find the browser. The browser name and version are extracted from the user agent through a regex. Based on these two, the <browser name> <version> is returned. The four conditional blocks following the user agent matching code are meant t...
Let's add a custom operator to multiply a CGSize func *(lhs: CGFloat, rhs: CGSize) -> CGSize{ let height = lhs*rhs.height let width = lhs*rhs.width return CGSize(width: width, height: height) } Now this works let sizeA = CGSize(height:100, width:200) let sizeB = 1.1 * si...
When we have two separate array and we want to make key value pair from that two array, we can use array's reduce function like below: var columns = ["Date", "Number", "Size", "Location", "Age"]; var rows = ["2001", "5", "B...
If realloc fails, it returns NULL. If you assign the value of the original buffer to realloc's return value, and if it returns NULL, then the original buffer (the old pointer) is lost, resulting in a memory leak. The solution is to copy into a temporary pointer, and if that temporary is not NULL, th...
Floating point types (float, double and long double) cannot precisely represent some numbers because they have finite precision and represent the values in a binary format. Just like we have repeating decimals in base 10 for fractions such as 1/3, there are fractions that cannot be represented fini...
Two terms may be compared via the standard ordering: variables @< numbers @< atoms @< strings @< structures @< lists Notes: Structures compare alphabetically by functor first, then by arity and lastly by the comparison of each argument. Lists compare by length first, t...
Equality operatorSucceeds ifX = YX can be unified with YX \= YX cannot be unified with YX == YX and Y are identical (i.e. they unify with no variable bindings occurring)X \== YX and Y are not identicalX =:= YX and Y are arithmetically equalX =\= YX and Y are not arithmetically equal
The pickle module implements an algorithm for turning an arbitrary Python object into a series of bytes. This process is also called serializing the object. The byte stream representing the object can then be transmitted or stored, and later reconstructed to create a new object with the same charact...
To install v6.x update the packages curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - Using the apt package manager sudo apt-get install -y nodejs
#include <stdio.h> #include <stdlib.h> int main (void) { int * pdata; size_t n; printf ("Enter the size of the array: "); fflush(stdout); /* Make sure the prompt gets printed to buffered stdout. */ if (1 != scanf("%zu", &n)) /* If zu is n...
Use Kernel.inspect to convert anything to string. iex> Kernel.inspect(1) "1" iex> Kernel.inspect(4.2) "4.2" iex> Kernel.inspect %{pi: 3.14, name: "Yos"} "%{pi: 3.14, name: \"Yos\"}"
The IEnumerable<T> interface has a single method, GetEnumerator(), which returns an IEnumerator<T>. While the yield keyword can be used to directly create an IEnumerable<T>, it can also be used in exactly the same way to create an IEnumerator<T>. The only thing that changes ...
This will create a timer to call the doSomething method on self in 5 seconds. Swift let timer = NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: Selector(doSomething()), userInfo: nil, ...
Swift timer.fire() Objective-C [timer fire]; Calling the fire method causes an NSTimer to perform the task it would have usually performed on a schedule. In a non-repeating timer, this will automatically invalidate the timer. That is, calling fire before the time interval is up will result ...
Swift timer.invalidate() Objective-C [timer invalidate]; This will stop the timer from firing. Must be called from the thread the timer was created in, see Apple's notes: You must send this message from the thread on which the timer was installed. If you send this message from another thr...
For example, if t1 is currently not an InnoDB table, this statement changes its storage engine to InnoDB: ALTER TABLE t1 ENGINE = InnoDB; If the table is already InnoDB, this will rebuild the table and its indexes and have an effect similar to OPTIMIZE TABLE. You may gain some disk space improv...
Below won't work on a Windows machine $file = $request->file('file_upload'); $sampleName = 'UserUpload'; $destination = app_path() . '/myStorage/'; $fileName = $sampleName . '-' . date('Y-m-d-H:i:s') . '.' . $file->getClientOriginalExtension(); $file->move($destination, $fileName); ...
There are three kinds of numeric RangeFields in Python. IntegerField, BigIntegerField, and FloatField. They convert to psycopg2 NumericRanges, but accept input as native Python tuples. The lower bound is included and the upper bound is excluded. class Book(models.Model): name = CharField(max_l...
It's simpler and easier to input values as a Python tuple instead of a NumericRange. Book.objects.create(name='Pro Git', ratings_range=(5, 5)) Alternative method with NumericRange: Book.objects.create(name='Pro Git', ratings_range=NumericRange(5, 5))

Page 105 of 417