Resize files using one command

Using ImageMagick it is easy to resize multiple images by the following command:

for i in `ls *.JPG`; do convert -resize 1024 $i $i; done


A bit detailed version of this script can be found in my bitbucket repository: resizer.sh

django-expense

About two years ago I tired Dajngo, the popular python web framework. I was impressed how easy and logical is the usage of it. I started to create some simple apps only for personal usage. One of these apps was django-expense, a simple personal/family expense tracker application.

Now I refactored a bit and put the source to bitbucket.

From the user view: It is uses the default Dajngo admin site and you can record expenses and check them in monthly or yearly view.

From technical view, you can find examples to the following django specific areas:

  • Aggregation

  • Customized ChangeList view

  • Custom filterspec


If you interested you can get the source using mercurial from bitbucket or download the latest version.

IKEv2 VPN Client Setup on Debian Squeeze

Recently my company was set up a Windows 2008 VPN server. It is configured to accept only SSTP and IKEv2 protocols.

I did not find any working clients for Linux that uses SSTP protocol, but for IKEv2 strongSwan provides a quite easily configurable and working solution.

To set up the VPN client I did the following:

1. Installed the strongswan-ikev2 package.
# apt-get install strongswan-ikev2

2. Configured the /etc/ipsec.conf file (changed the bold values):

# ipsec.conf - strongSwan IPsec configuration file

# basic configuration

config setup
charonstart=yes
plutostart=yes

# Add connections here.
conn %default
ikelifetime=60m
keylife=20m
rekeymargin=3m
keyingtries=1
keyexchange=ikev2

conn companyvpn
leftfirewall=yes
leftauth=eap
eap_identity=username
right=serverip
rightauth=pubkey
rightid="C=XX, ST=State, L=Location, O=Organization, OU=OrgUnit, CN=CommonName, E=email"
rightsubnet=192.168.1.0/24
auto=add
leftsourceip=%config

include /var/lib/strongswan/ipsec.conf.inc


3. Set up the password for the user name in the /etc/ipsec.secrets file:
username : EAP "password"

4. Put the certificate of the Certificate Authory into the /etc/ipsec.d/cacerts/ directory to trust the certificates which was created by this CA:
# mv CA.cer /etc/ipsec.d/cacerts/

5. Restart ipsec:
# /etc/init.d/ipsec restart

6. To run the VPN connection type:
# ipsec up companyvpn

7. Use the VPN connection.
8. To stop the VPN connection type:
# ipsec down companyvpn

Emacs Setup for Python Development on Debian Squeeze

This a brief description of how to install emacs as a python development environment on a Debian Squeeze.

If emacs is not installed than install it with apt:
$ sudo apt-get install emacs


Than install the following packages using apt:
$ sudo apt-get install python-mode pymacs auto-complete-el yasnippet pyflakes


However python-rope and python-ropemacs packages are available in the debian repository they are not working perfectly, so these packages should be installed by the python way, to do this we need the python-setuptools package:
$ sudo apt-get install python-setuptools

Now we have ease_install, so use it to install rope and ropemacs:
$ sudo easy_install rope
$ sudo easy_install ropemacs

If easy_install could not find ropemacs you can download and install it manually from http://bitbucket.org/agr/ropemacs

Create a file which initializes the installed modules and name it to init-python.el and put it into your .emacs.d directory.

Add the following lines into your emacs config:

(add-to-list 'load-path "~/.emacs.d/")
(progn (cd "~/.emacs.d")
(normal-top-level-add-subdirs-to-load-path))

; python setup
(require 'smart-operator)
(require 'auto-complete)
(global-auto-complete-mode t)
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/.emacs.d/snippets")
(load-library "auto-complete-yasnippet")
(load-library "init-python")


Ok, everything is ready let's try it. Start your emacs type and press TAB to complete, if everything is ok a popup should be appeared with the available completion:



Check C-h m to show key bindings.

References:
1. http://hide1713.wordpress.com/2009/01/30/setup-perfect-python-environment-in-emacs/
2. http://www.enigmacurry.com/category/emacs

Slow SSH Authenentication

I have set up an ssh server at my home from the default debian repository. Unfortunately, remote connections were quite slow, the authentication required about 30 sec. I tired to start the ssh client in verbose mode:

$ssh -v user@host
...
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received

And after the last line it was hanging for a while. I suspected that it could be related with DNS lookups, so I added the following line into the server's sshd_config file:
UseDNS no

After this the restart of the ssh server was required.
#/etc/init.d/ssh restart

and the problem went away...