Skip to content

Instantly share code, notes, and snippets.

View mstruve's full-sized avatar

Molly Struve mstruve

View GitHub Profile
mstruve / heap_dump_worker.rb
Created June 16, 2021 19:52
View heap_dump_worker.rb
require 'objspace'
class HeapDumpWorker
include Sidekiq::Worker
sidekiq_options queue: :medium_priority
def perform(filename), 'w') do |f|
ObjectSpace.dump_all(output: f, full: true)
mstruve / yay.rb
Created May 21, 2019 16:52
2016 Molly
View yay.rb
respond_to do |format|
format.json { render :json => { :success => true, :message => 'yay' } }
mstruve / redis.rb
Created November 16, 2018 19:48
Redis Readonly Console
View redis.rb
if ENV['REDIS_ACCESS_MODE'] == 'readonly'
class Redis
class Client
WRITE_COMMANDS = { |a| a[0] if a[2].include?('write') }.compact.to_set.freeze
def process(commands)
if commands.flatten.any? { |c| WRITE_COMMANDS.include?(c.to_s) }
raise NotImplementedError, "REDIS_ACCESS_MODE is set to 'readonly', disallowing writes"
mstruve / api.rb
Last active August 29, 2015 14:23
View api.rb
before do
client = headers["Auth-Token"])
error!('Unauthorized. Invalid token.', 401) unless client
error!('Unauthorized action.', 403) unless client.user_authorization_required? &&["X-Grpn-Email"]).authorized_action?(request.request_method)
mstruve / educations_controller.rb
Created August 24, 2012 21:48
Two Examples of methods that parse data from LinkedIn in order to get the Job and Education information for a user.
View educations_controller.rb
def linkedin
client ="API Key", "Secret Key")
client.authorize_from_access(current_user.link_token, current_user.link_secret)
#breakdown LinkedIn Hash into pieces in order to obtain data
@profile = client.profile
@school = client.profile(:fields => %w(educations))
@schools ={|t| t}