Tutorial by Examples: ad

By overloading the indexer you can create a class that looks and feels like an array but isn't. It will have O(1) get and set methods, can access an element at index 100, and yet still have the size of the elements inside of it. The SparseArray class class SparseArray { Dictionary<...
To add EntityFrameworkCore to your project, update the project.json file (add new lines into the dependencies and tools sections): "dependencies": { ... "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0", "Microsoft.EntityFrameworkCore.SqlServer.Des...
Two important things to note when adding fields to a Pivot Table are Orientation and Position. Sometimes a developer may assume where a field is placed, so it's always clearer to explicitly define these parameters. These actions only affect the given Pivot Table, not the Pivot Cache. Dim thisPivot ...
An atomic type can be used to safely read and write to a memory location shared between two threads. A Bad example that is likely to cause a data race: #include <thread> #include <iostream> //function will add all values including and between 'a' and 'b' to 'result' void add(int...
docker run --add-host="app-backend:10.15.1.24" awesome-app This command adds an entry to the container's /etc/hosts file, which follows the format --add-host <name>:<address>. In this example, the name app-backend will resolve to 10.15.1.24. This is particularly useful for t...
List.sortBy allows to use a function on the elements and use its result for the comparison. > List.sortBy String.length ["longest","short","medium"] ["short","medium","longest"] : List String -- because the lengths are: [7,5,6] It ...
Nobody wants to require or include every time a class or inheritance is used. Because it can be painful and is easy to forget, PHP is offering so called autoloading. If you are already using Composer, read about autoloading using Composer. What exactly is autoloading? The name basically says it al...
This code is to add and remove a value from a flagged enum-instance: [Flags] public enum MyEnum { Flag1 = 1 << 0, Flag2 = 1 << 1, Flag3 = 1 << 2 } var value = MyEnum.Flag1; // set additional value value |= MyEnum.Flag2; //value is now Flag1, Flag2 value...
See below for a simple example of how to use a Thread to do some time intensive stuff in a background process. public async void ProcessDataAsync() { // Start the time intensive method Thread t = new Thread(TimeintensiveMethod); // Control returns here before TimeintensiveMethod r...
The common idiom for loading shared library files in Java is the following : public class ClassWithNativeMethods { static { System.loadLibrary("Example"); } public native void someNativeMethod(String arg); ... Calls to System.loadLibrary are almost always...
Quite often you have a file which was edited within DOS or Windows and you are viewing it under UNIX. This can look like the following when you view the file with vi. First line of file^M Next Line^M And another^M If you wish to remove the ^M, it can be that you delete each ^M by hand. Alter...
class MyDataObject extends DataObject { private static $db = array( 'Name' => 'Varchar' ); private static $has_one = array( 'OtherDataObject' => 'OtherDataObject' ); private static $summary_fields = array( 'Name', 'OtherDat...
class MyAdmin extends ModelAdmin { ... function getEditForm($id = null, $fields = null) { $form = parent::getEditForm($id, $fields); if ($this->modelClass == 'MyDataObjectName') { $form->Fields() ->fieldByName($this->sanitis...
Hadoop Distributed File System (HDFS) is a Java-based file system that provides scalable and reliable data storage that is designed to span large clusters of commodity servers. HDFS, MapReduce, and YARN form the core of Apache™ Hadoop®. HDFS is designed to be highly fault-tolerant, which is achieve...
STEP 1: CREATE A DIRECTORY IN HDFS, UPLOAD A FILE AND LIST CONTENTS Let’s learn by writing the syntax. You will be able to copy and paste the following example commands into your terminal: hadoop fs -mkdir: Takes the path URI’s as an argument and creates a directory or multiple directories. Usag...
Julia uses similar binary operators for basic arithmetic operations as does mathematics or other programming languages. Most operators can be written in infix notation (that is, placed in between the values being computed). Julia has an order of operations that matches the common convention in mathe...
CREATE DATABASE LINK dblink_name CONNECT TO remote_username IDENTIFIED BY remote_password USING 'tns_service_name'; The remote DB will then be accessible in the following way: SELECT * FROM MY_TABLE@dblink_name; To test a database link connection without needing to know any of the objec...
Modify your Gemfile to include the Devise gem: gem 'devise' Then update your gems with: $ bundle install Run the installers in your project: $ rails generate devise:install Then create your Devise model (e.g. User) with: $ rails generate devise User you'll need to set up the default ...
class CreateAuthenticationProviders < ActiveRecord::Migration def change create_table "authentication_providers", :force => true do |t| t.string "name" t.datetime "created_at", :null => false ...
class CreateUserAuthentications < ActiveRecord::Migration def change create_table "user_authentications", :force => true do |t| t.integer "user_id" t.integer "authentication_provider_id" t.string "uid&q...

Page 43 of 114