Tutorial by Examples: st

CanCan is a a popular authorization library for Ruby on Rails which restricts user access to specific resources. The latest gem (CanCanCan) is a continuation of the dead project CanCan. Permissions are defined in the Ability class and can be used from controllers, views, helpers, or any other place...
Will select records in TableName that have records matching in TableName1. SELECT * FROM TableName t WHERE EXISTS ( SELECT 1 FROM TableName1 t1 where t.Id = t1.Id)
Although it's bad practice, it's possible to add multiple return statements in a exception handling block: public static int returnTest(int number){ try{ if(number%2 == 0) throw new Exception("Exception thrown"); else return x; } catch(Exception e){ ...
In this example we want to create a class that will generate and output to console, a random number between a range of two integers which are passed as arguments during the initialization. public class SimpleRangeRandom implements Runnable { private int min; private int max; pr...
The macro WITH-INPUT-FROM-STRING can be used to make a stream from a string. (with-input-from-string (str "Foobar") (loop for i from 0 for char = (read-char str nil nil) while char do (format t "~d: ~a~%" i char))) ; 0: F ; 1: o ; 2: o ; 3: b ;...
The macro WITH-OUTPUT-TO-STRING can be used to create a string output stream, and return the resulting string at the end. (with-output-to-string (str) (write-line "Foobar!" str) (write-string "Barfoo!" str)) ;=> "Foobar! ; Barfoo!" The same can be done ...
Gray streams are a non-standard extension that allows user defined streams. It provides classes and methods that the user can extend. You should check your implementations manual to see if it provides Gray streams. For a simple example, a character input stream that returns random characters could ...
Installing Tcl 8.6.4 on Windows : The easiest way to get Tcl on a windows machine is to install the ActiveTcl distribution from ActiveState. Navigate to www.activestate.com and follow the links to download the Free Community Edition of ActiveTcl for Windows (choose 32/64 bit version app...
Method stopLoading() stops the current loading process of the webview. Swift webview.stopLoading() Objective-C [webview stopLoading];
Some formats can take additional parameters, such as the width of the formatted string, or the alignment: >>> '{:.>10}'.format('foo') '.......foo' Those can also be provided as parameters to format by nesting more {} inside the {}: >>> '{:.>{}}'.format('foo', 10) '.......
By default the built-in Request Localization middleware only supports setting culture via query, cookie or Accept-Language header. This example shows how create a middleware which allows to set the culture as part of the path like in /api/en-US/products. This example middleware assumes the locale t...
The function angular.isString returns true if the object or value given to it is of the type string angular.isString(value1) Examples angular.isString("hello") // true angular.isString([1, 2]) // false angular.isString(42) // false This is the equivalent of performing typeof s...
In cases such as restoring a database dump, or otherwise wishing to push some information through a pipe from the host, you can use the -i flag as an argument to docker run or docker exec. E.g., assuming you want to put to a containerized mariadb client a database dump that you have on the host, in...
Consider this list: <cfset foo = "one,two,three,four" /> Tag syntax Parameters AttributeRequiredDefaultDescriptionlisttrueA list object. The variable must be evaluated (wrapped with ##)indextrueThe current element of the list. <cfoutput> <cfloop list="#foo#&...
Consider this structure: <cfset stFoo = { a = "one" , b = "two" , c = "three" , d = "foue" } /> Tag syntax Parameters Notice the use of the attribute item instead of index. AttributeRequiredTypeDefaultDescriptioncollection...
Similar to SQL for doing your first steps in MDX you need to start by installing a Server. There are several servers available that are compatible with MDX (check wikipedia page) with a couple of them free or with a community edition. Once you've your server you'll have to create your schema, you ...
JsonReader reads a JSON encoded value as a stream of tokens. public List<Message> readJsonStream(InputStream in) throws IOException { JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8")); try { return readMessagesArray(reader); } finall...
Laravel's Flysystem integration provides drivers for several "drivers" out of the box; however, Flysystem is not limited to these and has adapters for many other storage systems. You can create a custom driver if you want to use one of these additional adapters in your Laravel application....
The .every method tests if all array elements pass a provided predicate test. To test all objects for equality, you can use the following code snippets. [1, 2, 1].every(function(item, i, list) { return item === list[0]; }); // false [1, 1, 1].every(function(item, i, list) { return item === list[0...
Object obj = new Object(); // Note the 'new' keyword Where: Object is a reference type. obj is the variable in which to store the new reference. Object() is the call to a constructor of Object. What happens: Space in memory is allocated for the object. The constructor Object() is call...

Page 107 of 369