Delete self-pings

It seems that self-pings are bad for Google page ranking. Well, I have never spended too much time thinking about SEO but I find them a bit clutering and thus I’ve decided to remove them. There are some plugins which block new self-pings but none which deletes the existing ones. So here is a mysql command which does just that: Warning: don’t execute sql commands on your db if you don’t know anything about what sql is, it might ruin your base....

July 11, 2010 · len

Python xml namespace parsing with libxml2

The goal of this tinkering was simple: to parse a KML file for further interpretation and use using python and libxml2. First test <pre lang="python">#!/usr/bin/env python import libxml2, sys doc = libxml2.parseFile(sys.argv[1]) ctxt = doc.xpathNewContext() ctxt.xpathRegisterNs('kml', "http://www.opengis.net/kml/2.2") root = doc.getRootElement() res = ctxt.xpathEval("//kml:Placemark") for e in res: nodes = e.xpathEval('kml:name') if len(nodes) > 0: if nodes[0].content.strip().startswith('cp'): coord = e.xpathEval('kml:Point/kml:coordinates') if len(coord) > 0: print coord[0].content.split(',') doc.freeDoc() ctxt.xpathFreeContext() This sounded ok according to the scarce doc but resulted in the following error:...

July 9, 2010 · len

Koha search #2

As I said in the previous post related to koha search system things are a bit more complicated than you might assume as someone using sql queries to do a search. Everything is done in Zebra and Zebra is a matter of indices. So where is MARC? Actually there are 3 files which should interest you: koha/etc/zebradb/biblios/etc/bib1.att which defines the list of possible Z39.50 attributes. This is definition of names, it does not means all are used....

June 14, 2010 · len

Koha search #1

For people used to web searches and database oriented application Koha way of dealing with searches (since v.3) might seem a bit alien. This is a small set of notes related to some not very obvious questions which I had to answer in order to do some configurations which seemed trivial at the beginning. I am not saying this is wrong or ineffective, just different and different means time to learn....

June 11, 2010 · len

Mixing generated with mxml code

The problem this example tries to solve is the following: you have a Container component (Accordion, TabNavigator, etc.) and you wish it’s content to be generated dynamically but inside this generated content to use some content which is defined in the mxml, inside the Container. For those with Tapestry experience this behaviour is similar to the @RenderBody component. <my:CustomWrapper ...> <mx:VBox> ... </mx:VBox> </my:CustomWrapper> This is very similar to a Container definition but the VBox will not end as a child of CustomWrapper but further down in the hierarchy....

June 9, 2010 · len

Programmatically get the MAC address in C

This is a small example on how you can get the MAC address in C both in Linux and Windows. The example searches in fact the MAC address corresponding to a given IP address and returns it. /* * mac.cpp * Created on: May 25, 2010 * Author: len */ #ifdef WIN32 #include <stdio.h> #include <Windows.h> #include <Iphlpapi.h> #include <Assert.h> #pragma comment(lib, "iphlpapi.lib") /** * @return the mac address of the interface with the given ip */ char* getMAC(const char *ip){ PIP_ADAPTER_INFO AdapterInfo; DWORD dwBufLen = sizeof(AdapterInfo); char *mac_addr = (char*)malloc(17); AdapterInfo = (IP_ADAPTER_INFO *) malloc(sizeof(IP_ADAPTER_INFO)); if (AdapterInfo == NULL) { printf("Error allocating memory needed to call GetAdaptersinfo\n"); return NULL; } // Make an initial call to GetAdaptersInfo to get the necessary size into the dwBufLen variable if (GetAdaptersInfo(AdapterInfo, &dwBufLen) == ERROR_BUFFER_OVERFLOW) { FREE(AdapterInfo); AdapterInfo = (IP_ADAPTER_INFO *) malloc(dwBufLen); if (AdapterInfo == NULL) { printf("Error allocating memory needed to call GetAdaptersinfo\n"); return NULL; } } if (GetAdaptersInfo(AdapterInfo, &dwBufLen) == NO_ERROR) { PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;// Contains pointer to current adapter info do { sprintf(mac_addr, "%02X:%02X:%02X:%02X:%02X:%02X", pAdapterInfo->Address[0], pAdapterInfo->Address[1], pAdapterInfo->Address[2], pAdapterInfo->Address[3], pAdapterInfo->Address[4], pAdapterInfo->Address[5]); printf("Address: %s, mac: %s", pAdapterInfo->IpAddressList....

June 7, 2010 · len

Holux M-241 GPS

Read track via USB gpsbabel -t -w -i m241 -f /dev/ttyUSB0 -o gpx -F test.gpx Read track via Bluetooth Find mac: hcitool scan Scanning ... 00:1B:C1:05:XX:XX HOLUX_M-241 Bind to a serial port in /etc/bluetooth/rfcomm.conf rfcomm4 { bind yes; device 00:1B:C1:05:XX:XX; channel 1; comment "Serial Port"; } Connect the serial port: rfcomm connect 4 read track: gpsbabel -t -w -i m241 -f /dev/rfcomm4 -o gpx -F test.gpx

May 31, 2010 · len

Ubuntu Lucid Lynx

There was not much I expected from the new ubuntu Lucid Lynx as I was happy enough with the existing version already. But I a good tradition and because I woke up at 8:30 this Saturday I decided to go ahead and install it on my Dell D820. The install The install went smoothly, everything was detected, installed the upgrades, the nvidia drivers and some day to day packages: mozilla-thunderbird, pidgin, emacs....

May 8, 2010 · len

asdoc pain

Running asdoc should have been a breeze. Just create an ant task which calls the asdoc executable with the given parameters and voila! Well, it was not. <target name="compile"> <exec executable="${asdoc}" failonerror="true"> <arg line="-doc-sources ${src.dir}"/> <arg line="-window-title "My Application""/> <arg line="-output ${asdoc.output}"/> </exec> </target> The task started by spilling 100 errors similar to: [exec] ...budgetImport.as(9): col: 1 Error: The public attribute can only be used inside a package. [exec] [exec] public var importing:Boolean = false; [exec] ^ [exec] [exec] ....

May 5, 2010 · len

Tomcat query parameters and encodings

Did you ever wondered which from which encoding the query parameters are parsed by default in java (servlet) and the response in rendered? Say UTF-8. Wrong. Try ISO-8859-1. There are 3 cases to consider: 1. Query parameters as GET 2. Query parameters as POST 3. Response encoding. In order to solve 1 and 2 one solution is just to convert the parameters to UTF-8: String param = request.getParameter("test"); if(param != null) param = new String(param....

April 8, 2010 · len