Skip to content

Instantly share code, notes, and snippets.

View erochest's full-sized avatar

Eric Rochester erochest

View GitHub Profile
-- This script takes the values for enclosure post metadata and adds the length
-- and type fields, if they don't exist.
--
-- The REGEXP /\n[0-9]+\n/ is meant to look for the length field. If it's
-- missing, then the value needs to be patched.
SET @type := 'audio/mpeg';
SET @length := 0;
@erochest
erochest / .janus.rake
Created August 23, 2011 18:05
A .janus.rake file to pull in a rspec2 compiler from tooky/vim-ruby and suppress Windows errors.
require 'rbconfig'
require 'fileutils'
RSPEC2 = 'https://github.com/tooky/vim-ruby/blob/6f7656892806a2a95fb98a562f6531e27e7398c4/compiler/rspec2.vim'
directory 'compiler'
vim_plugin_task 'rspec2' do
if !File.directory?('compiler')
Dir.mkdir('compiler')
#! /usr/bin/env bash
# install local janus config
curl -L https://gist.github.com/raw/1166018/bfba67168e2f2b74fa7d7debf9ed13ca798429f1/.janus.rake > ~/.janus.rake
# install janus plugins for vim
curl https://raw.github.com/carlhuda/janus/master/bootstrap.sh -o - | sh
# install rvm
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
@erochest
erochest / Rakefile
Created September 14, 2011 20:33
Basic Sample Vagrantfile, Rakefile combination for working with OpsCode's and SLab's Chef cookbooks
require 'etc'
require 'fileutils'
require 'vagrant'
task :default => :usage
task :usage do
puts "You forgot to tell the computer what to do; try one of these commands:"
@erochest
erochest / index_by_length.rb
Created September 19, 2011 16:13
This indexes the words in a string by length.
# The input.
INPUT = 'The quick brown fox jumped over the lazy dogs. ABCDEF'
# Create a hash that returns an empty Array for missing item accesses.
len_index = Hash.new do |hash, key|
hash[key] = []
end
# Split the input and store each word in the hash, keyed by the length of the
@erochest
erochest / Rakefile
Created September 22, 2011 15:28
Vagrant/Rake config files for setting up a GeoServer instance.
require 'etc'
require 'fileutils'
require 'vagrant'
task :default => :usage
task :usage do
puts "You forgot to tell the computer what to do; try one of these commands:"
@erochest
erochest / fix_vim_perms.rb
Created September 29, 2011 20:06
Script to fix issues with Janus on Windows.
require 'pathname'
GVIMRC = <<EOF
" undefine all the custom NERDTree-aware commands.
" From https://github.com/carlhuda/janus/issues/174
cunabbrev cd
@erochest
erochest / di.py
Created October 5, 2011 19:54
Dependency Injection (DI) or Inversion of Control (IoC) in Python
#!/usr/bin/env python
"""\
A short explanation of dependency injection and how to use to make testing
easier.
Maybe this should be a mocking guide, because everything's going to be a mock
object.
@erochest
erochest / omg.py
Created October 20, 2011 13:18
OMG, and I thought this was a good idea.
# This file should be name omg.ptl.
class PageTemplate(object):
def _corner [html] (self):
'This gets output too. What fun!<br />\n'
if self._project():
return self._project().upper()
else:
'<font size="-1">Linguistic Atlas Projects</font>'
class Freq
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :input_text
validates :input_text, :presence => true
def initialize(attributes = {})