Dengar's Blog Logo

Dengar's blog...
We will see what I post, probably will be some random tutorials

Saturday, 29 October 2011

Script to disable & enable touchpads

I constantly touch the touchpad when I type. I also normally use an external mouse when I'm on my laptop. I seldom really need it, but I will sometimes want to switch it on (or off).

First you need to find the name of your touchpad in the xinput list:

$ xinput list
⎡ Virtual core pointer                     id=2 [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer               id=4 [slave  pointer  (2)]
⎜   ↳ Razer Razer Imperator                   id=10 [slave  pointer  (2)]
⎜   ↳ Razer Razer Imperator                   id=11 [slave  pointer  (2)]
⎜   ↳ PS/2 Mouse                               id=13 [slave  pointer  (2)]
⎜   ↳ AlpsPS/2 ALPS GlidePoint                 id=14 [slave  pointer  (2)]
⎣ Virtual core keyboard                   id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard             id=5 [slave  keyboard (3)]
    ↳ Sony Vaio Keys                           id=6 [slave  keyboard (3)]
    ↳ Video Bus                               id=7 [slave  keyboard (3)]
    ↳ Power Button                             id=8 [slave  keyboard (3)]
    ↳ USB 2.0 Camera                           id=9 [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard             id=12 [slave  keyboard (3)]

So in my case the touchpad is most likely: PS/2 Mouse on id 13.

You can easily identify if the device is "on" (enabled):
$ xinput list-props "PS/2 Mouse" 
Device 'PS/2 Mouse':
Device Enabled (144): 1
Coordinate Transformation Matrix (146): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (267): 0
Device Accel Constant Deceleration (268): 1.000000
Device Accel Adaptive Deceleration (269): 1.000000
Device Accel Velocity Scaling (270): 10.000000
Evdev Axis Inversion (271): 0, 0
Evdev Axes Swap (273): 0
Axis Labels (274): "Rel X" (154), "Rel Y" (155)
Button Labels (275): "Button Left" (147), "Button Middle" (148), "Button Right" (149), "Button Wheel Up" (150), "Button Wheel Down" (151)
Evdev Middle Button Emulation (276): 0
Evdev Middle Button Timeout (277): 50
Evdev Wheel Emulation (278): 0
Evdev Wheel Emulation Axes (279): 0, 0, 4, 5
Evdev Wheel Emulation Inertia (280): 10
Evdev Wheel Emulation Timeout (281): 200
Evdev Wheel Emulation Button (282): 4
Evdev Drag Lock Buttons (283): 0
 Now create yourself a little file (eg: "touchpad"):

# toggle synaptic touchpad on/off
SYNSTATE=$(xinput list-props "PS/2 Mouse" | grep Enabled | grep -Eo '.$')
if [ $SYNSTATE = 0 ]; then xinput set-int-prop "PS/2 Mouse" "Device Enabled" 8 1
else xinput set-int-prop "PS/2 Mouse" "Device Enabled" 8 0; fi
dengar@dengar-vaio:/usr/bin$ $ xinput list-props "PS/2 Mouse" 

This should sort you out. Don't forget to  change the name of your actual device, remember mine is "PS/2 Mouse"

Next you need to make the file executable:

sudo chmod +x touchpad

Now, to have that file available from the command line, simply copy it to /usr/bin.

Sunday, 4 September 2011

eConsultancy Paid Content

eConsultancy is one of the most renown blogs in the industry. Although eConsultancy staff insist that it is so much more than a blog, it really boils down to the articles that are emailed to you on a daily basis.
Also there are simply too many posts to look at and there are so many that are just blatant agency advertisements, it remains a referred to resource.

What often annoyed me is that, as a free user, you can't download their PDF documents. There are best practise guides and research papers advertised at horrendous prices. As a free user you only get a little teaser, so you never know if it's any good. 

Since a little while now, I have a paid account that is sponsored by my company. I have flicked through these precious PDFs and can assure you: it's not worth paying for. If you still want to read them, I have some here for free that I share with you :)..

Let me know if there are any missing...

Thursday, 23 June 2011

Facebook on the decline

It seems to me that it is set in stone: eConsultancy says it and even the Metro confirms it, the end of facebook has started. And it is welcome news indeed and it should have come much sooner. I can't wait for the time I don't have to read the blatant lies and white washing that is all to prominent in the marketing industry's media.

Digital publications

I have always disliked, but somehow, maybe because I enjoy being cynical, still read the articles in the online marketing press and blogs. Or maybe I was indeed looking for a change in this crappy platform for customer engagement and relatinship management; looking for the recipe of how to make it work, but I never found it..

One of such publications, the latest issue of Figaro Digital, arrived at my desk not too long ago and it was full of facebook junk. I understand that it is a buzz at the moment and that it represents, thanks to limiting API access to selected agencies, a gold mine for digital agencies that found themselves in need for clients as more and more SMBs would take their search marketing in house. Yes, agencies understand how to peddle dung! Three or more pages full of people that claim to understand social media and how to manage it with little columns of half-wisdom, but then: Martin B. With his outrageous claim: "It isn't outside the realm of possibility to suggest that one day facebook will be the internet."

Sure, it isn't outside the realm of possibility, it isn't outside the realm of possibility to suggest that one day man will be born with wings on their back we are all flying and and humankind is enslaved by man-bear-pigs, but you still have to be an imbecil to realistically sugget such a future vision.
But Figaro printing crap is no news to me. In a former role I was working alongside a Marketing Director who wrote the article 'Standing on the Shoulders of PPC Giants'. While this wasn't an agency, it was written to encourge SMBs to join the marketplace and forget doing their own PPC. Of course, joining a marketplace is not a bad idea and this marketplace doing SEM for your products is a great way for both parties to sell products, but this obviously shouldn't deter SMBs from doing their own search engine marketing. It is easy and effective!
Sadly it isn't just Figaro that sells out their good name. eConsultancy has it's fair share of guest blogger that promote their own ideas and flog their own agenda. It is just too tempting to get other people to do your work for you free of charge. Their reputation won't suffer as much, users are well aware that they are reading opinions and advertorials on their site.

The selling data game

The other thing that is shocking to see is how much anonomous data facebook sells. Well, when I say sells, they make these regbporting APIs available to their selected agencies only. These then sell the facebook advertising on to their clients. Agency and facebook are winning. The client however is left with a feeling of tapping into new audiences, wondering if they found a cheap way of building brand awareness. Having been in a meeting the other week with an agency that actually makes this data available, I think a lot of facebook users would think twice about using the site altogether.

Facebook knows this and with all likelihood hopes that their users stay unaware of this for some time to come.
Paying for likes
Yes, most companies tried facebook advertising. Either direct or through an agency. Your direct response / acquisition campaign was in all likelyhood unsuccessful and when you indeed tried it through an agency you would have received the suggestion to instead of getting traffic through to your site, you should acquire fans for your brand and use facebook as a tool to communicate with these people.

Beware, something went majorly wrong here! Instead of getting cold hard marketing leads that are measurable in terms of ROI from your advertising budget, you are trading it for - mmm - a bunch of extra people that you have to manage a relationship with on a platform that is difficult to control.

Today I was looking at an agency's report on how one of our campaigns is performing. New in this report: facebook doesn't allow the tracking of fans anymore, so we now measure the cost-per-like... £1.90.
I think it will take the next generation of martketers to figure out how you turn 'likes' into money.

The slow demise

It will take a long time and lots of 'internal restructuring' till facebook is really out of the marketing world and the majority of people currently working for it will be laid off or have moved on, but it is the beginning. As an advertising platform, it never performed and always seemed like a waste of time and effort. Yes, there are other opportunities for facebook to monetise. Selling their users data, one way or another, in bright daylight or the sneaky way.

As for the private investors, I believe they will get the big money when facebook floats. But take a good hard look at facebook and decide if you want to put your money in the concept of people "liking" things, by clicking on something out of pure boredom.

Not all is bad

No, facebook is a useful tool! It is ideal for viral marketing, managing reputation or making announcements. However, you do want to keep the majority of this communication in and on your own domain, simoly because you own and control it.
All these activities should be free and I believe they currently are. I believe facebook won't be earning money on these now or in the future.

Tuesday, 10 May 2011

Some simple MySQL date-time functions

I often need the first of the month, the last of the month or how many days are in the month for reporting and forecasting purposes.

You can, of course, like myself in the past look up how these things are done every time you need them. But this gets frustrating and it's often easier to surround yourself with your set of own SQL-functions that give you what you need and are easy to remember.

For this purpose I give you:

  1. First of the month date:
  2. drop function if exists fn_getFirstOfMonth;
    create function fn_getFirstOfMonth(date_ datetime) returns datetime
    set @dater = date_;
    set @dater = DATE_FORMAT(@dater ,'%Y-%m-01');
    return @dater;
  3. Last of the month date:
    drop function if exists fn_getLastOfMonth;
    create function fn_getLastOfMonth(date_ datetime) returns datetime
    set @dater = date_;
    set @dater = DATE_FORMAT(last_day(@dater) ,'%Y-%m-%d');
    return @dater;
  4. Days in the month:
    drop function if exists fn_getDaysInMonth;
    create function fn_getDaysInMonth(date_ datetime) returns int
    set @dater = date_;
    set @dater = day(last_day(@dater));
    return @dater;

Do let me know if there are other MySQL date and time functions that you would like to know.
Happy to post them here...

Saturday, 7 May 2011

Can I have some Thetan for my sandwich? - Buying religion off the shelf religion from the street

Scientologists, although not quite often recognised, have been flogging their religion on the streets for many decades now. And why not? - Other cults and religions are doing it too. Mormons, Heavens Gate and even the Manson Family have successfully advertised their ideology through direct promotion, they know the system works.

I believe people are naturally curious, but would be more careful when they know they are being 'evaluated' by a religious cult, so to circumvent the initial resistance that they would have to overcome, Scientology doesn't advertise with it's name, in fact, nothing at their meet stand indicated that they are in any way pursuing another agenda than offering a 'free stress test' and a giant book to help you through it.

Anyways, there I was, coming out of the tube and seeing the Scientologist stand right in front of the station. I was ready to be Scientologied.

"So this device checks how stressed I am by passing an insignificant amount of electricity through my body?"
I am surprised though how many people go for the "free stress test" offered by L. Ron Hubbard's minions though. I remember the 'Churches' earlier recruitment efforts required their subjects to undergo a more detailed test, that can still be taken online. It's a fun thing to do when you have absolutely nothing to do for 16 hours of your life. Feel free to do it here.
This time I was promised that the Free Stress Test would last only four minutes.

Soon enough I was handed the handles of the E-Meter, a device that measures changes in the electrical resistance of your body and the conductance of your skin by passing a very tiny current through your body. It did take a while, talking about various levels of potentially stress inducing scenarios until my tester, through turning and twisting of various dials, managed to get the needle to swing. I think about 4 minutes, in fact. It must've helped that my hands started to get a bit sweaty, after all that does increase the conductance of my skin. The result: yes, I am stressed - what a surprise.

My antidote was purchasing the Dianetics DVD and book for the little sum of £20. Since I always wanted to have a gander, I negotiated the price down to £5 for the book only, but I am afraid I have not had the chance to flick through it. After the sale, I was of course encouraged to give my name, address and email to the lead Scientologist, but I only left my first name and an old email address that I haven't used in a long time.
Your soul is possessed by this volcano and only Tom Cruise will be able to show you the way.
I did take the book home, but I was rather surprised when I saw it sodomising actual literature, see here how it forcibly engulfs my favourite book, Cannery Row by John Steinbeck.

Bad El-Ron! Down! Leave the Cannery Row alone!
It did seem rather popular with the crowd in front of this London tube station at 8.30 in the evening. Maybe buying religion off the shelf is a huge business? Maybe I should create a religion eCommerce shop where you can create your own religion by mix and match? Eg: mix some Judaism with Buddhism, top it up with Greek Mythology and sprinkle some Heaven's Gate over it. £350,000.
See, that's the clever thing about my religion shop: the product is easy to produce and even easier to source, but if you do pay THAT kinda money, you will treasure it...

Thursday, 14 April 2011

Create a home VPN and allow computers to connect with each other

Like most organisations, my workplace has quite strict security policies. For some reason, I wasn't allowed and able to connect to the data centre through the Cisco VPN that had been set-up by our company. I had to had a static URL at home that needed to be allowed, but I wouldn't consider changing my provider purely for that benefit.

There are plenty of options to 'break' that security restriction, like having a Terminal Server within your corporate network that you could log onto. The slow and clunkiness of that solution turned me off. In addition, I would have to get helpdesk to install all sorts of programmes and, since I'm a Linux man, I would have to compromise on every which way.

The easiest solution, I thought, was, since I can't VPN onto the network from home, to VPN to my home network from work!

I already have a server for various tools that keeps on running most days and nights, so why not also use it as a VPN server.

Installing and configuring the necessary software is easy and takes just minutes.
First you will need to install the PPTP daemon:
$ sudo apt-get install pptpd
In Ubuntu, the configuration file for the pptp-daemon is: /etc/pptpd.conf and we will need to modify it so there is a separate IP defined for a) the server (which can be the one the server is getting from your router) and b) the client(s). If you have more than one client you will obviously have to make sure you have a range of IPs available for the clients.

