Sunday, December 14, 2008

File Uploads with HAppS

I've updated the Not a HAppS Tutorial cookbook with an example of how to handle file uploads using file input types in forms.

Next step is to take a look at how sessions and session data is handled.

Categories: ,

Labels:

Monday, December 08, 2008

Not a Tutorial on HAppS

A long time ago I took a look at HAppS, a Haskell web application framework.

I recently got the excellent book Real World Haskell and have been working through the book. I wanted something to explore while doing this so I revisited HAppS to play around with web programming in Haskell.

There's some documentation out there on HAppS, compared to last time I looked at it. Some pointers:I found these very useful resources to learn about HAppS.

I'm documenting what I learn as I go, writing Not a HAppS Tutorial, but a cookbook of examples doing small things as I learnt them.

Not a HAppS Tutorial is hosted on a wiki written in HAppS called Gitit. It's a nice piece of work and it also proved very useful in learning HAppS, looking at the code for a working piece of software.

Categories: ,

Labels:

Random and Binary IO using Iteratees

I wrote previously about interesting developments related to left folds and i/o. Oleg Kiselyov has come up with more Iteratee based goodness involving binary i/o and random access.
Iteratees presuppose sequential processing. A general-purpose input method must also support random IO: processing a seek-able input stream from an arbitrary position, jumping back and forth through the stream. We demonstrate random IO with iteratees, as well as reading non-textual files and converting raw bytes into multi-byte quantities such as integers, rationals, and TIFF dictionaries. Positioning of the input stream is evocative of delimited continuations.
...
We show a representative application of the library: reading a sample TIFF file, printing selected values from the TIFF dictionary, verifying the values of selected pixels and computing the histogram of pixel values. The pixel verification procedure stops reading the pixel matrix as soon as all specified pixel values are verified. The histogram accumulation does read the entire matrix, but incrementally. Neither pixel matrix processing procedure loads the whole matrix in memory. In fact, we never read and retain more than the IO-buffer-full of raw data.


Categories:

Labels:

Thursday, December 04, 2008

Firefogg: an extension to encode and upload ogg videos

I got an email today about a great new extension that is being worked on to help with sites supporting Ogg Theora videos. Firefogg is a Firefox extension to allow selecting a video, encoding it into Ogg format, and uploading it to a server. Sites supporting this extension can receive videos transcoded to Ogg with all the work to do the transcoding done by the client.

The site has details on the client side JavaScript API as well as source for some server side examples using PHP and Django. The extension itself is open source. I plan to add support for this to tinyvid.tv to enable video uploads in Theora format.

Note that the extension requires a nightly build of Firefox 3.1.

Categories: , ,

Labels:

SRT Subtitles with HTML5 video

j^, the author of many cool open video related projects (including the Theora transcoder ffmpeg2theora) has written a jQuery based library to extract and show subtitles while a <video> is being played.

The jquery.srt page has details and a demo. Embedding code looks like:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.srt.js"></script>

<video src="http://example.com/video.ogv" id="video" controls>
<div class="srt"
data-video="video"
data-srt="http://example.com/video.srt" />
SRT is a common subtitle format and with this solution you can easily add subtitles to your HTML 5 videos.

Categories: , ,

Labels:

Changes to git mirror of Firefox repository

I've made changes to the way I manage the git repository holding the import of the Firefox source. Since the bulk of the HTML 5 <video> implementation is now in the main Firefox source I no longer maintain the video branch. I'll be removing that and the Firefox mirror soon.

The main Mozilla repositories have been split into two now. They are mozilla-central, which holds the current trunk code and represents Firefox 3.2 (or whatever the next version will be called), and mozilla-1.9.1, which is what will be Firefox 3.1. The details of that split are described in this post.

I now import these mercurial repositories directly into git using git's fast import tool. This gives me complete history and makes things like bisect and blame a bit easier to work with. The history of mozilla-1.9.1 being based on mozilla-central is also retained, as best as I could manage. These imported repositories can be browsed at http://gitweb.bluishcoder.co.nz. They can be retrieved via git:
git clone git://bluishcoder.co.nz/git/mozilla-central.git
git clone git://bluishcoder.co.nz/git/mozilla-1.9.1.git
The way I work with these mirrors is to create a git repository that has these added as remotes. This way I can switch between the two easily, cherry pick patches between them, and do logs and diffs between them. This is how I set that up:
$ mkdir firefox
$ cd firefox
$ git init
$ git remote add mozilla-central git://bluishcoder.co.nz/git/mozilla-central.git
$ git remote add mozilla-1.9.1 git://bluishcoder.co.nz/git/mozilla-1.9.1.git
$ git fetch mozilla-central
$ git fetch mozilla-1.9.1
When working on a bug I create a branch for that bug, based on mozilla-central/master:
$ git checkout -b bug123456 mozilla-central/master
...make changes...
$ git commit -a -m "my changes"
$ git diff -U8 mozilla-central/master >bug123456.patch
...attach bug123456.patch to bugzilla for review...
Once reviewed the patch is then applied to mercurial and pushed. If I want to apply the same patch to test on the mozilla-1.9.1 branch I just use 'git cherry-pick'. To make things like 'git status' a bit less clutted I have the following .gitignore:
$ cat .gitignore
obj-*
*~
.mozconfig
config.cache
config.log
*.pyc
CVS
.mozconfig*
.svn
cvsco.log
cvsco.log.old
NONE
configure
gitchangelog
gitchangelog.bak
.hg
.nss.checkout
*.swp
.gitignore

Categories: ,

Labels: