Mike’s Memoirs - The love of coffee, condiments and code.

Code

September 18, 2009

Toggling code blocks in Python

Tags: , , ,

I have found a pretty simple method of toggling large blocks of code in Python.

Basically this:

#Add/remove below hash to toggle code blocks.
#"""
print "Code block one!"
"""
print "Code block number 2."
"""
#"""

Note: This is not highlighted correctly because of a limitation of the highlighter I use :(

In this default state (with the initial #) the first block of text is active with the second commented out. Removing this hash will invent the code commenting.

I’ve been doing this in PHP for years, but only recently figured it out in Python!

Motorcycle

September 4, 2009

How to repair/mend/fix a scratched motorcycle visor

Tags: , , , , ,

If you ride a motorbike regularly, you’ll know that helmet visors get pretty dirty. Most people just use bog-roll, clean water and elbow grease to get their visors looking lovely. But, then came along the V2 sponge! It’s pretty much just an extremely fine wet sanding sponge, and it works amazingly. I used it on my tinted visor and it cut through the flies and crap like it was butter! Then same my clear visor; used the sponge, not a single bug on it, looks good! When I tried to clean off the water, I noticed that it had scratched the entire surface! It was not impossible to see through it!

After finding out that it is £29 for a new visor, I decided to try and find an alternative to buying one. I had the bright idea of using an electric polisher, or some more extremely fine sand-paper, but these would probably make it worse. I decided that eBay might hold the key to my success, so after a few searches for things like “plastic repair” and “fix plastic scratches” I came across plastic aquarium repair polish:

As I didn’t really have anything to lose, because if I didn’t repair it I would be buying a new visor anyway, I decided to give it a go. It was only a couple of quid and seemed like I would get results fairly quickly! Here’s a couple of pictures of my visor before I gave the aquarium repairer a go:

Not so awesome! (and yes, that’s a custom paint job on the mouse!)

The instructions on the packet were a bit short and to the point, but I gave them a go. After having little success (it was working, but only in small patches after I had treated the whole thing) I decided to make my own method. Here’s a quick run-down of what I did to get the results you can see below:

  • Clean the front of the visor properly (water and bog roll!). You’ve probably cleaned the polished surface off, but it cant hurt to give it another wipe!
  • Find the smooth sides of the cloths and lay them smooth-side-up. The instructions say to only polish with the smooth side, and it worked well for me!
  • Squeeze a small amount (small pea size) of the polish out onto the smooth side of one of the cloths (the other one will be your ‘clean’ cloth for buffing).
  • In circular motions, (This is important, even at the edges. Straight strokes don’t work for some reason!) rub the polish into the visor, small areas at a time. Use reasonable force.
  • Once you have used all the polish that you put on your ‘dirty’ cloth (it soaks  in/evaporates) use the other ‘clean’ cloth to buff it. (It should come up clean!)
  • Repeat the above 3 steps for the rest of the visor. In hard to reach areas (like by the opening tab) apply the polish directly to the visor instead of onto the cloth.

Then you should have something like this:

I stuck some Cat-Crap anti-fog stuff on it too and I’m pretty happy with the results! :)

Let me know what you think, or if you had similar results, in the comments!

Oxymorons

March 6, 2009

New Category

Tags:

I’ve decided to add a new category to my website, entitled Oxymorons.

I love these little contradictory phrases, so in my search to find the best oxymorons, I will be posting them to my blog!

It is defined as:

A rhetorical figure in which incongruous or contradictory terms are combined, as in a deafening silence and a mournful optimist.

Let’s get started:

  • Old news – this is a classic example.
  • Stiff drink – this has received mixed opinions, but I am certain it is an oxymoron.
  • Dry ice – what prompted me to add this post.

If anyone has any decent oxymorons, get them posted in the comments!

Photography,Rants

August 2, 2008

Disassembling the Canon EOS 30D

Tags: , , , , ,

My Thursday was spent converting my 30D to infrared. This is not an easy task!

Since selling my other infrared (IR) camera on eBay, I decided it was time to convert my newly acquired camera, a Canon EOS 30D to IR. Since converting my 300D to IR with Schott glass I felt quietly confident I could easily convert the 30D in the same way. As it turns out, having a conversion guide, or even disassembly instructions, simplifies the process greatly, as it did for my 300D.

When I started disassembling the 30D, I was kind of winging it, after having read a guide to disassembling the 20D. I found it is not very similar, and it was a challenge to get it done!

After the frustration of not having a guide, I have decided to write one with my hindsight comments added to it, in hope that someone else may have a use for it. By reading you agree I have no responsibility for you breaking your expensive camera. Here goes…

Tools

You will need:

  • Small jewellers Phillips screwdriver (the one with the cross head).
  • Small flat screw driver. This is for levering stuff up that you are de-soldering.
  • A soldering iron. I’ve got a £5 one from maplin electronics, but it sucks. It didn’t get hot enough and I got angry.
  • A tooth-pick/cocktail stick. Yep. Canon make tiny holes in their ribbon cables to let you get them out easier!
  • Black silicone in a tube (preferably a syringe). I got some “Loctite Superflex Black Silicone Sealant” from Halfords in the body repair section. It was not really suitable (it was way too thick to get out of the tiny hole I cut in the funnel top) but it did the job. This is only needed for an infrared conversion. If you are fixing something, you do not need this (unless you have scratched the low pass filter).
  • A steady hand. I’m not kidding, this is very fiddly.

Preparation

First step is to make sure you have somewhere nice to work, I did it in front of my computer. I’ve got a pretty big desk with a window behind it to give suitable lighting. You might want to print this page and take it to a garage or somewhere else suitable.

Second thing to do is get a piece of A4 paper or similar that can have a semi-permanent home while you are doing this to make sure you don’t lose any screws and you can document where they came from. I’ll try and help, but it’s best to use your own method. When you take a screw out of the camera, make a note on the paper, with the number of screws and where it came from. If you want to pre-label, write down the following in their own squares (1 square inch should be enough):

Back (1, silver), Eye cup (2, black), Diopter (1, weird, black), Left side (2, black, long), Bottom (2, black), Motherboard (3 short, 1 long), Sensor (3 long, 1 short), Gasket (2), Sensor clip (2)

I’ll put the names of the screws in bold, so you know when to put them aside, and under what name. On my pictures, they are labelled in red. Things you have to remove are white and points you need to use a soldering iron are blue.

OK, let’s go

First step is to remove the rubber where you place your them when using the camera. Stick this to a clean surface (I cleaned a part of my desk and stuck it there). Under there you will find the silver Back screw. I know the picture doesn’t show my rubber grip bit, I got a bit over-excited before I took pictures.

Take off the eye cup and put it aside, you will find the two black Eye cup screws under it. Also unscrew the Diopter screw. (Apparently this is unnecessary)

Next thing to do is flip up the rubber on the left side of the camera and remove the two Left side screws. These are long, so this is handy for re-assembly (but you should have put them in their own section so this does not matter!)

Remove the two Bottom screws and put them into their section.

The back section of the camera should not lift away easily (DON’T LIFT IT OFF QUICKLY, THERE ARE RIBBON CABLES UNDER IT!). If it does not, check you have taken out all of the screws. As I mentioned, there are two ribbon cables under the cover for the screen and controls. You simple “flip” up the brown piece of on top and the cable should pull out (you can use your tooth-pick if they are fiddly, but they should not be hard to remove). When re-assembling, simply hold the cable in with your tooth-pick and click the brown hinge down. Put the back off to one side and warm up your soldering iron.

Remove the side by un-clipping the plastic and the rubber part from the hole shown in photo.

Next thing to do is de-solder the four points shown below. The soldering iron has to be very hot for this (apparently Canon use good quality solder on this!). Once you have removed the shielding, put it to one side.

Next thing to do is remove all of the required ribbon cables on the back. Refer to the picture for which ones to do. On the bottom left, you have to peel back the copper tape to reveal a cable that you simply remove with a tooth-pick, no hinges! Once this is done, remove the four Motherboard screws (noting the long one, I can’t remember which it is, perhaps someone could comment) noting, for re-assembly, the bottom left screw is the longer of the 3 (thanks CSe ;-) ).

