Tutorial by Examples: com

A commit is probably the object type most familiar to git users, as it's what they are used to creating with the git commit commands. However, the commit does not directly contain any changed files or data. Rather, it contains mostly metadata and pointers to other objects which contain the actual c...
The git commit command does a few things: Create blobs and trees to represent your project directory - stored in .git/objects Creates a new commit object with your author information, commit message, and the root tree from step 1 - also stored in .git/objects Updates the HEAD ref in .git/HEAD t...
Any array can be quickly decomposed by assigning its elements into multiple variables. A simple example: arr = [1, 2, 3] # --- a = arr[0] b = arr[1] c = arr[2] # --- or, the same a, b, c = arr Preceding a variable with the splat operator (*) puts into it an array of all the elements that h...
The following compares two files with diff using process substitution instead of creating temporary files. diff <(curl http://www.example.com/page1) <(curl http://www.example.com/page2)
This feeds a while loop with the output of a grep command: while IFS=":" read -r user _ do # "$user" holds the username in /etc/passwd done < <(grep "hello" /etc/passwd)
1i # => (0+1i) 1.to_c # => (1+0i) rectangular = Complex(2, 3) # => (2+3i) polar = Complex('1@2') # => (-0.4161468365471424+0.9092974268256817i) polar.rectangular # => [-0.4161468365471424, 0.9092974268256817] rectangular.polar # => [3.605551275463989, 0.9827937232...
Consider the following C# code Expression<Func<int, int>> expression = a => a + 1; Because the C# compiler sees that the lambda expression is assigned to an Expression type rather than a delegate type it generates an expression tree roughly equivalent to this code ParameterExpres...
wikipedia definition: Command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time UML diagram from dofactory: Basic components and workflow: Command declares an interface for abst...
(This pitfall applies equally to all primitive wrapper types, but we will illustrate it for Integer and int.) When working with Integer objects, it is tempting to use == to compare values, because that is what you would do with int values. And in some cases this will seem to work: Integer int1_1 =...
1. Fix your contexts: Try using the appropriate context: For example since a Toast can be seen in many activities instead of in just one, use getApplicationContext() for toasts, and since services can keep running even though an activity has ended start a service with: Intent myService = new Inten...
If you need to know whether a value's type extends or implements a given type, but you don't want to actually cast it as that type, you can use the is operator. if(value is int) { Console.WriteLine(value + "is an int"); }
Django comes with a number of builtin management commands, using python manage.py [command] or, when manage.py has +x (executable) rights simply ./manage.py [command] . The following are some of the most frequently used: Get a list of all available commands ./manage.py help Run your Django ser...
The cmath module is similar to the math module, but defines functions appropriately for the complex plane. First of all, complex numbers are a numeric type that is part of the Python language itself rather than being provided by a library class. Thus we don't need to import cmath for ordinary arith...
To run a command in a shell, in which you required buffered output (i.e. it is not a stream), use child_process.exec. For example, if you wanted to run the command cat *.js file | wc -l, with no options, that would look like this: const exec = require('child_process').exec; exec('cat *.js file | w...
A presentation of a select; usually similar to a textbox where users can type ahead to select an option, or type to enter arbitrary text as a new item in the list. <input type="text" role="combobox" aria-expanded="false"> Typically, you would use JavaScript to...
A supporting section of the document, designed to be complementary to the main content at a similar level in the DOM hierarchy, but remains meaningful when separated from the main content. <div role="complementary"> <h2>More Articles</h2> <ul> <!-- ...
Suppose you have many changes in one or more files but from each file you only want to commit some of the changes, you can select the desired changes using: git add -p or git add -p [file] Each of your changes will be displayed individually, and for each change you will be prompted to choose...
When a React component is created, a number of functions are called: If you are using React.createClass (ES5), 5 user defined functions are called If you are using class Component extends React.Component (ES6), 3 user defined functions are called getDefaultProps() (ES5 only) This is the firs...
componentWillReceiveProps(nextProps) This is the first function called on properties changes. When component's properties change, React will call this function with the new properties. You can access to the old props with this.props and to the new props with nextProps. With these variables, you c...
componentWillUnmount() This method is called before a component is unmounted from the DOM. It is a good place to perform cleaning operations like: Removing event listeners. Clearing timers. Stopping sockets. Cleaning up redux states. componentWillUnmount(){ ... } An example of remo...

Page 15 of 65