Kate and cleaning Byte Order Mark

Once upon time BOM stole a few hours….

Over the years, Kate editor become my favorite editor and even more. With constant active development kate is more powerful than ever. Initially, I needed a light kde editor for my python projects: kate performed great. Over the time, I used kate more and more, and now it become my primary tool.

Recently, I noticed that somehow my session was set to add Byte Order Mark (BOM) to UTF-8 files. The byte order mark is a Unicode character used to signal the byte order of a text file. More importantly, it might confuse the python templates libraries such as mako, or babel. In kate, you can see if BOM is enabled for a specific file by looking at Tools->Add Byte Order Mark (BOM). As you can suspect, when one opens hundreds of files and accidentally attaches BOM at each one, it would be quite painful to clean BOM manually: uncheck Tools->Add Byte Order Mark (BOM). Here is the solution: find all files with BOM with find and awk


find . -type f -print0 | xargs -0r awk '
/^\xEF\xBB\xBF/ {print FILENAME}
{nextfile}'

And to clean BOM from all *.mako files


find . -type f -iname *.mako -exec sed 's/^\xEF\xBB\xBF//' -i.bak {} \; -exec rm {}.bak \;

and everyone lived happy ever after…

Awstats & virtual hosts

Gentoo has finaly moved away from webapp-config and simplified updating awstats. The example of apache config file setting awstats for apache virtual hosts runnig wsgi application is given bellow. Prerequisites are apache proxy for wsgi app, and awstats visible at www.some_domain.com/awstats.pl using authentication.

    <VirtualHost *:80>
        ServerName www.some_domain.com
        Serveralias some_domain.com
        ServerAdmin admin@some_domain.com

        ErrorLog /var/log/apache2/www.some_domain.com-error.log
        CustomLog /var/log/apache2/www.some_domain.com-access.log combined

        # awstats config
        Alias /awstats/classes "/usr/share/awstats/wwwroot/classes/"
        Alias /awstats/css "/usr/share/awstats/wwwroot/css/"
        Alias /awstats/icon "/usr/share/awstats/wwwroot/icon/"
        ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/"
        ScriptAlias /awstats "usr/share/awstats/wwwroot/cgi-bin/awstats.pl”
        ScriptAlias /awstats.pl "usr/share/awstats/wwwroot/cgi-bin/awstats.pl”

        <Directory "/usr/share/awstats/wwwroot">
                AllowOverride None
                Options None
                Order allow,deny
                Allow from all

                AuthType Basic
                AuthName "AWStats authenticated zone"
                AuthUserFile /etc/awstats/.htpasswd
                Require valid-user
        </Directory>
        <Directory "/usr/share/awstats/wwwroot/cgi-bin">
                SetHandler cgi-script
                Options +ExecCGI
        </Directory>

        ProxyPass /awstats !
        ProxyPass /awstats.pl !

        ProxyPass / http://localhost:5005/ retry=5
        ProxyPassReverse / http://localhost:5001/
        ProxyPreserveHost On
        <Proxy *>
            Order deny,allow
            Allow from all
        </Proxy>
    </VirtualHost>

Awstats config file (in /etc/awstats/) with geo-ip (emerge dev-perl/Geo-IP)

LogFile="/var/log/apache2/www.some_domain.com-access.log"

LogType=W
LogFormat=1
LogSeparator=" "
HostAliases="localhost 127.0.0.1 REGEX[myserver\.com$]"
DNSLookup=2
DirCgi="/cgi-bin"
DirIcons="/awstats/icon"
AllowToUpdateStatsFromBrowser=0
AllowFullYearView=2

LevelForFileTypesDetection=1
LevelForWormsDetection=2

SiteDomain="www.some_domain.com"
DirData="/home/some_user/awstats"

LoadPlugin="geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat"

To test configuration run
/usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=www.some_domain.com -update

If you wish cron to handle update on every hour:
crontab -e -usome_user

0 * * * * cd /etc/awstats/ && /usr/share/awstats/wwwroot/cgi-bin/awstats.pl  -config=www.some_domain.com -update  >/dev/null 2>&1

Error with log file

Error: LogFile parameter is not defined in config/domain file
Setup ('www.dajstadas.com' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).

obviously check LogFile and read permissions, however, this might fail if you call awstats update outside /etc/awstats directory. Retry with


cd /etc/awstats/ && /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=www.some_domain.com -update

Dora saves the Snow Princess

Today Ania completed on her own her first video game. Wii version of Dora saves the Snow Princess doesn’t teach much, but helps kids to figure out the basics of using wii game controller. In order to complete a specific action in a game a certain controller motion is needed. The game itself is repetitive and most likely if you are older than 5 you’ll find it boring.

Socks5 proxy and wget

I’ve tried to set wget bash loop over socks5 proxy and was surprised to find out that wget does not have included proxy support. First start your proxy tunnel on port 8080 with

ssh -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -f -C -N -D *:8080 user@my.proxy.server &> tunnel.log

My firefox utilizes this tunnel perfectly – the proxy config page has the following entries:

  Manual proxy configuration:
    SOCKS Proxy  127.0.0.1  Port 8080
    "SOCKS v5"  checked

Initially I’ve tried using wget –execute to set http_proxy with

wget -e "http_proxy = 127.0.0.1:8080" "http://url_to_get"

however it didn’t work giving me the following error.

Connecting to 127.0.0.1:8080... connected.
Proxy request sent, awaiting response... No data received.
Retrying.

Wget with Tsocks

The solution was to install tsocks. For gentoo just do

emerge -av tsocks

and modify the config file. Note that gentoo keeps the confing information in /etc/socks/tsocks.conf, while ubuntu keeps it in /etc/tsocks.conf

nano -w /etc/socks/tsocks.conf

server = 127.0.0.1
server_type = 5
server_port = 8080

If you used proxy on earlier versions of wget, remove any proxy cmds from ~/.wgetrc

Finally start your wget trough socks5 proxy using tsocks

tsocks wget http://url_to_get

starting two tsocks wget at the same time caused my system to slow down and gave me the following error:

Connecting to www.ccc.ccccc|192.xxx.xxx.xxxx|:443... failed: 
Transport endpoint is not connected.

After killing one of the processes, I got back my cpu.

Do you wanna do more? Try Tor.

Here it is

so I stared a blog! Wonderful. I can share my thoughts with anyone on the planet. Hello world. And who the hack cares what I think, what I do, what I eat, what I write, etc… Is this just yet another pathetic blog in the see of junk, or maybe something so popular that people set their home page to it? I have no idea! If in a few years I add my shitter account so anyone can follow what type of literature I go over while heating a toilet seat, you’ll now that I got social. If not, oh, well.

and Motivation

I got this domain as a birthday gift with a primary purpose to create my personal blog. Well, thank you my dear friend for forcing me to spend some time for a creative writing work instead on hacking, playing, surfing…. Dear reader, if you are gifting someone, maybe better put some cache in the envelope instead getting a domain…. Anyway, it took me a year to start, and finally got the last warning

    You better do something with mufljuz.com or I might not extended it for your 3something birthday.

So here I am.