Tutorial by Examples: st

This example shows how to mock out a function call that is irrelevant to our unit test, and then use the defer statement to re-assign the mocked function call back to its original function. var validate = validateDTD // ParseXML parses b for XML elements and values, and returns them as a map of ...
1.7+ Timing out an HTTP request with a context can be accomplished with only the standard library (not the subrepos) in 1.7+: import ( "context" "net/http" "time" ) req, err := http.NewRequest("GET", `https://example.net`, nil) ctx, _ := ...
Use Dojo from CDN Load Dojo through <script> tags in your HTML page pointing to Google CDN. Example: <script src="//ajax.googleapis.com/ajax/libs/dojo/1.11.2/dojo/dojo.js"></script> Install Dojo with Bower Type the following command in your project directory: bowe...
Mage::app()->getStores(); Returns an array of Mage_Core_Model_Store models.
To get started quickly with Express, you can use the Express generator which will create an application skeleton for you. First, install it globally with npm: npm install express-generator -g You may need to put sudo before this command if you get a "permission denied" error. Once th...
This operator checks whether the object is of a particular class/interface type. instanceof operator is written as: ( Object reference variable ) instanceof (class/interface type) Example: public class Test { public static void main(String args[]){ String name = "Buyya";...
First, instantiate a Toast object with one of the MakeText() methods. This method takes three parameters: the application Context, the text message, and the duration for the toast. It returns a properly initialized Toast object. You can display the toast notification with Show(), as shown in the fol...
The R-Logo is a multilayer raster file (red, green, blue) library(raster) r <- stack("C:/Program Files/R/R-3.2.3/doc/html/logo.jpg") plot(r) The individual layers of the RasterStack object can be adressed by [[. plot(r[[1]])
Behavior Driven Development (BDD) testing style revolves around "given", "when" and "then" stages in tests. However, classical Mockito uses "when" word for "given" phase, and does not include other natural language constructions that can encompass B...
In this example our project name is "helloworld" which was created with stack new helloworld simple First we have to build the project with stack build and then we can run it with stack exec helloworld-exe
Consider the case of creating a nested list structure by multiplying: li = [[]] * 3 print(li) # Out: [[], [], []] At first glance we would think we have a list of containing 3 different nested lists. Let's try to append 1 to the first one: li[0].append(1) print(li) # Out: [[1], [1], [1]] ...
iex> [1, 2, 3] -- [1, 3] [2] -- removes the first occurrence of an item on the left list for each item on the right.
Use in operator to check if an element is a member of a list. iex> 2 in [1, 2, 3] true iex> "bob" in [1, 2, 3] false
The Kotlin Standard Library also provides numerous useful functions to iteratively work upon collections. For example, the map function can be used to transform a list of items. val numbers = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 0) val numberStrings = numbers.map { "Number $it" } One of...
Use Conditionals via (syntax is in [brackets]): when [when:] Task: - name: run if operating system is debian command: echo "I am a Debian Computer" when: ansible_os_family == "Debian" loops [with_items:] loops [with_dicts:] Custom Facts [ wh...
Common use when: ansible_os_family == "CentOS" when: ansible_os_family == "Redhat" when: ansible_os_family == "Darwin" when: ansible_os_family == "Debian" when: ansible_os_family == "Windows" All Lists based on discuss here http://comments...
iText for Java Importing the iText jars from the Central Maven Repository is the best way to install iText 7. These simple videos explain how to do this using different IDEs: How to import iText 7 in Eclipse to create a Hello World PDF? How to import iText 7 in Netbeans to create a Hello World ...
1. Add Devise Gem Open up your Gemfile and add this line gem 'devise' Then run; bundle install 2. Set up devise in your app Run the following command in the terminal rails g devise:install 3. Configure Devise Ensure you have defined default url options in your environments files. Open...
In order to ssh into a server your identity's public key has to be added to the list of trusted keys. Most commonly this is done per-user: ssh-copy-id -i ~/.ssh/<identity>.pub <user>@<hostname> Which can be also done manually: cat ~/.ssh/<identity>.pub | ssh <user>...
Step 1: In Xcode: File -> New -> File -> Resource -> GPX File -> Next -> Give the GPX file a name(It's Taipei in this example) -> Create Step 2: Edit the GPX file <?xml version="1.0"?> <gpx version="1.1" creator="Xcode"> <wpt ...

Page 129 of 369