Skip to content

Instantly share code, notes, and snippets.

View pubis's full-sized avatar

Jonas Lundqvist pubis

  • Stockholm, Sweden
View GitHub Profile
@pubis
pubis / redis.rb
Created December 11, 2011 09:07
Redis config and initialization for rails
#config/initializers/redis.rb
require 'redis'
require 'redis/objects'
REDIS_CONFIG = YAML.load( File.open( Rails.root.join("config/redis.yml") ) ).symbolize_keys
dflt = REDIS_CONFIG[:default].symbolize_keys
cnfg = dflt.merge(REDIS_CONFIG[Rails.env.to_sym].symbolize_keys) if REDIS_CONFIG[Rails.env.to_sym]
$redis = Redis.new(cnfg)
Redis::Objects.redis = $redis
@pubis
pubis / application.controller.js
Last active November 30, 2015 15:23
Computed properties
import Ember from 'ember';
import Account from '../models/account';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
name: "",
balance: 0,
totalBalanceInCents: function() {
return this.model.reduce(function(previousValue, account) {
@pubis
pubis / klinkers.rb
Created July 20, 2012 16:16
Klinker goes Veritable
require 'veritable'
API_KEY = ENV['VERITABLE_KEY']
api = Veritable.connect(api_key: API_KEY)
rows = Veritable::Util.read_csv('klinkers-data.csv')
schema = {
'account' => {'type' => 'categorical'},
@pubis
pubis / bank.rb
Created July 20, 2012 16:03
Veritable quickstart
# Based on https://www.priorknowledge.com/docs/quickstart/python
require 'veritable'
API_KEY = ENV['VERITABLE_KEY']
api = Veritable.connect(api_key: API_KEY)
rows = Veritable::Util.read_csv('bank-data.csv')
@pubis
pubis / bootstrap_helper.rb
Created March 9, 2012 09:53
Simple helper for Twitter Bootstrap stuff
module BootstrapHelper
def icon_tag icon, opts = {}
defaults = {
white: false,
large: false
}
defaults.merge(opts)
class_string = "icon-#{icon.to_s}"
class_string = "#{class_string} icon-white" if defaults[:white]
class_string = "#{class_string} icon-large" if defaults[:large]
@pubis
pubis / .instructions
Created November 16, 2011 16:30
Rails 3.1 + Mongoid + rspec2 + guard + spork + factory girl
# This is my take on a rails 3.1 setup with mongoid, rspec2, guard, spork
# and factory girl.
#
# Thanks to:
# http://gist.github.com/568754/ (inspiration)
# http://railscasts.com/episodes/275-how-i-test (rspec and guard)
# http://railscasts.com/episodes/285-spork (spork and guard)
# http://github.com/diaspora/diaspora (.rvmrc)
# http://stackoverflow.com/questions/7801073/spork-timer-not-resetting-between-runs
# and others...