Tutorial by Examples

Step 1: Create a new Rails app gem install rails -v 4.1 rails new angular_example Step 2: Remove Turbolinks Removing turbolinks requires removing it from the Gemfile. gem 'turbolinks' Remove the require from app/assets/javascripts/application.js: //= require turbolinks Step 3: Add Angu...
Window functions are used to do operations(generally aggregation) on a set of rows collectively called as window. Window functions work in Spark 1.4 or later. Window functions provides more operations then the built-in functions or UDFs, such as substr or round (extensively used before Spark 1.4). W...
To calculate moving average of salary of the employers based on their role: val movAvg = sampleData.withColumn("movingAverage", avg(sampleData("Salary")) .over( Window.partitionBy("Role").rowsBetween(-1,1)) ) withColumn() creates a new column named m...
Always use Rails.logger.{debug|info|warn|error|fatal} rather than puts. This allows your logs to fit into the standard log format, have a timestamp and have a level so you choose whether they are important enough to be shown in a specific environment. You can see the separate log files for your appl...
<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://sche...
By default the Custom Tool property for a VB resource file is VbMyResourcesResXFileCodeGenerator. However, with this code generator the view (XAML) will not be able to access the resources. To solve this problem add Public before the Custom Tool property value. To select the Resources.resx file in ...
<Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc=&...
Open the resource file by double clicking it. Change the Access Modifier to "Public".
Bean1 @ManagedBean @ViewScoped public class Bean1 implements Serializable { /** * Just takes the given param, sets it into flash context and redirects to * page2 * * @param inputValue * @return */ public String goPage2(String inputValue) { ...
Sometimes you might accidentally run something in the shell that ends up waiting forever, and thus blocking the shell: iex(2)> receive do _ -> :stuck end In that case, press Ctrl-g. You'll see: User switch command Enter these commands in order: k (to kill the shell process) s (to st...
Computed observables are functions that can "watch" or "react" to other observables on the view model. The following example shows how you would display the total number of users and the average age. Note: The example below can also make use of pureComputed() (introduced in v3....
Erlang is a functional programming language. One of the features in a function programming language is handling functions as data (functional objects). Pass a function as an argument to another function. Return function as a result of a function. Hold functions in some data structure. In Erl...
In order to add Firebase Crash Reporting to your app, perform the following steps: Create an app on the Firebase Console here. Copy the google-services.json file from your project into your in app/ directory. Add the following rules to your root-level build.gradle file in order to inc...

Sum

The Enumerable.Sum extension method calculates the sum of numeric values. In case the collection's elements are themselves numbers, you can calculate the sum directly. int[] numbers = new int[] { 1, 4, 6 }; Console.WriteLine( numbers.Sum() ); //outputs 11 In case the type of the elements is a ...
You can return an anonymous object from your function public static object FunctionWithUnknowReturnValues () { /// anonymous object return new { a = 1, b = 2 }; } And assign the result to a dynamic object and read the values in it. /// dynamic object dynamic x = FunctionWithUnknowR...
You can return an instance of Tuple class from your function with two template parameters as Tuple<string, MyClass>: public Tuple<string, MyClass> FunctionWith2ReturnValues () { return Tuple.Create("abc", new MyClass()); } And read the values like below: Console.Wri...
You might want to use it when parsing DateTimes from different cultures (languages), following example parses Dutch date. DateTime dateResult; var dutchDateString = "31 oktober 1999 04:20"; var dutchCulture = CultureInfo.CreateSpecificCulture("nl-NL"); DateTime.TryParse(dutch...
You can install Magit from MELPA with: M-x package-install RET magit RET
Using a new List List<String> list = new ArrayList<String>(listOfElements); Using List.addAll() method Set<String> set = new HashSet<String>(); set.add("foo"); set.add("boo"); List<String> list = new ArrayList<String&...
The format of the struct statement is this: struct [structure tag] { member definition; member definition; ... member definition; } [one or more structure variables]; Example: declare the ThreeFloats structure: typedef struct { float x, y, z; } ThreeFloats; @inter...

Page 524 of 1336