Skip to content

Instantly share code, notes, and snippets.

@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
@szimek
szimek / capybara_select_dates_and_times.rb
Created August 31, 2010 09:26
Cucumber steps for selecting time and date (using Capybara)
require "xpath" # XPath is a separate gem now
module Cucumber
module Rails
module CapybaraSelectDatesAndTimes
def select_date(field, options = {})
date = Date.parse(options[:with])
selector = %Q{.//fieldset[contains(./legend, "#{field}")]}
within(:xpath, selector) do
find(:xpath, '//select[contains(@id, "_1i")]').find(:xpath, ::XPath::HTML.option(date.year.to_s)).select_option
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 / 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}
@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 / webgl-constants-by-name
Created January 3, 2011 21:28
WebGL context constants
ACTIVE_ATTRIBUTES: 35721
ACTIVE_ATTRIBUTE_MAX_LENGTH: 35722
ACTIVE_TEXTURE: 34016
ACTIVE_UNIFORMS: 35718
ACTIVE_UNIFORM_MAX_LENGTH: 35719
ALIASED_LINE_WIDTH_RANGE: 33902
ALIASED_POINT_SIZE_RANGE: 33901
ALPHA: 6406
ALPHA_BITS: 3413
ALWAYS: 519
@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 / 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 / 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 / clearfix.css
Created May 8, 2011 09:27
Facebook CSS
.clearfix {
display: block;
zoom: 1;
}
.clearfix::after {
clear: both;
content: ".";
display: block;
font-size: 0;