This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { GoogleAPI, GoogleLogin, GoogleLogout } from "react-google-oauth"; | |
import FacebookLogin from 'react-facebook-login'; | |
function App() { | |
return ( | |
<div className="App"> | |
<div className="App-header"> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :api, defaults: { format: :json } do | |
namespace :v1 do | |
mount_devise_token_auth_for 'User', at: 'auth', skip: [:omniauth_callbacks] # add this and overide the omniauth callbacks | |
post 'social_auth/callback', to: 'social_auth_controller#authenticate_social_auth_user' # this is the line where we add our routes | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.session_store :cookie_store, key: '_interslice_session' | |
config.middleware.use ActionDispatch::Cookies # Required for all session management | |
config.middleware.use ActionDispatch::Session::CookieStore, config.session_options | |
# I added this for cors to be able to accept request from client. for now it accepts from all origins | |
config.middleware.use Rack::Cors do | |
allow do | |
origins '*' | |
resource '*', | |
headers: :any, | |
expose: %w[access-token expired token-type uid client], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please find this find via config/initializers/devise.rb | |
# Add these to this file in case you're using these providers | |
config.omniauth :google_oauth2, | |
Rails.application.credentials[:google_app_id], | |
Rails.application.credentials[:google_app_secret], | |
{ scope: 'userinfo.email, userinfo.profile', skip_jwt: true } | |
config.omniauth :facebook, | |
Rails.application.credentials[:facebook_app_id], | |
Rails.application.credentials[:facebook_app_secret], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add these gems and run bundle i | |
gem 'omniauth' | |
gem 'omniauth-facebook' | |
gem 'omniauth-google-oauth2' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ApplicationRecord | |
# Include default devise modules. Others available are: | |
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable | |
# for omniauth token if its what you're using for your api, I am assuming its what you're using in this tutorial | |
include DeviseTokenAuth::Concerns::User | |
devise :database_authenticatable, :registerable, | |
:recoverable, :rememberable, :validatable, | |
:confirmable, :omniauthable, | |
omniauth_providers: %i[google_oauth2 facebook] # add omniauthable field and add the providers under omniauth_providers | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { GoogleAPI, GoogleLogin, GoogleLogout } from "react-google-oauth"; | |
import FacebookLogin from 'react-facebook-login'; | |
function App() { | |
return ( | |
<div className="App"> | |
<div className="App-header"> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
An array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7] (elements are shifted right by one index and 6 is moved to the first place). | |
The goal is to rotate array A K times; that is, each element of A will be shifted to the right K times. | |
Write a function: | |
def solution(A, K) | |
that, given an array A consisting of N integers and an integer K, returns the array A rotated K times. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Task description A non-empty array A consisting of N integers is given. | |
The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired. For example, in array A such that: A[0] = 9 A[1] = 3 A[2] = 9 A[3] = 3 A[4] = 9 A[5] = 7 A[6] = 9 the elements at indexes 0 and 2 have value 9, the elements at indexes 1 and 3 have value 3, the elements at indexes 4 and 6 have value 9, the element at index 5 has value 7 and is unpaired. Write a function: def solution(A) that, given an array A consisting of N integers fulfilling the above conditions, returns the value of the unpaired element. For example, given array A such that: A[0] = 9 A[1] = 3 A[2] = 9 A[3] = 3 A[4] = 9 A[5] = 7 A[6] = 9 the function should return 7, as explained in the example above. Write an efficient algorithm for the following assumptions: N is an odd integer within the range [1..1,000,000]; each element of |
NewerOlder