Now that the motherboard is loose, you need to remove it. This is done by lifting it slightly and pulling it down. Be careful not to move it too far as it is still connected. Just turn it over on it’s left hand side and rest it on the rest of the camera. See picture. Also note sensor with two ribbon cables attached.

Next thing to do is remove the entire sensor assembly from the camera. Remove the 3 long and 1 short Sensor screws as shown, noting that the short one is on bottom left. I removed the sensor before I took the picture because I was over-excited. Put the camera off to one side.

Now we’ve just got the sensor. Welcome to the fun part.

If you are doing an IR conversion, remove the 2 Gasket screws as pictured, and the 2 Sensor clip screws on the other side.

These were the last pictures I took because of how stressed out I got. Canon use a lot of black silicone and a sticky backed gasket to stick the glass to the gasket and the glass to the sensor glass. You need to basically lever both away without breaking anything. I has quite a hard time.

When you have done this (removed everything from the sensor and got the glass out of the gasket) I did the following:

  1. Put the sticky-back gasket back onto the sensor (make sure no sticky stuff got onto the sensor).
  2. Put the (clean!) glass onto the sticky gasket.
  3. Put a load of silicone all the way round the glass.
  4. Put the sliver and back gasket back on.
  5. Wipe off any excess silicone.
  6. Leave to dry (for about an hour).
  7. Clean top part of glass.

