2014-05-14

pyramid, apache, virtual hosting

I was on the lookout for the good old ++vh++ ZTK virtual hosting solution for Pyramid.
This is the opposite of the X-Vhm-Root mode.

Turned out to be a bit complicated.

The simplified solution is:

paster.ini:

...
[filter:paste_prefix]
use = egg:PasteDeploy#prefix

[pipeline:main]
pipeline =
    paste_prefix
    your.app
...
apache config:

<VirtualHost 192.168.1.1:443>
    ServerName ops.acme.org
    DocumentRoot d:/wwwroot/empty

    RewriteEngine on
 
    RequestHeader set X-FORWARDED-SCHEME https

    <Location /sv1>
        RequestHeader set X-FORWARDED-HOST ops.acme.org/sv1
    </Location>
    RewriteRule ^/sv1/(.*) http://192.168.1.1:9000/$1 [P,L]
    
    <Location /sv2>
        RequestHeader set X-FORWARDED-HOST ops.acme.org/sv2
    </Location>
    RewriteRule ^/sv2/(.*) http://192.168.1.2:9000/$1 [P,L]
</VirtualHost>



2014-04-30

xfce4 4.11, xubuntu 14.04, how to turn off session saving even HARDER

As kiosk mode also does not seem to work, create an upstart script:


start on (starting lightdm
          or starting kdm
          or starting xdm
          or starting lxdm)

description "kill XFCE sessions hard"
author  "Adamg"

task
normal exit 2

script 
 cd /home/username/.cache/sessions
 rm -rf *
 console output

end script
Replace username with yours. Enjoy a session free startup.

2014-04-24

xfce4 4.11, xubuntu 14.04, how to turn off session saving HARD

If the obvious

settings -> settings manager -> session & Startup -> general -> Automatically save session

way does not work,

sudo mkdir /etc/xdg/xfce4/kiosk
sudo nano /etc/xdg/xfce4/kiosk/kioskrc
[xfce4-session]
SaveSession=NONE

taken from
http://askubuntu.com/questions/250630/how-can-i-turn-off-xfce-session-saving-system-wide

2014-04-23

fixing skype + pulseaudio sound issues

env PULSE_LATENCY_MSEC=30 /usr/bin/skype

2014-04-22

updating to xubuntu 14.04

Being blessed with a hp 8470w with an AMD radeon ubuntu provided fglrx works quite OK.
Having some rendering issues with synaptic and chromium.
Installing fglrx-pxpress hold around 5W less power usage according powertop.

2014-04-06

How to or not to interview (IT)

I was reading various blog entries about interviews and various stuff around getting hired as I was looking for my next gig.
This would have been a nice blog series, but I got hired again, so I'm dumping here the most interesting ones for fellow job seekers and eventual employers reading.

The negatives:

The positives:

Tips and tricks of trade:

Tips for employers:

Note, my viewpoint is very subjective, I have the wanna be hired stake.

After reading all this stuff, if I could choose I would want a CV check, phone/skype screen, then work a few payed days on site. No whiteboard coding please -- who wants to swim dry?





2012-07-20

Persisting Chromium options on linux

Well, windows has a registry, linux has .profile.



Add to ~/.profile :
export CHROMIUM_USER_FLAGS="--disk-cache-dir=/tmp --disk-cache-size=50000000"

2010-08-01

z3c.language.negotiator speedup

zope.session is sooooo slow and z3c.language.negotiator calls it for each message to translate if set to session.
I fixed that. Now z3c.language.negotiator can have a cache on the request. That brings up to 1/3 speedup on an average page. Just make sure you set cacheEnabled to True.

2010-05-28

Rackspace speed test

Recently activated a smallest windows rackspace cloud server (512M RAM, 20GB disk, win2003 server 64bit).
Performance is a lot better than expected. After login the server has still over 250M RAM free.
It's a 4x Quad-Core AMD Opteron(tm) Processor 2374 HE (2.2GHz, 7GHz IMC, 512kB L2, 6MB L3). CPU slices are capped, but still.
SiSoftware Sandra

