Skip to content

Instantly share code, notes, and snippets.

@epall
epall / nt.sh
Created December 13, 2008 21:57
#!/usr/bin/env sh
# A simple script to open a new tab in Terminal in the current directory
# Author: Eric Allen
osascript -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' > /dev/null
osascript -e "tell application \"Terminal\" to do script \"cd $PWD && clear\" in window 1" > /dev/null
@epall
epall / gist:83178
Created March 22, 2009 14:28
test_controller.rb
class TestController < ApplicationController
def rubyversion
text = `which ruby`
text += "<br>"
text += "<br>"
text += `ruby --version`
text += "<br>"
text += "<br>"
text += `gem list --local`.split("\n").join("<br>")
render :text => text
#!/usr/bin/ruby
file = File.open('orders.tsv')
out = File.open('orders.csv', 'w')
file.each_line do |line|
fields = line.split("\t")
out.puts '"'+fields.join('","')+'"'
end
@epall
epall / lastblog.rb
Created September 7, 2009 17:44
lastblog.rb: a simple script for checking how recently I've posted to my blogs. Edit the BLOGS and MAX_ENTRY_INTERVAL globals to suit your tastes. term/ansicolor is an optional gem that will make the output prettier.
#!/usr/bin/env ruby
# lastblog: a simple script for checking how recently I've posted to my blogs.
# Edit the BLOGS and MAX_ENTRY_INTERVAL globals to suit your tastes.
# term/ansicolor is an optional gem that will make the output prettier.
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'
require 'date'
@epall
epall / v
Created October 21, 2009 18:58
# v: a simple script for intelligently launching MacVim
#!/bin/sh
open -a /Applications/Vim.app
while ! [ `/Applications/Vim.app/Contents/MacOS/Vim --serverlist 2>/dev/null` ] ; do true; done
/Applications/Vim.app/Contents/MacOS/Vim --remote-tab $@
# This is my fantasy for what I should be able to do with RubyGate.
# The basic VHDL translation is taken care of at the lowest level, and
# then I can build a "computer" DSL on top of it in pure Ruby. The
# generated VHDL might not be the fastest, most effiecient, or clearest,
# but it's really just an assembly language.
computer do |c|
c.instruction "add" do |x, y|
x+y
end
using terms from application "Quicksilver"
on process text ThisClipping
do shell script "/Users/epall/bin/addreplacement " & ThisClipping
end process text
end using terms from
@epall
epall / compact.sh
Created January 10, 2010 23:22
Garbage collect all git repos in the current directory
#!/bin/sh
startsize=`du -s -h | awk '{print $1}'`
find . -name .git -print0 | xargs -0 -n1 -I{} sh -c "cd {}; git gc"
endsize=`du -s -h | awk '{print $1}'`
echo "$PWD compacted from $startsize to $endsize"
require 'fileutils'
ARGV.each do |file|
clean_name = file.gsub('%20', ' ')
FileUtils.mv(file, clean_name) if clean_name != file
end
require 'Computer.Build'
controller = state_machine "ide_controller" do |m|
m.input :reset, VHDL::STD_LOGIC
m.input :instr_command, VHDL::STD_LOGIC_VECTOR(7..0)
m.input :instr_address, VHDL::STD_LOGIC_VECTOR(7..0)
m.input :instr_data, VHDL::STD_LOGIC_VECTOR(15..0)
m.output :result_command, VHDL::STD_LOGIC_VECTOR(7..0)
m.output :result_status, VHDL::STD_LOGIC_VECTOR(7..0)