In my case, since the networks should be quite separate at home and through VPN, I decided to use a different IP range. My router assigns IPs in the range 192.168.1.XXX, so I will use the range 192.168.0.XXX through my VPN server. You will need to update the last lines of your pptpd.conf like this:

This assigns the IP ~.1 to the VPN server (a separate interface) and allows the numbers ~.2 to ~.10 to be assigned to clients.

Next step: create VPN users and their passwords. This is stored in the /etc/ppp/chap-secrets file. Here is an example:

# Secrets for authentication using CHAP
# client server secret IP addresses
You could obviously restrict the IP addresses the client can connect, but a very long password should also be quite secure.
In theory that's all you need to connect, but you might want to allow clients to use the server's internet connection and allow it to connect to other IPs within your local network. For this we will need to use NAT and IP forwarding. You can enable this via adding this line to your /etc/rc.local (before exit):

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

and in /etc/sysctl.conf uncomment the line:
Now you can restart the daemon:
$ sudo /etc/init.d/pptpd restart
If your computer doesn't use the public IP address, eg. you are behind a modem - router or a firewall, you will need to forward the port 1723 to your server. And to avoid trouble with dynamic IP addresses you get from your ISP, you should use a dynamic DNS service. This will update your current IP to the DNS lookup tables and you get an easy URL name to remember. I think I use

