Skip to content

Instantly share code, notes, and snippets.

Jason Moiron jmoiron

Block or report user

Report or block jmoiron

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:0f4b7c54db9a72b7e35ed0536265cfdc
>>> humanize.naturalsize(1<<30)
'1.1 GB'
>>> humanize.naturalsize(1<<30, binary=True)
'1.0 GiB'
humanize.naturalsize(1<<30, gnu=True)
'1.0G'
View gist:c0b5b7ac6f2ceb057d992c1dba488ac9
~$ chef-shell -wat
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:230:in `parse_options': invalid option: -wat (OptionParser::InvalidOption)
from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36/lib/chef/shell.rb:288:in `parse_opts'
from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36/lib/chef/shell.rb:178:in `parse_opts'
from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36/lib/chef/shell.rb:56:in `start'
from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36/bin/chef-shell:34:in `<top (required)>'
from /usr/bin/chef-shell:57:in `load'
from /usr/bin/chef-shell:57:in `<main>'
@jmoiron
jmoiron / mp3.py
Created May 25, 2017
old weechat plugin using python interface for mp3 announcing from a bunch of diff linux mp3 players
View mp3.py
#!/usr/bin/env python
#
# this module uses code from Michael Hudson's xmms-py modules
# this code is available in its original form here:
# http://www.python.net/crew/mwh/hacks/xmms-py.html
# the original code had this notice on it:
#
# Released by Michael Hudson on 2000-07-01, and again on 2001-04-26
# public domain; no warranty, no restrictions
#
@jmoiron
jmoiron / hall_of_shame.txt
Last active Mar 26, 2017
corpus statustics
View hall_of_shame.txt
stats:
directories: 20185
projects: 1127
go files (*.go): 62783
vendored go files: 33314
duplicated paths: 23452
duplicated files: 14784
unique files: 47999
fmt stats:
View synpad.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Simple synaptics client save/restore."""
import argparse
import sys
import os.path
from collections import OrderedDict
from subprocess import *
@jmoiron
jmoiron / shm_test.c
Created Apr 2, 2015
if you mmap an shm_open created fd, then ftruncate+mmap again, do you lose the memory you've been writing to?
View shm_test.c
#include <stdbool.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
void print_region(char *ptr, size_t len);
// mark a few locations in a pointer
void mark(char *ptr, size_t len) {
@jmoiron
jmoiron / install.sh
Last active Jun 20, 2016
jinkies is a very simple jenkins cli
View install.sh
#!/bin/sh
python -c 'import docopt'
if [ $? != 0 ]; then
echo "Missing docopt module."
echo " pip install docopt"
echo ""
echo "or for ubuntu/debian users:"
echo " apt-get install python-docopt"
@jmoiron
jmoiron / Makefile
Last active Dec 23, 2015
monte carlo pi estimation in different languages
View Makefile
all: monte-c monte-go monte-rs monte-gccgo
monte-go:
go build montepi.go && mv montepi monte-go
monte-rs:
rustc -O -o monte-rs montepi.rs
monte-c:
gcc -std=c99 -O2 -o monte-c montepi.c -lm
View json-loads-stats.py
# github search for "json.loads(" => 210,000 matches
feed = urllib2.urlopen("http://example.com/api.json").read()
data = json.loads(feed)
# github search for "json.load(" => 58,000 matches
data = json.load(urllib2.urlopen("http://example.com/api.json"))
View wrong-way.sh
# this is how we program for some reason
ls > files.txt
grep "foo" files.txt > grepped.txt
wc -l grepped.txt
rm files.txt grepped.txt
You can’t perform that action at this time.