Skip to content

Instantly share code, notes, and snippets.



View GitHub Profile
View Gemfile
source ""
gem "rubocop", :require => false
import boto3
import json
lambda_client = boto3.client('lambda')
def invoke(event, context):
gingerlime / sidekiq.log
Created Jan 11, 2015
sidekiq redis connection errors
View sidekiq.log
2015-01-11T16:02:16.656Z 11444 TID-42mh0 ERROR: /var/local/deployment/vendor/bundle/ruby/2.2.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:55:in `rescue in _read_from_socket'
2015-01-11T16:02:16.656Z 11444 TID-42mh0 ERROR: /var/local/deployment/vendor/bundle/ruby/2.2.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:48:in `_read_from_socket'
2015-01-11T16:02:16.656Z 11444 TID-42mh0 ERROR: /var/local/deployment/vendor/bundle/ruby/2.2.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:41:in `gets'
2015-01-11T16:02:16.656Z 11444 TID-42mh0 ERROR: /var/local/deployment/vendor/bundle/ruby/2.2.0/gems/redis-3.1.0/lib/redis/connection/ruby.rb:273:in `read'
2015-01-11T16:02:16.656Z 11444 TID-42mh0 ERROR: /var/local/deployment/vendor/bundle/ruby/2.2.0/gems/redis-3.1.0/lib/redis/client.rb:238:in `block in read'
2015-01-11T16:02:16.656Z 11444 TID-42mh0 ERROR: /var/local/deployment/vendor/bundle/ruby/2.2.0/gems/redis-3.1.0/lib/redis/client.rb:226:in `io'
2015-01-11T16:02:16.656Z 11444 TID-42mh0 ERROR: /var/local/deployment/ve
View application.rb
config.middleware.insert_before ActionDispatch::ParamsParser, ::Rack::Robustness do |g|
# you might need to replace this with JSON::ParserError, depending on your Rails configuration
# or you can catch both...
g.on(MultiJson::ParseError) { |ex| 400 }
g.content_type 'text/plain'
g.body{ |ex| ex.message }
g.ensure(true) do |ex|
gingerlime /
Created Feb 15, 2014
trying to use url_prefix with Flask
#!/usr/bin/env python
# coding=utf8
from flask import Flask, Blueprint, redirect, url_for
from flask.ext.bootstrap import Bootstrap
bp = Blueprint('blueprint', __name__)
app = Flask(__name__)
app.register_blueprint(bp, prefix='/prefix')
gingerlime / analytics_js_loader.js.erb
Created Nov 20, 2013
analytics.js loader for rails
View analytics_js_loader.js.erb
// sources:
// Create a queue, but don't obliterate an existing one! || ( = []);
// A list of all the methods in analytics.js that we want to stub. = ['identify', 'track', 'trackLink', 'trackForm',
'trackClick', 'trackSubmit', 'page', 'pageview', 'ab', 'alias', 'ready',
'group', 'on', 'once', 'off'];
gingerlime / devise_mail_helpers.rb
Last active Dec 23, 2015 — forked from stevenharman/devise_mail_helpers.rb
small tweaks using `text_part` and slightly changed regex
View devise_mail_helpers.rb
module Features
module MailHelpers
def last_email
# Can be used like:
# extract_token_from_email(:reset_password)
def extract_token_from_email(token_name)
View .gitignore
gingerlime /
Created Nov 1, 2012
Redis Request iRregularities with Ruby

... I couldn't resist the temptation for some pseudo-alliteration.

Need for speed

When it comes to driving, I'm a rather slow driver. I can parallel park with my eyes-closed, merge in traffic easily, but I really don't enjoy driving fast (Mind you, I take public transport these days). But when it comes to squeezing performance out of a system, I guess I'm much more attracted to the idea of things running fast. The redis attraction is therefore quite obvious. In-memory database. It doesn't get much faster than that.

Bumps on the road

It was rather surprising to come across speed issues with redis, and fairly early-on with our project. At kenHub, we are building an anatomy learning platform. The platform must adapt to each and every student, and present them with the best question for their level. To do this, we must store statistics for each and every anatomy term for each user. Redis was a natural candidate for this. Quick access to read/write individual records allows us to u

View bla_controller.rb
class BlaController < ApplicationController
skip_before_filter :authenticate_user!
def index