Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
ORIGIN=`basename "$0"`
BRANCH=${1:-master}
set -e
git fetch "$ORIGIN"
REV1=`git rev-parse "$ORIGIN/$BRANCH"`
REV2=`git rev-parse "$BRANCH"`
#!/usr/bin/ruby
require 'pathname'
file, project = ARGV.take(2).collect do |p|
if p.empty?
nil
else
Pathname.new(p)
end
class ObjectSocket
BLOCK_SIZE = 4096
def self.pair
Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM, 0).map { |s| new(s) }
end
def initialize(socket)
@socket = socket
end
@wisq
wisq / iterm-vim.rb
Created December 8, 2011 17:21
Run vim in a new iterm tab
#!/usr/bin/ruby
require 'tempfile'
APPLESCRIPT = <<EOF
tell application "iTerm"
activate
tell the first terminal
set new_session to (make new session at the end of sessions)
@wisq
wisq / gist:1507733
Created December 21, 2011 21:14
Why I love zsh (and hate being forced to use bash)

Why I love zsh (and hate being forced to use bash)

  • Smarter completion. A few examples:
  • context sensitive -- if you have file "name1" and directory "name2", "cd nam<TAB>" completes to "name2/"
  • "tar xf <TAB>" completes to tarballs only. "unrar x <TAB>" completes to RARs only. etc.
  • rsync / scp completion: "rsync host:anything/<TAB>" shows you files on host under anything/
  • also works with rsync:// URLs
  • SSH host completion from ~/.ssh/config & ~/.ssh/known_hosts
  • lots of other smart completions: Rake tasks, git commands & SHAs, dpkg packages, dash-options for most commands, etc etc.
@wisq
wisq / zshenv.sh
Created December 21, 2011 22:06
My zshrc & zshenv
# Custom PATH to avoid every utility prepending more duplicate entries to it:
export PATH="$HOME/bin:$HOME/.rbenv/shims:$HOME/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
@wisq
wisq / knife.rb
Created March 7, 2012 05:32
knife 0.9.18 wrapper with suppressed warnings
#!/usr/bin/env ruby
# Optional: Force a particular Ruby version & gemset.
if ENV['BUNDLE_GEMFILE'].nil?
ENV['RBENV_VERSION'] = '1.9.3'
ENV['BUNDLE_GEMFILE'] = "#{ENV['HOME']}/ops/kitchen/Gemfile"
exec('bundle', 'exec', $0, *ARGV)
end
# Suppress iconv deprecation warning.
% ls
cache-fm/ crawl/ git-up/ misc/ ruby-build/ ssh-ride/ zsh-completions/
% ruby -e 'p IO.popen("echo *", &:read)'
"cache-fm crawl git-up misc ruby-build ssh-ride zsh-completions\n"
% ruby -e 'p IO.popen(["echo", "*"], &:read)'
"*\n"
@wisq
wisq / gist:2356189
Created April 11, 2012 01:33
Why chowning /usr/local is bad

So let's say you're trying to write an app that will get root privs on someone's Macbook. Okay, there's a few different ways to go about this.

One, you could just run an application that asks for their login password and hope they're stupid enough to supply it. You'll catch some newbies but a lot of people will notice something's wrong, and if you're trying to spread before anyone notices, it's game over.

Two, you could create your own "sudo" and put it somewhere in their $PATH, including altering their login to point their $PATH to a new directory somewhere. But firstly, you're relying on someone running sudo eventually (many people never touch the command line), and secondly, some people are still going to notice.

So here's your third option. You only infect people who are running Homebrew, who have their /usr/local chowned to them. Why is this handy? Because /usr/local is in the default system-wide path. You can bet there's some script that runs with root privileges, that has /usr/local/bin o

--- extrabiomes.cfg-client 2013-04-09 19:17:45.000000000 -0400
+++ extrabiomes.cfg-server 2013-03-04 18:48:06.000000000 -0500
@@ -1,176 +1,139 @@
# Configuration file
####################
-# biome
+# block
####################