Tutorial by Examples: e

When the only thing returned from a function is a recursive call, it is refered to as tail recursion. Here's an example countdown written using tail recursion: def countdown(n): if n == 0: print "Blastoff!" else: print n countdown(n-1) Any computat...
By default Python's recursion stack cannot exceed 1000 frames. This can be changed by setting the sys.setrecursionlimit(15000) which is faster however, this method consumes more memory. Instead, we can also solve the Tail Recursion problem using stack introspection. #!/usr/bin/env python2.4 # This...
We can declare a series of expressions in the REPL like this: Prelude> let x = 5 Prelude> let y = 2 * 5 + x Prelude> let result = y * 10 Prelude> x 5 Prelude> y 15 Prelude> result 150 To declare the same values in a file we write the following: -- demo.hs module De...
The following example creates a FileSystemWatcher to watch the directory specified at run time. The component is set to watch for changes in LastWrite and LastAccess time, the creation, deletion, or renaming of text files in the directory. If a file is changed, created, or deleted, the path to the f...
A common mistake a lot of people starting out with FileSystemWatcher does is not taking into account That the FileWatcher event is raised as soon as the file is created. However, it may take some time for the file to be finished . Example: Take a file size of 1 GB for example . The file apr ask c...
Dependencies can be added for specific configuration like test/androidTest androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' testCompile 'junit:junit:3.8.1' Alternatively create your own configuration configurations { myconfig } And then download dependency fo...
Suppose we have an array of integers and we want to figure out the maximum value without holding the whole array in memory all at once. This approach can be adapted to handle a variety of other situations in which data needs to be processed while being deserialized instead of after. extern crate se...
Selecting only the attribute value of a link:href will return the relative URL. String bodyFragment = "<div><a href=\"/documentation\">Stack Overflow Documentation</a></div>"; Document doc = Jsoup.parseBodyFragment(bodyFragment); ...
Placeholders can be used in strings to automatically substitute the values in the final string. container = "cup" liquid = "coffee" string = "Filling the #{container} with #{liquid}..." The above String - when printed - will say: Filling the cup with coffee... Yo...
GHCi supports imperative-style breakpoints out of the box with interpreted code (code that's been :loaded). With the following program: -- mySum.hs doSum n = do putStrLn ("Counting to " ++ (show n)) let v = sum [1..n] putStrLn ("sum to " ++ (show n) ++ " = "...
CoffeeScriptJavaScriptis, =====isnt, !=!==not!and&&or||true, yes, ontruefalse, no, offfalse@, thisthisofininNo equivalenta ** bMath.pow(a, b)a // bMath.floor(a / b)a %% b(a % b + b) % b
A singleton is a pattern that restricts the instantiation of a class to one instance/object. For more info on python singleton design patterns, see here. class Singleton: def __new__(cls): try: it = cls.__it__ except AttributeError: it = cls.__it__ =...
The TinkerPop "toy graphs" make it possible to quickly try out some basic features of Gremlin. These graphs are pre-built and packaged with the Gremlin Console. The most commonly used "toy graphs" are "Modern" and "The Crew". When asking questions on StackOver...
The disabled binding adds a disabled attribute to a html element causing it to no longer be editable or clickable. This is useful mainly for <input>, <select>, <textarea>, <a> and <button> elements <input data-bind="disabled: disableInput"/> <sc...
Many bugs in knockout data binds are caused by undefined properties in a viewmodel. Knockout has two handy methods to retrieve the binding context of an HTML element: // Returns the binding context to which an HTMLElement is bound ko.contextFor(element); // Returns the viewmodel to which ...
CREATE TABLE all_datetime_types( c_date date, c_timestamp timestamp ); Minimum and maximum data values: insert into all_datetime_types values ('0001-01-01','0001-01-01 00:00:00.000000001'); insert into all_datetime_types values ('9999-12-31','9999-12-31 23:59:59.999999999');
CREATE TABLE all_text_types( c_char char(255), c_varchar varchar(65535), c_string string ); Sample data: insert into all_text_type values ('some ****&&&%%% char value ','some $$$$#####@@@@ varchar value','some !!~~~++ string value' );
CREATE TABLE all_numeric_types( c_tinyint tinyint, c_smallint smallint, c_int int, c_bigint bigint, c_decimal decimal(38,3) ); Minimum and maximum data values: insert into all_numeric_types values (-128,-32768,-2147483648,-9223372036854775808,-99999999999999999999999999999999...
CREATE TABLE all_floating_numeric_types( c_float float, c_double double ); Minimum and maximum data values: insert into all_floating_numeric_types values (-3.4028235E38,-1.7976931348623157E308); insert into all_floating_numeric_types values (-1.4E-45,-4.9E-324); insert into all_floatin...
CREATE TABLE all_binary_types( c_boolean boolean, c_binary binary ); Sample data: insert into all_binary_types values (0,1234); insert into all_binary_types values (1,4321); Note: For boolean, internally it stored as true or false. For binary, it will store base64 encoded value....

Page 614 of 1191