Spacemacs

Some time ago I posted about how I had uploaded my Emacs configuration to GitHub. Well, after too many time searching for the best packages, the best keybindings… etc. I found Spacemacs, and I am quite impressed, to be honest. I had already seen some Emacs configurations, such as Prelude, Live, Graphene or Oh-my-emacs, but I like Spacemacs better.

Everything is just right in this one. Great project. Beautifully designed internally and externally, fast, VIM keybindings, consistent keybindings for packages, packages preconfigured, well mantained, etc, etc.

Check it out!

spacemacs-python

How to be a good developer

  1. Master your tools, specially your editor.
  2. Master your language.
  3. Master the complexity control techniques: encapsulation, separation of concerns, DRY, KISS, SSOT, YAGNI, automated testing, continuous integration.
  4. Concentrate on one thing at a time.

and lastly and most importantly:

  1. Sit and wait for the client to make his requests.

Dopemacs

Imagen

I have uploaded my Emacs configuration to Github and generalized it a bit under de name of Dopemacs. It contains lots of packages and things enabled by default, and very little elisp on the configuration itself.

I really like how it feels. I have put the description as follows:

 

Emacs configuration that aims to add lots of enabled-by-default, non-intrusive useful features while keeping traditional Emacs keybindings and workflow.

 

You can find it here:

https://github.com/kovan/dopemacs

 

 

Angular.js

First I tried JQuery… too mesy.

Then I tried Backbone… it didn’t provide the functionality.

Then I tried Knockout… it worked but it was messy.

Then I tried Angular… good stuff.

Emacs rebirth?

Yeahh!. Probably all the hackers have been using Emacs all along in their caves since the eighties, but who knows. Now, with the inclusion of package repositories functionality (package.el) in Emacs, GitHub, the back-to-the-basics movement from Java over-architecting back to Ruby, JavaScript, SCRUM, TDD… etc.,  and the rise of plain text editors like TextMate or Sublime versus bloated IDEs, Emacs seems to be living a bit of a rebirth. Or is my usage of Emacs rebirthing (after some years out of software development) and I am confusing it?. I don’t really know. What I do know is that I open Chrome and I feel just an observer of the world, but I open Emacs and I feel I have all the power to create, like an artist that opens a blank page in his notebook.

Today I am going to share with you my list of installed packages:

File types support, pretty self-explaining:

  • apache-mode
  • cmake-mode
  • clojure-mode
  • scala-mode
  • go-mode
  • ruby-mode
  • python-mode
  • coffee-mode
  • csv-mode
  • feature-mode
  • js2-mode
  • json-mode
  • php-mode
  • scss-mode
  • markdown-mode
  • less-css-mode
  • stylus-mode
  • syslog-mode
  • web-mode

Configuration:

  • better-defaults: I used to use emacs-starter-kit, but, as I was understanding what it did, I kept wanting to get away from it. better-defaults are almost a couple of configuration tweaks by the same guy who made emacs-starter-kit, to which I was already accustomed to.

Utilities:

  • rainbow-mode: colors #RGB values it finds with the corresponding color, like this: #33CCCC
  • ack: an interface for the grep-like command line utility
  • auto-complete: automatically shows a pop up list with possible completions. It has a lot of plugins.
  • browse-kill-ring: show all the kill history.
  • editorconfig: support for the editorconfig standard that aims at mantaining a consistent coding style within a project (tabs vs spaces… etc.).
  • fic-ext-mode: highlights words like TODO, FIXME… etc.
  • fiplr: search files within a project. A project root is marked by the presence of a .git or similar folder in the current buffer’s file directory or any of its parents.
  • flymake: on the fly syntax checking.
  • free-keys: show what keys are free (not already binded) for the current mode.
  • guess-offset: tries to guess the indentation style of the file (tabs vs spaces… etc.).
  • idle-highlight-mode: highlights all the occurrences of the word under cursor.
  • ido-ubiquitous: use IDO whenever possible.
  • magit: good GIT integration.
  • smex: a slightly better M-x.
  • sr-speedbar: speedbar as a frame. 
  • yasnippet: code snippets everywhere. Mature and with lots of snippets for all the programming languages.

 

This is what I have installed for now, but a glance at the output of M-x list-packages is enough to entertain any Emacs enthusiast for countless hours (and probably to save quite a lot of time while doing ACTUAL work with Emacs ;)).

Lastly, you can use this little elisp code in your init.el to automatically download and install your packages:

 

