Skip to content

Instantly share code, notes, and snippets.

View djanowski's full-sized avatar

Damian Janowski djanowski

View GitHub Profile
@djanowski
djanowski / missing-requires.sh
Created April 14, 2014 19:38
Find your missing requires in shotgun.rb
everywhere=$(ag '^\s*require' -w --ruby --no-numbers --ignore=test/ --ignore=tasks/ --ignore=scripts/ | awk -F: '{gsub(/^ */, "", $2); print $2}' | sort | uniq)
shotgun=$(ag '^\s*require' -w --no-numbers shotgun.rb)
echo "$everywhere" | grep -v -f <(echo "$shotgun")
cat $1 |
tr '[:upper:]' '[:lower:]' |
sed -e 's/^\.//' |
sed -e 's/\.con$/.com/' |
sed -e 's/\.con\.ar$/.com.ar/' |
sed -e 's/^www//' |
sed -e 's/^\+//' |
sed -e 's/@@/@/' |
sort |
uniq |
#! /bin/bash
# Creates passwords of the given length, all lower case for easier input on mobile devices.
length="${1:-24}"
password=$(openssl rand -base64 $(($length + 50)) | tr -Cd '[:lower:]' | cut -c 1-$(($length)))
echo "$password" | pbcopy
echo "$password"
git checkout master
git gc
git remote | while read remote; do
git remote prune $remote
done
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
@djanowski
djanowski / gist:d7c396d171dd1f9ae76b
Created November 8, 2014 20:26
HMote with Cuba::Mote
# cuba/mote tries to require mote, but we already
# provide hmote.
$LOADED_FEATURES << "mote.rb"
require "hmote"
require "cuba/mote"
#!/bin/sh
#
# Adam Sharp
# Aug 21, 2013
#
# Usage: Add it to your PATH and `git remove-submodule path/to/submodule`.
#
# Does the inverse of `git submodule add`:
# 1) `deinit` the submodule
# 2) Remove the submodule from the index and working directory
@djanowski
djanowski / backtrace.rb
Created March 4, 2015 01:07
Simple Ruby backtrace filtering
# Hook it up to your favorite testing framework:
#
# module MiniTest
# def self.filter_backtrace(bt)
# Backtrace.filter(bt)
# end
# end
module Backtrace
NOISE = Gem.path + $LOAD_PATH
git clone https://gist.github.com/djanowski/cfc662d64585b284db9c disque-crash
cd disque-crash
make
module Syro::Render
HTML = "text/html; charset=utf-8".freeze
TEMPLATES = {}
def page(path)
template(path, "layout")
end
def template(path, layout = nil)
TEMPLATES[[path, layout]] ||= begin
require "hmote"
class Page
include HMote::Helpers
attr_accessor :path
attr_accessor :layout
attr_accessor :params
def initialize(path, layout = nil)