Wednesday, April 29, 2009

New Blogs

Hi,

This blog has been abandoned.

If you're still checking it, hoping for updates, you can find me elsewhere on the Internet.

Visit my personal blog (updated infrequently), or my new blog about public speaking.

Thanks,
Andy

Tuesday, June 12, 2007

Optimise your Windows programming environment

In an ideal world every developer would be given fast computers, two high resolution monitors and the choice between Linux and Windows. Unfortunately this is rarely the case. I'm stuck with Windows - which is great for web browsing and creating Power Point presentations - but it doesn't really cut it for programming tasks out of the box.

This post outlines some of the programs I have installed, and the configurations I have used to make Windows a bearable programming environment. All applications have been chosen for their simplicity, low ram foot print and free availability. Any changes to Windows settings have been selected to either provide better information at a glance or reduce click count. The only prerequisites for applying these changes are that you know how to edit the registry and edit your path environmental variable.

Text Editor
Programming involves huge amounts of plain text manipulation whether it be source files, make files, scripts etc. What does Windows provide to edit these? Notepad.

I think the minimum one should expect from a plain text editor is: syntax highlighting, auto indentation, block indentation, parenthesis checking, a good search utility (across multiple files with regular expressions), a tabbed interface for multiple documents and speed. The final feature might sound obvious (it is just a text editor) but IDEs loaded with unnecessary features or even the most simple editor written in Java has the tendency to be slow.

I recommend Programmers' Notepad. Pn supports syntax highlighting for multiple languages including C/C++, perl, html and many others. It is fast as it is written natively for Win32. It's intuitive and has everything you would expect.

Even if you use an IDE for your primary development I would recommend getting hold of pn, you will always need a text editor to knock up scripts or html pages and there is no need to resort to using Notepad. Personally I will only ever use an IDE if I need to use the integrated debugger (which is rare because I work with hardware).

You'll want to associate your source files with pn2 (.cpp, .h etc.), however I come across new file types all the time and some I do not want to associate with an editor (e.g. .html, .bat, .pl). I avoid file association problems by adding an "Open with Programmers' Notepad" into my explorer context (right-click) menu.

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\Shell\Open with Programmers Notepad 2\command]
default="C:\Program Files\Programmers Notepad\pn.exe %1"
I've also included "C:\Program Files\Programmers Notepad;" in my path so it can be opened from the command line by typing pn filename

Text Comparison
When you have multiple versions of code kicking around a comparison tool is essential for quickly examining what has changed.

Unfortunately I couldn't find a free app that rivals Beyond Compare ($30). I use this because the company I work for has a site license. I've tried a few free alternatives and by far the most superior is WinMerge. This app provides a clean simple interface for text file comparison and you can edit text within the differencing pain (unlike KDiff3). The directory comparison utility isn't great so I'm still on the look out for something better.

Both Beyond Compare and WinMerge provide quick comparisons through the explorer context menu.

Hex Editor
If your developing anything for hardware, dealing with file systems or communications you will require a hex editor to read binary files.
I recommend ICY Hexplorer. It provides simple hex editing and colour schemes to highlight ASCII text, NULL bytes etc.

It is unlikely that you would ever want to associate a binary file (e.g. .exe) with an editor, so as before I've added an "Open with Hexplorer" option to my explorer context menu.
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\Shell\Open with Hexplorer\command]
default="C:\Program Files\hexplorer\hexplo.exe %1"
Command Line
I don't think anyone really likes DOS. I know lots of people who use cygwin, but I'm not keen on it as some things have to be done in DOS meaning you'll have to split what you're doing over two shells. To make the Windows Command Line Interface better I have done the following things:

Enabled TAB auto completion - This is not default in Windows2000 which is a disgrace.
[HKEY_CURRENT_USER/Software/Microsoft/Command Processor]
CompletionChar=9
PathCompletionChar=9
Installed unixutils - These are native Win32 ports of standard Unix utilities including grep, sed, tr, vi, cat etc. Put the \unixutils\usr\local\wbin directory in your path so you can access them from directory.

Installed Console - An interface on top of cmd.exe. It provides better layout options (font, transparency etc.) and multiple consoles in tabs.

Reusable Scripts Directory
Useful scripts and batch files get shoved into d:\scripts which is made globally accessible by adding it to the path environmental variable.

Obvious examples..

