(Symbolic) links in Windows

Windows has a concept in the NTFS filesystem that is quite similar to symlinks in Linux/Unix. Interestingly, these things have exotic names like reparse points and junctions. So for someone who is familiar with Linux/Unix terminology, the following mapping applies roughly:

  • Symbolic link == reparse point

In Linux/Unix, created with the command:
ln -s [target] [linkname]
In Windows (I think 7+), created with the command:
mklink [target] [linkname]
be aware though that for directories, you need to call the /D parameter in Windows.

  • Hard link == junction

In Linux/Unix created with the command:
ln [target] [linkname]
In Windows, created with the command:
mklink /J [target] [linkname]
again, don’t forget the /D for directories.

via https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/

Thursday, February 16th, 2017 Uncategorized No Comments

Installing a pip package directly from github

e.g. pip install git+https://github.com/uqfoundation/dill.git@master

Monday, November 9th, 2015 Uncategorized No Comments

How to integrate git-bash into ConEmu

Checked this with official git-bash 2.6.2 and ConEmuPack.151015.

Add a new tasks as follows (click on the pictures if you can’t read them):



Replace c:\app\git with the directory you installed git-bash into.

thanks to http://blog.tyrsius.com/setting-up-conemu-with-git-bash-on-windows/

Tags: , , ,

Saturday, October 24th, 2015 Uncategorized No Comments

Using (deep)copy in cython

If you want to be able to properly use copy or deepcopy in cython (without getting a segfault), you have to implement the pickle protocol for the class you want to (deep)copy.

via: http://stackoverflow.com/questions/7666873/cython-and-deepcopy-woes-with-referenced-methods-functions-any-alternative-id

Tuesday, October 20th, 2015 Uncategorized No Comments

Unlink of file failed for git gui or git gc on Windows

This happens usually when you have an IDE (like Eclipse, PyCharm) or a text editor with git integration (Emacs, Atom, Sublime) holding on to the files you want to unlink.

To solve it, close the IDE/editor and redo your git gc or git gui compression command.

via http://stackoverflow.com/questions/25138946/git-gc-git-gui-unlink-of-file-internal-pack-file-name-failed

Monday, October 5th, 2015 Uncategorized No Comments

Apache ant command line variables

You can easily set ant variables from the command line by using the -D parameter, e.g.:
ant -Djava.home=/my/java/home

Monday, November 24th, 2014 Uncategorized No Comments

Powershell Quirks

Calling functions: Parantheses or not?

When calling powershell functions, do not use parantheses and commas:

function Add($x, $y) {
    return $x + $y

$result = AddNumbers (5, 10) # Wrong! This passes the array (5,10) as the first argument
$result = AddNumbers 5 10 # Right

Source & more info: http://ss64.com/ps/syntax-functions.html

However, when calling methods of .NET objects, you should provide parantheses and commas for function calls.

$now = Get-Date # Note this is a System.DateTime object
$inAYear = $now.AddYears(1)

Writing output and returning stuff from functions is (mostly) the same

You can consider functions as part of your pipe and filter mechanism. Not only what you return using the return statement is returned, but also everything output with echo or Write-Output. Here are some examples of what is and what is not passed as output of a function.

Function A() {
    'a' # passed as output

Function B() {
    return 'b' # passed as output

Function C() {
    echo 'c' # passed as output

Function D() {
    Write-Output 'd' # passed as output

Function E() {
    Write-Host 'e'

Function F() {
    Write-Verbose 'f'

$out = "
A: '{0}'
B: '{1}'
C: '{2}'
D: '{3}'
E: '{4}'
F: '{5}'
" -f (A), (B), (C), (D), (E), (F)
Write-Output $out

The result of execution is:

A: 'a'
B: 'b'
C: 'c'
D: 'd'
E: ''
F: ''

Scoping… Global? Local?

Using a global variable inside a function introduces a local copy of that variable and does not update the global var by default:

$someglobal = 42</code>

Function IncrementAndPrint() {
    Write-Host "IncrementAndPrint before inc: $someglobal"
    $someglobal++ # Writing to a global introduces a local copy of the global var
    Write-Host "IncrementAndPrint after inc: $someglobal"

# Script
Write-Host "Script before: $someglobal"
Write-Host "Script after: $someglobal"

The output is:

Script before: 42
IncrementAndPrint before inc: 42
IncrementAndPrint after inc: 43
Script after: 42

To really a global you can change function IncrementAndPrint as follows:

Function IncrementAndPrint() {
    Write-Host "IncrementAndPrint before inc: $someglobal"
    Write-Host "IncrementAndPrint after inc: $someglobal"

The result is now:

Script before: 42
IncrementAndPrint before inc: 42
IncrementAndPrint after inc: 43
Script after: 43

Invoking external commands

A good resource on invoking external commands can be found here:

Wednesday, October 22nd, 2014 Uncategorized No Comments

Editing files remotely via sshfs

When accessing a remote host via sshfs there are two common problems when trying to edit files.

  1. UIDs/GIDs differ between your machine and the remote host. So permissions on the mounted filesystem are wrong.
  2. Files cannot be updated (e.g. saved from editors) for no apparent reason.

To address the first problem you can use the uid=… and gid=… options.
The second problem can be addressed with the workaround=rename option via sshfs.

To mount a remote location you can use the following command line.

sshfs -o uid=<local uid>,gid=<local gid>,workaround=rename <remoteuser>@<remotehost>:<path> <mountpoint>

For example if a user has uid 1000 and gid 1000 and wants to mount the /home/me directory on the remote server “myserver” to the local directory ~/mnt/me he could use the following command:

sshfs -o uid=1000,gid=1000,workaround=rename me@myserver:/home/me ~/mnt/me

Now files should have the correct permissions and saving (overwriting) files should work.

Tuesday, July 16th, 2013 Uncategorized No Comments

Switching GTK themes (widgets and icons)

The application lxappearance from XFCE is a useful tool to change icon and widget themes for your favourite window manager.

For me this tool was especially useful to regain icons in my file manager (e.g. thunar) when using a minimal window manager (e.g. awesome). Just run lxappearance and apply a theme, the items should now appear when you start your file manager.

Saturday, April 6th, 2013 Uncategorized No Comments

Ubuntu on ASUS EEE PC 1025CE

The ASUS 1025CE EEE PC has a cedarview Atom processor (N2800), 1 GB RAM, and the Intel GMA 3650 graphic chip.

Currently, the graphics chip is not well supported in linux. However it is possible to have a working system including smooth playback of 720p videos.

The following method worked for me:

  1. Install Xubuntu 12.04. I tried 12.10 first, but it didn’t work out for me despite the fact that it includes the newer gma500_gfx driver
  2. Boot your OS and fully update it. You may have to update twice. When update is done, reboot.
  3. sudo add-apt-repository ppa:sarvatt/cedarview
  4. sudo apt-get install add-apt-key
  5. sudo apt-get install cedarview-drm libva-cedarview-vaapi-driver cedarview-graphics-drivers
  6. sudo apt-get install gdm # The default login manager lightdm, didn’t start on my system
  7. sudo dpkg-reconfigure gdm # pick gdm as default
  8. Reboot your system.

On the 1025CE I tested audio, wifi, graphics including video acceleration, and suspend functionality.

Linux is a lot lighter on the RAM (~600MB free) than windows (~100MB free). This results in a smoother experience and more possibilities to run demanding apps.

Reference: http://askubuntu.com/questions/168986/cedar-view-drivers-arent-working

Friday, April 5th, 2013 Uncategorized No Comments