Skip to content

Instantly share code, notes, and snippets.

View gotbadger's full-sized avatar
🦡
Set your status

Philip Hayton gotbadger

🦡
Set your status
View GitHub Profile
@gotbadger
gotbadger / listen.coffee
Created May 18, 2012 08:37
AMQP Listener
amqp = require('amqp');
connection = amqp.createConnection { host: 'localhost' }
# Wait for connection to become established.
connection.on 'ready', ()->
exchange = connection.exchange 'phil-exchange'
# Create a queue and bind to all messages.
connection.queue 'phil-queue',{autoDelete:false,durable:true}, (q)->
# Catch all messages
@gotbadger
gotbadger / publish.coffee
Created May 18, 2012 08:38
AMQP Publisher
amqp = require 'amqp'
connection = amqp.createConnection { host: 'localhost' }
# Wait for connection to become established.
connection.on 'ready', ()->
exchange = connection.exchange 'phil-exchange'
exchange.publish '#',"hello"
@gotbadger
gotbadger / dav.nginx
Created June 19, 2012 08:45
Nginx PUT
server {
listen 8880;
root /var/www;
index index.html index.htm;
server_name localhost;
location / {
@gotbadger
gotbadger / gist:4979243
Created February 18, 2013 17:54
Setup SSH tunnel on OSX
#!/bin/bash
# setup local
BIND_ADAPTER="en0"
LOCAL_PORT=4000
# setup remote
REMOTE_USER="user"
REMOTE_HOST="server.example.com"
REMOTE_PORT=9999
@gotbadger
gotbadger / gist:5109289
Created March 7, 2013 16:25
compare the changes in two branches. in this case the changes between master and development
git --no-pager diff --stat --color master..development
@gotbadger
gotbadger / gist:6702336
Created September 25, 2013 16:35
Twitter Bootstrap 3 Find and Replace For Sublime. Usefull for adding all col sizes after only adding large
Find: col-lg-(\w)+
Replace col-lg-$1 col-md-$1 col-sm-$1 col-xs-$1
@gotbadger
gotbadger / gist:2a67466df091512e96a2
Created January 19, 2015 17:11
Change mac address OSX to something random
NEW_MAC_ADDRESS=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
echo Mac changed to $NEW_MAC_ADDRESS
sudo ifconfig en0 ether $NEW_MAC_ADDRESS
ifconfig en0 |grep ether
@gotbadger
gotbadger / gist:fed5973f70a4fef50c62
Created February 4, 2015 12:45
Grab your pubkey OSX
pbcopy < ~/.ssh/id_rsa.pub
@gotbadger
gotbadger / Makefile
Last active July 17, 2016 13:18 — forked from caius/Makefile
Save edge router config & scripts to current directory
.PHONY: save save_config save_commands save_scripts
save:
make -j save_config save_commands save_scripts
save_config:
ssh 192.168.1.1 "/opt/vyatta/bin/vyatta-op-cmd-wrapper show configuration" 2> /dev/null > config.txt
save_commands:
ssh 192.168.1.1 "/opt/vyatta/bin/vyatta-op-cmd-wrapper show configuration commands" 2> /dev/null > commands.txt
@gotbadger
gotbadger / asset.rake
Created August 16, 2016 14:42
Somtimes you need to diff the output of rake assets:precompile run this script after to remove fingerprints
task non_digested: :environment do
assets = Dir.glob(File.join(Rails.root, 'public/assets/**/*'))
regex = /(-{1}[a-z0-9]{32}*\.{1}){1}/
assets.each do |file|
next if File.directory?(file) || file !~ regex
source = file.split('/')
source.push(source.pop.gsub(regex, '.'))
non_digested = File.join(source)