Quick navigation:
d \really\really\really\ridiculously\long\directory\tree
Better formatting with showpath:
echo %path% | tr ';' '\n'

Personal Wiki
While not a Windows specific tip I use TiddlyWiki to note down useful bits and pieces such as:
  • Awesome regular expressions that I might want to reuse
  • Documents I'm currently writing (before I export them to the Word)
  • Useful bits of code
  • Todo list
  • Anything I might want to remember
TiddlyWiki is a single html file that edits itself using javascript, so it's easy to setup: just copy it locally, no need for a webserver. I keep mine in a shared directory so I can access it on my desktop and my laptop (either directly or through the VPN). It's also very easy to backup simply by gmailing it.

Cheat Sheets
Again not a Windows specific tip, but for ultra quick reference no programmer's desk would be complete without a cheat sheet. Check out ILoveJackDaniels for some pre-made ones including regular expressions .

Disable desktop icons
I don't like desktop icons, you're required to minimize everything you're working on to get to them and the desktop often becomes a dumping ground for crap. A clear desktop encourages storing files in a proper place. Disable them by right clicking on the desktop: Arrange Icons By -> Show Desktop icons.

Apply a consistent view to all folders
I like details view with file extensions enabled and hidden files shown. It's nice to be able to see when the component you're about to export is full of hidden temporary files, and it's nice to be able to change the file extension without having to open a command prompt. I prefer details view so I can quickly see the sizes and date/time of last modification at a glance (very useful to check if a binary has really been compiled).

I won't insult you with how to set that up, but Tools -> Folder Options -> View(Tab) is your friend.

Windows Search
If you've followed the steps above you can use the build in search tool in pn2 or grep -r to search for text within files. However a regular search facility is still required to search for files by name. I haven't experimented with an indexed search system (like the one included in google desktop) as I download fresh code before making a change, not really giving enough time for it to be indexed. In Windows XP the default search dialogue sucks. You can make it a little bit better by reverting the interface back to a Windows 2000 feel:

F3 (brings up the search dialog) -> Change Preferences -> Without an animated character
and
Change files and folders search behavior -> Advanced (lol)

When you disable the animated dog, it gives you one last smile and wanders off the screen.

Friday, June 08, 2007

Why are we Happy?

Less than an hour after posting my previous post where I discussed "The Power of Now" I stumbled upon on a talk that was presented at TED 2004 by Harvard psycologist Daniel Gilbert. One of the points he makes at the beginning nicely compliments one of Tolle's points without being vague and spiritual...It made my blogging fingers itch ;)

Gilbert describes how human evolution has resulted in the ability to simulate situations in our minds due to the presence of the frontal lobe. In essence people can make decisions by playing out two scenarios in their head and deciding which would make them happier. I think this illustrates Tolle's statement: "You are not your mind". There is a distinct difference between the images and thoughts in your head and the conciseness that must make the decisions.

Gilbert expands on this stating that whichever choice we make will have no baring on how happy we are in the future. People have the tendency to synthesise happiness to fit their situation even if their situation was initially unwanted. Usually we scoff at people who claim to be better off after they lost everything, but Gilbert claims that this synthesised happiness might be just as good or better as natural happiness (where you actually get what you want).

This is an awesome video, I think I'm going to buy his book..

Adblock


(video link)

Andrew on Spirituality and The Power of Now

I shy away from most things that claim to have a basis in spirituality. Religion, for example, seems absurd to me and I'm always slightly amused when someone from a mainstream religion like Anglicanism looks down upon a less widely followed religion like Mormonism or Scientology because they are equally ridiculous to me.

I do, however, believe that spiritual concepts can be employed by skeptics, however some people have the tendency to take things too far. For example I used to practice Aikido, a Japanese martial art translating to "The way of harmony". Central to Aikido was the concept of "ki" (or "chi" in some other martial arts) which is an intangible energy that can be focused into blows, movement balance etc. I didn't take this literally and I never believed that a successful dispatch of an opponent was the product of anything other than simple mechanics; however visualising ki running though my and my opponents bodies gave me new insight into the movements as well as aiding relaxation and peace of mind. Some people will take this further believe it is more than a useful psychological mechanism, while this is not harmful to their Aikido I think they are ceasing to be rational and may develop unrealistic expectations of what ki can really achieve or become lost in ceremony.
Another example is meditation. While I do not meditate I imagine that devoting time to relaxation and breathing could relieve stress or focus though in a better direction, however I think that most pragmatic individuals avoid such practice because of the association with "out of body experiences" and spirituality.

