haskell

[agda] Install agda on Mac OS

I’ve tried installing

cabal install Agda-2.3.2.1 

But got dependency errors.

cabal: cannot configure parallel-3.1.0.1. It requires deepseq ==1.1.*	

Installing an older version works:

cabal install Agda-2.3.0.1 

References

[1] http://wiki.portal.chalmers.se/agda/pmwiki.php?n=Main.MacOSX
[2] http://agda.orangesquash.org.uk/2012/November/14.html

emacs

How to reload .emacs without reopening emacs

Problem

How to reload .emacs without reopening emacs

Solution

Select the region you edited and do

M-x eval-region RET

This avoids the entire .emacs file to be executed twice which might break things.

Reference

[1] http://stackoverflow.com/questions/2580650/how-can-i-reload-emacs-after-changing-it

bash

[bash] Move and change directory (mv & cd)

In many cases when I move one or more files to a directory I want to change to that directory afterwards. I did a little search and found this discussion, which resulted in the following bash script function:

function mvcd () 
{ 
     num_of_files=$(($# - 1))
     for i in $(eval echo {1..$num_of_files})
     do
         eval mv \${$i} \${$#}
     done
     eval cd \${$#}
}

Example:

mkdir c
touch a.txt b.txt
mvcd a.txt b.txt c
linux · tip

[Linux] xclip command

Copying

The following command

echo "foo" | xclip -selection clipboard

will copy “foo” to you clipboard. Try pasting it elsewhere. The clipboard selection is the one used by Ctrl-C Ctrl-V commands. The default selection of xclip is the one used when you select text in linux (XA_PRIMARY).

A shorter version would be:

echo "foo" | xclip -sel c

Pasting

You can also send the contents of the current clipboard to the terminal (useful for piping).

xclip -sel c -out

Or

xclip -sel c -o

eclipse

[Eclipse] Find all occurrences where a variable is written

Problem

Search all occurrences where a given variable is written (but not read) in a workspace, using Eclipse.

Solution

Search for current references (Shortcut: Ctrl + Shift + G) and filter out occurrences by type using the menu illustrated in the image below. In this case, it’d probably suffice to check the ‘Read’ entry.

Reference

[1] http://stackoverflow.com/questions/9333634/find-all-assignments-to-variable