Tutorial by Examples

You can apply any kind of additional processing to the output by passing a callable to ob_start(). <?php function clearAllWhiteSpace($buffer) { return str_replace(array("\n", "\t", ' '), '', $buffer); } ob_start('clearAllWhiteSpace'); ?> <h1>Lorem Ipsum&l...
Variables you have provided in your view context can be accessed using double-brace notation: In your views.py: class UserView(TemplateView): """ Supply the request user object to the template """ template_name = "user.html" def get_context_data...
The datetime module contains three primary types of objects - date, time, and datetime. import datetime # Date object today = datetime.date.today() new_year = datetime.date(2017, 01, 01) #datetime.date(2017, 1, 1) # Time object noon = datetime.time(12, 0, 0) #datetime.time(12, 0) # Curr...
C++11 for loops can be used to iterate over the elements of a iterator-based range, without using a numeric index or directly accessing the iterators: vector<float> v = {0.4f, 12.5f, 16.234f}; for(auto val: v) { std::cout << val << " "; } std::cout <<...
This uses the Dropbox Python SDK to upload a file to the Dropbox API from the local file as specified by file_path to the remote path as specified by dest_path. It also chooses whether or not to use an upload session based on the size of the file: f = open(file_path) file_size = os.path.getsize(fi...
foreach is used to iterate over the elements of an array or the items within a collection which implements IEnumerable✝. var lines = new string[] { "Hello world!", "How are you doing today?", "Goodbye" }; foreach (string line in lines) { Con...
Useful for simple animations, the CSS transition property allows number-based CSS properties to animate between states. Example .Example{ height: 100px; background: #fff; } .Example:hover{ height: 120px; background: #ff0000; } View Result By default, hovering over an...
When creating animations and other GPU-heavy actions, it's important to understand the will-change attribute. Both CSS keyframes and the transition property use GPU acceleration. Performance is increased by offloading calculations to the device's GPU. This is done by creating paint layers (parts of...
For multi-stage CSS animations, you can create CSS @keyframes. Keyframes allow you to define multiple animation points, called a keyframe, to define more complex animations. Basic Example In this example, we'll make a basic background animation that cycles between all colors. @keyframes rainbow...
Using Item Sales Table from Example Database, let us calculate and show the total Quantity we sold of each Product. This can be easily done with a group by, but lets assume we to 'rotate' our result table in a way that for each Product Id we have a column. SELECT [100], [145] FROM (SELECT ItemI...
In JavaScript, any object can be the prototype of another. When an object is created as a prototype of another, it will inherit all of its parent's properties. var proto = { foo: "foo", bar: () => this.foo }; var obj = Object.create(proto); console.log(obj.foo); console.log(obj....
Suppose we have a plain object called prototype: var prototype = { foo: 'foo', bar: function () { return this.foo; } }; Now we want another object called obj that inherits from prototype, which is the same as saying that prototype is the prototype of obj var obj = Object.create(prototype); N...
Setting a filter applies to all channels that you will subscribe to from that particular client. This client filter excludes messages that have this subscriber's UUID set at the sender's UUID: NSString *expression = [NSString stringWithFormat:@"(uuid != '%@'", se...
This example uses the Dropbox .NET library to try to get the metadata for an item at a particular path, and checks for a NotFound error: try { var metadata = await this.client.Files.GetMetadataAsync("/non-existant path"); Console.WriteLine(metadata.Name); } catch (Dropbox.Api.A...
Constructor injection is the safest way of injecting dependencies that a whole class depends upon. Such dependencies are often referred to as invariants, since an instance of the class cannot be created without supplying them. By requiring the dependency to be injected at construction, it is guara...
Property injection allows a classes dependencies to be updated after it has been created. This can be useful if you want to simplify object creation, but still allow the dependencies to be overridden by your tests with test doubles. Consider a class that needs to write to a log file in an error co...
Method injection is a fine grained way of injecting dependencies into processing. Consider a method that does some processing based on the current date. The current date is hard to change from a test, so it is much easier to pass a date into the method that you want to test. public void ProcessRe...
Whilst extracting dependencies out of your code so that they can be injected makes your code easier to test, it pushes the problem further up the hierarchy and can also result in objects that are difficult to construct. Various dependency injection frameworks / Inversion of Control Containers have ...
A for loop executes statements in the loop body, while the loop condition is true. Before the loop initialization statement is executed exactly once. After each cycle, the iteration execution part is executed. A for loop is defined as follows: for (/*initialization statement*/; /*condition*/; /*it...
If you want to squash the previous x commits into a single one, you can use the following commands: git reset --soft HEAD~x git commit Replacing x with the number of previous commits you want to be included in the squashed commit. Mind that this will create a new commit, essentially forgetting...

Page 71 of 1336