Finally, you are on the client, but you can't see any other computers within the VPN or the local network of the server. This is because the routing is not set correctly on your client computer. You will want to "search" this VPN IP range through the VPN server, not your normal internet connection, so you can add a manual route like this:
route add -net netmask dev ppp0
Tadah! You can find other computers in the VPN!

For more advanced routing, eg: make your client's local connections available to hosts local connections, I advise to take a look at this page full of knowledge. The beauty is that once the VPN connection is established, you can bridge pretty much all connections through using routing and iptables.

Friday, 11 February 2011

Response to the Microsoft & Nokia partnership

I read this article about the partnership on BBC. I think it's very well written, good article and thank you, Preston, for it!

Yes, this, in my opinion, and I'm working in the New Media industry, is an act of desperation from both parties.

The Windows 7 phones have, and rightly so, not sold very well. This can be blamed on the marketing and the better marketing of the competitors, but that's just a cheap excuse.

I was always very fond of my Nokia phones, they simply work and keep on working, so that's a plus. On the other hand, I haven't owned a Nokia in over 7 years, cause their phones don't have the features you expect today.
I remember when I was in a Nokia store, back in the days when they actually existed, and asked for a phone with MP3 player. "Oh, people don't want to have phones that play MP3s", I was told - despite me being the customer. Thanks, dear shop employee, for reminding me what I actually want.

