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
{ Ref: https://evilmartians.com/chronicles/graphql-on-rails-3-on-the-way-to-perfection } | |
(Rails - 5, Graphql-ruby - 1.8.x) | |
# Gemfile | |
gem 'redis' |
<!-- ERROR -->
Jest encountered an unexpected token
Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
By default "node_modules" folder is ignored by transformers.
OlderNewer