Skip to content

Instantly share code, notes, and snippets.

Molly Struve mstruve

Block or report user

Report or block mstruve

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 yay.rb
respond_to do |format|
format.json { render :json => { :success => true, :message => 'yay' } }
end
@mstruve
mstruve / redis.rb
Created Nov 16, 2018
Redis Readonly Console
View redis.rb
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
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
@mstruve
mstruve / educations_controller.rb
Created Aug 24, 2012
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
@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}
You can’t perform that action at this time.