Skip to content

Instantly share code, notes, and snippets.

@shuber
shuber / attr_encrypted_test.rb
Created November 3, 2011 23:08
attr_encrypted test
require 'rubygems'
require 'attr_encrypted'
class User
attr_encrypted :last_name, :key => 'my super secret key'
def initialize(last_name)
self.last_name = last_name
end
end
@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
# This tmux statusbar config was created by tmuxline.vim
# on Thu, 09 Jan 2014
set -g status-bg 'colour238'
set -g message-command-fg 'colour249'
set -g status-justify 'left'
set -g status-left-length '100'
set -g status 'on'
set -g pane-active-border-fg 'colour150'
set -g message-bg 'colour237'
.ruby-version
.php-version
*.swp
*.swo
*.un~
# Compiled source #
###################
*.class
*.dll
(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 / add_index_patch.rb
Created April 1, 2015 07:43
ActiveRecord `add_index` patch for PostgreSQL JSONB GIN indexes
# This patch detects {index_columns} that match something like
# the example below, then strips the surrounding double quotes.
#
# "(settings->'example')"
#
# The resulting CREATE INDEX sql looks something like:
#
# CREATE INDEX "idx_users_on_settings_example" ON "users" USING gin ((settings->>'example'))
#
# Your {add_index} call should looks something like:
@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
[email protected]
[email protected]
# ...
[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)}`