Skip to content

Instantly share code, notes, and snippets.

View xxx's full-sized avatar

Michael Dungan xxx

View GitHub Profile
@xxx
xxx / fdw.sql
Last active July 14, 2017 22:08
CREATE SCHEMA staging;
CREATE EXTENSION postgres_fdw;
CREATE SERVER staging FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'hostname', dbname 'dbname', port'5432');
CREATE USER MAPPING FOR CURRENT_USER SERVER staging OPTIONS (user 'username', password 'password');
IMPORT FOREIGN SCHEMA public FROM SERVER staging INTO staging;
-- CREATE TABLE public.lol AS SELECT * from staging.users where <whatever>...
@xxx
xxx / .psqlrc
Last active July 17, 2017 19:03
\set PROMPT1 '%[%033[33;1m%]%x%[%033[0m%]%[%033[1m%]%/%[%033[0m%]%R%# '
\timing
\pset linestyle unicode
\pset border 2
\set show_slow_queries 'SELECT (total_time / 1000 / 60) as total_minutes, (total_time/calls) as average_time, query FROM pg_stat_statements ORDER BY 1 DESC LIMIT 100;'
\x auto
\pset null '␀'
\set COMP_KEYWORD_CASE upper
\pset format wrapped
@xxx
xxx / JolokiaCommands.md
Created February 10, 2017 23:08 — forked from yashpatil/JolokiaCommands.md
Jolokia URLs for quick access to A-MQ statistics

This is a quick reference to get to Jolokia statistics urls for JBoss Fuse or JBoss A-MQ statistics. Sometimes, when you are interested in very specific attributes, it's easier to keep monitoring a specific url rather than loading the full Hawtio console.

function eyserver {
local ey_env=$1
local server_scope=$2
if [ "$ey_env" = "" ]; then
ey_env="stipple_prod"
fi
if [ "$server_scope" = "" ]; then
server_scope="--all"
@xxx
xxx / redis.yml
Created January 28, 2013 22:41
initialization of sidekiq, the hard way
defaults:
:port: 6379
:host: localhost
development:
:db: 2
:namespace: development
# force use of Redis::Distributed
:host:
- localhost
function eyserver {
local ey_env=$1
local server_scope=$2
if [ "$ey_env" = "" ]; then
ey_env="stipple_prod"
fi
if [ "$server_scope" = "" ]; then
server_scope="--all"
@xxx
xxx / mutt-iterm
Created June 17, 2012 06:53
applescript to run mutt in an iterm (or iterm2)
tell application "iTerm"
activate
set t to (make new terminal)
tell t
set number of columns to 100
set number of rows to 30
tell (make new session at the end of sessions)
exec command "mutt"
end tell
end tell
@xxx
xxx / view_attachment.sh
Created June 16, 2012 23:35
view_attachment.sh file for mutt on OSX. Tweaked from others available on the net to handle filenames with multiple dots in them, as well as correctly parsing the output of `file -bi` when a type is not specified.
#!/bin/bash
#
# Author: Eric Gebhart
#
# Purpose: To be called by mutt as indicated by .mailcap to handle mail attachments.
#
# Function: Copy the given file to a temporary directory so mutt
# Won't delete it before it is read by the application.
#
# Along the way, discern the file type or use the type
@xxx
xxx / image_resize.js
Created April 6, 2012 02:08 — forked from felixge/image_resize.js
On demand image resizing with node.js in
// Usage: http://localhost:8080/image.jpg/100x50
var http = require('http');
var spawn = require('child_process').spawn;
http.createServer(function(req, res) {
var params = req.url.split('/');
var convert = spawn('convert', [params[1], '-resize', params[2], '-']);
res.writeHead(200, {'Content-Type': 'image/jpeg'});
convert.stdout.pipe(res);
@xxx
xxx / watermark.rb
Created June 28, 2011 19:11
Paperclip watermarking processor
module Paperclip
class Watermark < Processor
# Handles watermarking of images that are uploaded.
attr_accessor :current_geometry, :target_geometry, :format, :whiny, :convert_options, :watermark_path, :watermark_offset, :overlay, :position
def initialize file, options = {}, attachment = nil
super
geometry = options[:geometry]
@file = file
@crop = geometry[-1,1] == '#'