(when (>= emacs-major-version 24)
(setq package-list '(ack apache-mode yasnippet))
(require 'package)

(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/") t)
; activate all the packages (in particular autoloads)
(package-initialize)

; fetch the list of packages available
(unless package-archive-contents
(package-refresh-contents))
; install the missing packages
(dolist (package package-list)
(unless (package-installed-p package)
(package-install package)))
)

See you next time. Have fun ;).

De las 100 mayores empresas de software europeas, sólo una es española

Ahora se habla mucho de cambio de modelo productivo, fomento de la innovación… etc. para salir de la crisis. Nos queda mucho camino por recorrer.  Navegando por Internet, he encontrado el ránking de las 100 mayores empresas de software europeas por facturación. El desarrollo de software está bastante ligado a la innovación, no sólo porque internamente está en constante y vertiginosa evolución, sino porque la mayoría de las innovaciones, en todos los campos, requieren del desarrollo de software específico.

Se podría decir por tanto que, cuantas más empresas de un mismo país aparezcan en ese ránking, mejor infraestructura de innovación tiene el país en cuestión.

Bueno pues, ¿adivináis cuántas empresas españolas aparecen en el ránking?. No, no es ninguna. ¡Una!. Frente a las 22 de Francia, las 26 de UK o las  12 de Alemania. Se trata de Panda Security, la empresa de antivirus.

Aquí está el ranking completo.

He extraído el número de empresas por país: BE: 1,  FR: 22,  DE: 12,  NL: 4,  DK: 1,  NO: 6,  HQ: 1,  SW: 8,  IT: 5,  CZ: 1,  CH: 4,  AU: 2,  UK: 26,  FI: 6,  RM: 1,  SP: 1,  PL: 1.

¿Cómo podríamos mejorar esa cifra?. Esa es la pregunta del millón. Hay muchas cosas que habría que cambiar. No es un tema de clima o de carácter, al menos no únicamente. Posiblemente sea el efecto acumulado de un sistema universitario atrasado, un mercado laboral rígido y una poca cultura emprendedora.

O, simplemente, era mucho más fácil y rápido ganar dinero comprando y vendiendo pisos.

Linux shell tricks (I)

The UNIX command line has always characterized by its sheer power. Even Microsoft realized in 2006 that their servers could not compete agains UNIX servers without a powerful command line, so they created PowerShell.

Mastering the command line, and all it’s small utilities, is a task that takes years to accomplish. The UNIX philosophy says that each program must “do one thing, and do it well”. The trick here is know which programs do which things.

With the time, every UNIX user ends up with a handful of commands that do every day work easier, that do in one line things that otherwise would have taken much longer.

So, in the following weeks, I’ll be writing a series of posts with those commands.

Here is the first part.

* Compare a remote file with a local file:

ssh user@host cat /path/to/remotefile | diff /path/to/localfile -

* Serve current directory tree at http://HOSTNAME:8000/

python -m SimpleHTTPServer
* Compile with colorized output, multicore CPU support, and low CPU priority:
nice -n 19 colormake -j 3

* Colorized diff:

colordiff

* Guess your current public IP:

curl -s http://checkip.dyndns.org/ | grep -o \" [[:digit:].]\+\" "

* Copy *.h, *.c and *.cpp to other host for debugging:

rsync -a --cvs-exclude --progress --exclude='.*/' --include='*/' --include='*.c'
      --include='*.h' --include='*.cpp' --exclude='*' SOURCE DEST

* Make a backup of a directory

tar -cjvvf backup$(date +%Y%m%d_%H%M%S).tar.bz2

* Generate a list of random IPs:

nmap -n -iR 0 -sL | cut -d" " -f 2

* Benchmark an HTTP server:

ab -n 9000 -c 900 localhost:8080/index.php

* Display ncurses based network monitor:

nload -u m eth0
ethstatus -i eth0
ifstat -nt

* The same but by process:

nethogs -p eth0
ss -p
lsof -P -i -n

Post

I have a list of command line tricks that have proven to be useful, fast, or just curious. Here they are:

* Compare a remote file with a local file:

ssh user@host cat /path/to/remotefile | diff /path/to/localfile -

* Serve current directory tree at http://HOSTNAME:8000/

python -m SimpleHTTPServer
* Compile with colorized output, multicore CPU support, and low CPU priority:
nice -n 19 colormake -j 3

* Colorized diff:

colordiff

* Guess your current public IP:

curl -s http://checkip.dyndns.org/ | grep -o \" [[:digit:].]\+\" "

* Copy *.h, *.c and *.cpp to other host for debugging:

rsync -a --cvs-exclude --progress --exclude='.*/' --include='*/' --include='*.c'
      --include='*.h' --include='*.cpp' --exclude='*' SOURCE DEST

* Make a backup of a directory

tar -cjvvf backup$(date +%Y%m%d_%H%M%S).tar.bz2

* Generate a list of random IPs:

nmap -n -iR 0 -sL | cut -d" " -f 2

* Benchmark an HTTP server:

ab -n 9000 -c 900 localhost:8080/index.php

* Display ncurses based network monitor:

nload -u m eth0
ethstatus -i eth0
ifstat -nt

* The same but by process:

nethogs -p eth0
ss -p
lsof -P -i -n

* SSH connection through host in the middle:

ssh -t reachable_host ssh unreachable_host

* Create a persistent connection to a machine

ssh -MNf user@host

* Save a file as root when VIM was launched as another user:

:w !sudo tee %

* A better traceroute:

mtr google.com

* Copy SSH key to remote host, in order to enable login without password:

ssh-copy-id user@host

* Create a partition which resides in memory, so it has ultra-fast read/write:

mount -t tmpfs tmpfs /mnt -o size=1024m

* Like top, but for files:

watch -d -n 2 ‘df; ls -FlAt;’

* Make a backup of a file:

cp /long/path/to/filename{,.bak}

* Analyze traffic on a remote machine with Wireshark

ssh root@server.com ‘tshark -f “port !22″ -w -‘ | wireshark -k -i –

* Pipe stdout, stderr… etc. to separate commands:

some_command > >(/bin/cmd_for_stdout) 2> >(/bin/cmd_for_stderr)

* Execute a command with a timeout:

timeout 10 sleep 11

* Colored svn diff:

svn diff | vim -R –

* Hierarchic list of processes:

ps -e -o pid,args –forest

* Close shell keeping subprocesses running

disown -a && exit

* Open a file in a new, full screen, Emacs window:

function emw() { emacsclient -c -a ” -e “(progn (toggle-fullscreen) (find-file \”$*\”))”; }

* Display a one line description of one Wikipedia article:

function wikipedia() { dig +short txt ${1}.wp.dg.cx; }

* Search http://www.commandlinefu.com for the tricks that contain a command:

function cmdfu(){ curl “http://www.commandlinefu.com/commands/matching/$@/$(echo -n $@ | openssl base64)/plaintext”; }

* Backup Del.icio.us bookmarks:

wget –user=username –password=password https://api.del.icio.us/v1/posts/all -O bookmarks.xml

* Quick find files in a directory tree:

function ff() { find . -type f -iname ‘*’$1’*’ $2 $3 $4 $5 $6 $7 $8 $9 ; }

* Update the twitter status:

function twit() { curl -u myusername -d status=”$*” http://twitter.com/statuses/update.xml ; }

* Funtion that moves files to a recicle-bin folder instead of deleting them:

function trash()
{
if [ -z “$*” ] ; then
echo “Usage: trash filename”
else
DATE=$( date +%F )
[ -d “${HOME}/.Trash/${DATE}” ] || mkdir -p ${HOME}/.Trash/${DATE} for FILE in $@ ; do
mv “${FILE}” “${HOME}/.Trash/${DATE}”
echo “${FILE} trashed!”
done
fi
}

* Function that extracts the contents of a compressed archive, independently of it’s format:

function extract()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo “‘$1’ cannot be extracted via >extract<” ;; esac
else
echo “‘$1’ is not a valid file”
fi
}

* The Matrix:
tr -c ” [:digit:]” ” ” < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR=”1;32″ grep –color “[^ ]”

Bash tricks.

It took me some years to start really liking the Linux shell. Even though I know how to type and I knew the commands, it was just tedious to write the full paths, and the full commands every time. The turning point when I really started enjoying was when I learled some Bash tricks. Namely keyboard bindings plus some confiuration options.

  • Ctrl+R to search command history.
  • Alt+. to repeat the last argument
  • Alt+n+. to repeat the nth argument of the previous command.
  • Alt+Backspace to delete the last word.

Plus the Emacs ones:

  • Ctrl+_ to undo.
  • Ctrl+A/E to go to the start/end of the line.
  • Ctrl+F/B to go forward/backward one character.
  • Alt+F/B to go forward/backward one word.
  • Ctrl/Alt+D: delete a character/word forward.
  • Ctrl+P/N to move through command history.
  • Ctrl+K to kill the rest of the line.
  • Copy & paste commands (Ctrl+W, Ctrl+Y, Alt+Y…etc.)

And the configuration options. These go in ~/.inputrc, and are self explanatory:

  • set match-hidden-files off
  • set completion-ignore-case on
  • set show-all-if-ambiguous on
  • set bell-style none
  • set bell-style visible

These go in ~/.bashrc:

  • export HISTSIZE=1000000
  • export HISTFILESIZE=5000000
  • shopt -s checkwinsize
  • shopt -s histappend

The best thing among these keybindings is that they are not specific to Bash: they can be used in all the commands that use the Readline library for input, which, in Linux, ¡are almost all: gdb, python/ipython, sqlite, psql, mysql, bashdb… etc.

With these tricks, I’m probably 10x faster than I used to be before knowing them.