Blog

4/5

09. 09. 2012

When you print eps files, they are usually not scaled to fit the full A4 page. This script does this, but uses a rather ugly approach. It first converts the file to a pdf file, and then uses acroread to scale to A4 and ‘print’ into a postscript file. Afterwards, this ps file is sent to the printer using ‘lpr’.

#! /usr/bin/env python
import os,sys

# the names of the possible printers
printerlist = ['rubens','dkos','pssh']

# parse command line
try:
    file = sys.argv[1]
    printer = sys.argv[2]
except IndexError:
    sys.exit('Usage: printpage')

# produce pdf
os.system('epstopdf ' + file + ' --outfile=tmp.pdf')

# produce scaled ps
os.system('acroread -toPostScript -size a4 -expand tmp.pdf')

# produce scaled ps in landscape
#os.system('acroread -toPostScript -size a4 -expand -landscape tmp.pdf')

if printer in printerlist:
    print 'printing on %s' % printer
    os.system('lpr -P%s tmp.ps' % printer)
else:
    sys.exit('Error: wrong printer')

# clean up
os.system('rm -f tmp.pdf tmp.ps')

09. 09. 2012

This is something rather simple, a log-normal fit!

import sys,os
import numpy as np
import pylab as plt
import scipy.optimize

# function for fit - gauss curve - p = (mean,sigma)
func = lambda p, x: (1.0/ (p[1] * np.sqrt(2 * np.pi))) \
                                  * np.exp(-0.5 * ((x - p[0])/p[1])**2)
# residuals
res  = lambda p, x, y: func(p,x) - y

# initial parameters
pIni = [0,1.0]

# fetch the data
filename = '/home/jochen/somefile.data'
x,y = np.loadtxt(filename,usecols=(0,1),unpack=True)

# go log
y = np.log10(y)

# fit
p, sucess = scipy.optimize.leastsq(res,pIni,args=(x,y))

# plot
plt.plot(x,y,x,func(p,x))
plt.show()

23. 10. 2010

If Wifi keeps on disconnecting on Linux it could be because of conflicting kernel modules. One has to be blacklisted:

Remove corresponding kernel modules:

sudo modprobe -rf rt2800usb
sudo modprobe -rf rt2870sta

Reload kernel module:

sudo modprobe rt2870sta

Finally, put blacklist rt2800usb in /etc/modprobe.d/blacklist.conf

22. 10. 2010

in Thunderbird you can disable the creation of HTML mails for each account by unchecking:

Settings -> Composition -> Addressing -> Compose messages in HTML format

04. 09. 2010

A new post after quite some time!

I use elementary theme now. To use it under ubuntu just add the corresponding ppa to your sources.list:

sudo add-apt-repository ppa:elementaryart/ppa

Then install it using

sudo apt-get update
sudo apt-get install elementary-theme elementary-icon-theme

Now the theme can be activated in System > Preferences > Appearance. I like the buttons on the right, so, after activation, I add:

gconftool-2 -s /apps/metacity/general/button_layout  \
    --type=string ":minimize,maximize,close"

For a vertical panel to look good you need to comment out

bg_pixmap[NORMAL]  = "/Panel/panel.png"

in “/usr/share/themes/elementary/gtk-2.0/Apps/panel.rc”.

4/5
1