Tutorial by Examples: c

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'}
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...
The System.Web.SessionState.HttpSessionState object provides a way to persist values between HTTP requests. In the example below, a user's preference for warnings is being saved in the session. Later on, while serving another request to the user, the application can read this preference from session...
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...
user_one = User.find(1) user_two = User.find(1) user_one.name = "John" user_one.save # Run at the same instance user_two.name = "Doe" user_two.save # Raises a ActiveRecord::StaleObjectError
appointment = Appointment.find(5) appointment.lock! #no other users can read this appointment, #they have to wait until the lock is released appointment.save! #lock is released, other users can read this account
returnType (^blockName)(parameterType1, parameterType2, ...) = ^returnType(argument1, argument2, ...) {...}; float (^square)(float) = ^(float x) {return x*x;}; square(5); // resolves to 25 square(-7); // resolves to 49 Here's an example with no return and no parameters: NSMutableDicti...
If you want to use RSpec for a Rails project, you should use the rspec-rails gem, which can generate helpers and spec files for you automatically (for example, when you create models, resources or scaffolds using rails generate). Add rspec-rails to both the :development and :test groups in the Gem...
This is a copy of the advanced function snippet from the Powershell ISE. Basically this is a template for many of the things you can use with advanced functions in Powershell. Key points to note: get-help integration - the beginning of the function contains a comment block that is set up to be ...
To work with ConstraintLayout, you need Android Studio Version 2.2 or newer and have at least version 32 (or higher) of Android Support Repository. Add the Constraint Layout library as a dependency in your build.gradle file: dependencies { compile 'com.android.support.constraint:constraint...
Define your payload to send for possible more complex data $Payload = @{ text="test string"; username="testuser" } Use ConvertTo-Json cmdlet and Invoke-RestMethod to execute the call Invoke-RestMethod -Uri "https://hooks.slack.com/services/yourwebhookstring" -Metho...
SELECT department, COUNT(*) AS "Man_Power" FROM employees GROUP BY department;
1. Print the Hadoop version hadoop version 2. List the contents of the root directory in HDFS hadoop fs -ls / 3. Report the amount of space used and available on currently mounted filesystem hadoop fs -df hdfs:/ 4. Count the number of directories,files and bytes under the paths tha...
Fabric is a modular mobile platform that provides useful kits you can mix to build your application. Crashlytics is a crash and issue reporting tool provided by Fabric that allows you to track and monitor your applications in detail. How to Configure Fabric-Crashlytics Step 1: Change your build....
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...

Page 321 of 826