Tutorial by Examples: an

The idea of bound and unbound methods was removed in Python 3. In Python 3 when you declare a method within a class, you are using a def keyword, thus creating a function object. This is a regular function, and the surrounding class works as its namespace. In the following example we declare method ...
public class TrustLoader { public static void main(String args[]) { try { //Gets the inputstream of a a trust store file under ssl/rpgrenadesClient.jks //This path refers to the ssl folder in the jar file, in a jar file in the same directory ...
A rebase switches the meaning of "ours" and "theirs": git checkout topic git rebase master # rebase topic branch on top of master branch Whatever HEAD's pointing to is "ours" The first thing a rebase does is resetting the HEAD to master; before cherry-picking...
Check whether a string is empty: if str.isEmpty { // do something if the string is empty } // If the string is empty, replace it with a fallback: let result = str.isEmpty ? "fallback string" : str Check whether two strings are equal (in the sense of Unicode canonical equivale...
A Swift String is made of Unicode code points. It can be decomposed and encoded in several different ways. let str = "ที่👌①!" Decomposing Strings A string's characters are Unicode extended grapheme clusters: Array(str.characters) // ["ที่", "👌", "①", ...
The following is an example that displays 5 one-dimensional random walks of 200 steps: y = cumsum(rand(200,5) - 0.5); plot(y) legend('1', '2', '3', '4', '5') title('random walks') In the above code, y is a matrix of 5 columns, each of length 200. Since x is omitted, it defaults to the row n...
import java.awt.FlowLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.SwingUtilities; public class CustomFrame extends JFrame { public CustomFrame(String labelText) { setSize(500...
Node.js can also be used to create command line utilities. The example below reads the first argument from the command line and prints a Hello message. To run this code on an Unix System: Create a new file and paste the code below. The filename is irrelevant. Make this file executable with chmo...
git reset <filePath>
For Alerts since iOS 8, you would use a UIAlertController but for versions before, you would have used a UIAlertView, which is now deprecated. 8.0 var alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create(otherTitle, UIAlertActionStyl...
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...
When testing you PayPal integration on sandbox, you'll need to have sandbox user accounts set up to use to go through the payment flow. Go to https://developer.paypal.com/developer/accounts/, log in using your PayPal account, and click on "Create Account", as below: Enter in the accoun...
man <command> This will show the manual page for the specified command. For example, man ping will show: PING(8) BSD System Manager's Manual PING(8) NAME ping -- send ICMP ECHO_REQUEST packets to network hosts SYNOPSIS ping [-AaCDdfno...
This is how to send an SMS text message from a US number using Twilio's Node.js SDK. First you need to install the Node.js client using: npm install twilio Then, you have to create an account on their website. Once you have an account, you'll need the account SID and auth token that you can fi...
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,...
int a; printf("%d", a); The variable a is an int with automatic storage duration. The example code above is trying to print the value of an uninitialized variable (a was never initialized). Automatic variables which are not initialized have indeterminate values; accessing these can le...
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 ...

Page 14 of 307