Tutorial by Examples: and

Alamofire.request(.GET, "https://httpbin.org/get") .validate() .responseString { response in print("Response String: \(response.result.value)") } .responseJSON { response in print("Response JSON: \(response.result.value)") ...
If the formatting (white space, new lines, indentation) of the code matters, use the pre element in combination with the code element: <pre> <code> x = 42 if x == 42: print "x is … … 42" </code> </pre> You still have to esc...
Optional Parameters In TypeScript, every parameter is assumed to be required by the function. You can add a ? at the end of a parameter name to set it as optional. For example, the lastName parameter of this function is optional: function buildName(firstName: string, lastName?: string) { // ...
You can customize your theme’s color palette. Using framework APIs 5.0 <style name="AppTheme" parent="Theme.Material"> <item name="android:colorPrimary">@color/primary</item> <item name="android:colorPrimaryDark">@color/pri...
This tutorial explains how to download Image using AsyncTask in Android. The example below download image while showing progress bar while during download. Understanding Android AsyncTask Async task enables you to implement MultiThreading without get Hands dirty into threads. AsyncTask enables pro...
MediaPlayer class can be used to control playback of audio/video files and streams. Creation of MediaPlayer object can be of three types: Media from local resource MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.resource); mediaPlayer.start(); // no need to call prepare(); create...
Inline style You can manipulate the inline CSS style of an HTML element by simply reading or editing its style property. Assume the following element: <div id="element_id" style="color:blue;width:200px;">abc</div> With this JavaScript applied: var element = doc...
Immutable types are types that when changed create a new version of the object in memory, rather than changing the existing object in memory. The simplest example of this is the built-in string type. Taking the following code, that appends " world" onto the word "Hello" string ...
package { import flash.display.Sprite; import flash.events.Event; public class Viewport extends Sprite { /** Constructor */ public function Viewport() { super(); // Listen for added to stage event addEventListener(Event.ADDED_TO_STAGE, addedToStageHandle...
# load the library library(ggplot2) # create a blank canvas g <- ggplot(data = diamonds) g + geom_bar(aes(x = cut, fill = cut)) + scale_fill_discrete(guide = guide_legend(title = "CUT", keywidth = 2, ...
While in insert mode, press <C-o> to temporarily leave insert mode and execute a one-off normal command. Example <C-o>2w jumps to the second word to the left and returns to insert mode. Note: Repeating with . will only repeat the actions from returning to insert mode This allows for ...
Assuming we have an array myArray: var value:* = myArray[int(Math.random() * myArray.length)]; Note we use int to cast the result of Math.random() to an int because values like 2.4539543 would not be a valid array index.
First define the circle radius and its center: var radius:Number = 100; var center:Point = new Point(35, 70); Then generate a random angle in radians from the center: var angle:Number = Math.random() * Math.PI * 2; Then generate an effective radius of the returned point, so it'll be inside ...
function randomAngleRadians():Number { return Math.random() * Math.PI * 2; } Example outputs: 5.490068569213088 3.1984284719180205 4.581117863808207
To get any random color: function randomColor():uint { return Math.random() * 0xFFFFFF; } If you need more control over the red, green and blue channels: var r:uint = Math.random() * 0xFF; var g:uint = Math.random() * 0xFF; var b:uint = Math.random() * 0xFF; var color:uint = r <&...
This is the built-in way to deal with "exceptions" without relying on third party libraries like Try::Tiny. my $ret; eval { $ret = some_function_that_might_die(); 1; } or do { my $eval_error = $@ || "Zombie error!"; handle_error($eval_error); }; # use $ret ...
std::sort, found in the standard library header algorithm, is a standard library algorithm for sorting a range of values, defined by a pair of iterators. std::sort takes as the last parameter a functor used to compare two values; this is how it determines the order. Note that std::sort is not stable...
var alphabet:Vector.<String> = new <String>[ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", &q...
The Flex compiler (mxmlc) is one of the most important parts of the Flex SDK. You can edit AS3 code in any text editor you like. Create a main class file that extends from DisplayObject. You can trigger builds at the command line as follows: mxmlc -source-path="." -default-size [width in...
C++11 Deriving a class may be forbidden with final specifier. Let's declare a final class: class A final { }; Now any attempt to subclass it will cause a compilation error: // Compilation error: cannot derive from final class: class B : public A { }; Final class may appear anywhere in cl...

Page 26 of 153