Anybody that has had a Windows phone will have had experience with the issues of a Windows phone: slow, crashing, clunky sync and yes: SLOW, CRASHING! I nearly tossed my HTC Windows phone in the Thames one day.

So this partnership is really a partnership out of desperation:
Windows wants phones that people know are reliable - Nokia wants phones that are in the 21 century (and yes, I know there is a huge Symbian market)

Unfortunately (or fortunately), both will fail. Android is the best selling platform at the moment and will remain exactly that. I have and will continue to recommend ANYONE to ditch their phones and go for Android, cause it's free, fast, open-source and WORKS very, very well

Monday, 31 January 2011

My favourite Android Apps

I have an Android phone since the launch of the HTC Magic (in some countries Saphire) in July 2009. I have never found a phone more useful and, with 2.2 on most devices now, pity the people that are on Blackberry or iPhone when they had a chance to get an Android device.

I must admit, some models are just not as aesthetic than the iPhone and they don't seem to be as functional for business people, but that's where people are wrong...

I thought I give a quick run down, in separate posts, of my favourtie apps:

Astrid Tasks for Android phones

Astrid is, apart from standards such as email and calendar, my absolute must have app on Android. It syncs tasks with RememberTheMilk, Productee and Google Tasks.

Apart from it's easy to use interface and classic Android white-on-black theme, it's unbelievably useful for people that have a lot of things they want or need to do, but keep forgetting personal or work related tasks. I now slot everything - from watering the flowers or washing the laundry to preparing monthly KPIs - in my task list using Astrid.

