This file contains 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 RegistrationAPIViewTestCase(TestCase): | |
""" This class defines the test suite for the registration view. """ | |
def setUp(self): | |
self.existing_user_data = { | |
"username": "janejones", | |
"email": "jjones@email.com", | |
"password": "Enter-123"} |
This file contains 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 UserRetrieveUpdateAPIViewTestCase(TestCase): | |
""" | |
This class defines the test suite for the view | |
that retrieves and updates a user | |
""" | |
def setUp(self): | |
self.user_data_2 = { | |
"username": "nicksbro", | |
"email": "nicholus@gmail.com", |
This file contains 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
def determine_age(): | |
response = input('name and age:') | |
check = [int(i) for i in response.split() if i.isdigit()] | |
if check!=[]: | |
for i in check: | |
value = 100 - i | |
print('youare left with '+ str(value) +'years to clock 100') | |
print('pass in your age and name') | |
some() |
This file contains 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 |
This file contains 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 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 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 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 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 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], |
OlderNewer