From webpage to Kindle e-book

11. mars 2011

Actually, this little post should have been called «How to create e-pubs from web-pages, convert them to .mobi, and read them on your Kindle». But that was too long. I am short on time so I am just going to sum it up for you:

Forget about the content below: just use SendToReader – it is the easiest, most hassle-free solution by far 🙂 (Thanks go to Sergey!)

  1. Add the little bookmarklet from dotEPUB. This will enable you to convert any webpage to the epub format instantly. Pretty much like the pdf-printers most people are accustomed to.
  2. Download Calibre – a free-for-all e-book management system that can convert from/to any format. Available for all operating systems
  3. Go to any web page you would like to have converted and press the dotEPUB bookmarklet to get a epub version.
  4. Add the epub books you now have created to Calibre
  5. You can now mass-convert the titles to mobi or do this per title.
  6. Use Calibre to add them to your e-book reader. It can even send books using e-mail (for instance using Amazon Whispersync to deliver books to your Kindle).

There you go. Any web page is now downloadable as an e-book for your reading device of choice!

Lessons learned in JavaScript, Part 1: Cross domain JSON and Firebug logging

19. november 2010

Firebug has a little utility feature where you can log messages in your Javascript code to Firebugs console. This works a lot better than using a heap of alert() calls, but only works if you have Firebug running. Of course I found out the hard way when showing my work with Firebug turned off, at which time the code broke due to this undefined (actually undeclared) «console» variable.

Lesson learned: if you want to produce logs to see in Firebug, check to see if the console variable is declared. Now of course, you could check this before every call like this

if( typeof(console) != "undefined" )
  {console.log("graphBuilder(): success");}

The stupid with this approach is that you cannot move this bit into a function since the undeclared variable would throw a runtime error the moment you tried to pass it as an argument. What does work (for me), is that I define my own log() method and do the check within this. If console is not defined (e.g. Firebug is not loaded), I define both the console and the log function so they don’t throw a runtime error. The code looks like this:

function log(log_message) {
  /* check to see if Firebug is loaded. */
  if( typeof(console) == "undefined" ) {
    /* Avoid runtime errors by defining 
        the console object and its associated functions 
    console = {}
    console.log = function(arg){;}
  else console.log(log_message);

BTW, to those new to Javascript, variables have function scope, not block scope, so declaring a variable in the if statement works 😉

The other tidbit of knowledge I recently learned concerns JSON and the same origin policy. In theory, most modern browsers should not allow a script to call a service residing on a domain different from the page. So why does the following call work?

service = ''
parameters = {
$.getJSON(service, parameters, function(data) {

After posting the question on StackOverflow I found about a new header that is supported by newer browsers (for instance Firefox 3.5+) called  «Access-Control-Allow-Origin». If this header is set to allow * (meaning all domains), the request is let through by the browser to the calling script. You can also use this to whitelist specific domains. AFAI can tell, this could be a way of avoiding JSONP if your site has public, non-sensitive information.

<title /> bug in Internet Explorer

19. april 2008

Just thought I would bring along my experience on this little known bug in Internet Explorer. Les resten av dette innlegget »

Når Dilbert bare ikke er nok.

19. april 2007

Min nye favoritttegneserie
Min nye favoritttegneserie. For en gangs skyld føler jeg faktisk at jeg får bruk for utdanningen min i en kulturell sammenheng. Hurra.

Klassisk Ystenes m.m.

16. januar 2007

«Det var en anakreontisk ode med en så transcendental verbalisering at jeg er stolt av den selv.» Fant et klassisk leserinnlegg fra kjemiprofessor Martin Ystenes der han bit for bit renplukker dr.philos Stein Erik Johansen for enhver rest av akademisk ære. Høres dødtrøtt ut, men det fikk meg til å holde meg våken helt til slutten kl. ett på natten. Anbefalt!

Og vi har også: Magnekyl-brennstoff! Verdens energi- og miljøproblemer er løst!

Looks, Body, Service, BJ, Recommendation

27. desember 2006

Nettets veier er uransakelige… Lette etter sangen «Rock the Catbah» og endte opp på et forum for horekunder i Singapore. Sangen heter forresten «Rock the Casbah» og ikke «.. Catbah», fant jeg ut… Er det forresten noen som kan fortelle meg hva «The Clash» synger om i denne sangen?

Smak av kjendislivet

4. juni 2006

Gigolo Joe, what do you know? Ved en tilfeldighet fant jeg ut jeg har fått litt kudos på CasioNova . Wow, tenk… nå er jeg nesten kjendis på bloggen til en nerdete elektronikafyr fra Brisbane som utelukkende spiller på gamle Casio-keyboard fra åttitallet. Hvem skulle trodd at jeg noensinne skulle komme så langt i livet…