chinese chess

finally the confusion is solved:

chinese checkers is not chinese:

chinese chess is chinese, and comes from the same ancient indian game as occidental chess:

btw, chinese chess is called 象棋:

象 = elephant

棋 = board game

and in the indian game, one of the pieces was the elephant, later converted to a modern chess piece

Krusader varaible based bookmarking

For Krusader users.

The bookmark system is fine, except for one serious flaw: if you want to rename the root of your directory structure, you have to modify all the paths one by one.

A workaround I’m using for this is to build my path step by step with environment variables and use single instance mode, aliases and the terminal emulator.

For instance, I put this on my .bashrc:

$A=a $B="$A/b" $C="$B/c" alias kra 'krusader "$A"' alias krb 'krusader "$B"' alias krc 'krusader "$C"'

And to jump dirs just go to the embedded terminal emulator (open it with you shortcut, then control + down), and type the alias you want (kra for $A, and so on).

so if I want to rename “a” to “a2″, I only need to change “$A”, and all the others will be fine.

This is also a good method to set your $PATH variable.

At a glance exists in Chinese

Learning different languages teaches us about what is universal in human perception, and thus leads to common metaphors in both languages.

For example:

眼看 = very soon

眼 = eye

看 = see

Completely analogous to the English expression “At a glance”

Conclusion: what is the fastest thing that happens in human perception?

Seeing and understanding visual data, since both languages independently (probably, unlike say French and English which have enormous shared background) developed the same metaphor (as fast as looking and seeing)

Film lists to quench your film thirst

Top 100 AFI, American only:

Digital dream door films:

Mubi, social film site:

Theme lists from Criterion:

Essential art house (Criterion):

Get a webpage and all the pages it links to for local viewing with wget

wget -r -l1 -p -np -k -nH -P 'outdir'

#download bbb.html
#-r: recursivelly
#-l1: up to level 1 links, that is, download only the pages imediately linked to by
#   (-l1, could be -l2, -l3, ... for nth level links)
#-p: saving all necessary files to view the page locally (images, css)
#-np: not downloading parent directories pages
#-k: converting links in htmls that were downloaded into local links for offline viewing
#-nH: not creating a directory '' as would be default
#-P 'outdir': saving output inside a directory 'outdir', and creating it if it doesn't exist

Synctex forward search example

  1. make a multipage tex document with INPUT_PATH

  2. compile with:

    pdflatex -synctex=1 "$INPUT_PATH"

    this should generate “asdf.pdf” and the synctex file ( because of -synctex=1)

  3. run synctex as

    synctex view -i 77:1:/path/to/tex/file/./asdf.tex -o asdf.pdf

    77:1 means you are on line 77 column 1 of the tex file, and you want to get the position on the pdf. Note the ugly “/./” between the parent directory and the basename. It must be there!

  4. sample output

    This is SyncTeX command line utility, version 1.2
    SyncTeX result begin
    SyncTeX result end

    amongst other things, this is telling you that this position on the tex file corresponds to Page 2 of your pdf.

  5. Now all you have to do is to tell your pdf viewer to open that page. In Okular this would be:

    okular -p 2 asdf.pdf

Reasons to learn the bash command line

Bash suffers from a few disadvantages

  • Linux only
  • quite complicated variable/parameters passing

which in my opinion make python a better choice for anything that is not a one liner.

On the other hand, learning bash and the basic Linux commands can be very useful for a programmer

  • interface. the bash command line contains interface that is widely recognized and that has survived the test of time, meaning that you will be able to understand others programs and create programs that are more easily understandable. For example, if you name a method ‘find’, which does more or less the same as the Linux command, chances are that others will immediately understand and remember this, which is a crucial step to coping with complexity of programs.
  • raw power. some standard bash utilities are so amazingly powerful for the amount of code that you have to write, that it is just worth learning it.

Ubuntu 12.04 start Skype at startup missing icon

If when you simply add skype command to the Startup applications, Skype does start-up, but there is no icon in the system tray, so that if you close the main window, or have the option to start in system tray, you cannot access Skype anymore with a GUI. Even worse, the Skype instance continues to run on the background, preventing you from opening a new one.

To me, the solution was instead of simply adding a command skype, to add

bash -c "sleep 10 && skype"

This waits for a bit before starting up Skype, so it seems that the problem was that Skype was starting up too early before some other necessary things were ready.

Source: this ask Ubunutu page

How to recover from a power down during Ubuntu update if you can boot with no interface

If that happens for any reason and if you can still boot, but get a broken interface (no mouse and keyboard for me) a possible solution is:

  • BACKUP YOUR STUFF IN YOUR WINDOWS PARTITION IF YOU HAVE ONE: with this program called diskinternals
  • Open a tty (Control + Alt + F2)
  • type sudo apt-get -f dist-upgrade and follow the instructions

Refactoring code with find xargs sed

With the script to follow you can do:

# changed lines only 
# only in files .php
# under current dir
# but don't make them (0)
sed_multifile .php find replace 0

# make changes and list nothing (1)
sed_multifile .php find replace 1

# replace in all files
sed_multifile "" find replace 0

The script:

#!/usr/bin/env bash

	echo "Usage: sed_multifile dotext find replace dosubstitute"

# argument checking
if [ $# -ne 4 ]

# decide write or not
if [ $4 -eq 0 ]
then # don't replace
	find . -type f -name "*$1" -print0 | xargs -0 sed -n "s/$2/$3/gp"
else # replace
	find . -type f -name "*$1" -print0 | xargs -0 sed -i "s/$2/$3/g"

Just add it to your bash search path.