jueves, 8 de agosto de 2013

conkeror go to buffer

In conkeror, you're trying continuously to think emacs, so many commands and shortcuts just make sense when you're browsing.

A nice way to move through buffers is obviously c-x b, but from time to time I was typing M-g M-g as if it was a 'goto-line' in emacs, but meaning goto-buffer. 

So let's go and use js to have this goto-buffer 

viernes, 2 de agosto de 2013

TIL: 2013-08-02

  • lua's require can't return multiple values. An easy way to overcome it is using unpack.
    local _ , resource     = unpack(require 'controller_helpers')

lunes, 29 de julio de 2013

TIL: 2013-07-29


  • There are many different ways to completely remove a file from a git repo
  • A CLOS user can change the method combination algorithm for a given function.

martes, 23 de julio de 2013

TIL: 2013-07-23

Today I Learnt:

  • Push a local git branch to a remote with different name:
  • git push origin local_branch:remote_branch 
  • Nginx lua path refering to the nginx -p flag
  •   lua_package_path ";;$prefix/?.lua;";

New section: TIL

With my friend and coworker Mikz, the other day something came out:

"We could do a 'Today I Learnt' daily/weekly meeting, where everyone would tell the others in one sentence something that he/she (unfortunately 100% chances of he) learnt that day/week. That would be a nice starting point for ideas/brainstorms/discussions or just sharing knowledge.

I liked the idea so much that I'll start a section here, where I'll put this kind of stupid things you learn that you normally wouldn't share because "it's just in the docs", or "it's simple, you just have to use it once and that's it" .

We'll see how it turns out.

miércoles, 10 de julio de 2013

Iterating through closures

At 3scale we're developing a product using lua.

It's kind of fun to work in a new project and even more to work with a small and malleable language (and even *more* working with a top-notch lua guy).

Part of the fun working with lua is that the language is so minimal that you have to build your own helpers for some functions that you'd have in other languages, but lua makes it really easy and straighforward.

Here's an example that just appeared when I was writing some tests (using busted, of course)


                
                local f = function()
                  local c = false
                  return function()
                    c = not c
                    return c
                  end
                end
                local l = f()

It's a plain simple closure, I know, but maybe it'll be ilustrative to some ppl not used to this approach.

It's just an iterator that returns true/false as you keep calling it.

You know, closures are the poor-man's objects, and objects are the poor-man's closures.