Skip to content

Instantly share code, notes, and snippets.

(evil-define-state god
"God state."
:tag " <G> "
:message "-- GOD MODE --"
:entry-hook (evil-god-start-hook)
:exit-hook (evil-god-stop-hook)
:input-method t
:intercept-esc nil)
(defun evil-god-start-hook ()
@shuber
shuber / custom_domain.rb
Created August 12, 2009 02:22 — forked from speedmax/customdomain.rb
DNS lookup for dynamic domains in rack applications
require File.dirname(__FILE__) + '/../../vendor/gems/net-dns-0.4/lib/net/dns/resolver'
# Custom Domain
# A Rack middleware to to resolve the custom domain to original subdomain
# for your multi telent application.
#
# It's all transperant to your application, it performs cname lookup and
# overwrite HTTP_HOST if needed
#
# www.example.org => example.myapp.com
@shuber
shuber / restrict.rb
Created August 28, 2009 21:19 — forked from jondahl/has_many :dependent => :restrict
don't allow a record with has_many dependencies to be destroyed e.g. has_many dependent: :restrict
when :restrict do
method_name = "has_many_dependent_restrict_for_#{reflection.name}".to_sym
define_method(method_name) do
unless send(reflection.name).empty?
# change to named error...
raise ActiveRecord::StatementInvalid, "can't delete record because of dependent #{reflection.name}"
end
end
before_destroy method_name
end
@shuber
shuber / sync.rb
Created October 3, 2009 21:01 — forked from speedmax/sync.rake
sync files with a rake task
# app:sync
# Local and production synchronization
# - require yaml_db plugin
namespace :app
namespace :sync do
task :all => [:files, :db]
task :files do
`rsync -azv user@host:'/apps/myawesomeapp/shared/files/' #{Rails.root + 'files'}`
@shuber
shuber / main.cpp
Created March 14, 2012 05:28 — forked from betawaffle/main.cpp
Number to Words
#include <iostream>
#include <ctime>
#include <string>
using namespace std;
string convert(unsigned long n) {
static char *formats[16] = {
"", "%s%s%s", "%s%s", "%s%s-%s",
"%s hundred", "%s hundred and %s%s", "%s hundred and %s", "%s hundred and %s-%s",
@shuber
shuber / _test.rb
Created November 5, 2012 08:14 — forked from jcoglan/_test.rb
Rooby - ruby object system in ruby
$VERBOSE = nil
require File.expand_path('../rooby', __FILE__)
Person = Rooby::Class.new 'Person' do
define :initialize do |name|
@name = name
end
define :name do

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@shuber
shuber / buildkite-agent.service
Created July 5, 2016 21:35 — forked from sj26/buildkite-agent.service
Starting multiple buildkite-agents per-machine with systemd
[Unit]
Description=Buildkite Agents
Documentation=https://buildkite.com/agent
Wants=buildkite-agent@1.service
Wants=buildkite-agent@2.service
# ...
[Service]
Type=oneshot
ExecStart=/bin/true
@shuber
shuber / find_unused_images.rake
Created August 17, 2016 23:47 — forked from rafaelp/find_unused_images.rake
Rake task to find unused images on Rails project to deletion.
# It requires ACK - http://betterthangrep.com/
task :find_unused_images do
images = Dir.glob('app/assets/images/**/*')
images_to_delete = []
images.each do |image|
unless File.directory?(image)
# print "\nChecking #{image}..."
print "."
result = `ack -1 -G '(app|public)' --ruby --html --css --js #{File.basename(image)}`
@shuber
shuber / sqitch_alternatives.txt
Created February 10, 2017 21:29 — forked from begriffs/sqitch_alternatives.txt
sqitch alternatives
https://github.com/flyway/flyway
https://github.com/mattes/migrate
https://bitbucket.org/liamstask/goose
https://github.com/tanel/dbmigrate
https://github.com/BurntSushi/migration
https://github.com/DavidHuie/gomigrate
https://github.com/rubenv/sql-migrate