domingo, 26 de junio de 2016

Functional programming in small pieces

I've been articles on reading functional programming for some time, and little by little, I think I get a bit more of the whole stuff.

I found some nice articles/tutorials, and I understood most of them (yay!)
Although I'm still fighting with some other articles like this functional pearl about using foldr to make a function to give combinations of elements. It's been too long since I started looking at it, and I still don't get it.... :/

Well, have fun, and happy hacking.

sábado, 25 de junio de 2016

June 2016, Alan Kay is back

So it was early may 2016 when YCombinator anounced HARC, and the fact that Alan Kay and his team would be under YC's umbrella for some time (I guess 5 years at least). I got really excited. Also, some links like Alan Kay's recommended reading list. On that occasion I was happily surprised (or not so) when I saw the recommendation of Eduard deBono's Lateral Thinking.

Then, a few days ago, Alan Kay agreed to do an AMA in Hacker News, and the thing exploded.  People showing amazing respect for him, and himself answering tirelessly all questions with wise and info-stuffed answers. 'Too much' food for thought.  References to History of computers' books (The dream machine being one that I didn't know), to how to read books, state of funding, research, computers, history..... Oh, and Rich Hickey and Alan Kay discussing about data.

Today, a couple of links about restoring Alan Kay's XEROX Alto popped up in HN. And more links to Alto's hardware manual and Alto's manual.
Fun fact: One of the designers of Alto was Chuck Thacker, which was also co-inventor of the Ethernet LAN.

 And.... this post had to be published 3 days ago, but once you start looking for links on PARC related stuff, you enter the rabbit hole, and spend 3 days reading and watchin videos, without attending to any of your other duties. For me it's been these three videos. Two new one old.

Enjoy and be amused.

martes, 21 de junio de 2016

TIL: git ignore files locally

Adding this simple line to your .gitconfig you have an easy and semiautomated way to ignore files on your working tree, without messing the repo's .gitignore.

There's a file called .git/info/exclude that is basically another .gitignore file, but it never gets commited. So with the following line in your configs you can:

git exclude '*.csv'

And now the line itself:

exclude = !sh -c 'echo "$1" >> .git/info/exclude' -

TIL: Toggle tracing defuns with slime

A nice and quick way to trace/untrace defuns from slime:

(define-key slime-mode-map (kbd "C-c t") 'slime-toggle-trace-fdefinition)

jueves, 26 de mayo de 2016

keysnail plugin to navigate relations

I'm using keysnail as my emacsy browser. It's heavier than conkeror, but I'd say it's also more compatible with common plugins (adblockers, cookiemanagers, RES,...)

A feature not present in keysnail (until now) was the ability to navigate through a hierarchy of a web without reaching to the actual link (if any).

So I wrote this super simple keysnail-navigate-relations plugin that provides 3 commands (go-next, go-prev, go-up) and 3 keybindings (]], [[, ^) so you can navigate much more easily through structured webs.

Possible uses for it are:

As always, feedback is more than welcome.

martes, 17 de mayo de 2016

spying on lua function calls

Following on lua, there's been some trick I've been using for some time, and it's quite useful and (as usual), doable with tiny piece of code.

If we want to have a trace of function calls with their parameters and results, there's a super easy way to do it in lua.  The functionality is basically inspired by lisp's trace or elisp's trace-function.  The code is ridiculously simple, it's a basic case of rewriting key-values in modules and wrapping functions.

local function make_tracer()
  local indent = ""
  return function (mod, f_name)
    local old = mod[f_name]
    return function (...)
      print( string.format("%sCall: %s: params: ", indent, f_name), ...)
      indent = indent .. "   "
      local ret = {old(...)}
      indent = string.sub(indent, 4)
      print(string.format("%sRetn: %s: ",indent, f_name), unpack(ret))
      return unpack(ret)
local trace = make_tracer()
for m,_ in pairs(M) do M[m]=trace(M, m) end

It's great that with so simple code we can have a basic debugging tool like this one (btw, this tool is probably not very robust if we put coroutines in the mix, but for simple cases it works quite well).  All this is possible because lua embraces the Universal Design Pattern.