Skip to content

Instantly share code, notes, and snippets.

View phil's full-sized avatar
😄

Phil Balchin phil

😄
View GitHub Profile
@phil
phil / 0_basics.rb
Created June 11, 2014 12:44
A Basic Eventmachine
require "eventmachine"
EventMachine.run do
EM.add_periodic_timer(0.1) do
puts "Hello from A"
end
EM.add_periodic_timer(0.1) do
EM.defer do
@phil
phil / aperture_stats.sql
Created September 23, 2013 11:56
App Aperture SQL: Count Photos by make, model, lens
select count(results.versionid) as c, results.* from
(select t.versionid, max(t_make.stringproperty) as make_string, max(t_model.stringproperty) as model_string, max(t_lens.stringproperty) as lens_string from rkexifstringproperty t
left outer join (select stringProperty, modelid from rkuniquestring) t_model on (t_model.modelid = t.stringid and t.propertykey = 'Model')
left outer join (select stringProperty, modelid from rkuniquestring) t_make on t_make.modelid = t.stringid and t.propertykey = 'Make'
left outer join (select stringProperty, modelid from rkuniquestring) t_lens on t_lens.modelid = t.stringid and t.propertykey = 'LensModel'
/*where propertykey = 'Model' /* use any of 'LensModel', 'Model' */
group by t.versionid) results
group by results.lens_string, results.model_string
@phil
phil / gist:6428515
Created September 3, 2013 19:34
NyxBOT
class Nyx < RTanque::Bot::Brain
NAME = 'nyx'
include RTanque::Bot::BrainHelper
attr_accessor :target, :previous_target, :projected_target_heading
def tick!
seek_radar
if target = nearest_target
@phil
phil / shell_scripts.bash
Created March 25, 2013 13:43
Shell scripts
# Show sizes of log files
find . -iname '*log' -type f | xargs ls -lhaSr
@phil
phil / shell_tools.md
Created February 7, 2013 12:44
A Collection of useful shell tools an scripts
@phil
phil / gist:4704058
Created February 3, 2013 22:40
TaskWarrior Cheatsheet

#EDITING

add [tags] [attrs] description Adds a new task to the task list.

log [tags] [attrs] description Adds a new completed task to the task list.

append [tags] [attrs] description Appends information to an existing task description.

@phil
phil / gist:3038973
Created July 3, 2012 10:40
Vim Number/RelativeNumber mode switching
" Autocmds to switch number mode based on Vim Mode
autocmd InsertEnter * :set number
autocmd InsertLeave * :set relativenumber
" function switch number mode
function! ToggleLineNumbers()
if &number == 1
set relativenumber
else