This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Individual Practical | |
==================== | |
Part 1 - 21/10/10 | |
Operating Systems | |
================= | |
Practical - 12/11/10 | |
Essay - 26/11/10 | |
Algorithms & Data Structures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*Main> rmChar 'a' "Hallo" | |
"Hllo" | |
Is given by: | |
characterDrop a x = (a /= x) | |
rmChar :: Char -> String -> String | |
rmChar a xs = filter (characterDrop a) xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
char* strrev(char* start, char* end) | |
{ | |
char *i = start; | |
char *j = end; | |
while (i < j) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
name = Chris Brown | |
email = [email protected] | |
signingkey = D5E60FB1 | |
[github] | |
user = xoebus | |
token = [REDACTED] | |
[alias] | |
st = status | |
ci = commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nibbler' | |
require 'open-uri' | |
class SteamProfile < Nibbler | |
elements 'div.gameListRowItem' => :games do | |
element 'h4' => :title | |
element 'h5' => :playtime, :with => lambda { |time| | |
time.inner_text.strip.split(" ").first.to_f | |
} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nibbler' | |
require 'open-uri' | |
CODE_RE = /[A-Za-z1-9]{4}-[A-Za-z1-9]{4}-[A-Za-z1-9]{4}/ | |
class String | |
[:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white].each_with_index do |color, i| | |
define_method color do "\033[1;#{30+i}m#{self}\033[0m" end | |
define_method :"#{color}ish" do "\033[0;#{30+i}m#{self}\033[0m" end | |
end |