While I was in India I was reading The Power of Now by Eckhart Tolle which I originally heard of on Tyler's blog (the "evil" pickup artist from The Game). In late night, beer fueled discussion with my spiritual traveling buddy (what up Matt ;)) I asserted that I didn't think the Power of Now was spiritual which was met with an incredulous silence followed by ferocious debate. He later showed me the front cover smugly pointing out "The Power of now: a guide to spiritual enlightenment". I was surprised. I had simply not registered this. I had perceived the text as a series of logical descriptions about mind and consciousness and suggestions on how we should focus our thoughts. Anything vague or spiritual had been regarded as a psychological mechanism and the thesis had seemed sensible.

I get the feeling that the person who would buy this kind of book would be "more in touch with their spirituality" (hmmmm), so perhaps this is why this aspect has been promoted on the front cover. I do, however, believe that this book can be broken down into a few core concepts and I think the term "spiritual" is misleading and verging on redundant. I was pleased to discover that such a break down of the thesis exists on Wikipedia.. of which I will present my own adaptation:

(1) You are not your thoughts
Tolle challenges Descartes' famous quote: "I think therefore I am" claiming that the core description of one's self cannot be expanded beyond "I am". Your conciseness exists independently of mind/thoughts, although I would argue that both exist as electrical signals within your brain.
Your mind is a useful tool when used effectively, but it can also bombard you with negative unhelpful or irrelevant thoughts.

(2) Only the present moment exists
Ok..

(3) Accept the present moment

Accept - then act. Whatever the present moment contains accept it as if you had chosen it. Always work with it, not against it. Make it your friend and ally, not your enemy. This will miraculously transform your life
Don't resist what you can't control, don't wallow in self pity that things haven't gone as you hoped, accept things as they are and take action to rectify things if you need to.

(4) Observe the pain body
Observe how the mind produces negative thought patterns. Rather than identifying with them, observe how irrational and unhelpful they are.

I think that's quite simple and accessible to skeptics. Apparently this is very similar to Zen Buddhism, which I learned from several reviews accusing Tolle of plagiarism.

Sunday, June 03, 2007

Back From India

