Skip to content

Instantly share code, notes, and snippets.

View jpablobr's full-sized avatar

Pablo Barrantes jpablobr

View GitHub Profile
jose@jose-laptop:~/package/scripts$ sprinkle -c -s sprinkle.rb
--> Cloud hierarchy for policy scootypuff
Policy scootypuff requires package sqlite3
Policy scootypuff requires package sqlite3_driver
Package sqlite3_driver requires rubygems
Package rubygems requires build_essential
Package rubygems requires ruby
pablo@pablo-desktop:~/package$ cd scripts/
pablo@pablo-desktop:~/package/scripts$ sprinkle -c -s sprinkle.rb
--> Cloud hierarchy for policy scootypuff
Policy scootypuff requires package sqlite3
Policy scootypuff requires package sqlite3_driver
Package sqlite3_driver requires rubygems
Package rubygems requires build_essential
Package rubygems requires ruby
A master programmer passed a novice programmer one day. The master
noted the novice's preoccupation with a hand-held computer game. "Excuse me",
he said, "may I examine it?"
The novice bolted to attention and handed the device to the master.
"I see that the device claims to have three levels of play: Easy, Medium,
and Hard", said the master. "Yet every such device has another level of play,
where the device seeks not to conquer the human, nor to be conquered by the
human."
"Pray, great master," implored the novice, "how does one find this
mysterious setting?"
#!/bin/bash
# run with: curl -s http://gist.github.com/265272.txt | bash
set -e
localdir=$HOME/.mongodb
datadir=$localdir/data
conf=$localdir/mongod.conf
agent=$HOME/Library/LaunchAgents/org.mongodb.mongod.plist
brew install mongodb
emacs -q --eval '(condition-case err (progn (load "~/.emacs") (kill-emacs 0)) (error (kill-emacs 1)))'
# Source http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/bed5b2bd8b237f5a?pli=1
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
# History search with up and down arrow keys
bindkey '^[[A' history-beginning-search-backward
bindkey '^[[B' history-beginning-search-forward
require 'rexml/parsers/pullparser'
require 'htmlentities'
class String
# Truncate strings containing HTML code
# Usage example: "string".truncate_html(50, :word_cut => false, :tail => '[+]')
def truncate_html(len = 30, opts = {})
opts = {:word_cut => true, :tail => ' ...'}.merge(opts)
p = REXML::Parsers::PullParser.new(self)
tags = []
# -*- coding: utf-8 -*-
# S3 Backup Task for MySQL & SQLite
# Assumes InnoDB tables
# If using MySQL database user needs the "reload" permission on the database (for --flush-logs in mysqldump)
#
# Stores files in Amazon S3 using the excellent AWS Gem: http://amazon.rubyforge.org/
# For information about Amazon S3: http://aws.amazon.com/s3
#
# Installation
# 1) Install AWS Gem
# for cron job
# 0 3 * * * cd /path/to/app/ && /usr/local/bin/rake db:backup RAILS_ENV=production
require 'find'
namespace :db do
desc "Backup the database to a file. Options: DIR=base_dir RAILS_ENV=production MAX=20"
task :backup => [:environment] do
datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
base_path = ENV["DIR"] || "db"
backup_base = File.join(base_path, 'backup')