Skip to content

Instantly share code, notes, and snippets.

Chase Stephens chastep

Block or report user

Report or block chastep

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View sleep_func.js
const sleep = ms => new Promise(res => setTimeout(res, ms));
@chastep
chastep / find_missing.rb
Created Oct 3, 2019
Hacker Rank Find Missing Numbers
View find_missing.rb
# https://www.hackerrank.com/challenges/missing-numbers/problem
def missingNumbers(arr, brr)
og_hash = brr.inject(Hash.new(0)) { |h,v| h[v] += 1; h }
missing_hash = arr.inject(Hash.new(0)) { |h,v| h[v] += 1; h }
og_hash.select { |k, v| missing_hash[k] < v || (v == 1 && !missing_hash[k]) }.keys.sort
end
@chastep
chastep / gather_all_stripe_charges.rb
Created Sep 10, 2019
Collect more than 100 charges from Stripe::Charge.list
View gather_all_stripe_charges.rb
def gather_all_stripe_charges
all_charges = []
has_more = true
last_charge_id = nil
while has_more
charges = Stripe::Charge.list({ limit: 100, starting_after: last_charge_id})
all_charges += initial_charges['data'].map { |charge| {id: charge['id'], amount: charge['amount']} }
has_more = false unless charges['has_more']
last_charge_id = all_charges.last.id
View keybase.md

Keybase proof

I hereby claim:

  • I am chastep on github.
  • I am chastep (https://keybase.io/chastep) on keybase.
  • I have a public key ASBtzwze7sysup3j2kbMtugEMYKNMfGc1ky2UiiehnjNHAo

To claim this, I am signing this object:

@chastep
chastep / introrx.md
Created Mar 14, 2018 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
View introrx.md
View controller sessions.rb
get '/sessions/new' do
if session[:user_id]
redirect "/"
else
erb :'/sessions/new'
end
end
post '/sessions/new' do
user = User.authenticate(params[:email], params[:password)
You can’t perform that action at this time.