lunes, 27 de junio de 2011

read-only weekend

Pretty nice weekend:

Thursday night, a 'Gifted' concert with many of our friends attending.
Great St.Joan party.

From Friday to Sunday I didn't program anything but read a couple of
books. Yes, two. It's true both were quite easy reads and not very long.

One of them is OReilly's 'The productive programmer'. I found the
book a really easy read, but maybe it's beacause I already knew most
of the tricks. In fact I already knew I'd already know most of the
tricks. The second part of the book, though was a bit more abstract,
and I could make some use of the info there.

Points I found most interesting:

- Make a living doc. (From commit logs to wiki, for example)

- Learn to FOCUS. (I'll search for csikszentmihalyi's books)

- Composed Method and SLAP.

The other book I skimmed is more a long article than a book: Git Magic, by Ben Lynn.

It's a pretty nice source of info on git. Really concise and to the
point. Mostly beginner, but also contains some advanced tricks (with
the use cases explained), and a chapter on the git low-level stuff
(remember git from the bottom up?)

miércoles, 22 de junio de 2011

Don't quit emacs by accident

Today I read a blogpost by en emacser blogger (tsengf) about quitting emacs accidentally.

He writes a function to avoid closing emacs by accident when there's an opened file that belongs to any of your projects.

My approach is somewhat different:

Usually, when I have emacs opened, I have some processes running within it. That makes emacs warn me when I press c-x c-c by accident, and asks for confirmation (the same way as if I had unsaved buffers)

Anyway, sometimes my muscle memory screws everything, and presses 'y' without asking my conscious mind.

Here are a couple of solutions that work to some extend.

The first one is the radical one. Just do not shut up emacs. Yes, as strange as it seems, I rarely have to close emacs while my computer is on.

global-unset-key c-x c-c

Then you have to exit emacs with the name of the whole command save-buffers-kill-terminal

As a not-so-radical solution, my bet is for desktop-save to save every session in your home directory.

(defun desktop-save-main ()
(desktop-save "~/"))
(add-hook 'kill-emacs-hook 'desktop-save-main)

Then, if you want to recover the state of the previous session, you have to eval (desktop-read) or (desktop-read "~/") if you aren't on your home dir.

If you had sql sessions, erc sessions, or any other comint buffer... well... you lost them.

PS: If you happen to know how to make this blog/post appear on the emacsen planet, please comment, or mail me, or twitt it to some emacs aggregator.... or just twitt the post FEED ME MOAR RSS's!

jueves, 16 de junio de 2011

sleepsort for the lulz

Today I discovered a programmers' BBS on 4chan (It hit HN's front page).
There was a post talking about a sorting algorithm that the author called it 'sleepsort'
I couldn't believe I didn't thought of it before. In fact in a past post talking about Parallel::Iterator, I played with timers too.... I was sooo close :)

Lots of lols reading the full thread, with comments, optimizations, translations to other languages and puns there.

For example:

- complexity of the algo: O(highest_value_in_input)

- 40: Someone email this to Knuth.
- 41: >>40. Knuth doesn't do email anymore

Have fun.

martes, 14 de junio de 2011

vim.orthogonality > emacs.orthogonality

I already mentioned this same thing in other posts, but well, today I stumbled upon another example of it.

Vim is like a unix commanline, lots of little commands you can combine one to each other. It has the cognitive style of linux command line

bufdo,argadd,argdo... These are the 'pipes' of vim. multiplicity enablers that add functionality,commands and power in an exponential way.

When writing ReST docs to take notes at university, I used Vim, and I got used to underline titles with an add-hoc sequence I made up (yank line,paste,visual line, replace, char) . Vim doesn't need a specific command for it, because it's immediate, and like most vim combos, it's like talking to it in a funny slang.

On the other corner, emacs: as part of emacs-goodies (ubuntu package with a bundle of emacs plugins) There's under.el. A plugin that exports 'underhat-region'. A function that underlines a region with caret characters. The bad thing of underhat-region is that it's not parametrizable, but that's not the point. The fscking point is that in emacs you end up stumbling upon functionalities that are already there as commands, but probably sunken among zillions of other commands.

I'm more a vim-style guy myself, but couldn't resist emacs+vimpulse combination. I think I'm sold.

martes, 7 de junio de 2011

PAIP, special edition

I recently bought a copy of PAIP in dead tree format (as usual, a used one). When I received it, I was a little worried about the state of the book (it was expensive enough to be worried about it). I opened the package, glanced it and seemed pretty good. Nearly unused.

But when I opened it... OMG! The fist page contains a note from Peter Norvig!


lunes, 6 de junio de 2011

js can be fun(ctional) too. A new hope

Reviewing my latest gists, I re-discovered one in which I copied a js snippet that implemented foldr, one of those great higher order functions. As a proof of concept, I implemented some of the functions on 'Why functional programming matters' paper. In fact, I reimplemented nearly all builtins.scm (from my Half Assed Scheme implementation)

I recently took a quick look at coffeescript, and it seems very promising. Unfortunately, I didn't even try it (just the online interpreter). Maybe when I try rails 3.1