Skip to content

Instantly share code, notes, and snippets.

'$' () {
echo "📢 [${PWD##*/}] $*"
eval $*
if [[ $? -eq 0 ]]
then
announce "Success ${PWD##*/}"
else
announce "Error ${PWD##*/}"
fi
}
@jpoz
jpoz / discover.go
Created January 29, 2015 06:52
Script to view your Account Balance for your Discover Card
package main
import (
"fmt"
"net/http"
"net/http/cookiejar"
"net/url"
"os"
"time"
# remap prefix to Control + a
unbind C-b
set -g prefix C-a
# bind C-a send-prefix
bind-key a send-prefix
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
@jpoz
jpoz / gist:5324371
Last active December 15, 2015 21:18
Saturday Academy Clipboard
@jpoz
jpoz / gist:4975829
Last active December 13, 2015 21:18
class Hash
def to_url_params
elements = []
self.each_pair do |key, value|
elements << param_for(key, value).flatten
end
elements.join('&')
end
private
@jpoz
jpoz / gist:4498021
Created January 9, 2013 23:33
WTF Ruby
irb(main):021:0> m
=> "message"
irb(main):022:0> m.byteslice(0)
=> "s"
irb(main):023:0> "message".byteslice(0)
=> "m"
function announce {
say $1 && ~/bin/terminal-notifier.app/Contents/MacOS/terminal-notifier -message $1 -title $1
}
function @ {
./bin/$1 $2 $3 $4 $5
}
function $ {
eval $*
@jpoz
jpoz / gist:3900967
Created October 16, 2012 18:08
Delete all local rabbit queues
require 'json'
require 'cgi'
@host = 'http://localhost:55672'
@user = 'guest'
@pass = 'guest'
@queues = JSON.parse(`curl -u #{@user}:#{@pass} #{@host}/api/queues`)
@commands = @queues.map { |q| %Q{curl -i -u #{@user}:#{@pass} -H "content-type:application/json" -XDELETE #{@host}/api/queues/#{CGI::escape(q['vhost'])}/#{q['name']}} }
@jpoz
jpoz / upload_proxy.rb
Created February 12, 2012 23:20
Goliath File Upload Proxy Server
require 'goliath'
require 'em-synchrony/em-http'
class UploadProxy < Goliath::API
def on_headers(env, headers)
env.logger.info 'received headers: ' + headers.inspect
env['async-headers'] = headers
end
<button actlike='Example.button'>Click Me!</button>