Skip to content

Instantly share code, notes, and snippets.

View lgw4's full-sized avatar

Chip Warden lgw4

View GitHub Profile
@lgw4
lgw4 / brew-config
Created September 1, 2012 03:21
HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install sqlite --with-fts --with-functions --with-docs --universal
$ brew --config
HOMEBREW_VERSION: 0.9.3
HEAD: 4ef158906312451f267821e287a2a38e8ee7343e
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit ivybridge
OS X: 10.8.1-x86_64
Xcode: 4.4.1
CLT: 4.4.0.0.1.1249367152
GCC-4.0: N/A
@lgw4
lgw4 / range_vs_xrange.py
Last active December 17, 2015 22:19
range = getattr(__builtins__, 'xrange', range)
In [1]: import timeit
In [2]: timeit.timeit ('exes = [x for x in range(1000000)]', number=1000)
Out[2]: 62.725528955459595
In [3]: timeit.timeit ('exes = [x for x in xrange(1000000)]', number=1000)
Out[3]: 48.693825006484985
In [4]: range = getattr(__builtins__, 'xrange', range)
@lgw4
lgw4 / pypy_timeit.py
Last active December 17, 2015 22:49
ipython %timeit PyPy
In [1]: import sys
In [2]: print sys.version
2.7.3 (5acfe049a5b0, May 21 2013, 13:47:22)
[PyPy 2.0.2 with GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)]
In [3]: %timeit exes = [x for x in range(1000000)]
100 loops, best of 3: 16.3 ms per loop
In [4]: %timeit exes = [x for x in xrange(1000000)]
@lgw4
lgw4 / pip.conf
Last active December 25, 2015 07:29
Contents of my pip.conf file.
[global]
download-cache = /Users/lgw4/.pip/cache
respect-virtualenv = true
@lgw4
lgw4 / macos-post-install-config.sh
Last active July 25, 2022 19:52
macOS Post-Install Configuration
#!/usr/bin/env sh
# Set computer name
if [ $# -ne 1 ] && [ "$1" = "" ]; then
echo "Missing computer name. Exiting."
exit
fi
COMPUTER_NAME="$1"
HOST_NAME=$(echo "$COMPUTER_NAME" | tr '[:upper:]' '[:lower:]')
sudo scutil --set ComputerName "$COMPUTER_NAME"
sudo scutil --set HostName "$HOST_NAME"
@lgw4
lgw4 / clean_open_with_menu.sh
Last active June 8, 2022 15:53
Remove duplicate application entries in Open With contextual menu.
#!/usr/bin/env sh
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user
echo "Open With contextual menu has been rebuilt; Finder will relaunch now."
killall Finder
@lgw4
lgw4 / open_page_in_google_chrome.scpt
Created March 21, 2014 04:14
Open Page in Google Chrome
tell application "Safari"
set vURL to URL of current tab of window 1
end tell
tell application "Google Chrome.app"
if windows ≠ {} then
make new «class CrTb» at the end of window 1 with properties {«class URL »:vURL}
else
make new window
set «class URL » of («class acTa» of window 1) to vURL
@lgw4
lgw4 / vacuum_apple_mail_envelope_index.scpt
Last active October 23, 2019 10:25
Vacuum Apple Mail Envelope Index
(*
Speed up Mail.app by vacuuming the Envelope Index
Code from: http://www.hawkwings.net/2007/03/03/scripts-to-automate-the-mailapp-envelope-speed-trick/
Originally by "pmbuko" with modifications by Romulo
Updated by Brett Terpstra 2012
Updated by Mathias Törnblom 2015 to support V3 in El Capitan and still keep backwards compability
*)
tell application "Mail" to quit
set os_version to do shell script "sw_vers -productVersion"
@lgw4
lgw4 / a_better_finder_hide_command.scpt
Created March 21, 2014 04:18
A Better Finder Hide Command
tell application "System Events"
set frontProcess to first process whose frontmost is true
-- When it's down to just Finder and the front process, we have to switch
-- to the Finder first to get the front process to hide itself. Furthermore,
-- the Finder will not be listed as among the visible processes unless it
-- has open windows, so treat a condition of 2 *or fewer* visible apps as
-- meaning the Finder should be activated before hiding the front process.
@lgw4
lgw4 / retina_13_more_space.scpt
Last active September 2, 2015 21:03
More Space (1440 x 900) resolution for MacBook Pro 13" Retina, Yosemite version
-- More Space resoltuion (1440 x 900)
-- MacBook Pro 13" Retina, Yosemite version
tell application "System Preferences"
reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays"
end tell
tell application "System Events" to tell process "System Preferences" to tell window "Built-in Retina Display"
click radio button "Display" of tab group 1
click radio button "Scaled" of radio group 1 of tab group 1
click radio button 3 of radio group 1 of group 2 of tab group 1