Tutorial by Examples: al

In this example, we can use GROUP BY not only determined the sort of the rows returned, but also what rows are returned, since we're using TOP to limit the result set. Let's say we want to return the top 5 highest reputation users from an unnamed popular Q&A site. Without ORDER BY This query ...
Use len() to get the one-dimensional length of a list. len(['one', 'two']) # returns 2 len(['one', [2, 3], 'four']) # returns 3, not 4 len() also works on strings, dictionaries, and other data structures similar to lists. Note that len() is a built-in function, not a method of a list objec...
/* define a list of preprocessor tokens on which to call X */ #define X_123 X(1) X(2) X(3) /* define X to use */ #define X(val) printf("X(%d) made this print\n", val); X_123 #undef X /* good practice to undef X to facilitate reuse later on */ This example will result in the prep...
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...
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...
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...
To create a variable in Python, all you need to do is specify the variable name, and then assign a value to it. <variable name> = <value> Python uses = to assign values to variables. There's no need to declare a variable in advance (or to assign a data type to it), assigning a value ...
Install the svn client to start collaborating on the project that is using Subversion as its version control system. To install Subversion, you can build it yourself from a source code release or download a binary package pre-built for your operating system. The list of sites where you can obtain a...
4.0 To uppercase $ v="hello" # Just the first character $ printf '%s\n' "${v^}" Hello # All characters $ printf '%s\n' "${v^^}" HELLO # Alternative $ v="hello world" $ declare -u string="$v" $ echo "$string" HELLO WORLD To l...
In Ruby, there are exactly two values which are considered "falsy", and will return false when tested as a condition for an if expression. They are: nil boolean false All other values are considered "truthy", including: 0 - numeric zero (Integer or otherwise) "&qu...
In most environments, console.table() can be used to display objects and arrays in a tabular format. For example: console.table(['Hello', 'world']); displays like: (index)value0"Hello"1"world" console.table({foo: 'bar', bar: 'baz'}); displays like: (index)value"fo...
Background CSS colors may also be represented as a hex triplet, where the members represent the red, green and blue components of a color. Each of these values represents a number in the range of 00 to FF, or 0 to 255 in decimal notation. Uppercase and/or lowercase Hexidecimal values may be used (i...
Given a function that accepts a Node-style callback, fooFn(options, function callback(err, result) { ... }); you can promisify it (convert it to a promise-based function) like this: function promiseFooFn(options) { return new Promise((resolve, reject) => fooFn(options, (err, re...
The Problem The abstract equality and inequality operators (== and !=) convert their operands if the operand types do not match. This type coercion is a common source of confusion about the results of these operators, in particular, these operators aren't always transitive as one would expect. &...
The following example shows common AngularJS constructs in one file: <!DOCTYPE html> <html ng-app="myDemoApp"> <head> <style>.started { background: gold; }</style> <script src="https://code.angularjs.org/1.5.8/angular.min.js">&lt...
SELECT your_columns, COUNT(*) OVER() as Ttl_Rows FROM your_data_set idnameTtl_Rows1example52foo53bar54baz55quux5 Instead of using two queries to get a count then the line, you can use an aggregate as a window function and use the full result set as the window. This can be used as a base for fur...
Given this data: dateamount2016-03-122002016-03-11-502016-03-141002016-03-151002016-03-10-250 SELECT date, amount, SUM(amount) OVER (ORDER BY date ASC) AS running FROM operations ORDER BY date ASC will give you dateamountrunning2016-03-10-250-2502016-03-11-50-3002016-03-12200-1002016-03-1410...

Page 14 of 269