Sunday, July 27, 2008

The truth about New Zealanders and sheep

Every now and then on MSN, IRC, or in a game, it comes up that I'm from New Zealand. In almost all cases people will make the same jokes and ask the same boneheaded questions. I feel I must set matters straight once and for all — for the good of my country.

Yes.

All New Zealanders do in fact fuck sheep.

On a daily basis.

In New Zealand we shag sheep as though the apocalypse will probably arrive before dinner. On weekends we go out and get boozed, blazed, and randy as fuck before driving out to the country to tour the all-you-can-fuck sheep buffets run by the local farmers.

New Zealanders embrace polygamy. You may be disturbed by this, but we are not constrained by your moral, traditional or religious views. Our lust for the fluffy livestock overrules all such things, and is simply too great for one sheep to satisfy.

Also, we don't live in mammoth apartment buildings, stacked and racked on top and beside each other like Lego blocks. We all require backyards for our spouses to run free in while we're at work. Otherwise they would piss and shit all over the furniture. You get what I'm saying?

And our national sport is the Fluffofuckathon — a racing event where each contestant must propel a sheep down the 100 meter race track using only pelvic thrusts. Every year hundreds of spectators are trampled to death in the mad frenzy on the final race of the season. Everyone has their favourite team, but I personally root for Roger Ramjammer and his partner The Woolcano.



I am aware that such claims require photographic evidence. Lucky for you I just got married and have plenty of photos from my honeymoon.

Me and the missus outside the beehive in Sydney





Then we caught the train to downtown L.A. to see the pyramids


Then we drove up to Moscow to see the Eiffel Tower


There we rented pogo sticks and hopped over to the moon


From there it was just a short journey to China where we walked on the sun (fucking freezing this time of year)



I hope this has been educational.

Tuesday, July 22, 2008

The windows copying commands suck giant spicy boner

I really love using windows. Its almost as pleasant as having your balls severed, liquefied in acid then pumped intravenously back into your body. Trying to use the terminal is fucking great! Its only marginally less pleasant than having feral cats surgically implanted into your scrotum. The copying commands in said terminal are brilliant! Using them is not quite as pleasant as having flaming gerbils stuffed into your anus by a cult of psychotic homosexual rapists.

The other day I was hacking on the fucking NERD tree trying to implement copying tree nodes (i.e. files/directories) in windows. Vimscript doesn't provide a function to copy files/directories so you have to shell out to do it. This is fine on *nix and osx where you can be sure legions of sweaty computer nerds are, even as we speak, busting out the TLC to improve the terminals/terminal apps. The same cannot be said for the windows terminal. This goes a long way toward explaining why its copying commands suck the spicy rod of beelzebub.

When I was writing the copying code, I was wanting to shell out to a single command for each OS that required no user input.

This is the copying command the NERD tree uses for *nix/osx

cp -r source destination

Clearly this needs to be much more complex and difficult. Good thing we have windows. Lets take a look at the windows copying commands!

The first one I looked at was copy.

copy source destination

This is ok for files, but when source is a directory it (most logically) copies the entire contents of that directory into a single file. That's understandable. The programmer who wrote the command was handicapped. I get it.

The second command I looked at was xcopy.

xcopy /E source destination

This is almost good. Apart from the fact that the program is so abysmally fucking stupid that it has to ask you if destination should be a directory or a file. Could the programmer who wrote xcopy possibly be any more retarded? Let me put it like this: If a scientist was cloning a sheep for me and asked me whether said clone should be a sheep or a cow, I would take out my gun and strengthen the human gene pool by blowing his dumb ass out of it. Fuck you xcopy, you fail.

Next on the list of candidate commands was something called robocopy. Thankfully that wasn't even present on my install. Come on! "robocopy"!?! wtf, how many attempts does it take to make a program to copy stuff!?

I am aware that the windows terminal and all its shitty copying commands probably suck because they are complying to some standard or pseudo standard for backwards compatibility. I don't care, I'm still gonna hate on them, because they still suck sweaty ballsack.

