View heap_dump_worker.rb
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
require 'objspace' | |
class HeapDumpWorker | |
include Sidekiq::Worker | |
sidekiq_options queue: :medium_priority | |
def perform(filename) | |
File.open(filename, 'w') do |f| | |
ObjectSpace.dump_all(output: f, full: true) |
View yay.rb
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
respond_to do |format| | |
format.json { render :json => { :success => true, :message => 'yay' } } | |
end |
View redis.rb
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
if ENV['REDIS_ACCESS_MODE'] == 'readonly' | |
class Redis | |
class Client | |
WRITE_COMMANDS = ::Rails.cache.data.command.map { |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" | |
end |
View api.rb
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
before do | |
client = Client.active.find_by(token: headers["Auth-Token"]) | |
error!('Unauthorized. Invalid token.', 401) unless client | |
error!('Unauthorized action.', 403) unless client.user_authorization_required? && User.new(headers["X-Grpn-Email"]).authorized_action?(request.request_method) | |
end |
View educations_controller.rb
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 linkedin | |
@user=current_user | |
client = LinkedIn::Client.new("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 = @school.educations.all.map{|t| t} | |