/ DIY our die

Trumps speech according to speech recognition

Published januar 20th, 2017 by

The following text is an automatic transcription of Donald Trump's inaugoration speech, made using the vanilla window.SpeechRecognition in javascript, code provided by the lovely Wes Bos with a few small additions by me.


Posted in Testing


Published september 29th, 2015 by

Skulle egentlig ha dette prosjektet ferdig til Trondheim Maker Faire. Prototypen funker, og spiller av samples når man holder nede knappene, men rakk ikke gjøre orgelet helt ferdig.

Kan testes på
(Vent til det står Ready, da er lydene lastet inn. Trykk og hold nede piltastene. Lyden spiller så lenge tasten er holdt nede.

Drivorgelet spiller av lyder fra havet, og knappene har LEDs som lyser opp gjennomsiktige mangefargede klinkekuler når de er aktiverte.

Logikken gjøres på PC (via nettleser) via web audio api, og knappene er koblet til en hendig USB keyboard-emulator fra, kjøpt via Ebay.

Eta: Neste Maker Faire?


Posted in Artwork, DIY, Open Source, Postapokalyptisk Supermarked

Code: Showing a list of youtube videos using gdata and xslt with php

Published september 16th, 2008 by

Let’s start with a little demonstration. The section below is made by calling the php-script within an iframe:

Why iframe?
Just to make it easier to reuse and embed Youtube videos on different sites, and because it makes it easier to try out new ideas without adding messy bits to a larger project. Sort of like rapid prototyping/proof of concept before «committing» to a feature and spending alot of time integrating something you might end up throwing out.

This solution currently consists of these files:
youtube.php, takes s=whateveryouwanttofind and max=number of videos to return as GET parameters
youtube5.xsl, does all the transformation of the xml from youtube into lovely xhtml.
youtube.js, javascript file that handles clicking on the thumbnails to load a new video, using innerHtml
youtube.css, minimalist styling to keep things pretty.
swfobject.js, for embedding flash

The xslt:

<?xml version=»1.0″ encoding=»UTF-8″?> <xsl:stylesheet version=»1.0″ xmlns:xsl=»» xmlns:fn=»» xmlns:gd=»″ xmlns:media=»» xmlns:n1=»» xmlns:openSearch=»» xmlns:xdt=»» xmlns:xs=»» xmlns:xsi=»» xmlns:yt=»″ xmlns:altova=»»> <xsl:output method=»html» encoding=»ISO-8859-1″ doctype-public=»-//W3C//DTD XHTML 1.0 Transitional//EN» doctype-system=»»/> <xsl:param name=»SV_OutputFormat» select=»‘HTML'»/> <xsl:variable name=»XML» select=»/»/> <xsl:template match=»/»> <html> <head> <title> – Youtube playlist</title> <link rel=»stylesheet» href=»youtube.css» media=»screen» /> <script type=»text/javascript» src=»youtube.js»></script> <script type=»text/javascript» src=»swfobject.js»></script> </head> <body> <div id=»youtube»> <h1>YouTube Playlist</h1> <xsl:for-each select=»$XML»> <xsl:for-each select=»n1:feed»> <xsl:if test=»n1:entry[1]»> <div class=»youtubevideo»><div id=»cur_video»> <xsl:for-each select=»n1:entry[1]/media:group/media:content»> <xsl:if test=»@type = ‘application/x-shockwave-flash'»> <embed> <xsl:attribute name=»src»> <xsl:value-of select=»@url»/> </xsl:attribute> <xsl:attribute name=»width»>480</xsl:attribute> <xsl:attribute name=»height»>385</xsl:attribute> <xsl:attribute name=»quality»>high</xsl:attribute> <xsl:attribute name=»bgcolor»>#000</xsl:attribute> <xsl:attribute name=»id»>cur_video_swf</xsl:attribute> <xsl:attribute name=»name»>cur_video_swf</xsl:attribute> </embed> </xsl:if> </xsl:for-each> </div> <!– ends cur_video –> <div id=»cur_video_title»> <xsl:value-of select=»n1:entry[1]/n1:title»/> </div> </div>    <!– ends youtubevideo –> </xsl:if> <div class=»youtubethumbs»> <xsl:for-each select=»n1:entry»> <xsl:if test=»position() > 1″> <xsl:for-each select=»media:group»> <div class=»youtubethumb»> <xsl:for-each select=»media:content»> <xsl:if test=»@type = ‘application/x-shockwave-flash'»> <a> <xsl:attribute name=»href»>#</xsl:attribute> <xsl:attribute name=»onmousedown»>PlayVideo(‘<xsl:value-of select=»@url»/>’,’’, ‘Youtube’, true);</xsl:attribute> <xsl:attribute name=»onclick»>return false;</xsl:attribute> <xsl:for-each select=»../media:thumbnail[1]»> <xsl:element name=»img»> <xsl:attribute name=»src»><xsl:value-of select=»@url»/></xsl:attribute><xsl:attribute name=»lowsrc»>lowsrc.gif</xsl:attribute><xsl:attribute name=»width»>100</xsl:attribute><xsl:attribute name=»height»>60</xsl:attribute> </xsl:element> </xsl:for-each> <xsl:value-of select=»../media:title»/> </a> </xsl:if> </xsl:for-each> </div> <!– ends avslutter class youtubethumb –> </xsl:for-each> </xsl:if> <!– end if on position > 0 –> </xsl:for-each> </div><!– ends class youtubethumbnails –> </xsl:for-each> </xsl:for-each> <div class=»youtubefooter» style=»clear: both; color: #999999; font-size: 0.8em;»>Disclaimer: These videos are retrieved from Youtube through a simple search. Even though the search is done with a filter to remove «inappropriate material», it may still contain videos deemed offensive by some. Videos may or may not be in violation of international copyright law.</div> </div> <!– avslutter id youtube –> </body> </html> </xsl:template> </xsl:stylesheet>


$searchterm = $_GET[«s»];
$maxresults = $_GET[«max»];

/* load the xml file and stylesheet as domdocuments */
$xsl = new DomDocument();
$inputdom = new DomDocument();


$inputdom->load(«» . $searchterm . «&max-results=» . $maxresults);

//if you want to test with a local file

/* create the processor and import the stylesheet */
$proc = new XsltProcessor();
$xsl = $proc->importStylesheet($xsl);
//$proc->setParameter(null, «titles», «Titles»);
//not in use, but needed if you want to pass variables into the xslt from php

/* transform and output the xml document */
$newdom = $proc->transformToDoc($inputdom);
print $newdom->saveXML();

Posted in Code, Open Source

My wonderous Greasemonkey Idea

Published oktober 2nd, 2005 by

Adolf MacDonald
photo credit: Walt Jabsco

Greasemonkey (and other solutions for Opera and Windows) allows you to customize the way a webpage displays using small bits of JavaScript. Hundreds of scripts, for a wide variety of poular sites, are already available in the Greasemonkey script repository at

You can write your own scripts too. Mark Pilgrim’s definitive Greasemonkey guide, will show you how.

Greasemonkey Extension for Firefox

User Scripts

My new brilliant idea:
I haven’t used Greasemonkey that much yet but for years I’ve wanted a solution to get easy information about the ethical and environmental profile of a firm or product when I’m in a store. Unfortunatly this is not really feasible, but it could be done in the web using Greasemonkey (+ a wiki of conserned citizens, and perhaps import of existing data (?) by XML. And then the option to edit the wiki througt a greasemonkey script.)

I think I will check if there are any only databases with this kind of data, I know there used to be one in Norway. If you have any tips, just write a comment.

Supercool scripts:

Wikiproxy: Greasemonkey Edition
Inline Mp3 Player
Gmail: Random Signature.
Mailto Compose In GMail (with choice)
Jer’s Wonderful World of Internet

Another Cool Idea:
Replace banner-ads etc with artwork and poetry, or random naked chicks. I think the name should be Prettify-the-web! :)

Posted in Activism, Code, Ideas Amazon Sambok and BIBSYS ISBN Search

Published oktober 1st, 2005 by

La caverne aux livres
photo credit: gadl

Hey, my first Greasemonkey userscript! Amazon Sambok ISBN Search:

This is just a fast remake of the Hight Library Linky script. Its my first script, just wanted to check out how hard it would be to rework. Luckily for me it was super easy. It inserts links to two norwegian bibliographical databases.

Bibsys, containing material from universities and colleges.
And Sambok, containing material from most Public Libraries in Norway.

Pretty useful, at least in theory, since ISBN search is quite limiting. But it will have to do for now.

Posted in Code, Ideas, Portfolio, Webdev