Benchmark Results
Aggregate Arithmetic Performance : 26.28GOPS
Dhrystone ALU : 28.87GIPS
Whetstone iSSE3 : 23.7GFLOPS

Benchmark Results
Aggregate Memory Performance : 9.33GB/s
Integer Buff'd iSSE2 Memory Bandwidth : 9.25GB/s
Float Buff'd iSSE2 Memory Bandwidth : 9.4GB/s


They also have some serious disk subsystem:

2010-04-13

Window Shortcuts for Linux

Here is an enhanced version of a script found here: http://somanov.wordpress.com/2009/12/02/window-shortcuts-for-linux-desktops/

That version had the problem that it searched for the program_name in the complete wmctrl line not just in the class. That made it do bad switches. Like you had a folder open in Nautilus that had the name firefox in it, it considered Nautilus too as a Firefox candidate.



#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import commands


program_name = sys.argv[1] # the program to be focused


# get all windows from wmcontrol
windows = sorted([x.strip() for x in commands.getoutput(
        """wmctrl -l -x""" ).split("\n") if x !=''])


wins = []
for win in windows:
    win = win.replace('  ', ' ')
    parts = win.split(' ', 5)
    d = dict(id=parts[0], klass=parts[2], title=parts[4])
    wins.append(d)


# filter candidates on klass
candidates = [w['id'] for w in wins
              if program_name in w['klass'].lower()]


if candidates:
    # at least one candidate found , we need to check if the active window is among the candidates (for cycling)


    # Get the id of the active window


    # Note: wmctrl currently does not support getting information about the active window.  In order to realize this
    #       we use xprop here. Unfortunately xprop gives us the window id of the active window in a different format:
    #       Window ids from wmctrl always begin with 0x followed by 8 digits (leading zeroes for padding). xprop
    #       does not do the padding and might give a window id starting with 0x followed by only 6 digits. The
    #       lines below get the id of the current window and make the id returned by xprop comaptible with
    #       the window ids returned by wmctrl.
    active_window_string = commands.getoutput(
        'xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"')
    active_window_string =  active_window_string[active_window_string.find("#")+4:].strip()
    active_window = "0x" + "0" * (8-len(active_window_string)) + active_window_string


    # the window to display. (one of the windows in candidates)
    next_window = None
    if active_window not in candidates:
        # if the active window is not among the candidate windows
        # ..just show the first candidate window
        next_window = candidates[0]
    else:
        # we are already showing one of the candidate windows
        # show the *next* candidate in the list (cycling)
        next_window = candidates[
            (candidates.index(active_window)+1) % len(candidates)]


    if next_window:
        # tell wmcontrol to display the next_window
        os.system('wmctrl -i -a "%s"' % (next_window,) )
else : # no windows open which fit the pattern of program_name
    os.system("%s &" % (program_name,)) # open new window

2010-01-24

RIP debugzope, long live z3c.recipe.paster:debug

There was a nice debugzope script at the times when Zope 3 was packaged as a tarball. You could interactively dig into ZODB make your changes and commit.
Now at ZTK / egg / recipe / buildout times I was missing this. Therefore I created the recipe z3c.recipe.paster:debug.
(some code taken from grok ;-)

Add it to your buildout.cfg like this:

[debug]
recipe = z3c.recipe.paster:debug
app=app
where app is a z3c.recipe.paster:serve recipe.

2009-12-05

Still the munin-node for win32 subject

Some more fixes:

  • Sleep(100) on waiting for an external plugin to finish -- BAAH, Sleep(0) hogged the CPU
  • never (try to) write back the .ini file -- well you might not have permission and I(!) am the one who writes the config
  • PortNumber -- specify which port to bind to, well 4949 what else? but was a simple copy paste
  • LogConnections -- ability to turn off that insane connect logging every 5 mins
  • MasterAddress setting -- limit the IP address of the remote (master) server connecting. Right now to only 1 IP, but how many munin masters will you have?

