Tutorial by Examples

Annotation types are defined with @interface. Parameters are defined similar to methods of a regular interface. @interface MyAnnotation { String param1(); boolean param2(); int[] param3(); // array parameter } Default values @interface MyAnnotation { String param1() defau...
Switch statements compare the value of an expression against 1 or more values and executes different sections of code based on that comparison. var value = 1; switch (value) { case 1: console.log('I will always run'); break; case 2: console.log('I will never run'); break;...
fetch('/example.json', { headers: new Headers({ 'Accept': 'text/plain', 'X-Your-Custom-Header': 'example value' }) });
Posting form data fetch(`/example/submit`, { method: 'POST', body: new FormData(document.getElementById('example-form')) }); Posting JSON data fetch(`/example/submit.json`, { method: 'POST', body: JSON.stringify({ email: document.getElementById('example-email').val...
The first argument of re.match() is the regular expression, the second is the string to match: import re pattern = r"123" string = "123zzb" re.match(pattern, string) # Out: <_sre.SRE_Match object; span=(0, 3), match='123'> match = re.match(pattern, string) ma...
pattern = r"(your base)" sentence = "All your base are belong to us." match = re.search(pattern, sentence) match.group(1) # Out: 'your base' match = re.search(r"(belong.*)", sentence) match.group(1) # Out: 'belong to us.' Searching is done anywhere in the ...
Grouping is done with parentheses. Calling group() returns a string formed of the matching parenthesized subgroups. match.group() # Group without argument returns the entire match found # Out: '123' match.group(0) # Specifying 0 gives the same result as specifying no argument # Out: '123' Arg...
Special characters (like the character class brackets [ and ] below) are not matched literally: match = re.search(r'[b]', 'a[b]c') match.group() # Out: 'b' By escaping the special characters, they can be matched literally: match = re.search(r'\[b\]', 'a[b]c') match.group() # Out: '[b]' T...
Replacements can be made on strings using re.sub. Replacing strings re.sub(r"t[0-9][0-9]", "foo", "my name t13 is t44 what t99 ever t44") # Out: 'my name foo is foo what foo ever foo' Using group references Replacements with a small number of groups can be made a...
First, create a new SoapClient object, passing the URL to the WSDL file and optionally, an array of options. // Create a new client object using a WSDL URL $soap = new SoapClient('https://example.com/soap.wsdl', [ # This array and its values are optional 'soap_version' => SOAP_1_2, ...
This is similar to WSDL mode, except we pass NULL as the WSDL file and make sure to set the location and uri options. $soap = new SoapClient(NULL, [ 'location' => 'https://example.com/soap/endpoint', 'uri' => 'namespace' ]);
' Omitting the 4th and 5th argument ("xpos" and "ypos") will result in the prompt ' being display center of the parent screen exampleString = InputBox("What is your name?", "Name Check", "Jon Skeet", 2500, 2000) WScript.Echo "Your name ...
Make sure you see Registering for local notifications in order for this to work: Swift let notification = UILocalNotification() notification.alertBody = "Hello, local notifications!" notification.fireDate = NSDate().dateByAddingTimeInterval(10) // 10 seconds after now UIApplication.sh...
iOS 8 In order to present local notifications to the user, you have to register your app with the device: Swift let settings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories: nil) UIApplication.sharedApplication().registerUserNotificationSettings(settings) Objective...
Steam has a games under $10 section of their store page. Somewhere deep in the heart of their systems, there's probably a query that looks something like: SELECT * FROM Items WHERE Price < 10
The Basics The simplist way to convert one date format into another is to use strtotime() with date(). strtotime() will convert the date into a Unix Timestamp. That Unix Timestamp can then be passed to date() to convert it to the new format. $timestamp = strtotime('2008-07-01T22:35:17.02'); $new_...
MATLAB allows for several methods to index (access) elements of matrices and arrays: Subscript indexing - where you specify the position of the elements you want in each dimension of the matrix separately. Linear indexing - where the matrix is treated as a vector, no matter its dimensions. That ...
re.findall(r"[0-9]{2,3}", "some 1 text 12 is 945 here 4445588899") # Out: ['12', '945', '444', '558', '889'] Note that the r before "[0-9]{2,3}" tells python to interpret the string as-is; as a "raw" string. You could also use re.finditer() which works in...
Available in the standard library as defaultdict from collections import defaultdict d = defaultdict(int) d['key'] # 0 d['key'] = 5 d['key'] # 5 d = defaultdict(lambda: 'empty') d['key'] # 'empty' d['key'] = 'full' ...
Given some JSON file "foo.json" like: {"foo": {"bar": {"baz": 1}}} we can call the module directly from the command line (passing the filename as an argument) to pretty-print it: $ python -m json.tool foo.json { "foo": { "bar...

Page 76 of 1336