Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Arnell voidlock

View GitHub Profile
@voidlock
voidlock / pre-commit
Created Aug 21, 2013
Git commit hooks. Shove these in your project's `.git/hooks` directory and make them executable.
View pre-commit
#!/usr/bin/env bash
# Runs all executable pre-commit-* hooks and exits after,
# if any of them was not successful.
#
# Based on
# http://osdir.com/ml/git/2009-01/msg00308.html
data=$(cat)
exitcodes=()
@voidlock
voidlock / docker-vpn-fix.sh
Created Nov 27, 2015
Fixes docker after connection to Cisco VPN
View docker-vpn-fix.sh
#!/bin/sh
for MACHINE in $(docker-machine ls -q --filter "state=Running"); do
sudo route -n add -net $(docker-machine ip $MACHINE | cut -d '.' -f 1,2,3).0/24 -interface $(VBoxManage showvminfo $MACHINE --machinereadable | grep hostonlyadapter | cut -d '"' -f 2)
done
View info.txt
redis_version:1.3.8
arch_bits:64
multiplexing_api:epoll
process_id:2562
uptime_in_seconds:6124435
uptime_in_days:70
connected_clients:170
connected_slaves:0
blocked_clients:0
used_memory:999551863
View file.sc
import cherrypy
class HelloWorld(object):
def index(self):
return "Hello World!"
index.exposed = True
cherrypy.quickstart(HelloWorld()
View bravenet-interview.php
<?php
/*************************************/
/* Just little blurb on how things should work
/* 2 types of projects - Working and Coomplete
/* Working -> display normal info
/* Complete -> display badge consisting of
/* final work and rank
/*
/*************************************/
class User {
View snippet.rb
# stolen from ActiveSupport::Concern
module Concern
def self.extended(base)
base.instance_variable_set("@_dependencies", [])
end
def append_features(base)
if base.instance_variable_defined?("@_dependencies")
base.instance_variable_get("@_dependencies") << self
return false
View snippet.rb
require "geoip_city"
require "geoip"
require "benchmark"
db = '/usr/local/share/GeoIP/GeoIPCity.dat'
ip = '24.24.24.24'
geoip_c = GeoIP::City.new(db)
geoip_city = GeoIPCity::Database.new(db)
View gist:289104
require "rubygems"
require "redis"
redis = Redis.new
redis.delete "foo" # cleanup
puts "SETNX COMMAND:"
puts "Should be true:"
puts redis.set_unless_exists("foo", 1)
puts
View file.rb
require 'benchmark'
require 'logger'
logger = Logger.new("/dev/null")
logger.level = Logger::INFO
puts "Simple Strings"
Benchmark.bmbm do |x|
x.report("string form") {
100_000.times do
View file.rb
logger.info "some message"
logger.info { "some message" }
You can’t perform that action at this time.