At the end of my two week holiday in India I took a Taxi from Colaba, the tourist district of Bombay (or Mumbai: the seldom used non-anglicised official name) to the international airport; a transition in my journey that would eventually lead to familiar food and an abundance of clean seat-style toilets with soft toilet roll for which I had bean yearning. The taxis in Bombay are all the same ancientvehicles painted in yellow and green still holding together after about thirty years, decorated in true Indian style with frills and tassels across the windscreen and the overloaded boot tied shut with a piece of rope.
The driver, a chatty twenty-one year old is dressed smartly in a the shirt and trousers combination that almost every Indian man seems to wear even in the thirty-seven degree pique of Indian summer. He tells me that the hotel owners demanded a Rs120 (that's Rupees, £1=Rs80) for providing a customer, which was over a third of the total price of the journey. He's welcoming and friendly, and calls out to friends on the street with what I can only assume were laddish in-jokes. He's excited by the fact that I work with phones and is keen to show me his. He tells me that he's been a taxi driver for three years. His father came toMumbai to work as a private driver, leaving his family in a village south of Pune . At seventeen he came to live with his father, but after three days in Bombay his father was killed in a traffic accident. He was lefthomeless and and struggling to find a job. The driving job he eventually found paid Rs3500 (£43.75) a month, twelve hours a day, no holiday. He tells his family that he makes Rs5000 working in an office, rather than the profession that killed his father. He supports them with the money he earns, while having to sleep on the street at night.
He's in good company on the streets. Wandering around Colaba at 2am every alleyway was full of people sleeping on makeshift beds. People were sleeping on their market stalls and others sprawled over the pavement. The poverty in Bombay is just so IN YOUR FACE. Other backpackers at various stages in their round the world trips were frequently of the opinion is that the slums they had seen in India were by far the worse they had seen in South America and Africa, mainly due to the fact that they contained so many more people. I was quite surprised by that.
The population in India is immense. Even when we took the train out to rural areas it was hard to get away from vast crowds of people. Looking around Iremembered the quote "They have more honour roll students than we have students" from this video (that first came to my attention on Lloyd Morgans blog). I'm sure that as the economy develops we're going to see masses of innovation and new interesting businesses coming out of India - however they'll most likely to put up with providing cheap labour and programming to the West for a few more decades/centuries. My friend asked someone "Do the Indian government have any plans to address the poverty and population problems?" the response was "What could they possibly do?". Even though India must contain an abundance of extremely clever people its difficult to imagine what they could achieve on £43.75 a month.

Monday, May 21, 2007

Indian toilets

Am sitting in an internet cafe in Mumbai. Although not the primary reason for comming here I just did a quick google search for how to use Indian toilets. Here is the best description I found:

Butt Care

Ann, this is how it's done. Put one foot on each of the pads on
either side of the hole(or ditch). Squat and crap. Using your LEFT HAND, wet the
hand with your water supply. This is so the crap doesn't stick to the hand. Wipe
your anus clean with the wet fingers. Rinse off the feces from fingers with the
water supply. This leaves you clean as paper at least and not wet like the timid
splash method.



Nice!!!!!

Source

Friday, May 18, 2007

Mumbai

Arrived in Mumbai very early Thursday morning.

We are staying in the main touristy area, Colaba, which is in the southern tip of Mumbai. Yesterday we went to look around the market. Almost everything was overpriced rubbish aimed at tourists. We followed the market as far as it went and after about fifteen minutes of walking it turned into a slum. We were surrounded by makeshift houses and corrugated iron shacks. One section was selling fish which were covered in flies, the heat was making them stink so badly that I thought I was going to be sick. The town surrounded a beach that was a mountain of rubbish. Naked children were climbing over it and shitting into the sea.

This morning we went to Laughing Yoga in the park. This is essentially standing in a circle and doing different kinds of laughing with associated actions... like etiquette laugh (hand over mouth), American laugh (slapping thy), Computer laugh (pretending to type). :D

Headed up to the shrine of Matt's guru (Sri Nisargadatta Maharaj) today. An hour and a half on the Indian local trains. The trains themselves look like they are at least 50yrs old. people pack into them and hang out the side. We passed though countless slums on the ride up. Everyone has been really friendly and keen to offer advice/directions (with the exception of the hawkers). One cool guy we met, a trainee dentist, spent over an hour talking to us, drove us to a restaurant then dropped us off at the station.

We're off to Goa on Sunday night (11 hour sleeper train), where we'll hit the beach.

Tuesday, May 15, 2007

India Tomorrow

Tomorrow I fly to Mumbai, as I mentioned in this post. The general idea is that we turn up with little in the way of plans, and nothing in the way of accommodation. I'm excited and slightly apprehensive, especially seem as my travelling buddy, Matt (his abandoned(?) blog), suggested going to a place "somewhere around here" while circling an area the size of western Europe with his little finger and "westerners get approached to star in a Bollywood movie every few minutes or so".

I'm staying up late to pack so that I can sleep on the plane. This is what I'm bringing...

  • Karimor Jaguar 65+10l rucksack - Main Luggage
  • JanSport backpack - Hand Luggage/Day trips
  • Nine tee shirts - It's going to be hothothot out there. A few are free tees that I will just throw away after using them.
  • Three pairs of shorts - one of which is also swimming trunks
  • Twelve pairs of boxer shorts - they're all I have including the thirteenth I'm wearing now, I guess I'll have to be creative on day 13 and 14.
  • Fourteen pairs of socks - Prob won't need that many, but they stuff down pretty small
  • Vanns + two pairs of flipflops
  • Jeans+Hoody - to wear to and from Heathrow in the cold and wet London weather
  • Books: No Logo - Naomi Klein, The Power of Now - Eckhart Tolle, Rashomon - Ryunosuke Akutagawa, Lonely Planet guide to Goa
  • Folder full of printouts - from wikitravel, travel itineraries etc.
  • iPod - Including some awesome progressive breakbeat
  • Sony Ericsson P1i + charger - Because I can
  • Box of Pocky - That I got free today
  • Poi - Because they're s cool
  • Passport
  • Lots of toiletries
  • Malaria tablets
  • Diohrrea tablets - Lots
  • And a few other things...
Ok, getting tired. Off to bed. Watch this space for updates.