It's a very handy app when in meetings, conferences and when you are on the road. I task that needs doing comes up and instead to jotting down notes that you probably won't ever look again, you get it on Astrid and sync it back with your online task list.

Constant reminders keep nagging and encouraging you to finish tasks and you can schedule due dates and tags on your tasks.

Geo IP lookup - API integration using PHP

(this also explains the PHP DOM parser)

For one or the other reason, and be it that you want to determine the home country of your visitor for localisation and language options, you might find yourself looking at integrating an IP lookup through an external API.

I suppose they all work very similar, but I have just integrated my shopping cart with the API from How it works is explained below...

A word up-front, though: When using third party APIs - think! Do you really need to hit the API with every page request? Especially in this case, would it not be fair to assume that the whole sessions would be coming from the same IP and therefore the same country? To an extend, could you not assume that it is one user you are tracking here and that he would probably come back to your site from within the same country, even though his IP might have changed? Could you therefore store the result from the API in a browser session or in a cookie?
- I actually do store it in the DB per cookie, but that's not important for this little tutorial.

First up, you will need to have access to the API, so you need an API key, token-code or something to identify yourself with the API. On the site you can register and receive your free key within seconds.

Got the key? - off we go then: Thankfully this is a pretty simple API that doesn't use SOAP, but requires a simple HTML request and returns a nicely formatted XML. Here is a result:

