Skip to content

Instantly share code, notes, and snippets.

View 1stvamp's full-sized avatar
:shipit:

Wes Mason 1stvamp

:shipit:
View GitHub Profile
@1stvamp
1stvamp / celery_msgs.py
Created February 24, 2014 15:42
Simple tool for displaying contents of celery messages
from base64 import b64decode
from json import loads
from pprint import pprint
def parse_celery_msg(msg):
pprint(loads(b64decode(msg)))
@1stvamp
1stvamp / gist:9133125
Created February 21, 2014 12:00
Testing reliability of typesafe === operator in PHP for use in unit tests
$ phpsh
Starting php
type 'h' or 'help' to see instructions & features
php> echo array('foo'=>'bar') === array('foo'=>'bar')
1
php> echo array('foo'=>'baz') === array('foo'=>'bar')
php> echo array('foo'=>array(1)) === array('foo'=>array())
php> echo array('foo'=>array(1)) === array('foo'=>array(1))
@1stvamp
1stvamp / mkv_to_mp4.py
Created January 2, 2014 10:05
Script to convert mkv's in sub-dirs to mp4 containers using ffmpeg
import glob, sys, os, subprocess
path = os.path.abspath(os.path.dirname(__file__))
files = glob.glob('*/*.mkv')
ffmpeg = '/home/wes/ffmpeg-dmo-2.1.1/ffmpeg'
for f in files:
f = os.path.join(path, f).replace(' ', '\\ ').replace('(', '\(').replace(')', '\)').replace('&', '\&').replace(';', '\;')
@1stvamp
1stvamp / markgen.py
Last active January 1, 2016 22:49
Python module to allow the simple programmatic generation of Markdown mark-upped text.
def header(content, depth=1, underline=False):
if underline:
char = ('=', '-', '*')[(depth if depth < 4 else 3)]
return "{0}\n{1}".format(content, (char * len(content)))
return "{0} {1}".format(('#' * depth), content)
def quote(content, prefix='> '):
return "\n".join("> {0}".format(c) for c in content.split("\n"))
@1stvamp
1stvamp / fabfile.py
Created December 18, 2013 12:42 — forked from benatkin/fabfile.py
from fabric.api import env, task, run, sudo, cd, local
from fabric.decorators import with_settings
from fabric.operations import put
env.user = 'ec2-user'
env.hosts = [
'ec2-your-address-1.us-west-2.compute.amazonaws.com',
'ec2-your-address-2.us-west-2.compute.amazonaws.com',
'ec2-your-address-3.us-west-2.compute.amazonaws.com',
'ec2-your-address-4.us-west-2.compute.amazonaws.com',
@1stvamp
1stvamp / line_endings.js
Last active December 30, 2015 21:39
JS to detect line endings
var macLeRe = /\r[^\n]/,
winLeRe = /\r\n/,
posixLeRe = /[^\r]\n/;
function detectLineEnding(str) {
var type = 'unknown';
if (winLeRe.test(str)) {
type = 'windows';
} else if (macLeRe.test(str)) {
type = 'mac';
@1stvamp
1stvamp / phpweekly_nov_giveaway.php
Created November 19, 2013 23:55
PHP Weekly Reboot Giveaway winner pickin' script
<?php
$storm_subscribers = file(dirname(__FILE__) . '/phpstorm.txt');
$storm_winner = $storm_subscribers[array_rand($storm_subscribers)];
$signals_subscribers = file(dirname(__FILE__) . '/signalsebook.txt');
$i = array_rand($signals_subscribers);
$signals_winners = array(
$signals_subscribers[$i]
@1stvamp
1stvamp / 1_dict_hashmap.py
Last active December 22, 2015 03:49
Alternatives to the callable hashmap pattern in Python
"""This is the most common form of implementing a callable map in Python,
using a dict that names each callable.
However as you can it means effectively defining names in several places
when you need more than a simple lambda for your callable, due to Python
not having first class anonymous functions.
example: python 1_dict_hashmap.py complex
"""
@1stvamp
1stvamp / gist:6051782
Last active December 20, 2015 01:49
vagrant + vmware provider error, I cleared this by opening the VMWare Fusion GUI and forcing a shutdown of the VM which was stuck in a failed boot state.
An error occurred while executing `vmrun`, a utility for controlling
VMware machines. The command and output are below:
Command: ["start", "/Users/wes/projects/serverdensity/Vagrantfiles/honshuu-environment/.vagrant/machines/default/vmware_fusion/vm.vmwarevm/precise64.vmx", "nogui", {:notify=>[:stdout, :stderr]}]
Stdout: 2013-07-22T07:48:28.125| ServiceImpl_Opener: PID 98149
Error: The operation was canceled
Stderr:
Getting distribution for 'buildout.dumppickedversions==0.5'.
While:
Installing.
Loading extensions.
Getting distribution for 'buildout.dumppickedversions==0.5'.
Error: Couldn't find a distribution for 'buildout.dumppickedversions==0.5'.