Skip to content

Instantly share code, notes, and snippets.

View darkhelmet's full-sized avatar
🏠
Working from home

Daniel Huckstep darkhelmet

🏠
Working from home
View GitHub Profile
@darkhelmet
darkhelmet / balance.go
Created June 16, 2013 05:05
Simple TCP load balancer in Go.
package main
import (
"flag"
"io"
"log"
"net"
"strings"
)
#!/usr/bin/env ruby
class Symbol
def pipe(method)
proc { |array| array.send(method) { |elem| elem.send(self) } }
end
def detect
pipe(:detect)
end
@darkhelmet
darkhelmet / readability-bookmarklet.js
Created February 16, 2011 19:39
Original readability bookmarklet
javascript:(function(){readConvertLinksToFootnotes=false;readStyle='style-newspaper';readSize='size-medium';readMargin='margin-wide';_readability_script=document.createElement('script');_readability_script.type='text/javascript';_readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());document.documentElement.appendChild(_readability_script);_readability_css=document.createElement('link');_readability_css.rel='stylesheet';_readability_css.href='http://lab.arc90.com/experiments/readability/css/readability.css';_readability_css.type='text/css';_readability_css.media='all';document.documentElement.appendChild(_readability_css);_readability_print_css=document.createElement('link');_readability_print_css.rel='stylesheet';_readability_print_css.href='http://lab.arc90.com/experiments/readability/css/readability-print.css';_readability_print_css.media='print';_readability_print_css.type='text/css';document.getElementsByTagName('head')[0].appendChild(_readability_prin
@darkhelmet
darkhelmet / pre-commit
Created March 21, 2019 14:59
Never commit ruby syntax errors
#!/usr/bin/env bash
set -e
files() {
git diff --name-only --cached --full-index
}
check() {
while read file; do
filename=$(basename "$file")
class ApplicationRestriction
include Virtus.model(strict: true)
def to_module(&block)
restriction = self
mod = Module.new do
define_singleton_method(:inspect) do
"#{restriction.class.name}(#{restriction.attributes})"
end
end
mysql> EXPLAIN SELECT * FROM tf_users WHERE user_id = 'darkhelmet';
+----+-------------+----------+--------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+--------+---------------+------+---------+------+------+-------+
| 1 | SIMPLE | tf_users | system | NULL | NULL | NULL | NULL | 1 | |
+----+-------------+----------+--------+---------------+------+---------+------+------+-------+
1 row in set (0.00 sec)
2012/08/21 10:41:40 took 1.831589s (9 ns/op) to try 'a' for index 0
2012/08/21 10:41:42 took 1.812426s (9 ns/op) to try 'b' for index 0
2012/08/21 10:41:45 took 1.816416s (9 ns/op) to try 'c' for index 0
2012/08/21 10:41:48 took 1.82774s (9 ns/op) to try 'd' for index 0
2012/08/21 10:41:50 took 1.814831s (9 ns/op) to try 'e' for index 0
2012/08/21 10:41:53 took 1.825167s (9 ns/op) to try 'f' for index 0
2012/08/21 10:41:56 took 1.858311s (9 ns/op) to try 'g' for index 0
2012/08/21 10:41:59 took 1.818296s (9 ns/op) to try 'h' for index 0
2012/08/21 10:42:02 took 1.883082s (9 ns/op) to try 'i' for index 0
2012/08/21 10:42:04 took 1.834942s (9 ns/op) to try 'j' for index 0
@darkhelmet
darkhelmet / minikube-bootstrap.sh
Last active May 23, 2018 20:34 — forked from minrk/minikube-bootstrap.sh
bootstrap single node kubernetes with minikube (no vm)
set -x
# apt -y update
# apt -y dist-upgrade
# apt -y install docker.io
which minikube || (curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && mv minikube /usr/local/bin/)
which kubectl || (curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && mv kubectl /usr/local/bin/)
which helm || (curl -Lo helm.tar.gz https://kubernetes-helm.storage.googleapis.com/helm-v2.6.1-linux-amd64.tar.gz && tar -xzf helm.tar.gz && mv linux-amd64/helm /usr/local/bin/)
@darkhelmet
darkhelmet / Random Goodies
Last active March 12, 2018 22:15
MTG Want List
4 Azor, the Lawbringer
4 Back to Nature
1 Cruel Tutor
1 Deranged Hermit
1 Devoted Druid
3 Dire Fleet Daredevil
4 Dire Fleet Poisoner
1 Hypnotic Specter
1 Reflecting Pool
1 Stormbreath Dragon
gem 'resque', '>= 1.10.0'
gem 'heroku' # You will need the heroku gem for this too.