Accessing module global variable in a cython module from python

Let’s say you have a global module variable in your cython script:

cdef public bint myVal = True

Such a variable is hidden in C space, so you cannot access it directly from python space.
If you want to be able to change this value from another python script, you can just make a wrapper function around it, e.g.:

cpdef set_myval(bint val):
global myVal
myVal = val

Now you can access the variable in the cython module.

Wednesday, November 18th, 2015 Cython, Python No Comments

Installing a pip package directly from github

e.g. pip install git+

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

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.


Tuesday, October 20th, 2015 Uncategorized No Comments

Cropping an inserted object in Microsoft Word 2007

If you insert a picture, you can easily google how to crop it in Word 2007, but if you insert an object, like a Powerpoint slide into Word, it’s not so easy to google. I hope this post will change that.

The answer is simple, but not necessarily easy to find. Right click on the inserted object, click Format and then go to the Picture tab. In the top of this tab you will see the Crop from panel. Here you can fill in your crop values.

Thursday, October 15th, 2015 Word 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.


Monday, October 5th, 2015 Uncategorized No Comments

Making Atom Package Manager (apm) work behind a proxy

Add an environment variable as follows:



Thursday, September 10th, 2015 apm, Atom, Firewall, Proxy, Text editing No Comments

Downloading raw files from github

If you want to download a file directly non-interactively from github (for example in a script), you get some HTML page showing the file with line numbers etc. So if you want to download the file raw, you just modify the URL, as follows:

If you want to get<my>/<repo>/<file>
You use as URL:<my>/<repo>/raw/<file>

And if you want to download this file from a certain branch on the repo, you use:<my>/<repo>/raw/<branch>/<file>


  • <my> is the user or organization name on github
  • <repo> is the repository name
  • <branch> is a branch on the repository
  • <file> is the file you want to download
Saturday, February 7th, 2015 github 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:

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