Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Daniel Huckstep darkhelmet

🏠
Working from home
Block or report user

Report or block darkhelmet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@darkhelmet
darkhelmet / balance.go
Created Jun 16, 2013
Simple TCP load balancer in Go.
View balance.go
package main
import (
"flag"
"io"
"log"
"net"
"strings"
)
@darkhelmet
darkhelmet / pre-commit
Created Mar 21, 2019
Never commit ruby syntax errors
View pre-commit
#!/usr/bin/env bash
set -e
files() {
git diff --name-only --cached --full-index
}
check() {
while read file; do
filename=$(basename "$file")
View application_restriction.rb
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
View explain.sql
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)
View broken.txt
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 — forked from minrk/minikube-bootstrap.sh
bootstrap single node kubernetes with minikube (no vm)
View minikube-bootstrap.sh
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/)
View Random Goodies
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
View Gemfile
gem 'resque', '>= 1.10.0'
gem 'heroku' # You will need the heroku gem for this too.
View ajaxIntercept.js
(function(open) {
XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
// Do some magic
open.call(this, method, rewrittenUrl, async, user, pass);
};
})(XMLHttpRequest.prototype.open);
View app.coffee
# Assignment:
number = 42
opposite = true
# Conditions:
number = -42 if opposite
# Functions:
square = (x) -> x * x
You can’t perform that action at this time.