Skip to content

Instantly share code, notes, and snippets.

@johnd
johnd / add_sound_to_timelapse.sh
Created April 24, 2022 16:12
Script to automate adding a woooop sound to videos.
#!/usr/bin/env bash -e
#
# Copyright 2022 John Daniels <john@theelectricengine.com>
#
# Usage of the works is permitted provided that this instrument is retained
# with the works, so that any entity that uses the works is notified of this
# instrument.
# DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
# This script is intended to add a woooooooop sound to short vidoes.
@johnd
johnd / keybase.md
Created July 9, 2019 13:58
keybase.md

Keybase proof

I hereby claim:

  • I am johnd on github.
  • I am semanticist (https://keybase.io/semanticist) on keybase.
  • I have a public key ASBUJ0_KNxWIw9H6ue8WuA4w0lxDihv9_3lNS4apAK4FJAo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am johnd on github.
  • I am semanticist (https://keybase.io/semanticist) on keybase.
  • I have a public key whose fingerprint is EBE2 C121 15D5 171E DFA7 7C86 A1B0 0076 674E CA69

To claim this, I am signing this object:

#!/bin/bash
while /usr/bin/curl -s "http://www.myvue.com/latest-movies/info/cinema/Edinburgh%20Ocean%20Terminal/film/doctor-who-the-day-of-the-doctor-3d" | /usr/bin/grep "Sorry, there are no times"
do
echo "nope"
done
echo "yup"
@johnd
johnd / benchmark_results.txt
Created November 13, 2013 14:15
Benchmark output for explicit vs implicit returns against all the Rubies randomly installed on my desktop.
john@SLAB:~/Dropbox/Code$ rvm all --verbose do ruby explict_implicit_bm.rb
jruby-1.6.5: jruby 1.6.5 (ruby-1.8.7-p330) (2011-10-25 9dcd388) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_51) [darwin-x86_64-java]
Rehearsal --------------------------------------------
explicit 0.397000 0.000000 0.397000 ( 0.368000)
implicit 0.339000 0.000000 0.339000 ( 0.339000)
----------------------------------- total: 0.736000sec
user system total real
explicit 0.340000 0.000000 0.340000 ( 0.340000)
implicit 0.355000 0.000000 0.355000 ( 0.355000)
@johnd
johnd / touchpad_stalker.rb
Created August 22, 2011 17:09
Cheesy script for stalking cheap obsolete internet tablets.
require 'rubygems'
require 'nokogiri'
require 'open-uri'
URL = "http://www.dixons.co.uk/gbuk/r/touchpad/0_0_0/"
SELECTOR = ".prd-amount strong"
TARGET_PRICE = "89"
@johnd
johnd / gist:1073604
Created July 9, 2011 14:12
New prompt!
case "$UID" in
0)
user_colour="00;31"
;;
*)
user_colour="00;36"
;;
esac
case "$TERM" in
class Article < ActiveRecord::Base
after_validation :ensure_no_published_at_dates_in_the_future
# ...
private
def ensure_no_published_at_dates_in_the_future
self.published_at = Date.today if self.published_at > Date.today
end
@johnd
johnd / my_accessor.rb
Created April 7, 2011 14:38
#scotruby exercise
module Mod
def my_accessor(field)
@my_attributes ||= Array.new
Mod.add_all_attributes(field)
attr_accessor field
@my_attributes << field
end
@johnd
johnd / configuration.rb
Created April 7, 2011 10:58
ScotRuby tutorial exercise 2
class Configuration
attr_accessor :tail_logs, :max_connections, :admin_password
def app_server(&block)
@app_server_config ||= AppServer.new
block.call @app_server_config if block_given?
@app_server_config
end
end