Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonas Lundqvist pubis

  • Stockholm, Sweden
View GitHub Profile
@pubis
pubis / application.controller.js
Last active Nov 30, 2015
Computed properties
View application.controller.js
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 Jul 20, 2012
Klinker goes Veritable
View klinkers.rb
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 Jul 20, 2012
Veritable quickstart
View bank.rb
# 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 Mar 9, 2012
Simple helper for Twitter Bootstrap stuff
View bootstrap_helper.rb
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 / redis.rb
Created Dec 11, 2011
Redis config and initialization for rails
View redis.rb
#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 / .instructions
Created Nov 16, 2011
Rails 3.1 + Mongoid + rspec2 + guard + spork + factory girl
View .instructions
# 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...