Dual Booting Laptop: Win7, Slackware

September 10, 2009

Bam! School’s in. The inevitable has happened and the most hideously busy few months of my educational life have begun: the university applications term. And to support this packed timetable I reckoned I’d need some pretty decent technological backing. In other words Windows Vista had to go.

I’d been wanting to rid my laptop of this slick but extremely ungainly and messy monster for some time (ever since I bought the laptop actually) – it crashed at a very embarrassing moment at Young Rewired State (plugged into a projector in front of a big audience with lots of media cameras pointed at me…) which was probably the last straw for me, and it’s had reliably frequent networking issues (wifi and ethernet took it in turns to fail). After testing out Win7 on old machines and liking it, I decided to go for a dual boot with Win7 and Slackware – my opinion is that Linux shouldn’t be all about Ubuntu, Fedora and Debian and I reckoned this would be a good opportunity to give a less mainstream distro a try. There was of course a snag: the main reason I held off uninstalling Vista was that I had a setup of Firefly installed (for my freelance work) which had taken literally half a day to set up so I wasn’t too keen on losing that; clearly virtualisation is the key to the problem here. So I created a new VM in Virtualbox and installed Firefly and supporting software (SQL server, IIS etc.) onto that.

So I backed up my data and installed Win7 and Slackware side-by-side. The last thing Vista did for me was crash while trying to resize a partition so I took a chainsaw (= cfdisk) to my HDD and annihilated Vista. OK I’ll admit the reason I deleted Vista was because I screwed up and hit ctrl+c while cfdisk was running … oops. And I somehow managed to forget to install LILO (boot manager) at first so started off with no boot OS which was just a tad concerning … but in the end everything worked out! I’m using a ~100GB NTFS partition for Win7 + Windows programs. Slackware has ~20GB of ext3 and there’s a 100GB NTFS data drive.

Partition Table for my HDD. In hindsight I should really have used a separate partition for Windows programs and a swap partition. Oh well...

Partition Table for my HDD. In hindsight I should really have used a separate partition for Windows programs and a swap partition. Oh well... Click to embiggen

VirtualBox running in Slackware. Its so much more convenient using virtual machines - they can be transferred from Win7 to Slackware or my desktop or even to someone in China; the portability factor is seriously useful

VirtualBox running in Slackware. It's so much more convenient using virtual machines - they can be transferred from Win7 to Slackware or my desktop or even to someone in China; the portability factor is seriously useful

Linux on laptops, especially Slackware, is all about hackery and cool stuff so I’m hoping to implement sometime soon multitouch gestures (which Mac users have) and customise the OS beyond recognition.

Goods

I was also apprehensive that Windows 7 would fail to realise my laptop has a wifi card thus negating the entire point of the operation, but in the end everything works and wifi was set up as part of the installation process; even standby and hibernate which always crashed the computer in Vista work in Win7! Every time I use the OS I find some small but hugely awesome new little feature that makes me love it just that little bit more. MS have got it right this time in my opinion and I hope it sells well. And I couldn’t help but feel just a little smug when one of my friends came in with a new laptop with Vista on it complaining to me about a wifi failure…

Slackware’s also pretty great – it installed literally in about 15 minutes. I was slightly annoyed at first that it doesn’t have a package manager like apt-get or yum (or at least I can’t seem to find one) but actually now I find svn and make/make install more than adequate substitutes; although installing software is now a lengthier process I get up-to-date packages and have more control over installation. Even better (for me), Slackware starts with a command line and the GUI has to be started manually. So next time someone asks to borrow my laptop to check email be warned: you’ll be using lynx!!

Problems

There are still two things I can’t work out:

1. I’ve got all my Virtualbox information in the shared drive and I’ve managed to boot VMs in both OSes. However if I save the machine state in Win7 and then boot into Slackware it doesn’t seem possible to restore that saved state. If I run that state-saved VM in Slackware and save a new state then return to Win7, Win7 restores the state saved in Win7, not the one in Slackware. A perplexing problem – google time methinks.

2. Linux in general is allergic to Intel Wifi cards. Enough said; though I managed to connect through wifi in Backtrack 3 (not 4 beta though!) so maybe if I do a little driver shuffling it might work eventually.

Overall I’m pretty pleased with this. I didn’t intend to do much advertising in this post but I would certainly recommend Win7. At least give the RCs a try – it is *so* worth it. And having two very good OS’s should give me a huge amount of freedom: Win7 does what I *need* and Slackware does what I *want*. Perfect.


Automatic Email Reminders

June 22, 2009

