miércoles, 12 de julio de 2017

TIL: insert key in kinesis advantage

I found this in the kinesis FAQ.
 
How can I remap the embedded Insert key to the top layer, so it’s like my older keyboard?
1). Turn Keypad On.
2). Press and hold the Progrm key and tap F12 (LED’s on keyboard will flash rapidly).
3). Press and release the “Insert” key (LED’s will slow down).
4). Press and release the Keypad key.
5). Press and release the Insert key again (LED’s will speed up).
6). Exit by repeating step 2 (LED’s will stop flashing).

miércoles, 5 de julio de 2017

TIL: awk > grep

Well, I already knew that awk > grep, but what I learned today is this little trick of "regex over a single field":

cat file.tsv | awk '$1 ~ /-01$/'
foo-01  bar
 

domingo, 2 de julio de 2017

Announcing commit-msg-prefix.

When writing commit messages, it's usual that your company/organisation has some policies and rules about the format and contents in the messages.

Some use an issue number, or name, or start with keywords (or emojis) like Add:/Clean:/Remove:.. (that can be converted to emojis in emacs too). But it's clear that somehow there's value in some kind of standarization.

So I created commit-msg-prefix, which lists the previous git commit messages and lets you pick one of them, and it will insert the relevant part of the commit in your current buffer.

My use case is when I do not remember the issue name/number I'm working on, but I remember keywords of previous commits that belong to the same issue.

There are a few variables to configure, like the exact git (or other) command to fetch logs, and the regex to apply to the log to extract the relevant part to insert.

The variable "commit-msg-prefix-input-method" is one of the symbols ('completing-read 'ido-completing-read 'commit-msg-prefix-helm-read 'ivy-read).

it defaults to ido-completing-read, but the idea is that you use your favourite input method.  ivy or helm, I guess :)




martes, 27 de junio de 2017

Articles on transducers

Some time ago I wrote about recusion and the Y combinator. It is a nice mind puzzle to try to understand all those constructions and techniques. I also linked to a recursion-to-iteration series that was very deep in the subject.

Today, I'm comming with a copule of links to recusion, but also transducers .

If you haven't had enough, another great Eli's post about computed gotos.  It talks about how gotos are faster than a switch-case statement for a tight dispatch table. Aaron Patterson has a great talk about things like this at a higher level called something like "what's in a method" or something like this. Google it for more info.

lunes, 19 de junio de 2017

TIL: evil-buffer-regexps

So I have my evil-mode perfectly adapted to my workflow, activating or deactivating it by default depending on the major-mode, so that I don't get into normal mode on magit buffers, or sly-*, or eww.

BUT, there are some buffers which you cannot easily control, because they reuse some major mode where I usually want evil-normal, but not in those cases.

In my case, it's *sly-macroexpansion* and *sly-description* buffers. They are both "lisp-mode" buffers (for syntax highlighting purposes and such), but I want 'q' to quit them.   As they do not represent any file, I was out of luck binding modes to file extensions. (btw, here's some recent article talking bout the ways emacs chooses your major mode)

So trying to hack something using emacs hooks, I found that, in fact, evil has us covered, and provides a evil-buffer-regexps, that allows us to predefine modes on given buffer names.


(add-to-list 'evil-buffer-regexps
             '("\\*sly-macroexpansion\\*" . emacs))

miércoles, 14 de junio de 2017

Visualisation, patterns, and perspecives

This all started a couple of weeks ago in the J on the Beach conference, where I was in a talk by Santiago Ortiz, which was VERY inspirational to me.

He was talking about the infinite forms of visualizing information (with nice examples about "ways to represent the concept 75". It might seem a very stupid exercise, but it was very interesting to see way many more representations that I was expecting to see.)

Days passed, and I kept thinking about visualization of stuff via alternative and non usual ways. The fact that I'm reading "The Mind's I"(Hofstadter & Dennet) helped to keep thinking about Alan Kay, Seymour Papert, Douglas Hofstadter, who in one way or another they always look at things in ways that are different to what a normal layman would look at them, and they make connections at a cognitive level that other (we) can only grasp after-fact, and when we are spoon fed.

Something like tihs happened to me on that talk. Concepts that weren't totally alien to me ("a point of  view is worth 80 IQ", creating a callgraph as it executes to learn about memoizing), were made obvious when that guy was explaining them in a very vivid and enthusiastic way. Big kudos.

I've been always a fan of all kind of puzzles, and mind hacks (I still remember that 'Mind Hacks' OReilly book). The talk also had some mnemotechnic tips and tricks. Another +1.

So, fast forward 3 weeks, and I already have this dupplot repo where you can display code duplication as a dotplot. Very nice and handy :).

So today at work, my colleague Carlos passed me this article about using your visual capabilities as a computing engine.  A total mindfuck. check it out.

And this evening I've been looking for David Waltz's interpreting line drawings that I discovered in an excelent talk by Gerald Sussman. This line labeling makes a lot of sense when you think about it, and it's dead easy to get.

I still wanted to talk about smalltalk tools for visualizing and reasoning about code.  And about data ingestion growing linearly, while insight grows discontinuously, because it's from connections between nodes that people understand behaviours andget value from it.

Also, one of the games Santiago Ortiz did was about remembering triplets of (person, action, place) for every number from 0 to 99. Then, when you have to remember say, 6 digits, you group them by chunks of 2, and group those grouped numbers by 3. After that, you may remember a scene that is about the person that refers to the first 2 digits, doing the action of te second 2 digits, in the place ment by the third 2 digits.  Messi exploding the Moon was 104569.  Amazing how these things work so well. :)

Gracias!

lunes, 12 de junio de 2017

Visualizing code duplication as dot plots

 Lately I've been having to deal with some codebase which I suspected
  it had lots of duplicated code.

  My task was actually fix some parts of the application, cleanup the
  some of the parts, and end up owning the code as mine.

  So it was a perfect opportunity for me to give a serious thougth to 

Object Oriented Reengineering Patterns , refactoring, and Working with
  legacy code.  I started with OORP, because it's the less widely
  known about all three, and I thought maybe there would be advice
  that's not widely covered on other places in the internet.

  Among other advices (and related to other works in the smalltalk
  world), there's the thougth about trying to look at the code in
  different ways, not the obvious 'lines of text'.

  So here's dupplot, a small script I wrote to visualize code
  duplication through dotplots.

  While working with dupplot itself, I started pushing lines of code,
  to make it work the first time. And then, I was thinking that I had
  some code duplication (opening the file, normalizing lines,etc.) but
  it was generally ok-ish.

  Just for the sake of testing the program against itself, I ran it, and got this:


  So I thought that I'd try to fix some of the duplication, and yeah,
  now it looks much better.


Much much nicer, no? Both codes are available in https://github.com/kidd/dupplot, as dupplot.pl and dupplot2.pl.