Permalink
Browse files

Cool stuff from mathiasbynens

  • Loading branch information...
dflems committed Dec 3, 2013
1 parent cae4763 commit 5b9591a4a2879e5a2ddb20c0ea3a91339b5cab9e
Showing with 127 additions and 6 deletions.
  1. +0 −2 bin/lockme
  2. +14 −0 functions/calc
  3. +1 −0 functions/digga
  4. +10 −0 functions/fs
  5. +1 −0 functions/mkp
  6. +5 −0 functions/servit
  7. +31 −0 homebrew/Brewfile
  8. +1 −3 homebrew/install.sh
  9. +53 −0 osx/aliases.zsh
  10. +11 −1 system/aliases.zsh
View
@@ -1,2 +0,0 @@
-#!/bin/sh
-/System/Library/CoreServices/"Menu Extras"/User.menu/Contents/Resources/CGSession -suspend
View
@@ -0,0 +1,14 @@
+local result=""
+result="$(printf "scale=10;$*\n" | bc --mathlib | tr -d '\\\n')"
+# └─ default (when `--mathlib` is used) is 20
+#
+if [[ "$result" == *.* ]]; then
+ # improve the output for decimal numbers
+ printf "$result" |
+ sed -e 's/^\./0./' `# add "0" for cases like ".5"` \
+ -e 's/^-\./-0./' `# add "0" for cases like "-.5"`\
+ -e 's/0*$//;s/\.$//' # remove trailing zeros
+else
+ printf "$result"
+fi
+printf "\n"
View
@@ -0,0 +1 @@
+dig +nocmd "$1" any +multiline +noall +answer
View
@@ -0,0 +1,10 @@
+if du -b /dev/null > /dev/null 2>&1; then
+ local arg=-sbh
+else
+ local arg=-sh
+fi
+if [[ -n "$@" ]]; then
+ du $arg -- "$@"
+else
+ du $arg .[^.]* *
+fi
View
@@ -0,0 +1 @@
+mkdir -p "$@" && cd "$@"
View
@@ -0,0 +1,5 @@
+local port="${1:-8000}"
+sleep 1 && open "http://localhost:${port}/" &
+# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
+# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
+python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
View
@@ -0,0 +1,31 @@
+# Make sure we’re using the latest Homebrew
+update
+
+# Upgrade any already-installed formulae
+upgrade
+
+# Install GNU core utilities (those that come with OS X are outdated)
+install coreutils
+
+# Install GRC for coloring
+install grc
+
+# Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed
+#install findutils
+
+# Install wget with IRI support
+#install wget --enable-iri
+
+# Install more recent versions of some OS X tools
+install vim --override-system-vi
+
+# Install other useful binaries
+install ack
+install git
+install ngrep
+#install node
+install rename
+install tree
+
+# Remove outdated versions from the cellar
+cleanup
View
@@ -10,11 +10,9 @@ if test ! $(which brew)
then
echo " Installing Homebrew for you."
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" > /tmp/homebrew-install.log
-else
- brew update
fi
# Install homebrew packages
-brew install grc coreutils
+brew bundle "${0%/*}/Brewfile"
exit 0
View
@@ -1 +1,54 @@
+# Quick-open iOS Simulator
alias ios="open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app"
+
+# Clean up LaunchServices to remove duplicates in the “Open With” menu
+alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
+
+# Flush Directory Service cache
+alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"
+
+# Empty the Trash on all mounted volumes and the main HDD
+# Also, clear Apple’s System Logs to improve shell startup speed
+alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl"
+
+# Show/hide hidden files in Finder
+alias showhf="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
+alias hidehf="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
+
+# Hide/show all desktop icons (useful when presenting)
+alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
+alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
+
+# Spotlight
+alias spotoff="sudo mdutil -a -i off"
+alias spoton="sudo mdutil -a -i on"
+
+# One of @janmoesen’s ProTip™s
+for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
+ alias "$method"="lwp-request -m '$method'"
+done
+
+# PlistBuddy alias, because sometimes `defaults` just doesn’t cut it
+alias plistbuddy="/usr/libexec/PlistBuddy"
+
+# Ring the terminal bell, and put a badge on Terminal.app’s Dock icon
+# (useful when executing time-consuming commands)
+alias badge="tput bel"
+
+# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
+alias stfu="osascript -e 'set volume output muted true'"
+alias pumpitup="osascript -e 'set volume 7'"
+alias hax="growlnotify -a 'Activity Monitor' 'System error' -m 'WTF R U DOIN'"
+
+# Kill all the tabs in Chrome to free up memory
+# [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
+alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill"
+
+# Lock the screen (when going AFK)
+alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
+
+# OS X has no `md5sum`, so use `md5` as a fallback
+command -v md5sum > /dev/null || alias md5sum="md5"
+
+# OS X has no `sha1sum`, so use `shasum` as a fallback
+command -v sha1sum > /dev/null || alias sha1sum="shasum"
View
@@ -7,4 +7,14 @@ then
alias l="gls -lAh --color"
alias ll="gls -l --color"
alias la='gls -A --color'
-fi
+fi
+
+# Enhanced WHOIS lookups
+alias whois="whois -h whois-servers.net"
+
+# URL-encode strings
+alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
+
+# View HTTP traffic
+alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
+alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""

0 comments on commit 5b9591a

Please sign in to comment.