Sunday, July 27, 2014

WordPress br tag problem solved

WordPress automatically inserts br tags, well, everywhere. After some researching, I came up with a CSS trick to minimize its effect on my blog:

 .entry-content br {
  display: block !important;
line-height: 1% !important;
margin-top: -0.2em !important;
margin-bottem: -0.2em !important;

A more colorful commandline

To distinguish different filetypes by colors, do this in your ~/.bash_aliases:

# some aliases
alias lla='ls -AlFGh'
alias ll='ls -lFGh'
alias la='ls -AG'
alias ls='ls -G'
alias l1='ls -1G'
alias grep='grep --color=always'
alias fgrep='fgrep --color=always'
alias egrep='egrep --color=always'

For the ls command, -G is doing the magic.

Make a python script pipable

Python is a very nice language for scripting, it is only natural that it can be used as a pipe receiver. Here is the simplest example:

#!/usr/bin/env python3

# file: /tmp/
import sys

fromstdin =

Make it executable, then try this in shell:

echo "hi, there" | /tmp/

Karabiner: a keymapping tool for osx

I have found a wonder tool for remapping keys on osx: Karabiner - Software for OS X

User manual: Karabiner - Software for OS X

User's keymap settings are stored in a file called private.xml, it can opened like this:

Note that there is also a "Event Viewer" in which you can look up keycodes and app identifiers in action.

After browsing through the documentation I have come up with a xml configuration specifically effective for Eclipse text editor area:

<?xml version="1.0"?>
    <name>Esc to ctrl-bracket three times in Eclipse</name>
      KeyCode::BRACKET_LEFT, ModifierFlag::CONTROL_L, KeyCode::BRACKET_LEFT, ModifierFlag::CONTROL_L, KeyCode::BRACKET_LEFT, ModifierFlag::CONTROL_L 

Since I use vim mode (vrapper plugin), I use the Esc key a lot, so I mapped Esc to its equivalent ctrl-[ repeated three times.

This is indeed a extraordinary piece of software, I will definitely learn more about it later!