Skip to content

Instantly share code, notes, and snippets.

View route's full-sized avatar
Things only change when we change them

Dmitry Vorotilin route

Things only change when we change them
View GitHub Profile
import re
import shutil
import argparse
from os import path
from sys import stderr
# Author: Daxda
# Date: 02.04.2014
# WTF: This is a quick tool I've hacked together to easily remove the meta
route / template.rb
Last active November 25, 2022 10:24
AR template
View template.rb
class Example < ActiveRecord::Base
## includes
## plugins
## associations
## validations
## callbacks
## attr_*, delegate aliases, accepts_nested_attributes_for
## scopes
## class methods
## public methods
route / gist:4372148
Last active December 10, 2015 03:08
async_exec can return nil
View gist:4372148
require 'pg'
c = 'database')
[ { Thread.current[:r] = c.async_exec("SELECT * FROM users") }, { Thread.current[:r] = c.async_exec("SELECT * FROM users") }
].each { |t| t.join; p t[:r] }
View gist:3820687
#<NoMethodError: undefined method `sub' for nil:NilClass>
/Users/route/.rvm/gems/ruby-1.9.3-p194@grabber/gems/actionpack-3.2.8/lib/action_dispatch/testing/assertions/routing.rb:176:in `method_missing': undefined local variable or method `method_name' for #<ControllerSpec:0x007fa3c6560c68> (NameError)
puts e.backtrace
raise unless defined?(method_name)
View gist:3798746
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'bundler/setup' unless defined?(Bundler)
require 'minitest/autorun'
# Database cleaner strategy
require 'database_cleaner'
DatabaseCleaner.strategy = :transaction
View gist:3694068
require 'minitest/spec'
require 'minitest/autorun'
describe "Capture" do
it "should capture all output in the same process" do
out, err = capture_io do
puts "STDOUT"
warn "STDERR"
route / gist:3412287
Created August 21, 2012 05:50
TextMate 2 .tm_properties
View gist:3412287

This is all based on the [alpha release][1].


From the built-in help system:

For many settings TextMate will look for a .tm_properties file in the current folder and in any parent folders (up to the user’s home folder).

These are simple setting = value listings where the value is a format string in which other variables can be referenced.

route / gist:2601441
Created May 5, 2012 10:45
Static page generator
View gist:2601441
namespace :app do
namespace :error_pages do
desc "Generates static pages 500, 403, 404, 422"
task :generate => :environment do
av =
av.class_eval do
include ApplicationHelper
include Rails.application.routes.url_helpers
route / gist:2489600
Created April 25, 2012 13:11
Additions to rr stubbing
View gist:2489600
# Dynamic method stubbing
# user = Factory(:user)
# callbacks =
# stub_methods("user", callbacks)
def stub_methods(name, methods)
methods.each do |method|
eval "stub(#{name}).#{method}"
route / .ackrc
Created March 28, 2012 15:33
Ackrc for TextMate
View .ackrc