Skip to content

Instantly share code, notes, and snippets.

View veryhappythings's full-sized avatar
👋
Hello!

Mac Chapman veryhappythings

👋
Hello!
View GitHub Profile
@veryhappythings
veryhappythings / bubble_args.vim
Created October 24, 2011 14:30
Bubble arguments
" Put your cursor on an argument and user leader-w/leader-b to move it back and forth through the arg positions.
" Can't handle quotes and suchlike, but it's a start.
nmap <leader>w "adiww"sdw"aPF,"sPww
nmap <leader>b "sdiwF,b"adiw"sPww"aPbbb
#!/usr/bin/env python
# By Jeff Winkler, http://jeffwinkler.net
# http://jeffwinkler.net/2006/04/27/keeping-your-nose-green/
#
# Modified a little by Mac
# It'll loop forever and run tests whenever any code changes.
import glob,os,stat,time,sys,re
import optparse

So you want to fork your own repo?

I guess you want to take an existing code base as a starting point, and then alter it. Let's call our inital repo A.

[repoexample] ➔ pwd
/Users/mac/Documents/code/repoexample
[repoexample] ➔ ls
A

So you want to fork your own repo?

I guess you want to take an existing code base as a starting point, and then alter it. Let's call our inital repo A.

[repoexample] ➔ pwd
/Users/mac/Documents/code/repoexample
[repoexample] ➔ ls
A
@veryhappythings
veryhappythings / mongo-chef.rb
Created November 15, 2010 15:00
A chef recipe for installing mongoDB from apt-get on ubuntu.
execute 'apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10' do
user 'root'
end
ubuntu_version = node[:platform_version]
ubuntu_version.gsub! '.0', '.'
execute "echo 'deb http://downloads.mongodb.org/distros/ubuntu #{ubuntu_version} 10gen' >> /etc/apt/sources.list" do
user 'root'
not_if 'grep mongodb /etc/apt/sources.list'
end
@veryhappythings
veryhappythings / wc.vim
Created October 14, 2010 13:49
Display the WC output for the current file on save. Useful with NaNoWriMo coming up!
" Display wordcount
set laststatus=2
fun! NanoWC()
set stl=%{system('wc\ '.\ expand('%'))}
endfun
autocmd BufWritePost * :call NanoWC()
start-stop-daemon \
--start \
--pidfile=/path/to/ssh_tunnel.pid \
-b \
--exec /usr/bin/ssh -- \
-i /path/to/my_ssh_key \
-N \
-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
-f \
-L 27017:localhost:27017 username@myserver.example.com
@veryhappythings
veryhappythings / git-plush
Created May 4, 2010 14:51
For lazy git users.
#!/bin/bash
# It doesn't get more efficient than this.
git pull $@ && git push $@
num = ARGV[0].to_i
x = num
y = num - 2
grid = Array.new(y) { Array.new(x, '*')}
required_spiral_depth = x / 4 + 1
(1..required_spiral_depth*2).step(2) do |spiral_depth|
(spiral_depth..y-spiral_depth).each do |i|
@veryhappythings
veryhappythings / reload_gotcha.py
Created November 23, 2009 11:40
the from/reload gotcha.
#### mymodule.py ####
class ExampleClass(object):
pass
#### example.py ####
# Anything imported using a from statement does not get
# reloaded when the enclosing module is reloaded.
from mymodule import ExampleClass