Skip to content

Instantly share code, notes, and snippets.

View homelinen's full-sized avatar

Calum Gilchrist homelinen

View GitHub Profile
@homelinen
homelinen / deploy.rb
Created March 18, 2013 00:05
My Deploy file for my group project, in capistrano
require "bundler/capistrano"
require "capistrano-rbenv"
# Pre-compile assets
load 'deploy/assets'
set :application, "wattball"
set :repository, "[email protected]/USER/PROJECT"
set :branch, "master"
@homelinen
homelinen / difficulties.haml
Created March 18, 2013 22:55
Page for my general maintenance pages: http://chunk.homelinen.org/404
!!! 5
%html
%head
%title On It's Way
%link(rel="stylesheet" type = "text/css" href = "template.css")
%link(rel = "stylesheet"
type = "text/css"
href = "'http://fonts.googleapis.com/css?family=Roboto:700'")
@homelinen
homelinen / ability.rb
Created March 25, 2013 22:30
Wattball permissions
class Ability
include CanCan::Ability
def initialize(user)
alias_action :read, :create, :edit, :to => :modify
alias_action :read, :edit, :destroy, :to => :self_maintain
user ||= User.new
if user.team
@homelinen
homelinen / fair-and-square.rb
Created April 13, 2013 16:03
Ruby implementation for Part C of the Google Code Jam 2013
#!/usr/bin/env ruby
def is_palindrome?(num)
num == num.to_s.reverse.to_i
end
def is_square_of_palindrome?(num)
root = Math.sqrt(num)
@homelinen
homelinen / chinese-whispers.rb
Created July 21, 2013 22:38
Simple Implementation of Chinese Whispers. Supports varying iterations and percent change.
# Chinese Whispers
#
# author: Calum Gilchrist
#
# Experiment to distort a string based on the number of nodes between the
# sender and recipient
#
require 'raspell'
require 'optparse'
#!/bin/bash
#
# Implementation of a Known Plaintext Attack
#
# Author: Calum Gilchrist
# email: [email protected]
tmp_file=temp-$RANDOM.txt
if [[ ! $# -eq 2 ]]; then
@homelinen
homelinen / znc_rotate.sh
Last active December 30, 2015 10:29
My rotation script for bouncer files
#!/bin/bash
# Clear up log files for ZNC IRC Bouncer
#
# Author: Calum Gilchrist
ZNC_HOME="/home/homelinen/.znc/"
# Remove logs older than 30 days
find $ZNC_HOME -mtime +30 -type f -name "*.log" -exec rm -v {} +
@homelinen
homelinen / gist:04dfc4fdebb8433198a6
Created December 24, 2014 12:56
Top 10 Shell Commands in history
Generated from: http://www.smallmeans.com/notes/shell-history/
git 2946 ############################################################
vim 1148 ########################
ssh 753 ################
ack 528 ###########
cd 427 #########
ls 338 #######
aws 266 ######
brew 189 ####
dig 186 ####
@homelinen
homelinen / gist:aa0555f1fafc49928137
Last active August 29, 2015 14:12
Testing enum as a replacement for tuple primitives.
#!/usr/bin/env python
from enum import Enum
from time import time
class Fruit(Enum):
bannana = (0, 1)
apple = (1, 1)
$ ./bin/npme.js start
sh: 1: ./node_modules/.bin/ndm: not found
npmE is now running (curl http://localhost:8080).
$ ./node_modules/.bin/ndm
Deploy service daemons directly from npm packages
Usage:
ndm install ask user about environment variables and install service.
...