Skip to content

Instantly share code, notes, and snippets.

View xoebus's full-sized avatar
🤖
beep beep

Christopher Brown xoebus

🤖
beep beep
  • San Francisco, CA
View GitHub Profile
@xoebus
xoebus / Rakefile
Created April 23, 2010 15:00
Rakefile for managing lots of git repositories in one directory.
require "pathname"
GIT_REPOS = Dir["**/.git/.."].map { |path| path = Pathname.new(path).realpath }
desc "Update all repositories"
task :update do
GIT_REPOS.each do |repo|
command "git pull origin master", repo
end
end
@xoebus
xoebus / gist:377773
Created April 24, 2010 17:00
Ack output for a blog post.
[cb@titan:~/Presentations/at-tools-talk on master]
$ ack --text cen
01_title/01_title.md
1:!SLIDE center
02_intro/01_what.md
9:!SLIDE center
15:* cen
03_cen/01_cen.md
Music/iTunes/iTunes Music/Music/
|-- +44
| `-- When Your Heart Stops Beating
|-- 3 Doors Down
| |-- 3 Doors Down
| |-- Away From the Sun
| |-- Seventeen Days
| `-- The Better Life
|-- 30 Seconds To Mars
| |-- 30 Seconds To Mars
@xoebus
xoebus / terminal-width.rb
Created September 6, 2010 14:17
A snippet of code from HIRB to detect the terminal width.
def detect_terminal_size
if (ENV['COLUMNS'] =~ /^\d+$/) && (ENV['LINES'] =~ /^\d+$/)
[ENV['COLUMNS'].to_i, ENV['LINES'].to_i]
elsif (RUBY_PLATFORM =~ /java/ || !STDIN.tty?) && command_exists?('tput')
[`tput cols`.to_i, `tput lines`.to_i]
else
command_exists?('stty') ? `stty size`.scan(/\d+/).map { |s| s.to_i }.reverse : nil
end
rescue
nil
@xoebus
xoebus / ask.rb
Created September 15, 2010 12:06
def ask(question, default=nil, valid = /.*/, multiline=false)
output = question
output << " [#{default}]" unless default.nil?
output << " (Optional)" if valid =~ ""
output << ": "
puts output
matches = false
answer = default
@xoebus
xoebus / ask.rb
Created September 15, 2010 14:51
def ask(question, default=nil, valid = /.*/, multiline=false)
output = question
output << " [#{default}]" unless default.nil?
output << " (Optional)" if valid =~ ""
output << ": "
puts output
matches = false
answer = default
@xoebus
xoebus / Deadlines.txt
Created October 16, 2010 14:37
Coursework for Semester 1
Individual Practical
====================
Part 1 - 21/10/10
Operating Systems
=================
Practical - 12/11/10
Essay - 26/11/10
Algorithms & Data Structures
*Main> rmChar 'a' "Hallo"
"Hllo"
Is given by:
characterDrop a x = (a /= x)
rmChar :: Char -> String -> String
rmChar a xs = filter (characterDrop a) xs
#include <stdio.h>
#include <string.h>
char* strrev(char* start, char* end)
{
char *i = start;
char *j = end;
while (i < j)
{
TEX_FILES = FileList["*.tex", "figures/*", "*.bib", "*.cls"]
MAIN = "thesis" # name of main file without .tex suffix
MAIN_TEX = "#{MAIN}.tex"
OUT_PDF = "#{MAIN}.pdf"
file OUT_PDF => TEX_FILES do
%x{pdflatex -interaction=batchmode #{MAIN_TEX} >/dev/null 2>&1}
%x{makeindex #{MAIN} >/dev/null 2>&1}
%x{bibtex #{MAIN} >/dev/null 2>&1}
%x{pdflatex -interaction=batchmode #{MAIN_TEX} >/dev/null 2>&1}