Tutorial by Examples

It is perfectly fine to use a package name other than the folder name. If we do so, we still have to import the package based on the directory structure, but after the import we have to refer to it by the name we used in the package clause. For example, if you have a folder $GOPATH/src/mypck, and i...
This is the advanced approach with example class FundsController < ApplicationController def index @funds = Fund.all_funds(current_user) end def show @fund = Fund.find(params[:id]) respond_to do |format| format.html format.pdf do pdf = FundsPdf....
You need to add Gem and PDF MIME:Type inside mime_types.rb as we need to notify rails about PDF mime type. After that we can generate Pdf with Prawn in following basic ways This is the basic assignment pdf = Prawn::Document.new pdf.text "Hello World" pdf.render_file "assignment.p...
Sometimes gotoAndStop() is called in the middle of the code that refers some frame-based properties. But, right after the frame is changed all links to properties that existed on the current frame are invalidated, so any processing that involves them should be immediately terminated. There are two ...
A lambda can only have a trailing return type; the leading return type syntax is not applicable to lambdas. Note that in many cases it is not necessary to specify a return type for a lambda at all. struct Base {}; struct Derived1 : Base {}; struct Derived2 : Base {}; auto lambda = [](bool b) -&g...
You can create partial files that contain smaller snippets of your stylesheets. This allows you to modularize your CSS and allows for better structure of your stylesheets. A partial is a Sass file named with a leading underscore, i.e: _partial.scss. The underscore lets Sass know that the specific fi...
Iterators utilize a form of the for loop known as the generic for loop. The generic form of the for loop uses three parameters: An iterator function that gets called when the next value is needed. It receives both the invariant state and control variable as parameters. Returning nil signals term...
The Lua standard library provides two iterator functions that can be used with a for loop to traverse key-value pairs within tables. To iterate over a sequence table we can use the library function ipairs. for index, value in ipairs {'a', 'b', 'c', 'd', 'e'} do print(index, value) --> 1 a, ...
Both pairs and ipairs represent stateless iterators. A stateless iterator uses only the generic for loop's control variable and invariant state to compute the iteration value. Pairs Iterator We can implement the stateless pairs iterator using the next function. -- generator function which initial...
Stateful iterators carry some additional information about the current state of the iterator. Using Tables The addition state can be packed into the generic for loop's invariant state. local function chars_iter(t, i) local i = i + 1 if i <= t.len then return i, t.s:sub(i, i)...
The C programming language allows multidimensional arrays. Here is the general form of a multidimensional array declaration − type name[size1][size2]...[sizeN]; For example, the following declaration creates a three dimensional (5 x 10 x 4) integer array: int arr[5][10][4]; Two-dimensional A...
Multicasting is a type of Datagram Socket. Unlike regular Datagrams, Multicasting doesn't handle each client individually instead it sends it out to one IP Address and all subscribed clients will get the message. Example code for a server side: public class Server { private DatagramSo...
Step by Step Guide :- Step 1 :- Set constraint to UIView Leading. 2) Top. 3) Trailing. (From mainview) Step 2 :- Set constrain to Label 1 Leading 2) Top 3) Trailing (From it's superview) Step 3 :- Set constraint to Label 2 Leading 2) Top 3) Trailing (From its superview) Step...
Python 2.x2.7 In Python 2, if you want to define a class boolean value by yourself, you need to implement the __nonzero__ method on your class. The value is True by default. class MyClass: def __nonzero__(self): return False my_instance = MyClass() print bool(MyClass) # Tru...
import pandas as pd generate random DF df = pd.DataFrame(np.random.randint(0,10,size=(10, 3)), columns=list('ABC')) In [16]: print(df) A B C 0 4 1 4 1 0 2 0 2 7 8 8 3 2 1 9 4 7 3 8 5 4 0 7 6 1 5 5 7 6 7 8 8 6 7 3 9 6 4 5 select rows where value...
Example A var i,a,b,len; a = {x:0,y:0} function test(){ // return object created each call return {x:0,y:0}; } function test1(a){ // return object supplied a.x=0; a.y=0; return a; } for(i = 0; i < 100; i ++){ // Loop A b = test(); } for(i = 0; i < 100; ...
Without a try catch block, undefined functions will throw errors and stop execution: undefinedFunction("This will not get executed"); console.log("I will never run because of the uncaught error!"); Will throw an error and not run the second line: // Uncaught ReferenceError:...
Think of the mediator pattern as the flight control tower that controls planes in the air: it directs this plane to land now, the second to wait, and the third to take off, etc. However no plane is ever allowed to talk to its peers. This is how mediator works, it works as a communication hub among ...
It is also possible to pass your custom object to other activities using the Bundle class. There are two ways: Serializable interface—for Java and Android Parcelable interface—memory efficient, only for Android (recommended) Parcelable Parcelable processing is much faster than serializable....
.Rprofile is a file containing R code that is executed when you launch R from the directory containing the .Rprofile file. The similarly named Rprofile.site, located in R's home directory, is executed by default every time you load R from any directory. Rprofile.site and to a greater extend .Rprofil...

Page 562 of 1336