This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first clone your repo | |
git clone path/to/my/repo path/to/clone | |
# do some initial housecleaning: | |
rm -rf .git/refs/original/ | |
git reflog expire --expire=now --all | |
git gc --prune=now | |
git gc --aggressive --prune=now | |
# note the repo size: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set tabstop=4 " Tab characters = 4 spaces when displayed | |
set shiftwidth=2 " Use 2 spaces for each insertion of (auto)indent | |
set softtabstop=2 " Tabs 'count for' 2 spaces when editing (fake tabs) | |
set expandtab " <tab> -> spaces in insert mode | |
set autoindent " always set autoindenting on | |
set smarttab " Smart tabbing! | |
set shiftround " < and > will hit indent levels instead of +-4 always | |
set hlsearch | |
set incsearch | |
set number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_record' | |
ActiveRecord::Base.establish_connection( | |
:adapter => 'sqlite3', | |
:database => 'database') | |
ActiveRecord::Base.connection.execute <<-SQL | |
CREATE TABLE IF NOT EXISTS users ( | |
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, | |
name VARCHAR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install some dependencies | |
sudo apt-get install -y vim eclipse git \ | |
curl mysql-server zlib1g-dev coreutils libtool bison libxt-dev \ | |
sqlite3 libsqlite3-dev libxml2-dev libreadline-dev \ | |
libmagickwand-dev libmysqlclient-dev libmemcached-dbg \ | |
postgresql postgresql-client libpq-dev libxslt1-dev nodejs \ | |
libqt4-dev libqtwebkit-dev | |
# install rvm and ruby | |
curl -L get.rvm.io | bash -s stable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Benchmark.bm do|b| | |
b.report("exclusion join ") do | |
a = "" | |
10_000.times do | |
Element.find_by_sql( | |
<<-SQL | |
select e.* from elements e | |
left outer join elements leafs | |
on e.id = leafs.parent_id | |
where leafs.parent_id is null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
# capture root dir | |
root=$(pwd) | |
echo "cache url: $CACHE_URL" | |
mv lp_solve_5.5 /tmp/ | |
cd /tmp/lp_solve_5.5/lp_solve/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# Eager load application and dependencies | |
require File.expand_path('../../../config/environment', __FILE__) | |
Rails.application.eager_load! | |
# All classes to mutate | |
classes = ActiveSupport::Dependencies.autoloaded_constants. | |
map(&:constantize).grep(Class).map(&:name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/inflector' | |
inflectors_path = File.expand_path('./config/initializers/inflections.rb') | |
load inflectors_path if File.exist?(inflectors_path) | |
class Mutagen | |
def initialize(path) | |
file_match_expression = File.join(File.expand_path(path), '**/*.rb') | |
@source_files = Dir.glob(file_match_expression).map do |file_path| | |
SourceFile.new(file_path, path) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Trashable | |
module ClassMethods | |
def dependent_associations | |
reflect_on_all_associations.select do |association| | |
[:destroy, :delete_all].include?(association.options[:dependent]) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
ENV['RAILS_ENV'] = 'test' | |
require_relative '../config/environment' | |
class Speccer | |
def configuration | |
@configuration ||= RSpec::Core::Configuration.new | |
end |
OlderNewer