Tutorial by Examples: f

With the Class Based generic Views, it is very simple and easy to create the CRUD views from our models. Often, the built in Django admin is not enough or not preferred and we need to roll our own CRUD views. The CBVs can be very handy in such cases. The CreateView class needs 3 things - a model, t...
The widely used combination of tic and toc can provide a rough idea of the execution time of a function or code snippets. For comparing several functions it shouldn't be used. Why? It is almost impossible to provide equal conditions for all code snippets to compare within a script using above solu...
By default, GHCI's prompt shows all the modules you have loaded into your interactive session. If you have many modules loaded this can get long: Prelude Data.List Control.Monad> -- etc The :set prompt command changes the prompt for this interactive session. Prelude Data.List Control.Monad&g...
GHCi uses a configuration file in ~/.ghci. A configuration file consists of a sequence of commands which GHCi will execute on startup. $ echo ":set prompt \"foo> \"" > ~/.ghci $ ghci GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration...
The :l or :load command type-checks and loads a file. $ echo "f = putStrLn \"example\"" > example.hs $ ghci GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help ghci> :l example.hs [1 of 1] Compiling Main ( example.hs, interpreted ) Ok, modules ...
The fourth version of the framework focuses mainly on making mobile web application development easier. New features in AP.NET MVC 4 ASP.NET Web API ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devi...
Lets suppose you have 2 Lists A and B, and you want to remove from B all the elements that you have in A the method in this case is List.removeAll(Collection c); #Example: public static void main(String[] args) { List<Integer> numbersA = new ArrayList<>(); List<Intege...
Regular Map A map is an associative container, containing key-value pairs. #include <string> #include <map> std::map<std::string, size_t> fruits_count; In the above example, std::string is the key type, and size_t is a value. The key acts as an index in the map. Each key mu...
Python 2 includes a cmp function which allows you to determine if one object is less than, equal to, or greater than another object. This function can be used to pick a choice out of a list based on one of those three options. Suppose you need to print 'greater than' if x > y, 'less than' if x &...
You can apply the same change shown in the Index Settings example to all existing indices with one request, or even a subset of them: PUT /*/_settings { "index": { "indexing.slowlog.threshold.index.warn": "1s", "search.slowlog.threshold": { ...
Input must must read from the Update function. Reference for all the available Keycode enum. 1. Reading key press with Input.GetKey: Input.GetKey will repeatedly return true while the user holds down the specified key. This can be used to repeatedly fire a weapon while holding the specified key ...
import std.stdio; struct A { int b; void c(); string d; }; void main() { // The following foreach is unrolled in compile time foreach(name; __traits(allMembers, A)) { pragma(msg, name); } } The allMembers traits returns a tuple of string containing t...
Swift if let text = self.textView.text where !text.isEmpty { // Do stuff for text } else { // Do stuff for nil text or empty string } Objective-C if (self.textView.text.length > 0){ // Do stuff for text } else { // Do stuff for nil text or empty string }
All fragments should have an empty constructor (i.e. a constructor method having no input arguments). Therefore, in order to pass your data to the Fragment being created, you should use the setArguments() method. This methods gets a bundle, which you store your data in, and stores the Bundle in the ...
To define a new middleware we have to create the middleware class: class AuthenticationMiddleware { //this method will execute when the middleware will be triggered public function handle ( $request, Closure $next ) { if ( ! Auth::user() ) { return red...
Callbacks are often used to provide error handling. This is a form of control flow branching, where some instructions are executed only when an error occurs: const expected = true; function compare(actual, success, failure) { if (actual === expected) { success(); } else { failure...
#Get the active Worksheet my $Book = $Excel->Activewindow; my $Sheet = $Book->Activesheet; #List of Worksheet names my @list_Sheet = map { $_->{'Name'} } (in $Book->{Worksheets}); #Access a given Worksheet my $Sheet = $Book->Worksheets($list_Sheet[0]); #Add new Worksheet...
#Edit the value of a cell (2 methods) $Sheet->Range("A1")->{Value} = 1234; $Sheet->Cells(1,1)->{Value} = 1234; #Edit the values in a range of cells $Sheet->Range("A8:C9")->{Value} = [[ undef, 'Xyzzy', 'Plugh' ], [ 42, 'Pe...
#Insert a row before/after line 22 $Sheet->Rows("22:22")->Insert(xlUp, xlFormatFromRightOrBelow); $Sheet->Rows("23:23")->Insert(-4121,0); #xlDown is -4121 and that xlFormatFromLeftOrAbove is 0 #Delete a row $Sheet->Rows("22:22")->Delete(); ...
In ui-router a state can hold multiple views, each with his own controller and a template .state('dashboard', { name: 'dashboard', url: '/dashboard', views: { "view1": { templateUrl: "path/to/view1.html", controller: "...

Page 146 of 457