<?xml version="1.0" encoding="UTF-8"?>
<CountryName>United Kingdom</CountryName>
<RegionName>Windsor and Maidenhead</RegionName>
So far so good... Let's create a corresponding PHP class that will make the usage easy portable to different projects.

  1. I create a class and bunch of variables and add getter methods to the class, so I can return the variables when I need them:
    class geoIP {

    var $apiKey = "XXXXYOURKEYHEREXXXX";
    var $city;
    var $country;

    function getCity() {
    return $this -> city;
  2. Now I know that API key will be available when I initialise the object. Moving on to making a call...
    It's quite easy in this instance, because we don't need to set SOAP headers or anything. It's a simple API and all information we need to give IPInfoDB can be parsed into the request URL. Here is how it looks:
    So I create a method, let's say, "makeCityCall" that I can then send the IP to check to:

    function makeCityCall($ip) {
    $urler = ''. $this -> apiKey .'&ip='. $ip .'&timezone=false';
    The "$this -> apiKey" will return the API key that we declared and initialised as a global variable for this class. The "$ip" is what I send to the method.

  3. I know when I load this URL, I get an XML response. XML is best parsed via a DOM-parser. The DOM parser comes standard with most versions of PHP and is an object in it's own rights. We have to instantiate this and can then give it the URL we declared ($urler) to load:
    $parser = new DOMDocument();
    $parser  -> load($urler);
  4. As we saw by the result returned above, the interesting bit is wrapped in a XML node called Response. We only get one, of course, but I will still ask the DOM parser to repeat the process of getting the values from all nodes that it finds:
    $nodes = $parser -> getElementsByTagName("Response");
    foreach ($nodes as $node) {
    I now want to get the values of the nodes contained within the Response node:
    $cc  = $node -> getElementsByTagName('CountryCode');
    $cc =  $cc -> item(0)->nodeValue;
    $this -> countryCode = $cc;

    $cty = $node -> getElementsByTagName('City');
    $cty = $cty -> item(0)->nodeValue;
    $this -> city = $cty;

    $ctry = $node -> getElementsByTagName('CountryName');
    $ctry = $ctry -> item(0) -> nodeValue;
    $this -> country = $ctry;
    Thus setting the variables that I later want to retrieve via the getter methods.

  5. Lastly, if I now want to make a call from a PHP application, I simply need to instantiate the new class, get the IP address from the site visitor (or from wherever) and use the method to make a request. I can then retrieve the results from the getter-methods:
    $ip = $_SERVER['REMOTE_ADDR'];
    include ('PATHTOPHPFILE/geoIP.php');
    $gIP = new geoIP();
    $countCall = $gIP -> makeCityCall($ip);
    I can then write this out onto the page or re-use it as I wish:
    echo $gIP -> getCountry() . '<br />';
    echo $gIP -> getCity() . '<br />';
    echo $gIP -> getCountryCode() . '<br />';

I hope this gets you further...

Friday, 21 January 2011

Java Swing GUI builder for Eclipse

I often struggle to make Swing applications to look good, or even make them vaguely look like I intended. The different JFrame layout options and all the coordinates of where to place what and how long is that makes the creation of Swing interfaces difficult.

Since I don't like using different development environments and got very used to Eclipse for anything I need to do, I was looking for a good graphical GUI builder that works as a plugin for Eclipse. I came across this really nice one: Jigloo from CloudGarden.

It's pretty easy to install into Eclipse, via update site: and then creates GUIs by drag and drop in a way that I thought wouldn't have been possible. The commercial use of this product is prohibited without license, but this shouldn't stop any hobby programmer, much like myself, from using this great product.

Here is a screenshot I leeched off their site (I might attach one or two myself):


Friday, 7 January 2011


From: d3ngar
To: bear
Subject: Bear

Wow, Bear!

What a nick - what a movie...

You might not know this, Bear, but there is a movie with the same name, Bear, that came out last year. You might have guessed: it features a bear, named Bear...

You might wanna check out Bear, the movie, it's really great :

Best Regards,


Wednesday, 5 January 2011

BadgerComp / Cart & Opilion

Anyhow, so I decided to start using the Java code from Opilion for crawling tasks for
I probably will continue building on the image getter first. I'm thinking that you will want to upload them straight somewhere. Probably via FTP. Or you could download them to your local hard disk first.

I'll probably make the tool available via the BadgerCart Wiki, but it might be getting annoying to enter the user details all the time. Maybe I need to be able to load settings via XML?

where did all the social shopping go?

Maybe two years ago, when I was still working for an eTailer, "social shopping" became kind of the new buzz-word around town.

Social networking needed to be adapted into everything and, with women being the most active shoppers and gossipers, the connection of social shopping - a way of sharing your online shopping experience with friends - was an obvious one.

Many marketeers just assumed that women would happily sit in front of their computers at home, have a cup of tea and combine shopping with chatting to their best firend, whilst not having any worries at all.

I don't doubt that there are people like that, but it never took off and I doubt it will. The reason is that online shopping is simply fast, easy and anonymous. No standing in line, no filtering through piles of clothes, no need to have a coffee and stretch your legs. So why would you want to take a friend along?
Sure, the do-you-think-this-looks-good-on-me question is still something that you'd like to have answered, but that answer must come pretty much immediately and who can expect their friends to lurk on the social networking site ready to pounce on your "Can I wear this?" - question with a definite yes or no answer.

It won't even start working if you'd pay your visitors for such free PR and back-linking, because how much (net-revenue) have you got to give that you can incentevise links and make a margin?

Anyways, I think I will build and affiliate scheme onto BadgerComp, simply so that the Cart has everything :)