Tutorial by Examples: co

git rev-list --oneline master ^origin/master Git rev-list will list commits in one branch that are not in another branch. It is a great tool when you're trying to figure out if code has been merged into a branch or not. Using the --oneline option will display the title of each commit. The ^ ...
When testing you PayPal integration on sandbox, you'll need to have sandbox user accounts set up to use to go through the payment flow. Go to https://developer.paypal.com/developer/accounts/, log in using your PayPal account, and click on "Create Account", as below: Enter in the accoun...
cat file.txt will print the contents of a file. If the file contains non-ASCII characters, you can display those characters symbolically with cat -v. This can be quite useful for situations where control characters would otherwise be invisible. cat -v unicode.txt Very often, for interactive ...
man <command> This will show the manual page for the specified command. For example, man ping will show: PING(8) BSD System Manager's Manual PING(8) NAME ping -- send ICMP ECHO_REQUEST packets to network hosts SYNOPSIS ping [-AaCDdfno...
$url = "https://api.dropboxapi.com/2/users/get_current_account" $req = [System.Net.HttpWebRequest]::Create($url) $req.headers["Authorization"] = "Bearer <ACCESS_TOKEN>" $req.Method = "POST" $res = $req.GetResponse() Write-Host "Response Sta...
Consider the below list comprehension: >>> def f(x): ... import time ... time.sleep(.1) # Simulate expensive function ... return x**2 >>> [f(x) for x in range(1000) if f(x) > 10] [16, 25, 36, ...] This results in two calls to f(x) for 1,000 values of...
Defining a new protocol: @protocol NewProtocol - (void)protocolMethod:(id)argument; - (id)anotherMethod; @end
do './config.pl'; This will read in the contents of the config.pl file and execute it. (See also: perldoc -f do.) N.B.: Avoid do unless golfing or something as there is no error checking. For including library modules, use require or use.
To conditionally include a block of code, the preprocessor has several directives (e.g #if, #ifdef, #else, #endif, etc). /* Defines a conditional `printf` macro, which only prints if `DEBUG` * has been defined */ #ifdef DEBUG #define DLOG(x) (printf(x)) #else #define DLOG(x) #endif Norm...
func doSomething1(value: Double) { /* ... */ } func doSomething2(value: UInt) { /* ... */ } let x = 42 // x is an Int doSomething1(Double(x)) // convert x to a Double doSomething2(UInt(x)) // convert x to a UInt Integer initializers produce a runtime error if the value ove...
Use String initializers for converting numbers into strings: String(1635999) // returns "1635999" String(1635999, radix: 10) // returns "1635999" String(1635999, radix: 2) // returns "110001111011010011111&...
The key to correctly stretching is in the top and left border. The top border controls horizontal stretching and the left border controls vertical stretching. This example creates rounded corners suitable for a Toast. The parts of the image that are below the top border and to the right of the ...
var date1 = new Date(); date1.toJSON(); Returns: "2016-04-14T23:49:08.596Z"
Composer generates a vendor/autoload.php file. You might simply include this file and you will get autoloading for free. require __DIR__ . '/vendor/autoload.php'; This makes working with third-party dependencies very easy. You can also add your own code to the Autoloader by adding an autoload ...
INSERT INTO Customers (FName, LName, Email, PreferredContact) VALUES ('Zack', 'Smith', '[email protected]', 'EMAIL'); This statement will insert a new row into the Customers table. Data will only be inserted into the columns specified - note that no value was provided for the PhoneNumber column. ...
HTML comments can be used to leave notes to yourself or other developers about a specific point in code. They can be initiated with <!-- and concluded with -->, like so: <!-- I'm an HTML comment! --> They can be incorporated inline within other content: <h1>This part will be d...
Conditional comments can be used to customize code for different versions of Microsoft Internet Explorer. For example, different HTML classes, script tags, or stylesheets can be provided. Conditional comments are supported in Internet Explorer versions 5 through 9. Older and newer Internet Explorer ...
When you make a subclass of a base class, you can construct the base class by using : base after the subclass constructor's parameters. class Instrument { string type; bool clean; public Instrument (string type, bool clean) { this.type = type; this.clean = c...
An if statement checks whether a Bool condition is true: let num = 10 if num == 10 { // Code inside this block only executes if the condition was true. print("num is 10") } let condition = num == 10 // condition's type is Bool if condition { print("num is 10&...
To allow the use of in for custom classes the class must either provide the magic method __contains__ or, failing that, an __iter__-method. Suppose you have a class containing a list of lists: class ListList: def __init__(self, value): self.value = value # Create a set of al...

Page 9 of 248