Skip to content

Instantly share code, notes, and snippets.

@kenoir
kenoir / air-quotes.js
Created October 3, 2012 11:05 — forked from ryangadams/air-quotes.js
A js bookmarklet to extract the words on news websites that are 'quoted'.
// http://jsfiddle.net/AEg9s/
// Boomtown!
AirQuotes = {
run: function(){
var panel = (function(){
p = document.querySelector("#my-quote-panel");
if (p == null) {
<http://dbpedia.org/resource/Adolf_Hitler> <http://purl.org/NET/c4dm/event.owl#agent> "http://www.bbc.co.uk/history/events/germany_advances_through_europe" .
<http://dbpedia.org/resource/Winston_Churchill> <http://purl.org/NET/c4dm/event.owl#agent> "http://www.bbc.co.uk/history/events/germany_advances_through_europe" .
<http://dbpedia.org/resource/Neville_Chamberlain> <http://purl.org/NET/c4dm/event.owl#agent> "http://www.bbc.co.uk/history/events/germany_advances_through_europe" .
<http://dbpedia.org/resource/A._J._P._Taylor> <http://purl.org/NET/c4dm/event.owl#agent> "http://www.bbc.co.uk/history/events/germany_advances_through_europe" .
<http://dbpedia.org/resource/Paris> <http://purl.org/NET/c4dm/event.owl#place> "http://www.bbc.co.uk/history/events/germany_advances_through_europe" .
<http://dbpedia.org/resource/Richard_Holmes_(military_historian)> <http://purl.org/NET/c4dm/event.owl#agent> "http://www.bbc.co.uk/history/events/germany_advances_through_europe" .
<http://dbpedia.org/resource/Mo_Mowlam> <http
@kenoir
kenoir / insultatron.rb
Created October 4, 2012 20:09
Tube Coding
module Insultatron
class InsultGenerator
def modifier
["stinky","loser","arsey","daily mail reading"]
end
def subject
["weasel","arse","masterchef contestant"]
@kenoir
kenoir / gosub.go
Created October 7, 2012 19:44
Learning Go
// http://tour.golang.org/#13
package main
import (
"fmt"
"math"
)
var x string
@kenoir
kenoir / gist:3854773
Created October 8, 2012 20:27
Find random position in a hash
chain = {
:a => 1,
:b => 2,
:c => 3
}
(rand * chain.length).round.times do
start = chain.each.next
end
@kenoir
kenoir / gist:3855133
Created October 8, 2012 21:33
Markov chain interpolation of Jabberwocky and Twinkle Twinkle little star
The vorpal blade went snicker-snack! He left it dead, and with its head He went galumphing back And, has thou slain the Jabberwock? Come to my arms, my beamish boy! O frabjous day! Callooh! Callay! He chortled in his joy Twas brillig, and the slithy toves Did gyre and gimble in the wabe All mimsy were the borogoves And the mome raths outgrabe Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch! He took his vorpal sword in hand Long time the manxome foe he sought So rested he by the Tumtum tree And stood awhile in thought And, as in uffish thought he stood The Jabberwock, with eyes of flame Came whiffling through the tulgey wood Twas brillig, and the slithy toves Did gyre and gimble in the dark. Though I know not what you are. Up above the world so high, Like a diamond in the dark. Though
@kenoir
kenoir / gist:3865008
Created October 10, 2012 11:38
Useful openssl commands

Convert pkcs12 to pem

openssl pkcs12 -in keyStore.pfx -out keyStore.pem -nodes

Convert pem to der

openssl x509 -outform der -in <cert>.pem -out <cert>.der

Import der into keystore

@kenoir
kenoir / gist:3892934
Created October 15, 2012 14:57
CURLing through reith proxy with a cert
curl --cert ~/path/devcert.pem --cacert ~/path/ca.pem -x http://www-cache.reith.bbc.co.uk:80 https://url.of/the/thing/you/want
@kenoir
kenoir / RomanNumerals
Created October 18, 2012 09:14
Tube Coding
module RomanNumerals
def self.pairs
pairs = [
{ 1000 => "m" },
{ 900 => "cm" },
{ 100 => "c" },
{ 90 => "xc" },
{ 10 => "x" },
{ 9 => "ix" },
@kenoir
kenoir / quicksort.rb
Created October 18, 2012 21:47
Ruby in-place quicksort
module Quicksort
def self.partition(array,start_key,end_key)
pivot_value = array[start_key]
pivot_key = start_key
position = start_key + 1
puts "start",array.slice(start_key,end_key - start_key).inspect, pivot_value
while position <= end_key