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.

miércoles, 3 de julio de 2013

Farewell Mr Engelbart

So another of the great guys in CS passed away today.

The visionary man that conceived and brought to life many many things that we give for granted today.

Mouse and other input devices (I recall the one-hand keyboard), the first interactive systems, remote connections,.... all that during the fifties and sixties. A truly impressive amount of leaps from what existed at that time.

I haven't read anywhere explicitly about the relation between Engelbart and Smalltalk, but I'm more than sure that Douglas heavily influenced Kay, and probably the reverse is also true.  Probably one of the 5 most innovative guys in our field. Ever.

For those who don't know about Mr. Engelbart, you have to check "The mother of all demos". Look for the videos yourself. And try to imagine that in the sixties.

Here's a spanish link that talks about innovation, where Kay and Engelbart are mentioned lots of times. a good read also.

And another link about Aaron Schwartz, which links also to Douglas Engelbart. The image in that post and the post itself hit me hard when I saw them the first time. also, recommended read.



jueves, 27 de junio de 2013

github + emacs + conkeror = m-x github-clone-repo

Well, after a month of no activity in this blog (too many real life
issues to attend like european lisp symposium, european CL meeting or Barcelona Music HackDay and Sonar2013 itself), Whatever, I'm back to blogging.

Conkeror

Lately I started to use conkeror as my main browser. That means using
it for most of the tasks, and trying to configure it properly for all
my needs.

It feels really nice when the same shortcuts you'd use in emacs work
in your browser, and in fact, it has a very emacsy approach also on
the code. The browser is written in javascript, and it also has
page-modes, interactive functions, minibuffer, etc...

Awareness

When you use an extensible software you start becomming aware of your
movements.  I had that feeling and wrote org-protocol-github-lines to
add links in github pages that pointed to emacs.

Another feature of org-protocol-github-lines is that you have a new
button on top of github urls where you can clone a repo to your machine.


So what?

Since I have m-x in my browser, I try to write commands for repetitive
tasks (the same I'd do with emacs). So I wrote this little snippet
that you can put in your .conkerorrc and m-x github-clone-repo to get the repo on your box
. provided you have emacs-server running and
org-protocol-github-lines.el evaluated .

If you want to give it a try, you just have to get conkeror, org-protocol-github-lines, and this snippet. And configure them Probably I'll add the snippet to the repo. Pull Requests are also very welcome.

lunes, 27 de mayo de 2013

yet another git reset cheatsheet

After some time since my last git post, here I come again with a link to an explanation of wtf git reset is doing.

It's mostly the same as I pointed in a post 2 years ago, but just explained in a different way, shorter, and probably easier to print in a small paper and stick it in your table.

Enjoy :)

PS: There's a poll running on reddit about git clients. No matter what you're using, vote for magit :)

cool org-mode 8 features

This weekend I stopped playing with lua and finally got some time to upgrade org to the newest version.

Org 8 had lots of improvements and new features compared to 7.9.x.  There were a couple of those that I wanted to try as soon as possible:

  • New Exporters: org-mode now uses org-element to parse org files. That's a big big improvement because that allows users to write new exporters relying on a somewhat more abstract and high level parser api than what we had before.

  • orgstruct and orgstruct++ got orgstruct-heading-prefix-regexp option to set allowed prefixes and be able to fold parts of non-org files as if they where

On the exporters side, I tried org-reveal, and it works great so far. an exporter to make presentations using reveal.js   Probably I'll try it for real next week when when I'll be doing some talk at my workplace.

(require 'ox-reveal)
(setq org-reveal-root "reveal.js")

Meanwhile in orgstruct... being able to define prefixes for orgstruct-mode allows us to have foldable text files. For example, use the following line to make it work in elisp files.

(setq orgstruct-heading-prefix-regexp "^;; ")

miércoles, 22 de mayo de 2013

Lua vs javascript

I love lua.  Well, I luvit so far.

I haven't programmed many many things in lua, but the simplicity of it reminds me of smalltalk (in a veery different meaning of simplicity), or scheme.

The fact that it relies in very few known concepts as lexical scope, tables, and.... and that's it.

More that a language, is a language builder toolset.  It lets you do metaprogramming without really feeling that you're doing metaprogramming.  It makes it so simple you'd say it's "the normal thing".
  • loops? ok, you have 'for', and iterators. made from closures, or whatever, but that's it.
  • TCO? yes, but just if it's explicit.
  • splat arrays by default? as in Perl?... yes, just in the last position, perfect for apply-like calls. or you have unpack.
  • Varargs functions? yup.
With that and a bit of syntax sugar here and there, you have a really powerful language with near to no friction.  Provided you know a few other languages, you can always say: "ah, it behaves like js in the everything is hash, but it has proper scoping, and TCO ...."

I don't know much js, but I think lua is like a well done js.  Here's some funny Hacker News opinion



That and the community. #lua is full of people with background in many other languages, wise and helpful. and quite hacker style. I like it :)


Ah! and there's also metalua, which sounds like great fun. something like tcl's block syntax or lisp quasiquoting to mold lua to your needs.


sábado, 11 de mayo de 2013

Ryan Holiday TNW keynote: manipulating media

I'm having a hard time deciding whether to publish this entry or not, and which words to use to promote this video of Ryan Holiday where he talks about manipulating the media.

The media, and  how easy it is to generate buzz on the media and get traction. That guy might be some kind of marketing ninja.

So in TNW he did a talk about some experiences he had and how he sees the fragility of the truthiness in the media, and how they change mindful investigations for easy PR that will lead to easy clicks

If you watch the talk you'll understand the mixed feelings I had when writing about it. Hopefully the content is mostly correct and he's not playing on us.

Here is  the article, and the video: