12. May 2013

Unicode Python plugin for Unicode NSIS

NSIS is very common project for building installer packages. It requires less time to work with NSIS than using WiX or MSI.

It has also certain drawbacks like very weird programming language which resembles assembler mixed with Postscript. Quite scary at first glance. There is remedy for this glitch.

NSIS is good for building installer “container” and it could hand over more complex logic to its plugins like Python plugin.

Original NSIS has another one glitch: no support for unicode. Luckily guys took NSIS and they fixed the issue by creating Unicode NSIS.

Unfortunately unicode version was not able to work with former Python plugin.

It required some effort to fix Python calls from NSIS and voilà Unicode Python plugin is available at github – nsPythonUnicode. :-)

26. November 2012

There is more to C and C++. Slides from talk at FI MUNI 2012

This year I had opportunity to speak at two courses at FI MUNI. Check out slides :)

There is more to C (PDF)

Libraries ant tools for C++ (PDF)

Source code of examples is at GitHub: github.com/georgik/fimuni-c-cpp-examples

18. November 2012

Allegro5.1 and Visual Studio 2012 – Unable to start examples – missing dll files

It’s easy to work with Allegro 5.1 project in Visual Studio 2012. Just clone the project from git repo. Invoke cmake-gui.

Note: Make sure that you have installed Windows SDK for Windows 8.

You can do it using following commands (use Developer Command Prompt for VS2012 or set proper variables):

git clone git://git.code.sf.net/p/alleg/allegro
cd allegro
mkdir Build
cd Build
cmake-gui ..

Click Configure and Generate. Then open solution in Visual Studio.

You can build whole solution. The only problem is that when you want to invoke any example then you’ll see something like this:

Those DLL files are located in Build\lib\RelWithDebInfo (or something like that). It is sufficient to update PATH environment variable. You can do it on per-project basis.

Press Alt+F7 (Right click – Properties) – Debugging – Environment – Set/Add:

PATH=$(ProjectDir)..\lib\RelWithDebInfo

Run the example again (F5):

18. November 2012

Vim – How to edit Unicode files produced by PowerShell

It’s possible to redirect output of PowerShell command into file. E.g.:

Get-ChildItem -Recurse  | Select-Object -ExpandProperty FullName >file-list.txt

If you want to open this file-list.txt by vim you may be little bit surprised by unreadable text:

If you open the same file in notepad, then everything is perfectly readable.

There is simple fix for vim suggested by Tony Mechelynck. Just open .vimrc in your home directory and add following lines:

if has('multi_byte')                   " multibyte features compiled-in 
  if &encoding !~? '^u'                " the OS locale is not Unicode 
    if &termencoding == ''             " empty means 'use &enc' 
      let &termencoding = &encoding    " avoid clobbering keyboard codes 
    endif 
    set encoding=utf-8 " we can do it, now that the kb is taken care of 
  endif 
  set fileencodings=ucs-bom,utf-8,latin1 " heuristics for existing files 
  setglobal bomb fileencoding=latin1   " defaults for new files 
                     " 'bomb' doesn't apply to latin1 
                     " it applies when 'fenc' is manually set to Unicode 
endif

Result:

4. November 2012

Cygwin – transparent terminal

New version of Cygwin is distributed with resizable Cygwin Terminal.

Cygwin Terminal is configurable and it has some neat features like transparency.

In order to turn on transparency click the left top icon and select Options.

Change transparency in section Look – Transparency.

Click Ok or Apply.

3. November 2012

Cannot find module ‘couchapp’ – solution for Linux and Windows

It is possible to create HTML5/CouchDB application using Node.js with tool Couchapp.

You can find nice totorial at RelaxTV.

The first step: install Couchapp:

npm -g install couchapp

Now you have command couchapp and you can create boilerplate:

coachapp boiler blog

This works fine, but when you want to publish this application to CouchDB server you can see weird error:

PS C:\idea\couch\blog> couchapp push app.js http://localhost:5984/blog
module.js:340
 throw err;
 ^
Error: Cannot find module 'couchapp'
 at Function.Module._resolveFilename (module.js:338:15)
 at Function.Module._load (module.js:280:25)
 at Module.require (module.js:362:17)
 at require (module.js:378:17)
 at Object.<anonymous> (C:\idea\couch\blog\app.js:1:79)
 at Module._compile (module.js:449:26)
 at Object.Module._extensions..js (module.js:467:10)
 at Module.load (module.js:356:32)
 at Function.Module._load (module.js:312:12)
 at Module.require (module.js:362:17)

People at node.couchapp discussion suggest that you should set NODE_PATH. This path should point to the place where node stores modules. npm shows this path during installation of module.

Fix for Linux:

export NODE_PATH=/usr/local/lib/node_modules

Node is using little bit different storage on Windows, it stores data into ~\AppData\Roaming\npm.

Fix for Windows Powershell (ConEmu):

$env:node_path="$home\AppData\Roaming\npm\node_modules"

If you want to persist change for PowerShell, then you can put this line into: Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

20. August 2012

Problems with deploying Heroku Django app from Windows

Deploying Django app to Heroku from Windows machine is little bit tricky.

You can follow instructions in Heroku manual. The first problem that you may encounter is with Postgres support in Python. There is problem with this command:

pip install Django psycopg2 dj-database-url

If you do not have Visual Studio installed on your machine, you’ll receive error that vcvarsall.bat is missing.

Solution is quite easy. You don’t need to install Visaul Studio. Just download binary version of psycopg2 module from http://www.stickpeople.com/projects/python/win-psycopg/

Then you can exclude psycopg2 from pip install command, because it is installed in system directory of Python.

Another tricky issue is with command:

pip freeze >requirements.txt

If you type this command in PowerShell then it will automatically create Unicode file with extra bytes. When you try to deploy project with messed requirements.txt to Herou then you’ll see self explanatory error ;-)

TypeError: must be encoded string without NULL bytes, not str

Nice :-)

Just open requirements.txt file with notepad and select Save as. In Save as dialog choose ANSI.

Commit file and push project to Heroku. It will work ;)

19. August 2012

How to change font size in Skype

It’s quite easy to change default font size in Skype, but option is little bit hidden.

Open menu: Tools – Options.

Click: IM & SMS

Choose: IM appearance

Click: Change Font

Change the font and Save it.

5. August 2012

Console2 for Windows – semi-transparent NodeJS shell, PowerShell or cmd

Console2 is great little front-end for Windows. It makes PowerShell even more usable. It’s very flexible and you can configure console window to behave like terminal window on MacOS or Linux. It has also support for transparency. It’s simply great. No need to add any more words. Just try it.

I’d like to add few more hints.

Enable transparancy

  • Go to Settings – Appearance – More…
  • Select Window transparency – Alpha
  • Change alpha level of Active and Inacative window.

Result:

Copy on left mouse button click, paste on middle button click

Default configuration of mouse is not very useful. You have to press Shift and Left Mouse to select and copy text. Make small adjustment:

  • Settings – Hotkeys – Mouse
  • Change: Copy/clear selection to Left + Shift
  • Change: Select text to Left

Use Console2 as front-end for NodeJS

You can use Console2 to invoke also NodeJS shell. Just create Tab definition for NodeJS.

  • Go to Settings – Tabs
  • Add NodeJS and set Shell to: “C:\Program Files (x86)\nodejs\node.exe”

Create new Tab with NodeJS profile:

Awesome :)

14. July 2012

How to fix incorrect Cygwin permission in Windows 7

Cygwin started to behave quite strangely after recent updates. I was not able to edit files in vim, because it was complaining that files are read only. Even cp -r didn’t work correctly. Permission of new directory was broken and I was not able to remove it. Pretty weird behavior.

E.g. ls -l

total 2
----------+ 1 georgik None 34 Jul 14 18:09 index.jade
----------+ 1 georgik None 109 Jul 14 17:40 layout.jade

Hm. It is clear that something is wrong with permission. Even owner has no permission on those files.

Output of mount command:

C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)

I found a solution at cygwin forum. It’s quite easy to fix it.

Open /etc/fstab and enter following line:

none /cygdrive cygdrive binary,noacl,posix=0,user 0 0

Save it. Close all cygwin terminals and start new terminal.

Output of mount:

C: on /cygdrive/c type ntfs (binary,noacl,posix=0,user,noumount,auto)

Output of ls -l

total 2
-rw-r--r-- 1 georgik None 34 Jul 14 18:09 index.jade
-rw-r--r-- 1 georgik None 109 Jul 14 17:40 layout.jade

  • Babel fish

      Translate from:

      Translate to:

  • Where’s the fish?

  • Further info

  • Badges

  • Video channel

  • Learning

    Grow your brain.
  • Tags

  • Topics

  • May 2013
    M T W T F S S
    « Feb    
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
  • Comments