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...
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...
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
// array
var arr = [
'one',
'two',
'three',
'four'
];
$.each(arr, function (index, value) {
console.log(value);
// Will stop running after "three"
return (value !== 'three');
});
// Outputs: one two three
When offering IAP within an an app, you must first add an entry for each individual purchase within iTunes Connect. If you’ve ever listed an app for sale in the store, it’s a similar process and includes things like choosing a pricing tier for the purchase. When the user makes a purchase, the App ...
In iTunes Connect, click iTunes Connect in the top left corner of the window to get back to the main menu. Select Users and Roles, then click the Sandbox Testers tab. Click + next to the “Tester” title.
Fill out the information and click Save when you’re done. You can make up a first and last nam...