Tutorial by Examples

To increase the maximum amount of heap memory used Eclipse, edit the eclipse.ini file located in the Eclipse installation directory. This file specifies options for the startup of Eclipse, such as which JVM to use, and the options for the JVM. Specifically, you need to edit the value of the -Xmx JV...
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...
Using parse_line() of Text::ParseWords: use 5.010; use Text::ParseWords; my $line = q{"a quoted, comma", word1, word2}; my @parsed = parse_line(',', 1, $line); say for @parsed; Output: "a quoted, comma" word1 word2
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...
Who says you cannot throw multiple exceptions in one method. If you are not used to playing around with AggregateExceptions you may be tempted to create your own data-structure to represent many things going wrong. There are of course were another data-structure that is not an exception would be mor...
SkipWhile() is used to exclude elements until first non-match (this might be counter intuitive to most) int[] list = { 42, 42, 6, 6, 6, 42 }; var result = list.SkipWhile(i => i == 42); // Result: 6, 6, 6, 42
You can get list of available commands by following way: >>> python manage.py help If you don't understand any command or looking for optional arguments then you can use -h argument like this >>> python manage.py command_name -h Here command_name will be your desire command...
CSV(Comma Separated Values) is a simple file format used to store tabular data, such as a spreadsheet. This is a minimal example of how to write & read data in Python. Writing data to a CSV file: import csv data = [["Ravi", "9", "550"], ["Joe", "8...
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...
Descriptive statistics (mean, standard deviation, number of observations, minimum, maximum, and quartiles) of numerical columns can be calculated using the .describe() method, which returns a pandas dataframe of descriptive statistics. In [1]: df = pd.DataFrame({'A': [1, 2, 1, 4, 3, 5, 2, 3, 4, 1],...
explode and strstr are simpler methods to get substrings by separators. A string containing several parts of text that are separated by a common character can be split into parts with the explode function. $fruits = "apple,pear,grapefruit,cherry"; print_r(explode(",",$fruits))...
$ 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
Example for continue for i in [series] do command 1 command 2 if (condition) # Condition to jump over command 3 continue # skip to the next value in "series" fi command 3 done Example for break for i in [series] do command 4 if (condi...
Pass an open file object from Python to C extension code. You can convert the file to an integer file descriptor using PyObject_AsFileDescriptor function: PyObject *fobj; int fd = PyObject_AsFileDescriptor(fobj); if (fd < 0){ return NULL; } To convert an integer file descriptor back ...
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 ...

Page 261 of 1336