Tutorial by Examples: sin

Assuming the route: resources :users, only: [:index] And the controller: class UsersController < ApplicationController def index respond_to do |format| format.html { render } end end end The view app/users/index.html.erb will be rendered. If the view is: Hello &lt...
This function runs an AJAX call using GET allowing us to send parameters (object) to a file (string) and launch a callback (function) when the request has been ended. function ajax(file, params, callback) { var url = file + '?'; // loop through object and assemble the url var notFirst ...
To separate a URL into its individual components, use parse_url(): $url = 'http://www.example.com/page?foo=1&bar=baz#anchor'; $parts = parse_url($url); After executing the above, the contents of $parts would be: Array ( [scheme] => http [host] => www.example.com [path...
You can use curly braces to interpolate expressions into string literals: def f(x: String) = x + x val a = "A" s"${a}" // "A" s"${f(a)}" // "AA" Without the braces, scala would only interpolate the identifier after the $ (in this case f...
If you want to handle such scenario just add an if/else statement. if ( have_posts() ) : while ( have_posts() ) : the_post(); var_dump( $post ); endwhile; else : __('This Query does not have any results'); endif;
Since lambda functions are values themselves, you store them in collections, pass them to functions, etc like you would with other values. // This function takes two integers and a function that performs some operation on the two arguments fn apply_function<T>(a: i32, b: i32, func: T) -> ...
// Include sequence containers #include <vector> #include <deque> #include <list> // Insert sorting algorithm #include <algorithm> class Base { public: // Constructor that set variable to the value of v Base(int v): variable(v) { } i...
C++11 // Include sequence containers #include <vector> #include <deque> #include <list> #include <array> #include <forward_list> // Include sorting algorithm #include <algorithm> class Base { public: // Constructor that set variable to the va...
It is undefined behavior to access an index that is out of bounds for an array (or standard library container for that matter, as they are all implemented using a raw array): int array[] = {1, 2, 3, 4, 5}; array[5] = 0; // Undefined behavior It is allowed to have a pointer pointing to the en...
In Swift, structures use a simple “dot syntax” to access their members. For example: struct DeliveryRange { var range: Double let center: Location } let storeLocation = Location(latitude: 44.9871, longitude: -93.2758) var pizzaRange = DeliveryRange(range: 200...
Use this option if you don't need an Application subclass. This is the simplest option, but this way you can't provide your own Application subclass. If an Application subclass is needed, you will have to switch to one of the other options to do so. For this option, simply specify the fully-quali...
Using a Template Engine The following code will setup Jade as template engine. (Note: Jade has been renamed to pug as of December 2015.) const express = require('express'); //Imports the express module const app = express(); //Creates an instance of the express module const PORT = 3000; //Ra...
If you want to parse a String to enum with Gson: {"status" : "open"} public enum Status { @SerializedName("open") OPEN, @SerializedName("waiting") WAITING, @SerializedName("confirm") CONFIRM, @SerializedName(&...
SELECT s.name + '.' + t.NAME AS TableName, SUM(a.used_pages)*8 AS 'TableSizeKB' --a page in SQL Server is 8kb FROM sys.tables t JOIN sys.schemas s on t.schema_id = s.schema_id LEFT JOIN sys.indexes i ON t.OBJECT_ID = i.object_id LEFT JOIN sys.partitions p ON i.object_id = ...
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...
Since all lifecycle hooks in Vue.js are just functions, you can place any of them directly in the instance declaraction. //JS new Vue({ el: '#example', data: { ... }, methods: { ... }, //LIFECYCLE HOOK HANDLING created: function() { ...
The ROUND function rounds a value. The number of decimal places to round to is specified by a positive value in the num_digits parameter. A negative value for the num_digits will round the integer portion of the value left of the decimal point, e.g. to the nearest 10 (for -1) or to the nearest 1000 ...
The excel formula TRUNC is used to truncate a number to a given number of decimal places, specified by the optional num_digits parameter. If this parameter is defined as a negative value it will truncate the integer portion of the value. If the parameter is omitted then the default value is 0 which ...
The Excel function MROUND is used to round a number to an interval other than a power of 10. These examples show MROUND to the nearest quarter and to the nearest even number. Starting withMROUND(b,0.25)MROUND(b,2)23.9319521124.00242.7931353882.75221.9390306422.002213.7419373913.751416.7704741216.7...
A dotfile is a file whose names begin with a .. These are normally hidden by ls and not listed unless requested. For example the following output of ls: $ ls bin pki The -a or --all option will list all files, including dotfiles. $ ls -a . .ansible .bash_logout .bashrc .lesshst ...

Page 26 of 161