Skip to content

Instantly share code, notes, and snippets.

View djbender's full-sized avatar
🕵️‍♂️

Derek Bender djbender

🕵️‍♂️
View GitHub Profile
module CheapStrings
def `(str)
str
end
end
module A
extend CheapStrings
def self.make_lots_of_strings
#!/bin/sh
VBM=VBoxManage
VMNAME="smartos2"
VBDIR="/Users/me/Documents/VirtualBox"
DISK=1024 # 1GB
RAM=1024 # 1GB
VRAM=128 # arbitrary
mkdir -p "${VBDIR}/${VMNAME}" && cd "${VBDIR}/${VMNAME}"
[[ -f ${VMNAME}.iso ]] || curl -C - -o "${VMNAME}.iso" https://download.joyent.com/pub/iso/latest.iso
$VBM createvm --name $VMNAME --ostype OpenSolaris_64 --register
@djbender
djbender / _flash.html.erb
Last active December 16, 2015 22:09 — forked from potomak/_flash.html.erb
Using this in Rails v4.0.0.rc1 and Bootstrap v2.3.1
<% [:notice, :error, :alert, :success].each do |level| %>
<% unless flash[level].blank? %>
<div class="alert alert-<%= flash_class(level) %>">
<a class="close" href="#">×</a>
<%= content_tag :p, flash[level] %>
</div>
<% end %>
<% end %>
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
module MyApp
class Money
include Mongoid::Fields::Serializable
def cast_on_read?; true; end
def deserialize(object)
return nil if object.blank?
::Money.new(object[:cents] || object["cents"], object[:currency] || object["currency"])
end
module Mokha
class HomeController < Mokha::BaseController
def index
@view = Mokha::HomePresenter.new
@view.user = User.includes(:ratings).find(current_user)
@view.user.track('Opened Mokha')
end
module Extensions
module_function
def separate(path)
extensions = path.reverse
.scan(/\G\w+\./)
.map { |e| e[0..-2].reverse }
.reverse
file_name = path.split(".")[0..-(extensions.size + 1)].join(".")
[file_name, extensions]
@djbender
djbender / README.md
Created February 13, 2012 02:10 — forked from netmute/README.md
Game of Life

Game of Life

An implementation of Conway's Game of Life in 140 characters of Ruby.

Author

Created by Simon Ernst (@sier).

@djbender
djbender / rbenv-install-system-wide.sh
Created January 23, 2012 22:02
rbenv install and system wide install on Ubuntu 10.04 LTS.
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path: