Tutorial by Examples: c

EXTENDED_ARG = 145 # All opcodes greater than this have 2 operands HAVE_ARGUMENT = 90 # All opcodes greater than this have at least 1 operands cmp_op = ('<', '<=', '==', '!=', '>', '>=', 'in', 'not in', 'is', 'is ... # A list of comparator id's. The indecies are used as opera...
Python is a hybrid interpreter. When running a program, it first assembles it into bytecode which can then be run in the Python interpreter (also called a Python virtual machine). The dis module in the standard library can be used to make the Python bytecode human-readable by disassembling classes, ...
The iloc (short for integer location) method allows to select the rows of a dataframe based on their position index. This way one can slice dataframes just like one does with Python's list slicing. df = pd.DataFrame([[11, 22], [33, 44], [55, 66]], index=list("abc")) df # Out: # 0...
[targethost] 192.168.1.1 ansible_user=mrtuovinen ssh_private_key_file=~/.ssh/custom_key
[targethost] 192.168.1.1 ansible_user=mrtuovinen ansible_port=2222
This example creates a new file named "NewFile.txt", then writes "Hello World!" to its body. If the file already exists, CreateFile will fail and no data will be written. See the dwCreationDisposition parameter in the CreateFile documentation if you don't want the function to fa...
Trap expressions don't have to be individual functions or programs, they can be more complex expressions as well. By combining jobs -p and kill, we can kill all spawned child processes of the shell on exit: trap 'jobs -p | xargs kill' EXIT
The typing.TypeVar is a generic type factory. It's primary goal is to serve as a parameter/placeholder for generic function/class/method annotations: import typing T = typing.TypeVar("T") def get_first_element(l: typing.Sequence[T]) -> T: """Gets the first ele...
df = pd.DataFrame({'old_name_1': [1, 2, 3], 'old_name_2': [5, 6, 7]}) print(df) # Output: # old_name_1 old_name_2 # 0 1 5 # 1 2 6 # 2 3 7 To rename one or more columns, pass the old names and new names as a dictionary: df.r...
df = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [7, 8, 9]}) To list the column names in a DataFrame: >>> list(df) ['a', 'b', 'c'] This list comprehension method is especially useful when using the debugger: >>> [c for c in df] ['a', 'b', 'c'] This is the long w...
NuGet version Before you start: make sure your NuGet version is up to date. In Visual Studio, go to Tools > Extensions and Updates, then Updates > Visual Studio Gallery. Check if there is a NuGet Update available and install it. Or, you can uninstall the existing nuget and reinstall it. It w...
In Fortran functions and subroutines need to be explicitly declared as recursive, if they are to call themselves again, directly or indirectly. Thus, a recursive implementation of the Fibonacci series could look like this: recursive function fibonacci(term) result(fibo) integer, intent(in) :: te...
It is possible to detect whether an operator or function can be called on a type. To test if a class has an overload of std::hash, one can do this: #include <functional> // for std::hash #include <type_traits> // for std::false_type and std::true_type #include <utility> // for s...
You can validate any object, even plain ruby. class User include ActiveModel::Validations attr_reader :name, :age def initialize(name, age) @name = name @age = age end validates :name, presence: true validates :age, numericality: { only_integer: true, greater_than...
Swift func createCollectionView() { let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height), collectionViewLayout: layout) collectionView.dataSource = sel...
// MARK: - UICollectionViewDelegateFlowLayout extension ViewController: UICollectionViewDelegateFlowLayout { func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { return ...
As Rails follows the MVC pattern Views are where your "templates" are for your actions. Let's say you have a controller articles_controller.rb. For this controller you would have a folder in views called app/views/articles: app |-- controllers | '-- articles_controller.rb | '-- vie...
struct MetricDistance { var distanceInMeters: Double init(fromCentimeters centimeters: Double) { distanceInMeters = centimeters / 100 } init(fromKilometers kilos: Double) { distanceInMeters = kilos * 1000 } } let myDistance = MetricDistance(fromCentim...
The Number constructor has some built in constants that can be useful Number.MAX_VALUE; // 1.7976931348623157e+308 Number.MAX_SAFE_INTEGER; // 9007199254740991 Number.MIN_VALUE; // 5e-324 Number.MIN_SAFE_INTEGER; // -9007199254740991 Number.EPSILON; // 0.000...
With the use of the extends keyword among classes, all the properties of the superclass (also known as the Parent Class or Base Class) are present in the subclass (also known as the Child Class or Derived Class) public class BaseClass { public void baseMethod(){ System.out.println(&...

Page 134 of 826