Skip to content

Instantly share code, notes, and snippets.

@lackac
lackac / bibliaolvaso.conf
Created September 23, 2012 09:54
Upstart configuration for Bibliaolvasó
# Generated by Chef
description "Bibliaolvaso"
author "Laszlo Bacsi"
start on startup
stop on shutdown
respawn
respawn limit 15 5
@lackac
lackac / haproxy.cfg
Created September 22, 2012 19:14
HAProxy configuration with Websocket support
global
maxconn 4096 # Total Max Connections. This is dependent on ulimit
nbproc 2
log 127.0.0.1 local1 notice
defaults
mode http
log global
frontend all 0.0.0.0:80
@lackac
lackac / auth.coffee
Created September 20, 2012 22:26
Authentication with everyauth in Derby
derby = require 'derby'
everyauth = require 'everyauth'
config = require './config'
users = require('mongoskin').db(config('mongo_url')).collection('users')
# let's make sure there is a userId set, this way there will always be a user
exports.ensureUser = ->
(req, res, next) ->
req.session.auth ||= {}
# basics
set -g default-terminal "screen-256color"
set -g prefix C-a
set -sg escape-time 0
# let's free the original prefix
unbind C-b
# make sure we can send prefix to other apps
bind C-a send-prefix
@lackac
lackac / mongoose_ext.coffee
Created October 24, 2011 15:44
Patches mongoose with a method to separate reference properties from their referenced object accessors
{Model} = module.exports = mongoose = require 'mongoose'
# Make populated references available as separate properties
# e.g.
# if `ProductSchema` has `brand_id: { type: String, ref: 'Brand' }`,
# `Product.findById(some_id).populate('brand').run(cb)` will populate
# using `brand_id` but the populated brand object will be available as
# `product.brand`.
originalInit = Model::init
Model::init = (doc, query, fn) ->
@lackac
lackac / .irbrc
Created September 7, 2011 08:10
Use Pry everywhere
require 'rubygems'
# This makes pry itself and all pry gems available
$LOAD_PATH.push(*Dir["#{ENV['HOME']}/.prygems/gems/*/lib"]).uniq!
begin
# Use Pry everywhere
require 'pry'
rescue LoadError => e
end
@lackac
lackac / 0_intro.coffee
Created June 6, 2011 15:59
vows + should.js + sinon.js (presentation for budapest.js, June 6, 2011)
vows.describe("Presentation")
.addBatch
"László Bácsi from Secret Sauce Partners, Inc.":
topic: "vows + should.js + sinon.js"
"should vow to do BDD": (tools) ->
tools.should.include "vows"
tools.should.include "should"
tools.should.include "sinon"
.export(budapest.js)
" Toggle ruby blocks
" requires the matchit plugin
function! s:ToggleRubyBlocks()
let c = getline(".")[col(".")-1]
if c =~ '[{}]'
" don't use matchit for {,}
exe 'normal! %s'.(c=='}' ? 'do' : 'end')."\<esc>``s".(c=='}' ? 'end' : 'do')."\<esc>"
else
let w = expand('<cword>')
if w == 'do'
@lackac
lackac / custom_tracer.rb
Created November 18, 2010 14:46
Custom Memprof Tracer and a Controller/View pair to browse traces
require 'memprof/tracer'
class CustomTracer
def initialize(app, opts = {})
@app = app
@options = opts
@options[:except] = %r{^/(?:memprof|admin)\b}
end
def call(env)