Blog

No more netbooks in future

as I read in the Guardian this morning, Asus (et all) are stopping the production of netbooks. It seems the economy of the netbook has failed. Too many tablets are being sold and the that has probably crippled the already poor performing PC hardware market.

It’s not even that the UltraBooks have moved into the market, no, it was partly notebooks, partly tablets and – most shockingly – the licensing that had to be paid to Microsoft for Windows XP or 7. These additional £30 – £70 meant that the netbook margin almost disappeared.

What a shame, as I really enjoyed having an inexpensive, small, durable, USB and SD card slot wielding, low energy consuming netbook when on the go. Thank god I still have one!

What I found most disappointing about the whole story was that this, kinda, seals the fate of the One Laptop Per Child campaign from a few years back. The Raspberry PI won’t be the same, as you still need big screens, keyboards and mice on each desk. I also don’t think that a tablet, least of all the iPad, would be a good addition to the classroom. It’s too simple, it’s not good for typing for a long time and it’s bound to be more restrictive than a computer in so many ways. You can’t teach children IT and programming on a tablet (yet).
The netbook would have the solution and meant that you could have run a complete system – like I already am – with IDEs, services (such as MySQL, Tomcat, Apache…) and that would have really made a difference in the classroom.

It’s a shame that this was possibly never recognised. Maybe a large scale production of netbooks for schools would have been an excellent solution and netbooks would have become even more affordable. After all, they are able to build tablets for under £100…

The amount that could have been saved on books and materials over the years would be massive.

I wonder if anyone ever looked into this.

Python on MS SQL (via pyodbc)

I have been struggling, albeit not very long, to set up a DB connection to a remote MS SQL server through Python. I thought that the process is not as straight forward as I’d like it to be, but I guess that’s okay because as far as I can see the best solution is to cobble it together a bit.

Basically it seems that the best solution is not to use a python end to end module as a driver, but to use features that are available otherwise, such as ODBC. Then use a ODBC driver for the MS SQL engine and then use ODBC within Python.
As a Linux person, I first had to install unixodbc:

sudo apt-get install unixodbc unixodbc-dev

This takes care of you being able to use ODBC to connect to ODBC database servers. The other part is having a ODBC driver for the connection to the MS SQL server. There are probably others and I shall list them in due time, but for MS SQL, I found it easiest to use FreeTDS (an implementation of the Tabular Data Stream for Linux).

To install:

sudo apt-get install freedts-dev tdsodbc

With this done, you can preceed to modifying the /etc/odbcinst.ini:

sudo nano /etc/odbcinst,ini

[ODBC]
Trace = Yes
TraceFile = /tmp/odbc.log

