Tutorial by Examples: sin

You are right in the middle of working on a new feature, and your boss comes in demanding that you fix something immediately. You may typically want use git stash to store your changes away temporarily. However, at this point your working tree is in a state of disarray (with new, moved, and removed ...
Note: this is not very efficient due to the nature of List (see Remarks below). It will be better to construct the list the "right" way from the beginning than to construct it and then reverse it. > List.reverse [1,3,5,7,9] [9,7,5,3,1] : List number
sample on price increases: UPDATE ItemPrice SET Price = Price * CASE ItemId WHEN 1 THEN 1.05 WHEN 2 THEN 1.10 WHEN 3 THEN 1.15 ELSE 1.00 END
Sometimes we need to make a lot of POST requests to one or many different endpoints. To deal with this scenario, we can use multi_curl. First of all, we create how many requests as needed exactly in the same way of the simple example and put them in an array. We use the curl_multi_init and add eac...
To create a XML using DOMDocument,basically, we need to create all the tags and attributes using the createElement() and createAttribute() methods and them create the XML structure with the appendChild(). The example below includes tags, attributes, a CDATA section and a different namespace for the...
Following the 'Form Request Validation' example, the same Request Class can be used for POST, PUT, PATCH so you do not have to create another class using the same/similar validations. This comes in handy if you have attributes in your table that are unique. /** * Get the validation rules that a...
In PCRE, matched groups used for backreferences before a recursion are kept in the recursion. But after the recursion they all reset to what they were before entering it. In other words, matched groups in the recursion are all forgotten. For example: (?J)(?(DEFINE)(\g{a}(?<a>b)\g{a}))(?<a...
public partial class Form1 : Form { Timer myTimer = new Timer(); int timeLeft = 10; public Form1() { InitializeComponent(); //set properties for the Timer myTimer.Interval = 1000; myTimer.Enabled = tru...
This will only install PHP. If you wish to serve a PHP file to the web you will also need to install a web-server such as Apache, Nginx, or use PHP's built in web-server (php version 5.4+). If you are in a Ubuntu version below 16.04 and want to use PHP 7 anyway, you can add Ondrej's PPA repo...
class MyDataObject extends DataObject { private static $db = array( 'Name' => 'Varchar' ); private static $has_one = array( 'OtherDataObject' => 'OtherDataObject' ); private static $summary_fields = array( 'Name', 'OtherDat...
You can think of an OperationQueue as a line of tasks waiting to be executed. Unlike dispatch queues in GCD, operation queues are not FIFO (first-in-first-out). Instead, they execute tasks as soon as they are ready to be executed, as long as there are enough system resources to allow for it. Get th...
So you want to deploy your app to multiple sites? and your project has too many dependencies to install them one-by-one? Npm has a solution just issue the following command: npm init In the project's root folder then follow the instructions on screen (type in the desired value then press enter) ...
To detect the endian of the device var isLittleEndian = true; (()=>{ var buf = new ArrayBuffer(4); var buf8 = new Uint8ClampedArray(buf); var data = new Uint32Array(buf); data[0] = 0x0F000000; if(buf8[0] === 0x0f){ isLittleEndian = false; } })(); Lit...
db.people.createIndex({name: 1}) This creates an ascending single field index on the field name. In this type of indexes the sort order is irrelevant, because mongo can traverse the index in both directions.
1. Setup your formatter and routing in Register of (App_Start/WebApiConfig) public static class WebApiConfig { public static void Register(HttpConfiguration config) { GlobalConfiguration.Configuration.Formatters.Clear(); GlobalConfiguration.Configuration.Formatters.Add...
public class Sheep { private String name; private int weight; public Sheep(String name, int weight) { this.name = name; this.weight = weight; } public static Sheep newInstance(Sheep other); return new Sheep(other.name, other.wei...
Suppose we have the following XAML snippet: <ListBox x:Name="MyListBox" /> Then in the code-behind for this XAML file, we write the following in the constructor: MyListBox.ItemsSource = new[] { 1, 2, 3, 4, 5 }; Running the application, we get a list of numbers we enter...
For Facebook config.omniauth :facebook, facebook_app_id, facebook_secret_key, :display => "popup", :scope => 'email,publish_actions', info_fields: 'email,name' For Twitter config.omniauth :twitter, twitter_app_id, twitter_secret_key, :display => "popup", :scope =&gt...
gem 'omniauth-oauth2' , '~> 1.3.1' gem 'omniauth' gem 'omniauth-facebook' gem 'omniauth-twitter' gem 'omniauth-gplus' gem 'omniauth-linkedin' Run the bundle install command, restart your server and off you go!

Page 60 of 161