Tutorial by Examples: er

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...
Pattern matching extensions for C# enable many of the benefits of pattern matching from functional languages, but in a way that smoothly integrates with the feel of the underlying language switch expression Pattern matching extends the switch statement to switch on types: class Geometry {} cl...
Create your RecyclerView in your layout xml file: <android.support.v7.widget.RecyclerView android:id="@+id/recycleView" android:layout_width="match_parent" android:layout_height="match_parent" /> Create your Model...
When should I use it When the code inside an inline listener is too big and your method / class becomes ugly and hard to read You want to perform same action in various elements (view) of your app To achieve this you need to create a class implementing one of the listeners in the View API. ...
Some LINQ methods return a query object. This object does not hold the results of the query; instead, it has all the information needed to generate those results: var list = new List<int>() {1, 2, 3, 4, 5}; var query = list.Select(x => { Console.Write($"{x} "); return ...
In general, functions that operate on other functions, either by taking them as arguments or by returning them (or both), are called higher-order functions. A higher-order function is a function that can take another function as an argument. You are using higher-order functions when passing callbac...
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController include OmniConcern %w[facebook twitter gplus linkedin].each do |meth| define_method(meth) do create end end end Note: In the part “%w[facebook twitter gplus linkedin]”, you should list ...
module OmniConcern extend ActiveSupport::Concern def create auth_params = request.env["omniauth.auth"] provider = AuthenticationProvider.get_provider_name(auth_params.try(:provider)).first authentication = provider.user_authentications.where(uid: auth_params.uid).first...
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...
belongs_to :user belongs_to :authentication_provider serialize :params def self.create_from_omniauth(params, user, provider) token_expires_at = params['credentials']['expires_at'] ? Time.at(params['credentials']['expires_at']).to_datetime : nil create( user: user, ...
include OmniauthAttributesConcern has_many :user_authentications devise :omniauthable, :database_authenticatable, :registerable,:recoverable, :rememberable, :trackable def self.create_from_omniauth(params) self.send(params.provider,params) end
module OmniauthAttributesConcern extend ActiveSupport::Concern module ClassMethods Add Methods here end end In this concern we can create methods for each social media to fetch and store attributes. def twitter params (params['info']['email'] = "dummy#{SecureRan...
devise_for :users, controllers: {omniauth_callbacks: 'users/omniauth_callbacks'}
Moving away from a buffer with unsaved changes will cause this error: E37: No write since last change (add ! to override) You can disable this by adding set hidden to your .vimrc file. With this option set your changes will persist in the buffer, but will not be saved to disk.
When one wishes to convert a list to a vector or data.frame object empty elements are typically dropped. This can be problematic which a list is created of a desired length are created with some empty values (e.g. a list with n elements is created to be added to an m x n matrix, data.frame, or data...
Example of calling an extension method as an extension and as a regular method. public Class MyClass Sub Main() 'Extension called directly on the object. Dim Version = Assembly.GetExecutingAssembly.GetVersionFromAssembly() 'Called as a regular method. ...
Create a Dictionary<TKey, TValue> from an IEnumerable<T>: using System; using System.Collections.Generic; using System.Linq; public class Fruits { public int Id { get; set; } public string Name { get; set; } } var fruits = new[] { new Fruits { Id = 8 , Nam...
There are times when an include file has to generate different output from the preprocessor depending on whether the compiler is a C compiler or a C++ compiler due to language differences. For example a function or other external is defined in a C source file but is used in a C++ source file. Since...

Page 164 of 417