Still need to adjust external plugins to be able to use existing munin-node plugins.
Goal would be to install (active)perl and run the existing munin plugin that's usually written in perl. Who wants to reimplement that again with e.g. python?

patch binary

2009-12-02

Monitoring windows with munin

Who said monitoring a windows server is impossible with munin?

There is munin-nodewin32 on github, but it was a bit crippled with external plugins.
The problem with monitoring memory usage was fixed in svn but not yet compiled.
Here is a patch and binary that fixes that.
After that it's easy to write plugins (in python) to monitor what you want.

2008-03-12

debugzope howto

There's a script called debugzope, that sounds like a debugger. But in real life you can examine the whole ZODB with it. You can even make changes to the ZODB or ZEO. All in all quite handy if you have to correct a few objects in the database, also on a live system.

$ bin/debugzope
Now the variable root becomes your DB's root. All configuration should be taken from the live system in which context it was started.

>>> root
zope.app.folder.folder.Folder object at 0x01C31C70
You can do any changes (and anything) using the usual python commands. The whole Zope infrastructure is in place.

Don't forget to commit when you are ready:

>>> import transaction
>>> transaction.commit()
Otherwise all changes will be reverted on exit!

debugzope(.bat) is usually available if you use the old zopeskel style deployment. The next task is to figure out how to do this with a buildout based deployment.

2007-08-21

nokia E61 and Google Docs

Who said that Google Docs and Spreadsheets is not working with a nokia mobile?
OK - it's not pleasure, but at least I can see what I wrote after some hacking.

This is the spreadsheet. Read only, the guys check the browser. At least I can see something.

This is the Docs. It is almost working! Click on the tabs is working:


Trying to login through docs.google.com results in:
Adding /?browserok=true at the end of the URL does not help too much. The document list is empty:

Stay tuned for more.

That was done using a nokia E61, SW: 3.0633.09.04, with the stock-builtin browser.

2007-08-16

OT: updating nokia E61 software

Just bought a nokia E61 to play around.
Tried to update the firmware in it. The nokia software updater did not even start up.
The error message was: "Network connection lost. Check your network connection or wheter a firewall is prventing the application from working properly".
Nope, no firewall problem. Internet explorer was "working offline". Thanks Bill.

2007-03-08

ZODB tracing done

Project home is now z3c.zodbtracing on svn.zope.org.
Read more here: http://svn.zope.org/z3c.zodbtracing/trunk/src/z3c/zodbtracing/
Performance can be an issue if using this storage, but that's not for production, just for debugging so don't come whining.

How to debug UnpickleableError

Sometimes happens that you put a security proxied object into a persistent object's property. Then on transaction commit you get the error:
UnpickleableError: Cannot pickle objects
Now you can search al your code and guess where you set that property.
That can be solved much simpler:
modify ZODB/serialize.py temporarly as follows:
def _dump(self, classmeta, state):
# To reuse the existing cStringIO object, we must reset
# the file position to 0 and truncate the file after the
# new pickle is written.
self._file.seek(0)
self._p.clear_memo()
self._p.dump(classmeta)
try:
self._p.dump(state)
except:
#your favorite debugger's break command

self._file.truncate()
return self._file.getvalue()

And voila, classmeta is the class concerned, state is a dict holding the state. From these values it's piece of cake.

2007-03-02

Restart Z3 with a single click

Put a bookmark into your browser's toolbar that points to http://localhost:8080/++etc++process/servercontrol.html?restart=1
That simple it is.

ZODB debugger

The questions "how-to check the structure of ZODB", "what is stored in the ZODB" pops up here and there.
The answer is: http://svn.zope.org/z3c.zodbbrowser/
This is a wxPython package running independently of the Z3 app server. In fact shut it down before trying to start the ZODB debugger.