Skip to content

Instantly share code, notes, and snippets.

View dgholz's full-sized avatar

Daniel George Holz dgholz

  • Edinburgh
View GitHub Profile
blake = "some guy"
Bleak = "a cool dude"
def hi_blake
puts "hi blake you are #{blake}"
end
def hi_bleak
puts "hi bleak you are #{Bleak}"
end
@dgholz
dgholz / gist:8313960
Last active January 2, 2016 13:59 — forked from anonymous/gist:8308733
def prompt(text=[])
text = [text].flatten
text.unshift('>').push(nil) # for trailing space
print text.join(' ')
return gets
end
def counter(maxcount)
numbers = []
for i in maxcount
@dgholz
dgholz / update-dns-with-dhcp-lease.rsc
Last active November 24, 2016 22:20
RouterOS script to create/delete DNS entries to match DHCP leases. Set it as your lease-script on your DHCP server.
/ip dhcp-server network
:local domain "default"
:do { :set domain [ get [ find where $leaseActIP in address ] domain ] } on-error={}
/ip dhcp-server
:local ttl [ get [ find where name=$leaseServerName ] lease-time ]
/ip dhcp-server lease
:local name
:do { :set name "$[ get [ find where server=$leaseServerName && address=$leaseActIP && mac-address=$leaseActMAC ] host-name ].$domain" } on-error={}
@dgholz
dgholz / .vimrc
Last active February 16, 2017 16:40
for each in ~/.vim/bundle/*/.git; do git -C $( dirname $each ) remote get-url origin; done | sort -k2 -t /
" git@github.com:tpope/vim-pathogen.git
runtime bundle/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect()
" git@github.com:altercation/vim-colors-solarized.git
set background=dark
colorscheme solarized
" git@github.com:ctrlpvim/ctrlp.vim.git
let g:ctrlp_map = '<c-p>'
@dgholz
dgholz / fizzbuzz.bf
Created February 20, 2017 20:29
FizzBuzz (Befunge93)
1:v!`*5*54p2*62*77,*5<
v _@>v >v>:#<.>1+:2^
>:3%|>:5%|> 1#^_^
v"z"<pvv<"p
:>v>v2,"-z2
"",8**,B5"*
iF,622#"::4
"",,3*^<^<3
>^>^>^>,8#^6#*<
@dgholz
dgholz / perlf_test.sh
Last active August 24, 2017 23:45
Performance comparison test script for https://github.com/dgholz/detect_virtualenv/issues/13
#!/bin/bash
function switch_branch() {
for branch in master f/fast_find
do
git -C ~/.vendor/detect_virtualenv checkout $branch >/dev/null 2>&1
. ~/.vendor/detect_virtualenv/detect_virtualenv 2>/dev/null
$@ $branch
done
}
class TileWithNeighbours
@@instances = []
attr_accessor :instances
def initialize(filename, **neighbours)
@filename = filename
@neighbours = neighbours
@@instances << self
end
attr_accessor :filename
attr_accessor :neighbours