Many services seem to provide automatic email reminders these days – notably Google Calendar; however what I need is something that can send me daily reminders about things, and setting up a Google calendar with daily repeats seems an altogether inelegant solution. Virgin Media operates a throttling policy in which downloading is limited between 10am and 3pm, and again between 4pm and 9pm. As far as I’m concerned, all this means is I need to make sure I’m not downloading much between those times. I thought of setting up my various alarm clocks and watches to ring at 10am, 3pm, 4pm and 9pm to remind me – but considering I’d have to use four different devices (none of my alarm clocks support multiple alarms) and the fact that it would all be useless if I’m not at home, the best solution is to use a daily email reminder which would alert me even if I’m working off my laptop at school (for example).

I also jumped at the opportunity to find out more about Linux and PHP; besides I didn’t want to sign up for several free email reminder services hunting for a good one so opted simply to write my own. For the sake of anyone attempting to implement any of the features of PHP and Linux I used, here is my solution which can essentially be broken down into four parts:

1. Emailing script

It was fairly easy to find out how to send an email via SMTP in PHP so I set up a script to connect to my gmail and send an email from there to myself. After turning it all into a function, in accordance with the modular approach to development, I was ready to proceed.

2. Scheduler

This was more difficult. PHP can’t by itself do anything on a schedule so it was necessary to delve into Debian’s scheduling system. I tried to look up how to make the damn thing work and eventually found (amongst other irrelevant info – hurry up Wolfram Alpha and add support for coders!) how to use it. It seems like cron is already pre-installed upon Debian installation, and is constantly running as a daemon. It checks a file every minute to check whether it should be executing a scheduled task. To edit this file you type ‘crontab -e’ and get a plaintext editing interface (looks like vi). The format of the file is a list of lines, each one representing a scheduled task. Each line’s format is:

[minute : int] [hour : int] [day of month : int] [month of year : int] [year : int] [script pathname : string]

So to run the program ‘rtorrent’ at 17:30 every 3rd of the month, you go:

30 17 3 * * rtorrent

Asterisks are, as always, wildcards. To execute a process every minute, the first 5 terms look like ‘* * * * *’. There is a slight problem with this: you can’t use vi from a PHP script (at least it’s not possible using exec). It turns out there’s an alternative way of using crontab – by importing a file. So the command looks like:

crontab foo.txt

Great. So the PHP script creates a text file containing the new line then executes a command to add that file to the cron file. Eventually I set it to run the script every minute and have the script itself check for whether it should be doing anything by referencing a MySQL database.

So in the end the PHP looked like this:

$fh = fopen(“foo.txt”, ‘w’) or die(“can’t open file”);
$stringData = “* * * * * /opt/lampp/bin/php /opt/lampp/htdocs/php/ereminders/s_mail.php &> /dev/null\n”;
fwrite($fh, $stringData);
fclose($fh);
exec(“crontab foo.txt” . ‘ 2>&1′, $output);

The &> /dev/null is just to stop it ‘helpfully’ sending email to root every time it runs (i.e. every minute) containing a log of exactly what happened.

3. Database

It’s a fairly simple MySQL thing – nothing fancy. I wrote a nice function in PHP to tabulate the results of a query which I use in my screenshot. It’s a single table and I haven’t bothered to normalise it or anything. Nothing to see here. Move on.

4. Admin panel

This was, like with most good things, the final stage of development. I was also getting lazy and bored so it’s pretty rudimentary; I wrote it just so I don’t have to go into PHPMyAdmin to change things. It makes use of that rather neat ‘tabulate’ function that I had written which tabulates the MySQL query. The var_dump is the contents of the cron file.

Final thoughts

In hindsight, this is pretty good for two hours’ work, especially considering about half an hour was spent writing scripts to automate things from an admin panel. I’ve also actually found it quite useful (pardon the surprise) – the other day I wanted to download an episode of Lost Windows 7 but the throttling period had already started and that one download would probably have pushed me over the download limit. At exactly 9pm I got an email reminding me to download so was able to watch the episode install the OS that very night. Though I doubt it’ll be much use to anyone other than me since there exist systems out there that do the same thing, just much better (probably).

๏̯͡๏﴿


Dual Monitors

April 14, 2009

When I noticed a recent burst of activity from a number of the productivity junkies at Lifehacker showing off their awesome desk/cubicle layouts involving about eight screens, and a friend of mine proudly announced that he’d spent his Arkwright Scholarship money on a second monitor, I couldn’t resist the temptation of giving this whole dual monitor thing a go. My desk was crowded to the extreme: two external hard drives were selfishly sitting exactly where I wanted the second monitor, and paper, stationery, food, cables, multimeters, a keyboard, a mouse, playing cards, a tape measure and some old editions of the New Scientist occupied most of the rest of this space; clearly there was a problem. Using some of the ideas from Lifehacker about elevating the monitor and caching stuff beneath it, I proceeded to construct vaguely convex structures from bent acrylic, old books and power adaptors in the hope of squashing cables and other such paraphernalia into the cavities thus fabricated and sitting the 19″ primary monitor on top. This left the secondary (15″) monitor enough space to perch precariously atop a German dictionary.

