Weather Balloons and New Arduino Shields Have Arrived

Weather BalloonThis week I received several very exciting parcels of stuff, for my near-space photography project.

First was my weather balloons and parachutes, which came from Flow-Tronic, a company in Belgium. What a weird package, two bright orange plastic parachutes and two clear plastic bags with what are essentially giant 1.5m long condoms in them! The really extraordinary things is that although the balloons will start out at about 1.5m across when inflated, they will expand as they rise (due to the drop in atmospheric pressure) and will end up about 7m across before they burst. That is frickin’ huge!

The next packages to arrive were some new electronic gadgets for the tracking and communication part of the project. After not having much luck with my Navman Jupiter GPS modules (struggled to get a fix), I decided to bite the bullet and get a decent one, as well as the brilliant GPS and SD Card Logger Shield from Adafruit, built specifically for the Arduino. This comes in kit form, so will require me to get my soldering skills back up to scratch.

GPS and SD Card Logger KitI also bought a Cellular Shield from Cool Components which gives you SMS, GSM/GPRS, and TCP/IP capabilities to your Arduino project. I’ll be using it to send SMS messages of the units current location from the above mentioned GPS receiver. This should allow tracking of the weather balloon when at low altitudes, and hopefully aid in recovery when it comes crashing back to earth! This means I will have two stacked shields on my Arduino, so this will require some careful planning to make sure they won’t interfere with each other.


PHP Quine

I was reading the Wikipedia page on Quine programs, which are computer programs whose only output is their own source code. At first glance this sounds simple until you think it through, your mind ends up recursively parsing pseudo code! It took a while to get my head round how they work, but in the end it kinda made sense.

I decided to port one of the given C examples into PHP as an experiment, and here is what I came up with (I think it’s correct at least!).


If you run this in PHP it should, well, output the above! Try it and then diff the output to the original source. Fingers crossed it should be the same.

It seems that the ‘challenge’ is to find the shortest possible quine in any given language. Since making the above I have found other PHP examples that use a very similar approach but cut down the code even further, such as this nice example from Komea Pimeässä:


It uses some nice PHP shortcuts to remove unnecessary characters, like dropping the trailing ?> and putting the string assignment ($q=’…) as the first parameter of the printf call, instead of declaring it outside the function call and then referencing it again which wastes characters. It also uses one final difference from mine, and one which I wasn’t aware of, and that is using numbered specifiers in the printf function (%1$c in this case), so he can reuse the first specifier (%c) twice in his string without needing to declare it twice in the function call. Nice.

I don’t think I’m likely to find any way of shortening that further, but I’ll keep thinking it over.

UPDATE (15 minutes later):

I just had a thought on this, It may be considered cheating but surely this is a tiny valid PHP quine:


Or, in fact, and text. Why do we need to actually break into PHP mode? It’s still a valid PHP file, and it will indeed output only it’s own contents, but it does just seems like a dirty trick. It doesn’t seem right that it doesn’t actually include any PHP statements.

After thinking of this, I had a more detailed read of the Wikipedia article for any rules. In fact it mentions that someone once submitted an empty file as the shortest possible quine in a C programming competition. They did however win the “worst abuse of the rules” prize. So maybe this single caracter PHP example just another, albeit not quite so short, example of the same abuse of rules? I’ll let someone else argue over that!

Arduino has arrived!

ArduinoMy Arduino has arrived, feeling very geeky now. I haven’t done any electronics in quite a while, so looking forward to finding something to do with it now!

First quick script fades three LEDs (Red, Green and Blue) through the colour spectrum. Unfortunately I don’t have a blue LED to hand so the effect is a little lost, but the principle is there at least!