Skip to content

Instantly share code, notes, and snippets.

require 'open3'
module Derp
def self.system(*args)
raise "No arguments specified." unless args && args.class == Array && args.size > 0
# This style of calling system allows for redirection and pipes, where the normal array style does not.
command = (args.flatten.compact.map{|a| a.match(/ /) ? "\"#{a}\"" : a }).join(' ')
puts command if $DEBUG
@chorn
chorn / gist:bf0c82058880f2fb1d0a
Last active August 29, 2015 14:23
popen4 woo hoo
require 'open4'
module Derp
def self.system(*args)
raise "No arguments specified." unless args && args.class == Array && args.size > 0
# This style of calling system allows for redirection and pipes, where the normal array style does not.
command = (args.flatten.compact.map{|a| a.match(/ /) ? "\"#{a}\"" : a }).join(' ')
puts command if $DEBUG
iops_simple() {
local _dir="$1"
[[ -d "$_dir" ]] || return
local _output=$(mktemp fio_XXXX)
local _size="2G"
local -i _jobs=8
local _engine="vsync"
local -i _files=$((_jobs * 4))
local -i _depth=$((_jobs * 8))
iops_simple() {
local _dir="$1"
[[ -d "$_dir" ]] || return
local _output=$(mktemp fio_XXXX)
local _size="2G"
local -i _jobs=8
local _engine="vsync"
local -i _files=$((_jobs * 4))
local -i _depth=$((_jobs * 8))
#!/bin/bash
#------------------------------------------------------------------------------
# netfilter-pants
#
# The MIT License (MIT)
#
# Copyright (c) 1999 Chris Horn
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
#!/usr/bin/env bash
declare -i _COLUMNS=$(sh -O checkwinsize -i -c 'echo $COLUMNS')
((_COLUMNS > 80)) || _COLUMNS=80
declare -i _PIDW=7
declare -i _USERW=15
declare -i _PORTW=$(($_COLUMNS / 6))
declare -i _CMDW=_COLUMNS-_PIDW-_USERW-_PORTW-_PORTW-7
_truncate_cmd=3

Keybase proof

I hereby claim:

  • I am chorn on github.
  • I am chorn (https://keybase.io/chorn) on keybase.
  • I have a public key whose fingerprint is 5694 FB04 DD13 19D0 5C5D 8A10 65CB EA2B 9A68 DAB3

To claim this, I am signing this object:

unset __messy_path
unset __cleaned_path
unset __path_check
declare -A __path_check
__messy_path+=(/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin /Applications/VMware\ Fusion.app/Contents/Library /Applications/Postgres.app/Contents/Versions/{9.3,9.4}/bin /{usr,opt}/{local,X11}/{bin,sbin} $HOME/bin)
__messy_path+=($(IFS=:; echo $PATH))
__messy_path+=(/{usr,opt}/{bin,sbin} /{bin,sbin})
unset __messy_path
unset __cleaned_path
unset __path_check
declare -A __path_check
__messy_path+=(/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin /Applications/VMware\ Fusion.app/Contents/Library /Applications/Postgres.app/Contents/Versions/{9.3,9.4}/bin /{usr,opt}/{local,X11}/{bin,sbin} $HOME/bin)
__messy_path+=($(IFS=:; echo $PATH))
__messy_path+=(/{usr,opt}/{bin,sbin} /{bin,sbin})
@chorn
chorn / gcc49.rb
Created July 8, 2014 11:53
OS X Homebrew Formula compatible with Yosemite (10.10) and Xcode6 Beta as of 2014-07-08
require 'formula'
class Gcc49 < Formula
def arch
if Hardware::CPU.type == :intel
if MacOS.prefer_64_bit?
'x86_64'
else
'i686'
end