Skip to content

Instantly share code, notes, and snippets.

View schlueter's full-sized avatar

Brandon Schlueter schlueter

  • United States of America
View GitHub Profile
@schlueter
schlueter / recursive_chef_path.rb
Last active August 29, 2015 14:01
Recursively create folders with chef
split_path = path.split('/')
split_path.each_with_index.map do | _, index |
# Reconstruct each path that makes up the target path and ensure they are created
partial_path = ::File.join split_path.slice(0, index + 1)
next if partial_path == ''
directory partial_path do
owner node[:oracle][:database][:install_user]
group node[:oracle][:database][:install_group]
mode 0775
end
@schlueter
schlueter / osx_init.sh
Last active August 29, 2015 14:18
OS X Init
# Show hidden files
defaults write -g AppleShowAllFiles -bool true
killall Finder
# Hide desktop
defaults write com.apple.finder CreateDesktop false
killall Finder
@schlueter
schlueter / gist:50cf66775c8c0426b06e
Created April 2, 2015 20:01
Pyenv install OS X 10.10.2
CFLAGS="-I$(xcrun --show-sdk-path)/usr/include -I$(brew --prefix openssl)/include" LDFLAGS="-L$(brew --prefix openssl)/lib" pyenv install 3.4.3
@schlueter
schlueter / gist:af81bf0eb258379d1c49
Created April 15, 2015 14:50
pyenv python install os x
CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 3.4.3
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.
@schlueter
schlueter / gist:bb0d50df0e5e1a981c08
Created June 16, 2015 03:38
CLI progress output (for Bytes) when partial and total may be queried
import math
def update(partial, total):
measurement_heuristic = int(math.floor(math.log10(total)) - 1)/3
unit, divisor = {
0: ('B', 1),
1: ('kB', 1000),
2: ('MB', 1e6),
3: ('GB', 1e9),
4: ('TB', 1e12)
@schlueter
schlueter / git one liners.sh
Last active September 8, 2015 15:24
Helpful git one liners
# When you want the original versions of files during a rebase
git status | awk '/(both added|both modified):/ {
sub(/(both added|both modified):/, ""); print $1
}' | xargs -n1 git checkout $(git show | awk ' /commit/ { print $2 }')
# When you don't want files added during a rebase
git status | awk '/added by them:/ {
sub(/added by them:/, ""); print $1
}' | xargs -n1 git rm
@schlueter
schlueter / cleanup.sh
Last active November 9, 2015 19:07
Source cleanup on OS X
# Remove trailing whitespace
find . -not \( -name .git -prune \) -type f -print0 | LC_ALL=C xargs -0 sed -i '' -E "s/[[:blank:]]+$//"
# Add newline @ eof if missing
find . -type f -print0 | LC_ALL=C xargs -0 sed -i -e '$a\' file
@schlueter
schlueter / gist:fc7a418a8f8a5fac5a84
Last active February 9, 2016 03:00
Useful Oracle Queries
# discover what programs are still connected to a db
select sid,serial#,program from v$session where username = '<your_schema>';
# and forcibly disconnect them
select 'alter system kill session ''' || sid || ',' || serial# || ''';' from v$session where username = '<your_schema>'
#Shutdown and restart cdb and pdb
shutdown;
#then
startup;
INFO global: Vagrant version: 1.8.1
INFO global: Ruby version: 2.2.3
INFO global: RubyGems version: 2.4.5.1
INFO global: VAGRANT_OLD_ENV_SSH_TTY="/dev/ttys000"
INFO global: VAGRANT_OLD_ENV_MAIL="/var/mail/vagrant"
INFO global: VAGRANT_OLD_ENV_PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="/opt/vagrant/embedded"
INFO global: VAGRANT_OLD_ENV_SSH_CONNECTION="192.168.2.1 60992 192.168.2.133 22"
INFO global: VAGRANT_OLD_ENV_SSH_CLIENT="192.168.2.1 60992 22"
INFO global: VAGRANT_OLD_ENV_OLDPWD="/Users/vagrant"