Then I re-assembled the camera by following the steps backwards and all was good!

If some functions don’t work, you probably didn’t insert the ribbon cables fully!

The focus on mine needs adjusting (because of the glass’ different thickness and therefore different refractive index), but this is the same as all Canon cameras and there is a small hexagonal screw-hole under the hot mirror. More on this later in the week!

I hope this guide helps someone if they feel the task in a bit daunting!

Infrared,Photography

July 31, 2008

Getting your Lightroom work-flow back when using IR

Tags: , , ,

I’ve recently started taking infrared (IR) photos with a full time IR camera (a Canon EOS 300D.) This is all well and good until you come to editing them in your favorite RAW editor, Adobe Lightroom. Because Adobe Camera RAW (ACR) had a limit of 2000K for their RAW file’s white balance, you had to convert your image to another format (I used the TIFF format with dcraw) and then edit them.  This is a hassle, because it adds another step into the workflow, and because TIFF files are 16-bit, they are huge (32MB compared to 12MB for CR2′s).

Now that Adobe have released Lightroom 2.0 with ACR 4.5 you can create a custom profile for each camera and have the white balance settings preserved! Here’s how:

Firstly, grab the Adobe DNG Converter and the DNG Profile Editor.

Now grab an IR RAW file and put it in it’s own folder on your desktop. Open the DNG converter and select the folder you put it in (I put mine on my desktop)

Click convert, and you should have a fresh new DNG file in your folder.

Now fire up the DNG profile editor. Load the DNG that you just created and go to the Colour Matrices tab.

Slide the White Balance Temperature and Tint sliders as shown in the image above.

Then from the File menu choose Export DNG Camera Profile and save it in the default location.

We’re finished with the profile editor, so it can be closed. Open Lightroom and in the Library tab, choose Filter: Metadata. Select the IR camera that corresponds to the DNG we created earlier.

Now in the Develop tab, go to the Camera Calibration section, select the Profile we just created.

Now the image should look as it did on your camera when you took it, and the As shot white balance will be honoured. But we want this to be the default for all our current and existing images!

In Lightroom, choose Edit, Preferences and go to the Presets tab. Tick the box that says Make defaults to camera serial number and click OK.

Now we can set the default profile for a camera. Select the image we just chose the profile for. Whilst holding the alt key, click the Set default button we just enabled.

Press Update to Current Settings on the confirmation box (assuming you are using a full time IR camera)

This will now make this profile default on all of the new images that are imported to lightroom!

If you want to make all of the existing images in Lightroom have this profile, select all of the images from the IR camera (assuming you have the metadata filter on, you can just press Ctrl+A)

Now click the image you’ve set the profile to (don’t worry, this won’t deselect the others) and from the menu choose Develop Settings > Sync Settings.

In this dialogue, click the Check None button and then select the Calibration box.

When you click the Synchronise button, all of the images will be given the camera profile.

When I found this out (via the Infrared Photography Community Forums) I was very happy to be able to keep the same workflow as my visible light images!

Big thanks to Peter Cox for discovering this

Code,News,Rants

July 2, 2008

ReactOS and why is it (potentially) awesome

ReactOS Logo

When I stumbled upon ReactOS last week, I though of it as nothing more than one of those “hey, here’s another great idea that will ultimately die out from lack of enthusiasm” projects. After some thought, I decided this is one of the greatest ‘hit-or-miss’ projects I have seen for a long time. This is because it is basically a clone of Windows.

Although strictly speaking, it is a clone of the Windows NT subsystem, with a new (particularly familiar looking) shell to use it in. The benefits of this operating system are amazingly awesome, and I’ve decided to list some of them for you that I will be looking forward to. I may even decide to have a hand in developing them if I get some time.

This list is more like potentials than actual features that could be implemented (so take them with a grain of salt) because they are all, as I see it, a huge amount of work for anyone.

  • No annoyances (potentially); the fact that this projects is open source means that anyone can develop it. Now, in practice, this is not the case. Not everyone can program, nor does everyone want to, but this young operating system will potentially inspire everyone to give it a go.
  • Software support;
  • Hardware support;
  • Familiarity;
  • Expandability;

Hopefully this list has given you some insight into what I personally expect from the project when it reaches its final stages (because it is nowhere near at the moment). I will definately be keeping my eye on it, and really hope it does not go the same way as so many other great projects.

