require 'oauth2'
require 'legato'
client = OAuth2::Client.new('client-ID', 'client-secret', {
:authorize_url => 'https://accounts.google.com/o/oauth2/auth',
:token_url => 'https://accounts.google.com/o/oauth2/token'
})
client.auth_code.authorize_url({
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
# challenge is to add ',' at the end of every number which is not pin-code. Pincodes are the number lesser or equal to 5. | |
# Also, make sure they all are one space apart. | |
# ex: "123 23424324 34534 2342442234" | |
# function should return: "123 23424324, 34534 2342442234," | |
# | |
a = "1234 23434242 232342442 345 2342341234" | |
a.scan(/[\w']+/) do |w| | |
if w.length > 5 | |
b << "#{w}," | |
next |
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
# Calculate the Total Price of a Model of Car based on the policy(which will | |
# decide margin) and based price provided by User. Every policy has a condition | |
# to calculate the margin which will then gets added to base price to get the | |
# total price of the car. | |
class Models | |
require 'open-uri' | |
require 'nokogiri' | |
def self.calculate_total_price(pricing_policy, base_price) | |
case pricing_policy |
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
HTTP status code symbols for Rails | |
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
Status Code Symbol | |
1xx Informational | |
100 :continue | |
101 :switching_protocols | |
102 :processing |
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 code; code.interact(local=dict(globals(), **locals())) |
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
1. Create Procfile at the root of each frontend and backend folder (with command to start the server) | |
2. Create Heroku dynos for each (frontend and backend) | |
``` | |
heroku create -a my-awesome-frontend | |
heroku create -a my-awesome-backend | |
``` | |
3. Get the auth token from Heroku by running: `heroku auth:token` #=> HEROKU_API_TOKEN | |
4. Add remote origin for frontend and backend | |
``` |
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
{ Ref: https://evilmartians.com/chronicles/graphql-on-rails-3-on-the-way-to-perfection } | |
(Rails - 5, Graphql-ruby - 1.8.x) | |
# Gemfile | |
gem 'redis' |
OlderNewer