Tutorial by Examples: er

class File(): def __init__(self, filename, mode): self.filename = filename self.mode = mode def __enter__(self): self.open_file = open(self.filename, self.mode) return self.open_file def __exit__(self, *args): self.open_file.close() ...
OnClick Listener: @OnClick(R.id.login) public void login(View view) { // Additional logic } All arguments to the listener method are optional: @OnClick(R.id.login) public void login() { // Additional logic } Specific type will be automatically casted: @OnClick(R.id.submit) publi...
Fragments have a different view lifecycle than activities. When binding a fragment in onCreateView, set the views to null in onDestroyView. Butter Knife returns an Unbinder instance when you call bind to do this for you. Call its unbind method in the appropriate lifecycle callback. An example: pub...
You need to set who you are *before* creating any commit. That will allow commits to have the right author name and email associated to them. It has nothing to do with authentication when pushing to a remote repository (e.g. when pushing to a remote repository using your GitHub, BitBucket, or Gi...
Swallowing Exceptions One should always re-throw exception in the following way: try { ... } catch (Exception ex) { ... throw; } Re-throwing an exception like below will obfuscate the original exception and will lose the original stack trace. One should never do this! The st...
Similar to the built-in function zip(), itertools.zip_longest will continue iterating beyond the end of the shorter of two iterables. from itertools import zip_longest a = [i for i in range(5)] # Length is 5 b = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] # Length is 7 for i in zip_longest(a, b): x...
Visual Basic has Left, Right, and Mid functions that returns characters from the Left, Right, and Middle of a string. These methods does not exist in C#, but can be implemented with Substring(). They can be implemented as an extension methods like the following: public static class StringExtens...
$ react-native -v Example Output react-native-cli: 0.2.0 react-native: n/a - not inside a React Native project directory //Output from different folder react-native: react-native: 0.30.0 // Output from the react native project directory
In the app folder find package.json and modify the following line to include the latest version, save the file and close. "react-native": "0.32.0" In terminal: $ npm install Followed by $ react-native upgrade
You can also pattern match on Elixir Data Structures such as Lists. Lists Matching on a list is quite simple. [head | tail] = [1,2,3,4,5] # head == 1 # tail == [2,3,4,5] This works by matching the first (or more) elements in the list to the left hand side of the | (pipe) and the rest of the ...
The BorderPane is separated into five different areas. The border areas (Top, Right, Bottom, Left) have preferred sized based on their content. By default they will only take what they need, while the Center area will take any remaining space. When the border areas are empty, they do not take up ...
When Intel defined the original 8086, it was a 16-bit processor with a 20-bit address bus (see below). They defined 8 general-purpose 16-bit registers - but gave them specific roles for certain instructions: AX The Accumulator register. Many opcodes either assumed this register, or were faster i...
When Intel produced the 80386, they upgraded from a 16-bit processor to a 32-bit one. 32-bit processing means two things: both the data being manipulated was 32-bit, and the memory addresses being accessed were 32-bit. To do this, but still remain compatible with their earlier processors, they intro...
The first four 16-bit registers could have their upper- and lower-half bytes accessed directly as their own registers: AH and AL are the High and Low halves of the AX register. BH and BL are the High and Low halves of the BX register. CH and CL are the High and Low halves of the CX register. D...
Segmentation When Intel was designing the original 8086, there were already a number of 8-bit processors that had 16-bit capabilities - but they wanted to produce a true 16-bit processor. They also wanted to produce something better and more capable than what was already out there, so they wanted t...
AMD is a processor manufacturer that had licensed the design of the 80386 from Intel to produce compatible - but competing - versions. They made internal changes to the design to improve throughput or other enhancements to the design, while still being able to execute the same programs. To one-up I...
When the x86 Arithmetic Logic Unit (ALU) performs operations like NOT and ADD, it flags the results of these operations ("became zero", "overflowed", "became negative") in a special 16-bit FLAGS register. 32-bit processors upgraded this to 32 bits and called it EFLAGS, ...
(defun foobar (x y) (format t "X: ~s~@ Y: ~s~%" x y)) (foobar 10 20) ; X: 10 ; Y: 20 ;=> NIL
Optional parameters can be specified after required parameters, by using &OPTIONAL keyword. There may be multiple optional parameters after it. (defun foobar (x y &optional z) (format t "X (~s) and Y (~s) are required.~@ Z (~s) is optional.~%" x y z)) ...
Global named functions are defined with DEFUN. (defun foobar () "Optional documentation string. Can contain line breaks. Must be at the beginning of the function body. Some will format the docstring so that lines are indented to match the first line, although the built-in DESCRIBE-func...

Page 84 of 417