Tutorial by Examples: e

This substitute command can use Regular Expressions and will match any instance of foo followed by any( one ) character since the period . in Regular Expressions matches any character, hence the following command will match all instances of foo followed by any character in the current line. :s/foo....
Use the from and to attributes to specify how many iterations should occur. The (optional) step attribute allows you to determine how big the increments will be. <cfloop from="1" to="10" index="i" step="2"> <cfoutput> #i#<br />...
You can loop over the results of a ColdFusion query. <cfquery name="getMovies" datasource="Entertainment"> select top 4 movieName from Movies </cfquery> <cfloop query="getMovies"> #movieName# </cfloop>
You can loop over a file. <cfloop file="#myFile#" index="line"> <cfoutput> #line#<br /> </cfoutput> </cfloop>
You can loop over a Structure or COM collection. <cfset myBooks = StructNew()> <cfset myVariable = StructInsert(myBooks,"ColdFusion","ColdFusion MX Bible")> <cfset myVariable = StructInsert(myBooks,"HTML","HTML Visual QuickStart")> <cf...
Exporting a database is a simple two step process: sqlite> .output mydatabase_dump.sql sqlite> .dump Exporting a table is pretty similar: sqlite> .output mytable_dump.sql sqlite> .dump mytable The output file needs to be defined with .output prior to using .dump; otherwise, the...
Instead of web pages, we can also load the document files into iOS WebView like .pdf, .txt, .doc etc.. loadData method is used to load NSData into webview. Swift //Assuming there is a text file in the project named "home.txt". let localFilePath = NSBundle.mainBundle().pathForResource(&...
Creating Gradient UIImage with colors in CGRect Swift: extension UIImage { static func gradientImageWithBounds(bounds: CGRect, colors: [CGColor]) -> UIImage { let gradientLayer = CAGradientLayer() gradientLayer.frame = bounds gradientLayer.colors = colors ...
+ (CALayer *)gradientBGLayerForBounds:(CGRect)bounds colors:(NSArray *)colors { CAGradientLayer * gradientBG = [CAGradientLayer layer]; gradientBG.frame = bounds; gradientBG.colors = colors; return gradientBG; }
Python multithreading performance can often suffer due to the Global Interpreter Lock. In short, even though you can have multiple threads in a Python program, only one bytecode instruction can execute in parallel at any one time, regardless of the number of CPUs. As such, multithreading in cases w...
Use threading.Thread to run a function in another thread. import threading import os def process(): print("Pid is %s, thread id is %s" % (os.getpid(), threading.current_thread().name)) threads = [threading.Thread(target=process) for _ in range(4)] for t in threads: t.sta...
Use multiprocessing.Process to run a function in another process. The interface is similar to threading.Thread: import multiprocessing import os def process(): print("Pid is %s" % (os.getpid(),)) processes = [multiprocessing.Process(target=process) for _ in range(4)] for p in...
As all threads are running in the same process, all threads have access to the same data. However, concurrent access to shared data should be protected with a lock to avoid synchronization issues. import threading obj = {} obj_lock = threading.Lock() def objify(key, val): print("O...
Code running in different processes do not, by default, share the same data. However, the multiprocessing module contains primitives to help share values across multiple processes. import multiprocessing plain_num = 0 shared_num = multiprocessing.Value('d', 0) lock = multiprocessing.Lock() ...
Place Picker is a really simple UI widget provided by Places API. It provides a built-in map, current location, nearby places, search abilities and autocomplete. This is a sample usage of Place Picker UI widget. private static int PLACE_PICKER_REQUEST = 1; private TextView txtPlaceName; @Ove...
You can get the current location and local places of user by using the Google Places API. Ar first, you should call the PlaceDetectionApi.getCurrentPlace() method in order to retrieve local business or other places. This method returns a PlaceLikelihoodBuffer object which contains a list of PlaceLi...
To rename remote, use command git remote rename The git remote rename command takes two arguments: An existing remote name, for example : origin A new name for the remote, for example : destination Get existing remote name git remote # origin Check existing remote with URL git remote -...
Informally, a monad is a container of elements, notated as F[_], packed with 2 functions: flatMap (to transform this container) and unit (to create this container). Common library examples include List[T], Set[T] and Option[T]. Formal definition Monad M is a parametric type M[T] with two operatio...
Returns a sub string starting with the left most char of a string and up to the maximum length specified. Parameters: character expression. The character expression can be of any data type that can be implicitly converted to varchar or nvarchar, except for text or ntext max length. An integer n...
Returns the start index of a the first occurrence of string expression inside another string expression. Parameters list: String to find (up to 8000 chars) String to search (any valid character data type and length, including binary) (Optional) index to start. A number of type int or big int. ...

Page 488 of 1191