Skip to content

Instantly share code, notes, and snippets.

root :to => "users#dashboard", :constraints => lambda { |r| r.env["warden"].authenticate? }
root :to => "home#index"
@szimek
szimek / aspect.js
Created July 21, 2011 13:44
devmeetings.pl aspect js task implementation
var aspect = {};
aspect.add = function (obj, fnName, aspectFn, when, once) {
if ('object' !== typeof obj) throw new TypeError('Must pass an object as the first argument');
obj = obj || window;
if (Array.isArray(fnName)) {
fnName.forEach(function (name) {
aspect._add(obj, name, aspectFn, when, once);
@szimek
szimek / backbone_extensions.js
Created June 15, 2011 10:20
Extensions for Backbone.
// TODO:
// - TemplateView
// - change the way templates are compiled (store compiled version inside view "class"?)
//
// - CollectionView
// - cleanup layout rendering if it depends on collection (remove collection container from DOM, rerender the layout and attach it again?)
// - store model views together with models (?)
//
// - ModelView
// - extend Model#toJSON to convert nested objects as well (http://rcos.rpi.edu/projects/concert/commit/got-requests-displaying-properly-again/)
@szimek
szimek / delayed_job_mailer.rb
Created March 23, 2011 09:01
Initial version - the idea is to make Mail::QueuedDelivery a proxy that takes original delivery_method as a parameter
# lib/mail/queued_delivery.rb
require 'mail'
module Delayed
class PerformableMail
attr_reader :mail
def initialize(mail)
@mail = mail
end
@szimek
szimek / init.el
Created March 5, 2011 21:01 — forked from mig/init.el
;; emacs configuration
(push "/usr/local/bin" exec-path)
(add-to-list 'load-path "~/.emacs.d")
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)
@szimek
szimek / executer.js
Created February 20, 2011 20:21
capybara-zombie server segmentation fault
var net = require('net'),
util = require('util'),
zombie = require('zombie'),
browser = new zombie.Browser,
buffer = "";
net.createServer(function (socket) {
socket.setEncoding('utf8');
socket.on('data', function (data) {
@szimek
szimek / config.ru
Created December 19, 2010 17:22
Script for serving static pages in a directory
# Using Ruby with "rack" gem - run using "rackup"
use Rack::Static, :urls => [""]; run nil
@szimek
szimek / dont_handle_asynchronously.rb
Created October 13, 2010 13:05
Disable delayed_job in tests
class ActiveRecord::Base
# Allow to bypass Delayed Job asynchronous handling
def self.dont_handle_asynchronously(*methods)
method_aliases = {}
methods.each do |method|
# TODO move this part into Delayed::MessageSending::ClassMethods#handle_asynchronously
aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1
with_method, without_method = "#{aliased_method}_with_delay#{punctuation}", "#{aliased_method}_without_delay#{punctuation}"
method_aliases[method] = {:with => with_method, :without => without_method}
From d75eb570e16f765b5c6acee8f1fc1c8013eeba4f Mon Sep 17 00:00:00 2001
From: Szymon Nowak <szimek@gmail.com>
Date: Mon, 11 Oct 2010 19:37:03 +0200
Subject: [PATCH] Return a valid empty JSON on successful PUT and DELETE requests.
---
.../lib/action_controller/metal/responder.rb | 20 ++++++++++++++++++++
actionpack/test/controller/mime_responds_test.rb | 19 +++++++++++++++++++
2 files changed, 39 insertions(+), 0 deletions(-)
@szimek
szimek / post-checkout
Created August 5, 2010 15:40
Git hook to switch Ruby versions when changing branches
#!/bin/bash
if [ -f .rvmrc ]; then
source .rvmrc
fi