Tutorial by Examples: df

Reading the contents of a file within a web application can be accomplished by utilizing the HTML5 File API. First, add an input with type="file" in your HTML: <input type="file" id="upload"> Next, we're going to add a change listener on the file-input. This e...
instance Monoid [a] where mempty = [] mappend = (++) Checking the Monoid laws for this instance: mempty `mappend` x = x <-> [] ++ xs = xs -- prepending an empty list is a no-op x `mappend` mempty = x <-> xs ++ [] = xs -- appending an empty list is a no-op x...
Using the Vector.<T> type and the for each loop is more performant than a conventional array and for loop: Good: var list:Vector.<Sprite> = new <Sprite>[]; for each(var sprite:Sprite in list) { sprite.x += 1; } Bad: var list:Array = []; for (var i:int = 0; i < ...
So you've uploaded your files to a folder say /backend/web/uploads/ and you want these uploads to be visible on the frontend too. The easiest option is to create a symlink in the frontend that links to the backend: ln -s /path/to/backend/web/uploads/ /path/to/frontend/web/uploads In your views y...
() is a Monoid. Since there is only one value of type (), there's only one thing mempty and mappend could do: instance Monoid () where mempty = () () `mappend` () = ()
ForEach() is defined on the List<T> class, but not on IQueryable<T> or IEnumerable<T>. You have two choices in those cases: ToList first The enumeration (or query) will be evaluated, copying the results into a new list or calling the database. The method is then called on each it...
Folds are (higher-order) functions used with sequences of elements. They collapse seq<'a> into 'b where 'b is any type (possibly still 'a). This is a bit abstract so lets get into concrete practical examples. Calculating the sum of all numbers In this example, 'a is an int. We have a list of...
Incorrect usage: In the following snippet, the last match will never be used: let x = 4 match x with | 1 -> printfn "x is 1" | _ -> printfn "x is anything that wasn't listed above" | 4 -> printfn "x is 4" prints x is anything that wasn't listed abov...
AngularJS has digest loop and all your functions in a view and filters are executed every time the digest cycle is run. The digest loop will be executed whenever the model is updated and it can slow down your app (filter can be hit multiple times, before the page is loaded). You should avoid this: ...
Information The ABSTRACT and FINAL additions to the METHODS and CLASS statements allow you to define abstract and final methods or classes. An abstract method is defined in an abstract class and cannot be implemented in that class. Instead, it is implemented in a subclass of the class. Abstra...
Collection initialization syntax can be used when instantiating any class which implements IEnumerable and has a method named Add which takes a single parameter. In previous versions, this Add method had to be an instance method on the class being initialized. In C#6, it can also be an extension me...
UIGraphicsBeginPDFContextToFile(fileName, CGRectZero, nil); UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 612, 792), nil); [self drawText]; UIGraphicsEndPDFContext(); fileName is the document file where You are going to append or attach NSString* temporaryFile = @"firstI...
NSString* fileName = @"firstIOS.PDF"; NSArray *arrayPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES); NSString *path = [arrayPat...
UIGraphicsBeginPDFContextToFile(fileName, CGRectZero, nil); UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 600, 792), nil); UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 600, 792), nil); UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 600, 792), nil); ...
To connect to a local Wildfly server via the command line, the tool bin/jboss-cli.sh can be used: $ ./bin/jboss-cli.sh --connect [standalone@localhost:9990 /] To connect to a remote Wildfly server, use the --controller option: $ ./bin/jboss-cli.sh --connect --controller=localhost:9990 [stan...
Use 403 Forbidden when a client has requested a resource that is inaccessible due to existing access controls. For example, if your app has an /admin route that should only be accessible to users with administrative rights, you can use 403 when a normal user requests the page. GET /admin HTTP/1.1 ...
ceil() The ceil() method rounds a number upwards to the nearest integer, and returns the result. Syntax: Math.ceil(n); Example: console.log(Math.ceil(0.60)); // 1 console.log(Math.ceil(0.40)); // 1 console.log(Math.ceil(5.1)); // 6 console.log(Math.ceil(-5.1)); // -5 console.log(Math....
The two functions fn1 and fn2 can return multiple tensors, but they have to return the exact same number and types of outputs. x = tf.constant(1.) bool = tf.constant(True) def fn1(): return tf.add(x, 1.), x def fn2(): return tf.add(x, 10.), x res1, res2 = tf.cond(bool, fn1, fn2)...
Functions in python are first-class objects. They can be defined in any scope def fibonacci(n): def step(a,b): return b, a+b a, b = 0, 1 for i in range(n): a, b = step(a, b) return a Functions capture their enclosing scope can be passed around like any other...
Below won't work on a Windows machine $file = $request->file('file_upload'); $sampleName = 'UserUpload'; $destination = app_path() . '/myStorage/'; $fileName = $sampleName . '-' . date('Y-m-d-H:i:s') . '.' . $file->getClientOriginalExtension(); $file->move($destination, $fileName); ...

Page 4 of 21