Tutorial by Examples: at

Supplying pow() with 3 arguments pow(a, b, c) evaluates the modular exponentiation ab mod c: pow(3, 4, 17) # 13 # equivalent unoptimized expression: 3 ** 4 % 17 # 13 # steps: 3 ** 4 # 81 81 % 17 # 13 For built-in types using modular exponentiation is only possible...
Concatenate strings with the + operator to produce a new string: let name = "John" let surname = "Appleseed" let fullName = name + " " + surname // fullName is "John Appleseed" Append to a mutable string using the += compound assignment operator, or usi...
You have up to 5 sources for git configuration: 6 files: %ALLUSERSPROFILE%\Git\Config (Windows only) (system) <git>/etc/gitconfig, with <git> being the git installation path. (on Windows, it is <git>\mingw64\etc\gitconfig) (system) $XDG_CONFIG_HOME/git/config (Linux/Mac on...
Using the strtotime() function combined with date() you can parse different English text descriptions to dates: // Gets the current date echo date("m/d/Y", strtotime("now")), "\n"; // prints the current date echo date("m/d/Y", strtotime("10 September 2...
import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; public class FrameCreator { public static void main(String args[]) { //All Swing actions should be run on the Event Dispatch Thread (EDT) //Calling SwingUtilities.invokeLater ma...
import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; public class CustomFrame extends JFrame { private static CustomFrame statFrame; public CustomFrame(String labelText) { setSize(500, 500); ...
git reset <filePath>
To pass data from the current view controller to the next new view controller (not a previous view controller) using segues, first create a segue with an identifier in the relevant storyboard. Override your current view controller's prepareForSegue method. Inside the method check for the segue you j...
A data.frame is a special kind of list: it is rectangular. Each element (column) of the list has same length, and where each row has a "row name". Each column has its own class, but the class of one column can be different from the class of another column (unlike a matrix, where all elemen...
In order to begin building with PayPal APIs, you have to create an application to obtain a client ID and secret. Go to https://developer.paypal.com/developer/applications/, sign in, and click on "Create App", as shown below: Next, enter an application name, select the sandbox testing a...
$url = "https://api.dropboxapi.com/2/users/get_current_account" $req = [System.Net.HttpWebRequest]::Create($url) $req.headers["Authorization"] = "Bearer <ACCESS_TOKEN>" $req.Method = "POST" $res = $req.GetResponse() Write-Host "Response Sta...
Static method can be inherited similar to normal methods, however unlike normal methods it is impossible to create "abstract" methods in order to force static method overriding. Writing a method with the same signature as a static method in a super class appears to be a form of overriding,...
Consider the below list comprehension: >>> def f(x): ... import time ... time.sleep(.1) # Simulate expensive function ... return x**2 >>> [f(x) for x in range(1000) if f(x) > 10] [16, 25, 36, ...] This results in two calls to f(x) for 1,000 values of...
To create a new Date object use the Date() constructor: with no arguments Date() creates a Date instance containing the current time (up to milliseconds) and date. with one integer argument Date(m) creates a Date instance containing the time and date corresponding to the Epoch time (...
The !important declaration is used to override the usual specificity in a style sheet by giving a higher priority to a rule. Its usage is: property : value !important; #mydiv { font-weight: bold !important; /* This property won't be overridden by the ...
Data Manipulation Language (DML for short) includes operations such as INSERT, UPDATE and DELETE: -- Create a table HelloWorld CREATE TABLE HelloWorld ( Id INT IDENTITY, Description VARCHAR(1000) ) -- DML Operation INSERT, inserting a row into the table INSERT INTO HelloWorld (D...
require Exporter; This will ensure that the Exporter module is loaded at runtime if it hasn't already been imported. (See also: perldoc -f require.) N.B.: Most users should use modules rather than require them. Unlike use, require does not call the module's import method and is executed at runti...
To conditionally include a block of code, the preprocessor has several directives (e.g #if, #ifdef, #else, #endif, etc). /* Defines a conditional `printf` macro, which only prints if `DEBUG` * has been defined */ #ifdef DEBUG #define DLOG(x) (printf(x)) #else #define DLOG(x) #endif Norm...
The searched CASE returns results when a boolean expression is TRUE. (This differs from the simple case, which can only check for equivalency with an input.) SELECT Id, ItemId, Price, CASE WHEN Price < 10 THEN 'CHEAP' WHEN Price < 20 THEN 'AFFORDABLE' ELSE 'EXPENSIVE' E...
Templating can also be applied to functions (as well as the more traditional structures) with the same effect. // 'T' stands for the unknown type // Both of our arguments will be of the same type. template<typename T> void printSum(T add1, T add2) { std::cout << (add1 + add2) &...

Page 14 of 442