[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
CPTimeout =
CPReuse =
UsageCount = 1

Please note that the paths for libtdsodbc.so and libtdsS.so are not necessarily as the ones given in this example. For one, I’m using a 64bit version, so on 32 the path is probably different. Another possible location for the files would be: /usr/lib/odbc/.
Either search for the location or seek Google to find where your distribution saves these files.

You will also need to have the python-dev stuff installed:

sudo apt-get install python-dev 

Now that the system is installed, you will want to install the pydobc module. You can download the latest version of the pyodbc module here. Extract the file where it’s convenient for you and ‘cd’ into the folder.
To install simply do:

sudo python setup.py install

More and more sponsored content on facebook

I logged into facebook today to see how Myko was getting on yesterday (he was on a UK game show).

Unfortunately, facebook is taken over by useless ‘like’ messages. All I can see is this guy likes Heinz Beans, this girl like Burberry, someone else likes Coca-Cola, Amazon, Hotels.com…

Is there something wrong with me that I don’t care what sh*t you people like? Or something with other people that need to tell everyone when they like something so trivial and unimportant like a brand? it makes me wonder how much people really like beans? A lot more than me?

Or could it be facebook being incredibly desperate to get some kind of advertising revenue that they swamp us with this nonsense? Unfortunately I seem to be unable to opt-out of these ‘This c*nt likes that sh*t’ messages.

Am I the only person that is bothered by all the adverts that are being communicated out to me? The way that this is done is also incredibly subliminal – first there were few messages here and there, now it’s everywhere and meant to be adapted by us all.

I have never been a ‘fan’ of facebook, but I’m getting increasingly turned off by the whole ordeal.

Websites won’t work properly without cookies

Yet the European legislative that has passed a few weeks ago now make it mandatory to advise people how cookies are being used.
It’s like stopping every customer that enters your high street store and telling him how the CCTV system works, what they are going to do with your purchase and other information and only then letting them through…

Nevermind, protecting yourself from pesky third party advertising cookies is easy. Check this page to opt out of all sorts of networks that use behavioural and remarketing cookies.

This, btw, also works through cookies!

Olympic Glory in Broadcasting

Some post Olympic humour……

 
Here are the top nine comments made by NBC sports commentators during the London Summer Olympics that they would like to take back:

1. Weightlifting commentator: “This is Gregoriava from Bulgaria. I saw her snatch this morning during her warm up and it was amazing.”
 
2. Dressage commentator: “This is really a lovely horse and I speak from personal experience since I once mounted her mother.”
 
3. Paul Hamm, Gymnast: “I owe a lot to my parents, especially my mother and father.”
 
4. Boxing Analyst: “Sure there have been injuries, and even some deaths in boxing, but none of them really that serious.”
 
5. Softball announcer: “If history repeats itself, I should think we can expect the same thing again.”

6. Basketball analyst: “He dribbles a lot and the opposition doesn’t like it. In fact you can see it all over their faces.”
 
7. At the rowing medal ceremony: “Ah, isn’t that nice, the wife of the IOC president is hugging the cox of the British crew.”

8. Soccer commentator: “Julian Dicks is everywhere. It’s like they’ve got eleven Dicks on the field.”

9. Tennis commentator: “One of the reasons Andy is playing so well is that, before the final round, his wife takes out his balls and kisses them… Oh my God, what have I just said?”

Auto Download File From FTP – then rename

A little while ago my friend asked me to help him with some Windows commandline scripting. Basically he was waiting for ages for the development team in his company to sort this simple task out and asked me how he can every day automatically download a file from FTP, then rename it with the current date.

I don’t do Windows very much and Linux is just much better for exactly these things, but this seemed like an easy enough challenge.

In the end I didn’t manage to do everything in one file, but I think that two should work just as well when you add them to the Windows task scheduler…

Here are the files with some explanation:

downloader.bat:

@ftp -i -s:”%~f0″&GOTO:EOF
open ftp.someserver.com
[username]
[password]
!:— FTP commands below here —
mget “*.*”
disconnect

The first line starts the windows command line FTP client and the parameters essentially say that everything else in the file should be ignored by the command line itself, but be parsed to the FTP client.
Line two opens the connection and line three and four will send the authentication details. Line six gets all files in the current directory. You could really do here anything you want on the remote and local server, eg: change the local directory path (lcd …), the remote one (cd …) send files (put) or even delete them (rm). At the end, I simply disconnect.
renamer.bat:

for /f “tokens=1-5 delims=/ ” %%d in (“%date%”) do rename “SomeFileName.txt” SomeFileName_%%f-%%e-%%d.txt

In one line: I’m starting a for-loop and I use a tokeniser to delimit the following string into 5 (1-5) sections. %%d specifies the beginning character used for the token (d) and all that follow will be e,f,g…
then I use the %date% (in (“%date%”) function to get the current date. Now, In the do part, I will rename the file from SomeFileName.txt to SomeFileName_yyyy-MM-dd.txt
I hope this makes sense and helps a few people. Best of luck…

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.

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
    begin
    set @dater = date_;
    set @dater = DATE_FORMAT(@dater ,’%Y-%m-01′);
    return @dater;
    end

  3. Last of the month date:

    drop function if exists fn_getLastOfMonth;
    create function fn_getLastOfMonth(date_ datetime) returns datetime
    begin
    set @dater = date_;
    set @dater = DATE_FORMAT(last_day(@dater) ,’%Y-%m-%d’);
    return @dater;
    end

  4. Days in the month:

    drop function if exists fn_getDaysInMonth;
    create function fn_getDaysInMonth(date_ datetime) returns int
    begin
    set @dater = date_;
    set @dater = day(last_day(@dater));
    return @dater;
    end

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

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…

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:

localip 192.168.0.1
remoteip 192.168.0.2-10

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
CLIENTLOGIN pptpd CLIENTPASSWORD *

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:

net.ipv4.ip_forward=1

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 DynDNS.org.

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 192.168.0.0 netmask 255.255.255.0 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.