Skip to content

Instantly share code, notes, and snippets.

View rorhug's full-sized avatar
📀
out on dvd

Rory Hughes rorhug

📀
out on dvd
View GitHub Profile
@rorhug
rorhug / Bolt error
Created July 18, 2012 20:50
Bolt error
bolt create my_first_site
** Starting Bolt...
/home/rory/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- test/unit/ui/console/testrunner (LoadError)
from /home/rory/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/rory/.rvm/gems/ruby-1.9.3-p194/gems/bolt-0.2.15/lib/bolt/runners/test_unit.rb:2:in `<top (required)>'
from /home/rory/.rvm/gems/ruby-1.9.3-p194/gems/bolt-0.2.15/lib/bolt/runner.rb:35:in `runner'
from /home/rory/.rvm/gems/ruby-1.9.3-p194/gems/bolt-0.2.15/lib/bolt/runner.rb:13:in `initialize'
from /home/rory/.rvm/gems/ruby-1.9.3-p194/gems/bolt-0.2.15/lib/bolt/listener.rb:24:in `new'
from /home/rory/.rvm/gems/ruby-1.9.3-p194/gems/bolt-0.2.15/lib/bolt/listener.rb:24:in `initialize'
from /home/rory/.rvm/gems/ruby-1.9.3-p194/gems/bolt-0.2.15/lib/bolt.rb:85:in `new'
def lrgst(a)
largest = 0
a.each {|i| largest = i if i > largest }
largest
end
def radix_lsd(uns)
sorted = (0..Math.log10(lrgst(uns)).floor).inject(uns) do |memo, index|
groups = Array.new(10).map{|x| [] }
memo.each { |u| groups[(u / 10**index) % 10] << u }
@rorhug
rorhug / bank.py
Created October 8, 2013 21:42
Aidan bank thingy
def get_current_num():
f = open("statement", "r")
num = int(f.read())
f.close()
return num
def write_new_num(n):
f = open("statement", "w")
stmt_string = str(n)
f.write(stmt_string)
@rorhug
rorhug / countdown.js
Created December 13, 2013 18:26
Countdown with padded seconds
// set the date we're counting down to
var target_date = new Date("Aug 15, 2019").getTime();
// variables for time units
var days, hours, minutes, seconds;
// get tag element
var countdown = document.getElementById("countdown");
// update the tag with id "countdown" every 1 second
@rorhug
rorhug / gulpfile.js
Created February 9, 2014 17:12
merging streams
// Sass and css libs
gulp.task('css', function () {
var sassStream = gulp.src('./assets/*.scss').pipe(sass());
var cssFiles = gulp.src('./assets/csslib/*.css');
var queue = new StreamQueue();
queue.queue(
cssFiles,
sassStream
);
@rorhug
rorhug / gist:9080955
Created February 18, 2014 21:48
Database dilema
DB ORM Lang
MongoDB(ok but no joins) + Mongoose(Great) + Node.js(Great)
Postgres(ok but schemas) + Sequelize(Great) + Node.js(Great)
RethinkDB(Great) + Thinky(ok but no validations) + Node.js(Great)
RethinkDB(Great) + nobrainer(Great) + Ruby(Good but already started app in Node.js and a little slow)
@rorhug
rorhug / gulpfile.js
Created February 19, 2014 15:01
XtraGulpFile
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
// var uglify = require('gulp-uglify');
var nodemon = require('gulp-nodemon');
var sass = require('gulp-sass');
var StreamQueue = require('streamqueue');
@rorhug
rorhug / q2.py
Created February 21, 2014 21:01
aipo 2013 q2
import math
def is_whole(x):
return x % 1 == 0
n = int(raw_input())
c_list = set()
c = 5
while len(c_list) < n:
@rorhug
rorhug / q3.py
Created February 21, 2014 23:27
aipo final 2013 q3
n = int(raw_input())
a = [ int(raw_input()) for x in range(n) ]
average_count = 0
for (i, el) in enumerate(a):
a.pop(i) # remove that element
for to_avg_with in a:
avg = (el + to_avg_with) / 2
if avg in a:
average_count += 1
@rorhug
rorhug / s2.py
Created February 22, 2014 18:56
final 2014 q2
room_count = int(raw_input())
def tb(x):
return x == "*"
def get_room_in_bools():
height, width = [ int(y) for y in raw_input().split(" ") ]
return [ [ tb(x) for x in list(raw_input()) ] for y_axis in xrange(0, height) ]
room_grids = [get_room_in_bools() for x in xrange(0, room_count)]