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

Archive for the 'My Projects' Category

dumbsvnreview 0.4 released

Tuesday, May 17th, 2011

I could simply name this release as "syntax highlighting coolness" which was really simple to implement on my part because I just had to provide Meld the correct file extensions to figure out the file format. Apart from that, I've worked around an svn bug that provided many redundant parameters to the diff utility.

If you upgrade to this version, please make sure that you update your /etc/sudoers to contain the meld-wrapper script instead of meld.

Go for it!

Ultimate Flash XHTMLizer 0.1 released

Sunday, April 24th, 2011

Ultimate Flash XMTMLizer is a WordPress plugin that turns Flash embed code into well-formed XHTML by escaping object tags on the server side and unescaping them on the client side using JavaScript.

dumbsvnreview 0.3 released

Sunday, April 24th, 2011

Check the changelog and the actual release.

dumbsvnreview 0.2 released

Friday, March 25th, 2011

I'm just contradicting myself of not doing another release. This is just a small bugfix making PHP warnings and notices disappear. Get it while it's hot!

dumbsvnreview 0.1 released

Friday, March 18th, 2011

Not that I plan yet another release but it has proved itself to be a handy tool over the last few weeks.

Stick your file to a specific path with stickfile

Thursday, January 20th, 2011

Update (2011-04-22): Zach let me know in the meantime that there's a much easier way to implement stickfile in BASH:

0
1
2
3
while true; do
      inotifywait -q -q -e modify -e delete $2
      cp $1 $2
done

Moral of the story: I should have searched for inotify command line which would lead me to inotify-tools which contains inotifywait.

And now to the original post:

My employer uses SonicWALL NetExtender for his VPN needs. Saying that I'm not a fan of IPsec would be definitely an understatement, but my major problem is that NetExtender overwrites my resolv.conf upon every connection which screws the hostname resolution on my LAN from my laptop. chmoding or chowning resolv.conf doesn't help because it gets re-chowned and re-chmoded by NetExtender.

I was thinking about overwriting resolv.conf on a regular basis from a script but it seemed rather inelegant. But how should I do it otherwise? With inotify, of course.

Here's the script I've written which you should save as "stickfile" to a directory that is featured in your $PATH.

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
 
import os
from sys import argv, exit
from shutil import copyfile
from pyinotify import *
 
def add_watch():
    global watch_manager, watch_descriptor, file_to_stick
    watches = watch_manager.add_watch(file_to_stick, IN_MODIFY | IN_DELETE_SELF)
    watch_descriptor = watches[file_to_stick]
 
def remove_watch():
    global watch_manager, watch_descriptor
    watch_manager.rm_watch(watch_descriptor)
 
class MyProcessEvent(ProcessEvent):
    def process_IN_DELETE(self, event):
        self.stick_file()
 
    def process_IN_MODIFY(self, event):
        self.stick_file()
 
    def stick_file(self):
        global file_to_stick, file_to_clone
        print 'Sticking %s as %s' % (file_to_clone, file_to_stick)
        remove_watch()
        copyfile(file_to_clone, file_to_stick)
        add_watch()
 
if __name__ == '__main__':
    if len(argv) != 1+2:
        program_name = argv[0]
        print 'Usage %s: FILE-TO-CLONE FILE-TO-STICK' % (program_name)
        exit(1)
 
file_to_clone = argv[1]
file_to_stick = argv[2]
 
watch_manager = WatchManager()
notifier = Notifier(watch_manager, MyProcessEvent())
add_watch()
 
while True:
    try:
        notifier.process_events()
        if notifier.check_events():
            notifier.read_events()
    except KeyboardInterrupt:
        notifier.stop()
        break

After I created a valid resolv.conf and saved it as /etc/resolv.conf.orig I only had to execute the following as root before starting up NetExtender:

0
stickfile /etc/resolv.conf.orig /etc/resolv.conf

rootify 0.2.3 released

Wednesday, January 5th, 2011

I've moved it over to Google Code and fixed its help instructions. I've also included builds to the tarball both for i386 and amd64.

chnorm 0.4 released

Wednesday, January 5th, 2011

I've just moved it over to Google Code and improved its help instructions.

Cleaning up excess whitespaces using wspurify

Tuesday, October 12th, 2010

I've just written a handy little utility which I named wspurify. I think it's a nice example of how such small utilities can do a lot.

Let's backup our tweets using twitter-backup.sh

Sunday, September 5th, 2010

Update (2010-10-23): I've just uploaded twitter-backup.sh to Google Code.

I've written a very simple BASH script to backup my tweets.  It's very easy to use:

0
1
2
3
4
5
6
7
8
9
$ ./twitter-backup.sh
Usage ./twitter-backup.sh TWITTER-USERNAME
$ ./twitter-backup.sh mondalaci
2010-09-05 17:46:04 URL:http://twitter.com/statuses/user_timeline/mondalaci.xml?page=1 [40899/40899] -> "twitter-backup-mondalaci-2010-09-05_17-46-03/1.xml" [1]
2010-09-05 17:46:06 URL:http://twitter.com/statuses/user_timeline/mondalaci.xml?page=2 [42928/42928] -> "twitter-backup-mondalaci-2010-09-05_17-46-03/2.xml" [1]
2010-09-05 17:46:07 URL:http://twitter.com/statuses/user_timeline/mondalaci.xml?page=3 [42753/42753] -> "twitter-backup-mondalaci-2010-09-05_17-46-03/3.xml" [1]
2010-09-05 17:46:09 URL:http://twitter.com/statuses/user_timeline/mondalaci.xml?page=4 [42784/42784] -> "twitter-backup-mondalaci-2010-09-05_17-46-03/4.xml" [1]
2010-09-05 17:46:11 URL:http://twitter.com/statuses/user_timeline/mondalaci.xml?page=5 [42872/42872] -> "twitter-backup-mondalaci-2010-09-05_17-46-03/5.xml" [1]
2010-09-05 17:46:11 URL:http://twitter.com/statuses/user_timeline/mondalaci.xml?page=6 [6465/6465] -> "twitter-backup-mondalaci-2010-09-05_17-46-03/6.xml" [1]
2010-09-05 17:46:12 URL:http://twitter.com/statuses/user_timeline/mondalaci.xml?page=7 [75/75] -> "twitter-backup-mondalaci-2010-09-05_17-46-03/7.xml" [1]

I've followed the holy way of Unix, the KISS principle when developing this little script:

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
 
if [ $# -ne 1 ]; then
    echo "Usage $0 TWITTER-USERNAME"
    exit 1
fi
 
username=$1
 
backup_dir=twitter-backup-$username-`date +%Y-%m-%d_%H-%M-%S`
mkdir $backup_dir
 
page=1
while true; do
    dest_file=$backup_dir/$page.xml
    wget -nv -O $dest_file http://twitter.com/statuses/user_timeline/$username.xml?page=$page
    page_size=`stat -c%s $dest_file`
 
    if [ $page_size -lt 1000 ]; then
        break  # We've reached a final, empty page so let's exit from the loop.
    fi
 
    page=$(($page+1))
done
 
rm $dest_file  # Delete the last, empty page.