Sunday, November 02, 2008

daily tweets

  • 22:00 Finished Philip Dick's Radio Free Albemuth: what a flop... #

Friday, October 24, 2008

daily tweets

Tuesday, October 21, 2008

daily tweets

  • 12:49 Got my new OCZ Rally2 USB 2.0 dual channel 16GB flash memory drive (tinyurl.com/o3ph9). I can now make that odd DVD soft copy. #

Monday, October 20, 2008

daily tweets

  • 17:29 Lunch at Milos, hilton. Best restaurant service ever. #
  • 19:58 Vicky Cristina Barcelona=Woody Alen's sexual fantasies. Thank you very much, my own are more than enough. I'll tell my little niece though.. #
  • 20:31 Best "commercial" feta cheese: Sgouritsas, Taygetos. Hard to find (Vassilopoulos, N. Psychiko is one place I know) and pricey; my favourite. #

Saturday, October 18, 2008

daily tweets

  • 01:07 Just came back from Nonna pina, Daphni. A good italian restaurant it turned out to be. #

Friday, October 17, 2008

daily tweets

Thursday, October 16, 2008

daily tweets

  • 22:18 Vaio gives me: "The installed battery may not be properly connected to the computer or may not be compatible with the computer" ??!!?!?!? #
  • 22:32 Kill ISBMgr.exe process to stop nagging message. Run msconfig and uncheck ISB Utility in Startup tab. Sony's ISB Utility update went tits up #

Wednesday, October 15, 2008

emails, images, base64 and html

How many times have you received an image-laden email that can't quite show itself properly and instead you get the source? This is a recent email I received in Outlook:


Return-Path: <sender@gmail.com>
X-Original-To: you@somedomain.com
Delivered-To: you@somedomain.com
Received: from localhost (localhost [127.0.0.1])
.
.
. 
by Subject: More 3D Chalk Drawings by Julian Beever!
In-Reply-To: <BAY123-DS3D0865B1F4499DF30C37EA6310@phx.gbl>
MIME-Version: 1.0
Content-Type: multipart/related; 
 boundary="----=_Part_66037_8745117.1224059387776"
References: <BAY123-DS3D0865B1F4499DF30C37EA6310@phx.gbl>
To: undisclosed-recipients:;

------=_Part_66037_8745117.1224059387776
Content-Type: multipart/alternative; 
 boundary="----=_Part_66038_2852077.1224059387777"

------=_Part_66038_2852077.1224059387777
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Excellent, as usual!

------=_Part_66038_2852077.1224059387777
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div dir="ltr"><div class="gmail_quote"><br><br><br>
.
.
.
</div><br></div>

------=_Part_66038_2852077.1224059387777--

------=_Part_66037_8745117.1224059387776
Content-Type: image/jpeg; name=image008.jpg
Content-Transfer-Encoding: base64
Content-ID: <image008.jpg@01C92D89.A8F97520>
X-Attachment-Id: 0.8

/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIf
.
.
.
d1qMmLqKKoagXqjRKiijQgpXJWePioorETGoxVvRRRUf/9k=
------=_Part_66037_8745117.1224059387776--

This is a mime-multipart html mail, that's got a few image/jpeg parts. To get the image(s) out of it, save it as .msg somewhere and open it with an editor (e.g. Notepad++). Look for the image part you're interested in:

Content-Type: image/jpeg; name=image008.jpg
Content-Transfer-Encoding: base64
Content-ID: 

Then strip everything off leaving only the base64-encoded image payload that appears beneath (the one that starts with /9j/ and ends in /9k= in our example). Save as say img-base64.txt. This should now look like:

/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIf
IiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7
...
JW+6Mj+7T9ixQoEAUFQTiqxPzn61zyep0QWhE4PULioGUk8mrjAbajYcGkiim2egpsSkvz0qcgUi
EjpSY0i1Gp2/KpxRUauxH3jRUG1j/9k=

This is your image, base64 encoded. The "save as .msg" bit was necessary as what's shown in Outlook is fiddled with and will not decode properly.

Now there are several options on how best to proceed. You may use Notepad++ builtin base64 decoding capabilities (TextFX, TextFX Tools, Base64 Decode) and save it as .jpg. Or, if Notepad++ is not available, you may use a command line utility for that, like the excellent base64 by John Walker.

Few people are aware though that the base64 payload can be used directly into html pages, letting the browser do all the hard work! The simplest way is putting the payload in an <img> element:


<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEA...UG1j/9k="/>

Likewise in a CSS background:

div.image {
  background-image:url(data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEA...UG1j/9k=);
}

This paradigm applies to other types of entities not just images. CSS stylesheets and javascript scripts can also appear as base64 encoded payloads in html pages. I will simply reiterate here two examples by Grey Wyvern:

<link rel="stylesheet" type="text/css" href="data:text/css;base64,LyogKioqKiogVGVtcGxhdGUgKioq..." />:  


<script type="text/javascript" href="data:text/javascript;base64,dmFyIHNjT2JqMSA9IG5ldyBzY3Jv..."></script>  

Now, I don't know why anyone would want to do that with javascript in particular, since base64 encoding bloats original size by a factor of 4/3, other than a perverse pleasure of tinkering about.

Tuesday, October 14, 2008

daily tweets

  • 23:19 I just now realized that all of the urls include the last dot when the tweets are posted to my blog! #

Sunday, October 12, 2008

daily tweets

  • 20:13 Happy go lucky: pleasant if you've lived in the UK. #
  • 01:50 Dinner at Pakindian, Menandrou: not that great food... #