Wednesday, July 16, 2008

Vim pr0n: Visual search mappings

I've always maintained that, if you're looking to jack off to the vim help pages, a good place to start is at :help * or :help #. That shit is guaranteed to please. Strangely, vim has no baked-in visual mode equivalents to these mappings i.e. there is no mapping to search for other occurrences of the currently selected text. This is kind of gay, but it's also a blessing when you're in mob formation with a pack of bored-as-fuck nerds on irc. Let me tell you a tale ...

A few days ago in #vim on freenode someone asked how you can create the aforementioned visual mode * and # mappings. Id recently stolen some basic versions from godlygeek's vimrc so I paste binned these and posted the link:
vnoremap * y/<c-r>"<cr>
vnoremap # y?<c-r>"<cr>

Nerds immediately attacked, pointing out that they didn't handle regex escaping. For example if you searched for the string "\<foo.*", the mappings would treat the \< and .* as regex magic rather than the literal strings. So we revised the mappings to these:
vnoremap * y/\V<c-r>=escape(@", '\')<cr><cr>
vnoremap # y/\V<c-r>=escape(@", '\')<cr><cr>

Nerds everywhere began furiously jacking off with one hand while updating their vimrcs with the other. Then strull dumped his version into the channel:
vmap * :<C-U>let old_reg=@"<cr>gvy/<C-R><C-R>=substitute(escape(@",'\/.*$^~[]'),"\n$","","")<CR><CR>:let @"=old_reg<cr>

This one doesn't clobber the unnamed register, and also chops off any trailing \n — handy if you hit * from visual-line mode. His regex escaping was inferior though.

Building on this, godlygeek came along with:
exe 'vnoremap * <C-\><C-n>'
\.':let [@", @/] = reverse([@", @/])<CR>'
\.'gvy'
\.':let [@", @/] = reverse([@", @/])<CR>'
\.":let @/='\\V'.escape(@/, '\\')<CR>"
\.":let @/=substitute(@/, '\\n', '\\\\'.'n', 'g')<CR>"
\."/<CR>"
vmap # *?<CR>?<CR>

He was quite proud of his version because the # mapping was expressed in terms of the * mapping, and because the search string was rightfully jammed in the / register. Probably also because the mapping was fucking nigh incomprehensible.

After a couple more revisions it ended up being expressed, somewhat more readable as this:
function! s:VSetSearch()
let temp = @@
norm! gvy
let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
let @@ = temp
endfunction

vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR>
vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR>

This is the version that is sitting in my vimrc at the moment. Try it out. It owns. Visit the official wiki page here.

Sunday, July 13, 2008

git commit --amend gives me an erection

Sometimes at work, I find out something that is so fucking awesome I just have to tell someone. Unfortunately, there usually is no one at work to tell since no one would understand my ravings. At times like these the best I can do is check left, then right, then quietly jack off under my desk.

Needless to say, when I discovered the --amend flag for git commit, my righty was down my pants in a flash.

Lemme explain the use case. One day that evil porn star genius Doctor Coctopus decides to upgrade the AI in his extra appendages to allow him to act in multiple sex scenes simultaneously. He hacks furiously at the mainframe for a bit and arrives at a good point to commit his work. He does the following:

git add pron_hacks.c
git add more_pron_hacks.c
git add extreme_pron_hacks.c
git commit

He then does some more hacks before realising that he forgot to add some stuff to the previous commit! Fuck!

If he didn't know about git commit --amend he might do something like this:

git reset --soft HEAD~1
git add auxiliary_pron_hacks.c
git commit

He would then have to remember the commit message he typed and reproduce it (adding some extra bits for the new stuff).

But, if he did know about git commit --amend he would do something like this instead:

git add auxiliary_pron_hacks.c
git commit --amend

This would alter the previous commit, incorporating the new changes. It would also prefill his commit message with the old commit message.


I forget to add code to my commits all the fucking time (probably because I use git add -i and go into patch mode so much), so for me the --amend flag is THA SHIT.