Tutorial by Examples: f

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...
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 ...
if true do "Will be seen since condition is true." end if false do "Won't be seen since condition is false." else "Will be seen. end unless false do "Will be seen." end unless true do "Won't be seen." else ...
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, ...
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...
Functions always establish a block around the body. This block has the same name as the function name. This means you can use RETURN-FROM with this block name to return from the function and return values. You should avoid returning early whenever possible. (defun foobar (x y) (when (oddp x) ...
The normal orElse method takes an Object, so you might wonder why there is an option to provide a Supplier here (the orElseGet method). Consider: String value = "something"; return Optional.ofNullable(value) .orElse(getValueThatIsHardToCalculate()); // returns "some...
A static member function is just like an ordinary C/C++ function, except with scope: It is inside a class, so it needs its name decorated with the class name; It has accessibility, with public, protected or private. So, if you have access to the static member function and decorate it correctl...
To access a member function of a class, you need to have a "handle" to the particular instance, as either the instance itself, or a pointer or reference to it. Given a class instance, you can point to various of its members with a pointer-to-member, IF you get the syntax correct! Of course...
sp_who2 This procedure can be used to find information on current SQL server sessions. Since it is a procedure, it's often helpful to store the results into a temporary table or table variable so one can order, filter, and transform the results as needed. The below can be used for a queryable v...
string nullString = null; string emptyString = ""; string whitespaceString = " "; string tabString = "\t"; string newlineString = "\n"; string nonEmptyString = "abc123"; bool result; result = String.IsNullOrEmpty(nullString); ...
Declaring a generic interface interface IResult<T> { wasSuccessfull: boolean; error: T; } var result: IResult<string> = .... var error: string = result.error; Generic interface with multiple type parameters interface IRunnable<T, U> { run(input: T): U; } ...
In interfaces: interface IRunner { runSafe<T extends IRunnable>(runnable: T): void; } In classes: class Runner implements IRunner { public runSafe<T extends IRunnable>(runnable: T): void { try { runnable.run(); } catch(e) { } ...
Create generic class instance: var stringRunnable = new Runnable<string>(); Run generic function: function runSafe<T extends Runnable<U>, U>(runnable: T); // Specify the generic types: runSafe<Runnable<string>, string>(stringRunnable); // Let typescript figu...
Using the mmap module allows the user to randomly access locations in a file by mapping the file into memory. This is an alternative to using normal file operations. import mmap with open('filename.ext', 'r') as fd: # 0: map the whole file mm = mmap.mmap(fd.fileno(), 0) # print ...
If you are familiar with jQuery and Sizzle syntax, d3 selections should not be much different. d3 mimics the W3C Selectors API to make interacting with elements easier. For a basic example, to select all <p> and add a change to each of them: d3.selectAll('p') .attr('class','textClass') ...
The lubridate package provides convenient functions to format date and datetime objects from character strings. The functions are permutations of LetterElement to parseBase R equivalentyyear%y, %Ym (with y and d)month%m, %b, %h, %Bdday%d, %ehhour%H, %I%pm (with h and s)minute%Msseconds%S e.g. ymd(...
$this->helper('customer/data')->getForgotPasswordUrl(); OR Mage::helper('customer/data')->getForgotPasswordUrl();
The easiest way to get started with Gremlin is to install the Gremlin Console. The Gremlin Console is a REPL that allows immediate feedback on the results of Gremlin traversals. As a prerequisite, Java 8 is required for the Gremlin Console to run. Ensure that it is installed prior to moving forward...
return http://www.example.com/skin/frontend/{interface}/{theme}/images/my-image.jpg

Page 85 of 457