Infrared,Photography

June 30, 2008

300D Infrared conversion

So after buying a (relatively) cheap Canon EOS 300D locally, I decided to convert it for Infrared photography.

Normal infrared photography would mean buying a filter (typically a Hoya R72), composing the image on a tripod, fitting the filter in front of the lens with correct filter size and taking a long exposure (~30 secs in sunlight). This still doesn’t yield a very good photo as the noise generated by the process is substantial.

What I did (with the guidance of wnelson of POTN) was to replace the filter in front of the sensor itself with one that allows radiation with wavelength greater than 715nm (to ~1200nm) to pass through. This allows only (invisible to humans) infrared to pass through, resulting in images such as this:

My back garden

All in all I think the 20 or so hours I spent disassembling, driving around to get parts and stress was well spent :-)

Code,News

June 23, 2008

Full Motion Violence

No, I am not becomming an axe murderer. Full Motion Violence (fmv) is the name of a Counter-Strike Source clan that has been revived by it’s previous leader, Adam (a.k.a. Terminator or Hack^)

Back in the days of Counter-Strike 1.6 the A-Team players (which I filled in for occasionally) were at the top of the most prestigious league of the time, Enemy Down. Now that some players have been reassembled and new ones scouted to play for us we are re-entering the league and hoping for the best.

The reason I am featuring it on my blog is I am also the webmaster for the fmv site and have created some WordPress themes and plug-ins that I will be publishing on here. The theme I originally created was my first, so will not be publicly shown (it was pretty terrible), but I have created a WordPress Widget for monitoring Source Engine servers from WordPress. This will be published soon (it needs some proper testing!)

Blog

June 9, 2008

My Free Time

Now that I have finished at University (with a 2:1, yay!) I am looking for a job. Now that I have a lot of free time I can develop all of the applications I started at Uni that were benched because of workload. I will be publishing them on this blog in a number of weeks when they are polished and compiled for the main operating systems (Windows, Mac OS X and Linux.) Most of the programs are inspired by popular shareware and trial software or only for a single operating system, such as NewsLeecher, Magic File Renamer and The Regex Coach.

Uncategorized

March 29, 2008

Amazing Invention

T-BuddyThis is completely stolen from pure|zing, but it’s an awesome idea!

Brilliant! Solid, attractive, and innovative, you are going to want this hot or cold, go anywhere, brew coffee or tea container!

Nine inches tall and made from an unbreakable PC (polycarbonate) product that is temperature resistant up to 137 degrees Celsius, a brewing element is part of the design…. and it doesn’t have a plug!

The smaller removable cap is for drinking from and is the end that you add water to. This smaller cap additionally has an air vented pressure relief lid that makes it safe for hot liquids. The wider base also has a removable end, and is where you pour loose tealeaves, flora tea, fruit tea, herbal infusions, or coffee grounds into a fine gauge sieve.

Start by putting the tea or coffee in the brewing sieve and put the cap back on the base end. Turn the container over and add hot or cold water into the drinking end. After steeping, remove the cap and drink your hot or cold tea or coffee!

If you use the T-2Go Green Tea, you never even have to remove the tea leaves after steeping as they never make your tea bitter! If you are using some other kind of tea, or even coffee, when the brewing is done, flip the container, unscrew the wide end, remove the filter and dispose of the contents. Put the filter back in…and the base back on. You now have a portable, freshly brewed 20 or 25-ounce container of the beverage of your choice!

In a hurry in the morning and don’t have time to wait for your coffee to brew? Add your ground beans to the wide end, pour hot water in the other, and leave for the office: your coffee will brew on the way! Want a great tea when everyone else is drinking coffee? Have your favorite tea or even tea bags in the infuser…and all you need is hot or cold water. You have tea to go in your own personal, attractive container!

This container comes with a simple black neoprene sleeve to protect your fingers from heat as well as a simple and sturdy carrying strap that snaps to the tiny eyelets just below the drinking cap. We find that the neoprene sleeve also helps to insulate the contents, helping to keep contents hot or cold for a longer period and the strap is large enough to fit over your wrist if you are carrying other objects.

The design is simple, elegant and can comfortably be used by men or women. The look is clean and contemporary and is easy to assemble, wash, dry, and store. This container also arrives in a sturdy box with complete directions that are easy to understand. This innovative concept would be great as a gift for anyone that you know who loves freshly brewed coffee or tea. Our whole team loves the ease of use, the portability and that it can be used for tea or coffee, whether it’s hot or cold. Very versatile and easy to use, this is Pure Zing!!