There was however a hardware problem: the primary monitor was plugged into the only VGA socket available on my desktop, the other being a DVID, and I wasn’t sure whether the RADEON graphics card and XP would manage to work together to split my desktop into two screens. I eventually managed with the unfortunate consequence of a bit of imbalanced latency between the two screens. No biggie…

I’ve assigned two windows permanently to the secondary monitor: Mozilla Thunderbird and a Pidgin conversation window which I’m using for Twitter, and after using it for a few weeks I’m definitely starting to see all sorts of advantages. I don’t need to expend effort to check my email (all I have to do is glance to the left). I can use more than one maximised window at once. I can monitor what’s happening on my XP computer while I’m working on my Debian machine. There are a few untoward side-effects: print screen seems to have partially stopped working; memory usage is generally higher, perhaps just a consequence of having more programs open at once from having more screen space; I get glare from screen 2 while working on screen 1 (which I have subsequently attempted to minimise by skinning thunderbird and pidgin with dark themes); programs are constantly opening in the wrong screen, it’s harder to find the mouse pointer, and there’s this oddity that lasts a few seconds when I boot up:

I have to say though, overall, despite the annoyances, I came out of it with more screen real estate, theoretically higher productivity, and, for me most importantly, a clearer and less cluttered and wire-filled desk. So if you happen to have a second monitor sitting around, I’d definitely recommend going for it and setting it up as an auxiliary screen.

๏̯͡๏﴿


5 ways for a techie to revise without knowing it

April 12, 2009

It’s approaching that time in the holidays when people start thinking revision might have been a good idea after all – that is certainly the case for me. But over the past few days I’ve come up with five original ways to revise without really trying. Clearly it’s no substitute for ‘proper’ revision but hey, I think there are still some pretty neat ideas here.

1. Passwords

Like CAPTCHAs, the use of passwords seems, to me at least, time wasted – I suspect very few people invent and learn new passwords each time – normally passwords have some sort of personal meaning, however obscure. So rather than, every time you sign in to facebook, regurgitating a well-known word or phrase, you could use registration to a new service as an opportunity to learn a new word or piece of vocab. If there’s an item of German vocab for example that you can just never remember, consider using that as your password so every time you enter it, you’re reinforcing that in your long-term memory. Even better, you always know where that password is from, so even if you forget it, it’s always written down somewhere while being sufficiently obscure as to be more or less unguessable.

2. Mouse mats

There was a point when St Paul’s decided to sell advertising space on their mouse mats (well, it seemed that way at the time) – every bit of space counts and can theoretically be utilised. A Dell mouse mat can be replaced with something more useful and potentially revision-compatible. Like Clarkey’s Organic chemistry reaction thingy:

The advantage of this is that you’ll end up looking at it every day, whether you like it or not. Whether I’ll actually benefit from this measure is another matter…

3. Desktop Backgrounds / Screen Savers

Essentially the same philosophy as mouse mats – you can avoid books and sheets and revision notes but you can’t avoid looking at your desktop background every time you hit Win Key + D.

4. Google Calendar

GCal has this useful little feature that emails reminders to you about calendar appointments, for example if you create an appointment at 2pm you’ll get an email at 1:50 reminding you to do that. So if you create a reminder called something like “Electronegativity: Ability to pull electron density towards yourself through a covalent bond” you’ll get an email saying just that. If you make lots of appointments like that it’s possible to get constantly reminded of easily forgettable facts and definitions.

5. Stumbleupon

A friend actually suggested this as history revision. For the non-stumblers [wiki]:

StumbleUpon is an Internet community that allows its users to discover and rate Web pages, photos, and videos. It is a personalized recommendation engine which uses peer and social-networking principles.

Web pages are presented when the user clicks the “Stumble!” button on the browser’s toolbar. StumbleUpon chooses which Web page to display based on the user’s ratings of previous pages, ratings by his/her friends, and by the ratings of users with similar interests.

It’s also possible to stumble by topic, which is apparently an excellent way to read around the subject in subjects where that is required for the exam (like History, apparently). It’s normally less boring than reading notes because of SU’s system of correlating frequency of stumbles with the rating of a website. Of course, don’t trust everything you read on SU, especially if it’s from The Onion (!) but it is allegedly a productive use of an afternoon.


Surviving Black Ice on Bike

December 5, 2008

I present you with my new God Hypothesis: if and only if God exists, he is far from benevolent. It would appear the legendary Pure Mathematician Godfrey Harold Hardy agrees: “Another example of [Hardy] trying to fool God was when he went to cricket matches he would take what he called his “anti-God battery”. This consisted of thick sweaters, an umbrella, mathematical papers to referee, student examination scripts etc. His theory was that God would think that he expected rain to come so that he could then get on with his work. Since Hardy thought that God would then have the sun shine all day to spite him, he would be able to enjoy the cricket in perfect sunshine” (Toller made me aware of this; quotation taken from here). God, in order to spite me, over the last two weeks has strategically placed black ice in exactly the same spot of road causing me to fall spectacularly on both occasions causing grievous (= light) damage to my elbow followed by my face, as some sort of obscene joke.

