Tutorial by Examples: l

Before starting with the example I'd recommend to create a Singleton with a delegate class member so you could achieve a use case of uploading a file in the background and let the user keep using your app while the files are being uploaded even when the app is the background. Let's start, first, we...
If all you need is to wrap the value into a promise, you don't need to use the long syntax like here: //OVERLY VERBOSE var defer; defer = $q.defer(); defer.resolve(['one', 'two']); return defer.promise; In this case you can just write: //BETTER return $q.when(['one', 'two']); $q.when ...
C-h t runs the function help-with-tutorial, which opens a buffer containing a tutorial on the basic editing functionality of emacs, including moving around in text, and working with files, buffers, and windows.
Pressing C-h a will run the emacs function apropos-command which makes emacs prompt for words (or a regexp) to search for. It will then show a buffer containing a list of names and descriptions related to that topic, including key bindings for each of the functions available via keystrokes. Pressin...
Another powerful & mature concurrency tool in Haskell is Software Transactional Memory, which allows for multiple threads to write to a single variable of type TVar a in an atomic manner. TVar a is the main type associated with the STM monad and stands for transactional variable. They're used m...
The Data.Vector module provided by the vector is a high performance library for working with arrays. Once you've imported Data.Vector, it's easy to start using a Vector: Prelude> import Data.Vector Prelude Data.Vector> let a = fromList [2,3,4] Prelude Data.Vector> a fromList [2,3,4]...
Filter odd elements: Prelude Data.Vector> Data.Vector.filter odd y fromList [1,3,5,7,9,11] :: Data.Vector.Vector
Vectors can be map'd and fold'd,filter'd andzip`'d: Prelude Data.Vector> Data.Vector.map (^2) y fromList [0,1,4,9,16,25,36,49,64,81,100,121] :: Data.Vector.Vector Reduce to a single value: Prelude Data.Vector> Data.Vector.foldl (+) 0 y 66
Zip two arrays into an array of pairs: Prelude Data.Vector> Data.Vector.zip y y fromList [(0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11)] :: Data.Vector.Vector
select returns a new hash with key-value pairs for which the block evaluates to true. { :a => 1, :b => 2, :c => 3 }.select { |k, v| k != :a && v.even? } # => { :b => 2 } When you will not need the key or value in a filter block, the convention is to use an _ in that place:...

SEL

Selectors are used as method identifiers in Objective-C. In the example below, there are two selectors. new and setName: Person* customer = [Person new]; [customer setName:@"John Doe"]; Each pair of brackets corresponds to a message send. On the first line we send a message containin...
Cleaning and compiling code for iPhone, on project MyProject for schema Qa: xcrun xcodebuild clean \ -workspace "MyProject.xcworkspace" \ -scheme "YourScheme" \ -sdk iphoneos \ -configuration Debug \ archive \ -archivePath builds/MyProject.xcarchive...
These rules apply only if you use manual reference counting! You own any object you create By calling a method whose name begins with alloc, new, copy or mutableCopy. For example: NSObject *object1 = [[NSObject alloc] init]; NSObject *object2 = [NSObject new]; NSObject *object3 = [object2 ...
Here is a quick example of using multiple forms in one Django view. from django.contrib import messages from django.views.generic import TemplateView from .forms import AddPostForm, AddCommentForm from .models import Comment class AddCommentView(TemplateView): post_form_class = AddPo...
package main import( "fmt" "time" ) func main() { for _ = range time.Tick(time.Second * 3) { fmt.Println("Ticking every 3 seconds") } }
To install a new package, e.g. aeson: cabal install aeson
After you have opened a split window in vim (as demonstrated by many examples under this tag) then you will likely want to control windows quickly. Here is how to control split windows using keyboard shortcuts. Move to split Above/Below: Ctrl + w and k Ctrl + w and j Move to split Left/Right...
<?php $to = '[email protected]'; $subject = 'Sending an HTML email using mail() in PHP'; $message = '<html><body><p><b>This paragraph is bold.</b></p><p><i>This text is italic.</i></p></body></html>'; $headers =...
Many unbound generic parameters, like those used in a static method, cannot be recovered at runtime (see Other Threads on Erasure). However there is a common strategy employed for accessing the type satisfying a generic parameter on a class at runtime. This allows for generic code that depends on ac...
# Deny access to a directory from the IP 255.0.0.0 <Directory /path/to/directory> order allow,deny deny from 255.0.0.0 allow from all </Directory> # Deny access to a file from the IP 255.0.0.0 <FilesMatch "^\.ht"> order allow,deny deny fro...

Page 407 of 861