Tutorial by Examples: ble

Go is a statically typed language, meaning you generally have to declare the type of the variables you are using. // Basic variable declaration. Declares a variable of type specified on the right. // The variable is initialized to the zero value of the respective type. var x int var s string va...
In Go, you can declare multiple variables at the same time. // You can declare multiple variables of the same type in one line var a, b, c string var d, e string = "Hello", "world!" // You can also use short declaration to assign multiple variables x, y, z := 1, 2, 3 ...
Creating an empty table is as simple as this: local empty_table = {} You can also create a table in the form of a simple array: local numeric_table = { "Eve", "Jim", "Peter" } -- numeric_table[1] is automatically "Eve", numeric_table[2] is "Ji...
INSERT INTO Customers (FName, LName, PhoneNumber) SELECT FName, LName, PhoneNumber FROM Employees This example will insert all Employees into the Customers table. Since the two tables have different fields and you don't want to move all the fields over, you need to set which fields to insert int...
The Lua standard library provides a pairs function which iterates over the keys and values of a table. When iterating with pairs there is no specified order for traversal, even if the keys of the table are numeric. for key, value in pairs(input_table) do print(key, " -- ", value) en...
Reflection is often used as part of software testing, such as for the runtime creation/instantiation of mock objects. It's also great for inspecting the state of an object at any given point in time. Here's an example of using Reflection in a unit test to verify a protected class member contains the...
5 We can avoid a property from showing up in for (... in ...) loops The enumerable property of the property descriptor tells whether that property will be enumerated while looping through the object's properties. var obj = { }; Object.defineProperty(obj, "foo", { value: 'show', enu...
Syntax: SELECT * FROM table_name Using the asterisk operator * serves as a shortcut for selecting all the columns in the table. All rows will also be selected because this SELECT statement does not have a WHERE clause, to specify any filtering criteria. This would also work the same way if you...
This query will return the number of tables in the specified database. USE YourDatabaseName SELECT COUNT(*) from INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' Following is another way this can be done for all user tables with SQL Server 2008+. The reference is here. SELECT COUNT(...
Note that these only work in the developer tools of certain browsers. $_ gives you the value of whatever expression was evaluated last. "foo" // "foo" $_ // "foo" $0 refers to the DOM element currently selected in the Inspector. So if &l...
Sometimes the property name needs to be stored into a variable. In this example, we ask the user what word needs to be looked up, and then provide the result from an object I've named dictionary. var dictionary = { lettuce: 'a veggie', banana: 'a fruit', tomato: 'it depends on who yo...
- (void)reachabilityChanged:(NSNotification *)note { Reachability* reachability = [note object]; NetworkStatus netStatus = [reachability currentReachabilityStatus]; if (netStatus == NotReachable) { NSLog(@"Network unavailable"); } }
// Java: Stream.of(1.0, 2.0, 3.0) .mapToInt(Double::intValue) .mapToObj(i -> "a" + i) .forEach(System.out::println); // a1 // a2 // a3 // Kotlin: sequenceOf(1.0, 2.0, 3.0).map(Double::toInt).map { "a$it" }.forEach(::println)
Using .Graph will filter the results to only include those that match the tagset for the alert. For instance an alert for os.low.memory{host=ny-web01} would only include series with the host=ny-web01 tags. If multiple series match then only the first matching result will be used. template graph.tem...
Using .GraphAll will include all the results in the graph. template graph.template { subject = ... body = `{{template "header" .}} <strong>GraphAll</strong> <div>{{.GraphAll .Alert.Vars.graph}}</div> <strong>GraphAll With Y Axis...
The examples below fill in a PhoneNumber for any Employee who is also a Customer and currently does not have a phone number set in the Employees Table. (These examples use the Employees and Customers tables from the Example Databases.) Standard SQL Update using a correlated subquery: UPDATE ...
Some regex flavors (Perl, PCRE, Oniguruma, Boost) only support fixed-length lookbehinds, but offer the \K feature, which can be used to simulate variable-length lookbehind at the start of a pattern. Upon encountering a \K, the matched text up to this point is discarded, and only the text matching th...
Variable substitutions should only be used inside double quotes. calculation='2 * 3' echo "$calculation" # prints 2 * 3 echo $calculation # prints 2, the list of files in the current directory, and 3 echo "$(($calculation))" # prints 6 Outside of doubl...
You shouldn't call NSLog without a literal format string like this: NSLog(variable); // Dangerous code! If the variable is not an NSString, the program will crash, because NSLog expects an NSString. If the variable is an NSString, it will work unless your string contains a %. NSLog will pars...
We can illustrate this problem with the following pseudo-code function foo() { global $bob; $bob->doSomething(); } Your first question here is an obvious one Where did $bob come from? Are you confused? Good. You've just learned why globals are confusing and considered a bad p...

Page 4 of 62