Tutorial by Examples

Whenever a value in set in localStorage, a storage event will be dispatched on all other windows from the same origin. This can be used to synchronize state between different pages without reloading or communicating with a server. For example, we can reflect the value of an input element as paragrap...
The sessionStorage object implements the same Storage interface as localStorage. However, instead of being shared with all pages from the same origin, sessionStorage data is stored separately for every window/tab. Stored data persists between pages in that window/tab for as long as it's open, but is...
To clear the storage, simply run localStorage.clear();
Given the following input: aaaaaAlazyZgreeedyAlaaazyZaaaaa We will use two patterns: one greedy: A.*Z, and one lazy: A.*?Z. These patterns yield the following matches: A.*Z yields 1 match: AlazyZgreeedyAlaaazyZ (examples: Regex101, Rubular) A.*?Z yields 2 matches: AlazyZ and AlaaazyZ (exampl...
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); ...
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...
Using the AdvancedRTFEditorKit library you can serialize a DefaultStyledDocument to an RTF string. try { DefaultStyledDocument writeDoc = new DefaultStyledDocument(); writeDoc.insertString(0, "Test string", null); AdvancedRTFEditorKit kit = new AdvancedRTFEditorKit(); ...
git reset <filePath>
This layout uses one floated column to create a two-column layout with no defined widths. In this example the left sidebar is "lazy," in that it only takes up as much space as it needs. Another way to say this is that the left sidebar is "shrink-wrapped." The right content column...
git rev-list --oneline master ^origin/master Git rev-list will list commits in one branch that are not in another branch. It is a great tool when you're trying to figure out if code has been merged into a branch or not. Using the --oneline option will display the title of each commit. The ^ ...
Functions can be declared without parameters or a return value. The only required information is a name (hello in this case). func hello() { print("Hello World") } Call a function with no parameters by writing its name followed by an empty pair of parenthesis. hello() //output...
Functions can take parameters so that their functionality can be modified. Parameters are given as a comma separated list with their types and names defined. func magicNumber(number1: Int) { print("\(number1) Is the magic number") } Note: The \(number1) syntax is basic String I...
Functions can return values by specifying the type after the list of parameters. func findHypotenuse(a: Double, b: Double) -> Double { return sqrt((a * a) + (b * b)) } let c = findHypotenuse(3, b: 5) //c = 5.830951894845301 Functions can also return multiple values using tuples. f...
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...
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...
In iOS 8 Apple introduced the self sizing cell. Layout your UITableViewCells with Autolayout explicitly and UITableView takes care of the rest for you. Row height is calculated automatically, by default rowHeight value is UITableViewAutomaticDimension. UITableView property estimatedRowHeight is use...
We can make an AJAX request to Stack Exchange's API to retrieve a list of the top JavaScript questions for the month, then present them as a list of links. If the request fails or the returns an API error, our promise error handling displays the error instead. 6 View live results on HyperWeb. c...
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...

Page 53 of 1336