Click for original image

In fairness I shouldn’t be blaming some being who was invented a long time ago and exists solely in books. The real reason is that my bike’s tyres were worn almost smooth by regular trips to Richmond Park over the Summer and Autumn. But as Winter is setting on, a relatively high tyre pressure (pumped up in the hope of improved speeds) and non-grippy road (rather than mountain-biking) tyres are hardly ideal for the conditions. So I decided to do some research on how not to die at the hands of Winter, squashed between a bus and a centimetre of ice. I’ve organised my incoherent thoughts into a list of tips for anyone who is, like me, foolish enough to attempt to overcome whatever God throws at him, including icy road conditions. Since my expertise with ice cycling is evidently somewhat lacking, I’ve nicked half of these from different sources.

Technique

Keep upright and turn slowly

Both times I fell it was because P was too great; too great to be resisted by friction (F). To minimise this you want to minimise the torque created by N and W, i.e. minimise the angle theta: keep as vertical as possible as increased torque increases the effect of P. You also need to slow down (as Dr Zetie has just taught us, centripetal acceleration v^2/r where r is the curve radius and in this case it is provided by friction – if friction isn’t enough to resist the centrifugal force created by high-speed turns, God wins and you fall). I’ll shut up about Physics now.

Brake gently

This might seem obvious but it’s actually even worse than you might think. Friction with the ice when braking melts some of it creating water, which on ice is amazingly ‘fail’ at friction. Bad.

Brake with rear wheel

When you brake, torque makes the bike lean on its front wheels, so if that front wheel locks you’re screwed. Don’t brake with it. Braking with the rear wheel is also great for skidding down icy hills (apparently).

Let the bike get it

If it does come to it and you’re about to crash, a friend of mine advises you just throw the bike at whatever you’re going to hit and either land on it or hit the ground at a much reduced velocity. Not sure how good this advice is, but it’s probably a good idea on the personal safety front. Maybe not for other road users or indeed the bike…

It’s also better to get scrapes than go head-first into a solid object – I’m no expert but I’m pretty sure grazes heal faster than fractures.

Ride the gravel

There tends to be a load of crap at the side of roads, especially gravel which is great for cyclists when the rest of the road resembles an ice-rink. Snow is also better than ice.

Kit out your bike

Use studded tyres

These are the best tyres for grip in icy conditions. Also consider chaining your tyres.

Click for original image

Lifehacker also did a post on it.

Also, slightly underinflating car tyres helps for low-grip surfaces. Presumably the same applies for bikes, especially for wide tyres.

Dress for the Arctic

Wear an anti-God outfit complete with crash-helmet so you’ll just bounce if you hit the road.

- -

Hopefully when I try (most of) this next week I won’t die in the process. And don’t blame me if you do attempt it all and still get hit by a bendy-bus after skidding into the middle of a road.

Most of these ideas and images came from here.

Click for original image


Organising school paper documents

September 14, 2008

Following on from my ideas about going paperless, here is how I organise all the many sheets of paper I receive daily at school in preparation for scanning or somehow making it electronic, a solution which I personally find it highly effective.

In brief

The system uses a single lever-arch file and a set (or two) of dividers. The folder is effectively split into two parts: the main section at the front which deals with preps, blank paper and paper miscellany; and the subject section, split into the different subjects that I’m doing.

1. The Main Section

‘Paper’ is fairly obviously where blank sheets of paper are stored – lined, graph and blank paper. The next bit is prep. The first tab, ‘Set’, is where I dump all the homework sheets that need doing. Once the preps are completed the question sheet and my answers get stapled together and moved into the ‘Done’ section. When a prep gets marked it goes into the ‘Returned’ section which is scanned upon arrival home. The paper then gets shredded, leaving me with a bunch of scanned files on my HDD rather than a huge folder full of paper. The ‘Unis’ section is anything I pick up about university choices / preparation / general future education.

2. The Subjects Section

This bit is devoted entirely to subjects. Each subject has its own divider, and this section is used as a temporary cache for everything that isn’t prep (classwork, handwritten notes etc.) pending scanning and shredding upon arrival home.

Extra bits

There are always some special documents which don’t fit into any category in the system. The front of the folder contains my timetable (as can be seen in the first photo) and the back a load of transparent A4 paper wallets for anything that can’t for any reason be hole-punched.

The entire one-folder solution is incredibly simple but I’ve found it immensely effective as a system for getting everything from paper to HDD, and I hope this helps someone out there.