Tutorial by Examples

Grouping with the data.table package is done using the syntax dt[i, j, by] Which can be read out loud as: "Take dt, subset rows using i, then calculate j, grouped by by." Within the dt statement, multiple calculations or groups should be put in a list. Since an alias for list() is .(), bo...
To send a file and form data in single request, content should have multipart/form-data type. using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Threading.Tasks; public async Task<string> UploadFile(string url, string filename, Diction...
Use the following flowchart to choose the right Collection for the job. This flowchart was based off [http://i.stack.imgur.com/aSDsG.png).
parse_url(): This function parses a URL and returns an associative array containing any of the various components of the URL that are present. $url = parse_url('http://example.com/project/controller/action/param1/param2'); Array ( [scheme] => http [host] => example.com ...
explode(): Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter. This function is pretty much straight forward. $url = "http://example.com/project/controller/action/param1/param2"; $parts = explode(...
basename(): Given a string containing the path to a file or directory, this function will return the trailing name component. This function will return only the last part of an URL $url = "http://example.com/project/controller/action/param1/param2"; $parts = basename($url); // Out...
Choosing which C++ Container to use can be tricky, so here's a simple flowchart to help decide which Container is right for the job. This flowchart was based on Mikael Persson's post. This little graphic in the flowchart is from Megan Hopkins
Static members have class scope as opposed to object scope C++ Example // define in header class Singleton { public: static Singleton *getInstance(); private: Singleton() {} static Singleton *instance; }; // initialize in .cpp Singleton* Singleton::instance = 0...
Defined within Another Class C++ Nested Class[ref] (needs a reference to enclosing class) class Outer { class Inner { public: Inner(Outer* o) :outer(o) {} private: Outer* outer; }; }; Java [non-static] Nested Class (aka Inner Class or Member Class...
Many argue that Java is ONLY pass-by-value, but it's more nuanced than that. Compare the following C++ and Java examples to see the many flavors of pass-by-value (aka copy) and pass-by-reference (aka alias). C++ Example (complete code) // passes a COPY of the object static void passByCopy(Pa...
C++ & Java are both object-oriented languages, thus the following diagram applies to both.
Beware of using "downcasting" - Downcasting is casting down the inheritance hierarchy from a base class to a subclass (i.e. opposite of polymorphism). In general, use polymorphism & overriding instead of instanceof & downcasting. C++ Example // explicit type case required Child ...
Abstract Method declared without an implementation C++ pure virtual method virtual void eat(void) = 0; Java abstract method abstract void draw(); Abstract Class cannot be instantiated C++ cannot be instantiated; has at least 1 pure virtual method class AB {public: virtual void f() = ...
This example shows how to to display specific property in dropdown but bind with the whole object. autocomplete-overview-example.html: <md-input-container> <input mdInput placeholder="State" [(ngModel)]="selection" [mdAutocomplete]="auto" [formCo...
data.service.ts: import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; import 'rxjs/add/operator/map'; @Injectable() export class DataService { constructor(private http: Http) { } fetchData(){ return this.http.get('https://dinstruct-d4b62.firebaseio....
This example requires FormsModule and ReactiveFormsModule. Please import them in your application/module. import {FormsModule, ReactiveFormsModule} from '@angular/forms'; input-form-example.html <form class="example-form" (ngSubmit)="submit(addForm.value)" [formGroup]=&qu...
This example requires FormsModule and ReactiveFormsModule. Please import them in your application/module. import {FormsModule, ReactiveFormsModule} from '@angular/forms'; autocomplete-overview-example.html: <md-input-container> <input mdInput placeholder="State" [mdAutocom...
Add a new file to Xcode (File > New > File), then select “Source” and click “Header File“. Name your file “YourProjectName-Bridging-Header.h”. Example: In my app Station, the file is named “Station-Bridging-Header”. Create the file. Navigate to your project build settings ...
Add a new Swift file to your Xcode project. Name it as you please and you should get an alert box asking if you would like to create a bridging header. Note: If you don’t receive a prompt to add a bridging header, you probably declined this message once before and you will have to add the header m...
To find the word foo in the file bar : grep foo ~/Desktop/bar To find all lines that do not contain foo in the file bar : grep –v foo ~/Desktop/bar To use find all words containing foo in the end (WIldcard Expansion): grep "*foo" ~/Desktop/bar

Page 1324 of 1336