Andy Wenk

Dec 17

CouchDB Buch Website

Moin Moin,

Till Klampaeckel und ich haben ein Buch über CouchDB geschrieben. Es ist im Galileo Computing Verlag erschienen. Till hat ausserdem eine coole website mit vielen Informationen, Code und Links zum Buch erstellt. Einfach mal hier gucken:

http://www.couchdb-buch.de

Cheers

Andy

Dec 10

Image Manipulation with Ruby gem MiniMagick

Moin Moin,

in a recent project, I have to resize uploaded images because the images have to be shown in a gallery. The user who uploads the image likes comfort, so I started to use

https://github.com/jnicklas/carrierwave

for handling the upload and

https://github.com/probablycorey/mini_magick

to resize the images in the upload process. MiniMagick is a wrapper for the cli tool

ImageMagick

well known for its huge image editing possibilities

If you just need basic resizing, carrierwave can do the job for you as well.

Here’s a simple example (taken from the github site). The script is called magic.rb and there is a image called input.jpg in the same folder. where I run the script:

#!/usr/bin/env ruby

require 'rubygems'
require 'mini_magick'

image = MiniMagick::Image.open("input.jpg")
image.resize "100x100"
image.write  "output.jpg"
puts "width: #{image[:width]}"
puts "height: #{image[:height]}"
puts "compression: #{image["%Q"]}"

The output is:

duke@Macintosh:~/workspace/programming/ruby/MiniMagick$ ./magic.rb 
width: 71
height: 100
compression: 99

Simple! But the one thing I wanna point you to is the following line in magic.rb:

puts image["%Q"]

This is cool, because you can use the format options provided by ImageMagick. You can find a list of all options at

http://www.imagemagick.org/script/escape.php.

So again a cool gem which saves hours of work!

Cheers

Andy

Aug 30

How Browsers Work Article (Tali Garsiel)

Moin Moin,

I recently read the super awesome article “How Browsers Work” here:

http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/

Paul Irish cleaned up the original article written by Tali Garsiel, an Israeli developer. You can find her article here:

http://taligarsiel.com/Projects/howbrowserswork1.htm

I strongly recommend all people who develop software for the web to read this article. It provides a great look behind the scenes of how browsers work. The topics are:

_ the rendering engine - processing the HTML document
_ the parser with it’s lexical and syntax analysis - the lexer (tokenizer) creating tokens and the parser constructing the pars-tree by applying syntax rules
_ the HTML parser based on a DTD
_ the resulting DOM-tree after parsing HTML
_ the parsing algorithm of the HTML Parser
_ the tokenization algorithm
_ the tree construction algorithm creating elements of the resulting DOM-tree and each of it’s token
_ CSS parsing
_ render tree construction
_ creating the layout (or reflow) out of the render tree
_ the painting process - display the content elements by traversing the created render-tree
_ the CSS2 visual model

This is a lot of stuff and actually I am reading the article the second time. Imho the biggest benefit of studying the article is the deeper understanding how all the components of a browser work together to present the resulting website.

Here are some links I extracted for further reading.

_ The webkit rendering engine used by Chrome and Safari browsers: http://www.webkit.org/

_ context free grammar:
http://en.wikipedia.org/wiki/Context-free_grammar

_ Flex parser generator:
http://en.wikipedia.org/wiki/Flex_lexical_analyser

_ Bison parser generator:
http://www.gnu.org/software/bison/

_ HTML5 specification:
http://dev.w3.org/html5/spec/Overview.html

_ WHATWG community working on HTML:
http://www.whatwg.org/

_ parsing HTML:
http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html

_ HTML syntax:
http://www.w3.org/TR/html5/syntax.html#html-parser

_ CSS2:
http://www.w3.org/TR/CSS2/

_ CSS specification:
http://www.w3.org/TR/CSS2/grammar.html

_ CSS2 box-model:
http://www.w3.org/TR/CSS2/box.html

Some of the links are kind of lame to read in a way but still very interesting for digging deeper.

I hope you enjoy reading the article the same way I do.

Cheers

Andy