My pretty face [ László Monda's Blog ]
Exploring the cyberspace, one quadrant at a time!
 
Main Page | Blog | Projects

Archive for the 'My Code' Category

chnorm 0.3 released

Tuesday, June 16th, 2009

You can fetch it while it's hot.

I've fixed the output of the --help option which crashed due to "invalid" characters in my accentuated name.  Thanks for Tamás for letting me know about this bug!

How to make Konsole tab names always reflect the hostname of the current host

Saturday, August 23rd, 2008

Put this script to some directory that precedes /usr/bin in $PATH, like /usr/local/bin to wrap ssh:

#!/bin/bash

if [ "x$KONSOLE_DCOP_SESSION" = "x" ]; then
    exec ssh $*
fi

function restore_old_session_name {
    dcop $KONSOLE_DCOP_SESSION renameSession "$old_session_name"
}

if [ "x$KONSOLE_DCOP_SESSION" != "x" ]; then
    old_session_name=`dcop $KONSOLE_DCOP_SESSION sessionName`
    hostname="${!#}"  # we expect the last arg to ssh to be the hostname
fi

trap "restore_old_session_name" SIGINT SIGTERM

if [ "x$KONSOLE_DCOP_SESSION" != "x" ]; then
    if [ "x$hostname" != "xecho FISH:; /bin/sh" ]; then
        dcop $KONSOLE_DCOP_SESSION renameSession "$hostname"
    fi
fi

/usr/bin/ssh $*

if [ "x$KONSOLE_DCOP_SESSION" != "x" ]; then
    restore_old_session_name
fi

Make Apple Trailers work with MPlayer plugin on Linux

Saturday, August 23rd, 2008

I've just written a Greasemonkey script that does the above job.

Kill Right Click Blocking Copyright Monkeys!

Tuesday, August 28th, 2007

Has it ever occured to you that you visited a site, wanted to do some mouse gestures and a nasty pop-up window said to you: "This page is copyrighted. You are not allowed to copy from my page."?

If your answer is yes, it's time to install my Greasemonkey extension. Works well against most of such pages.

Goodbye Feedy, Greetings Google Reader!

Thursday, July 26th, 2007

I've recently trashed my feed reader, Feedy. I started it about a half year ago, but it took too much time to maintain it. I knew about Google Reader for a long time, but I didn't like it's interface. Now that I use it for two weeks I have no doubts about its superior usability. I'm very satisfied with it.

Although I doubt anyone would use Feedy, I put it out, because I think it has a nice UI and a good database layout that prevents feed duplication pretty effectively so it may be a good base for developing a more robust feed reader.

feedy.tar.bz2 is not a release. A release is a carefully compiled end product that is easy to install. Feedy is not easy to install, but check out the README file for some information.

Lastly but not leastly here are some screenshots:


Image
The news items screen

Image
The config screen

How to Make Firefox Restore Your Session under Linux

Wednesday, July 25th, 2007

When you restart your GNOME / KDE session, Firefox asks you the same boring question once again:

Image

Seems familiar?

The reason it happens is that Firefox doesn't implement the X session protocol so every time you log out from your Linux desktop, Firefox gets mercilessly killed. I don't plan to patch Firefox to implement X session protocol, because I don't have the special knowledge and it'd took too much time for me, but I present you a pretty good hack that works really nice.

Edit {your-firefox-directory}/components/nsSessionStartup.js as follows:

Original code:

// prompt and check prefs
this._doRestore = this._lastSessionCrashed ? this._doRecoverSession() : this._doResumeSession();

Updated code:

// prompt and check prefs
var ignoreSessionCrash = this._getPref("sessionstore.ignore_session_crash", false);
this._doRestore = !ignoreSessionCrash && this._lastSessionCrashed
                      ? this._doRecoverSession()
                      : this._doResumeSession();

From now on if you want to always restore your session upon startup, you have to set the sessionstore.ignore_session_crash variable to true within the about:config page of Firefox (you have to type about:config in the address bar).

if Firefox keeps crashing due to an evil web page that is saved in your session, then you have to manually set the sessionstore.ignore_session_crash variable to false by editing the {your-home-directory}/.mozilla/firefox/{your-profile-dir}/prefs.js file as follows:

original line: user_pref("browser.sessionstore.ignore_session_crash", true);
updated line: user_pref("browser.sessionstore.ignore_session_crash", false);

Good luck hacking your Firefox until the X session protocol gets implemented in it!

How to Automatize HTTP Requests Using Greasemonkey

Thursday, May 31st, 2007

There are some sites that I use daily. The sad thing is, many of them don't provide me any mechanisms to log in automatically, so I have to always do it manually. I also had to fill the same form in on these sites and carry on the same operation over and over again. This was very frustrating for me so I decided to come up with a solution. Greasemonkey seemed to have the potential to solve my burning need.

I want to share the core function I've written that can help you in such scenarios. It's a simple, but very useful one.

function submit_form(method, action, elements, target)
{
    var form = document.createElement('form');
    document.body.appendChild(form);
    form.method = method;
    form.action = action;
    for (element_i in elements) {
        var element = document.createElement('input');
        element.setAttribute('type', 'hidden');
        element.setAttribute('name', element_i);
        element.setAttribute('value', elements[element_i]);
        form.appendChild(element);
    }
    if (target) {
        form.target = target;
    }
    form.submit();
}

Requests are typically triggered based on the content of window.location.href or document.referrer.

Greasemonkey has some ugly annoyances, but fortunately most of them can be worked around. The LiveHTTPHeaders add-on can also help you tremendously constructing the fields of the forms.

Symlinker 0.0.2 Released

Sunday, May 20th, 2007

It's a small bugfix release.

Symlinker 0.0.1 Released

Wednesday, May 9th, 2007

I've just released Symlinker 0.0.1. Symlinker is a minimalistic PHP file manager that is built to primarily operate with symlinks. Read more about it on its project page.

Power 0.2.2 Released

Friday, March 16th, 2007

I've just released Power 0.2.2. It's a small bugfix release. Although this bug was small, it was an irritating one.