Wednesday, April 20, 2011

Wow, Michael Abrash's graphics programming black book is available here
http://www.gamedev.net/page/resources/_/reference/programming/140/283/graphics-programming-black-book-r1698
Couple of quick tips -

To concat multiple pdfs -
gs --sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite-sOutputFile=output.pdf file1.pdf file2.pdf file3.pdf [...]


I got it from - 
http://doeidoei.wordpress.com/2009/04/12/easy-way-to-concatenate-pdf-files-in-ubuntu-linux/

Second ... httperf complaining about unavailable file handles - check out
http://gom-jabbar.org/articles/2009/02/04/httperf-and-file-descriptors
and http://www.cs.uwaterloo.ca/~brecht/servers/openfiles.html

Wednesday, April 13, 2011

Even better is http://www.bolet.org/jgz/index-en.html - much more modular hence easier to understand

Monday, April 11, 2011

I found a pure ruby implementation of zlib - https://github.com/djberg96/pr-zlib -  god bless the authors

I'm gonna try a Haskell port :)
lmbench

looks like we need to get into the results dir and do a make summary to get human readable results.

Monday, March 07, 2011

Haskell Parsec

I am going to illustrate the usage of Parsec to parse an expression into an AST. Something that took me quite a while to come up with (with help from the cafe) - Hoping, someone will find this useful

http://legacy.cs.uu.nl/daan/download/parsec/parsec.html has a sample for expression parsing - but that evaluates the expression.

And if you have not looked at http://www.cse.chalmers.se/edu/year/2010/course/TDA341/Papers/parser-hutton.ps - please do so, and fall in love with Haskell all over again :)

Say you have created an AST as follows -


data Tree a = Nil | Node a (Tree a ) (Tree a) deriving (Show)
data Element = Number Float | Plus | Minus | Multiply | Divide deriving (Show)
type AST = Tree Element


And given an expression 1+2, you need to parse it into the above mentioned AST -

Right (Node Plus (Node (Number 1.0) Nil Nil) (Node Multiply (Node (Number 2.0) Nil Nil) (Node (Number 3.0) Nil Nil)))


Full code for it is here - https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/parsec/FormParse.hs

Beautiful, is it not!

Sunday, January 17, 2010

I finally got around to play with Midi Haskell...

cabal install Haskore ...

then downloaded Haskore package from hackage and tried out a couple of programs in the examples dir ... they beautifully generate midi files!!!

I think I need to revisit the Haskell School of Expression!

Thursday, December 24, 2009

yield in Ruby took a while to sink in - Today, I used it for an implementation and thats when I understood it well - For the new year greeting program - to send automatic customized emails.

I had to send customized inline images in the email - for that I had to write an Image manipulation program. I used Ruby for that (Only because I am not comfortable with Haskell yet!) git://github.com/ckkashyap/UtilityPrograms.git

So the Image class contains [] operators etc but for any function to be applied on the image, you typically need to go over each pixel and change it in some manner. Also, if the color value went out of the range (less than 0 or greater than 255), it had to be brought back into the range. I found myself uninterestingly repeating the act of traversing over the pixels and ensuring that the resulting value stayed in the range. That's when it occurred to me that I could abstract it out into the image class into a function called - apply function! - it looks like this

def applyFunction
@width.times do |x|
@height.times do |y|
(r,g,b)=self[x,y].unpack("C*")
(r,g,b)=(yield x,y,r,g,b).map! {|c| Image.normalizeColor c}
self[x,y]=[r,g,b].pack("C*")
end
end
end

Monday, July 06, 2009

Okay ... I got a little confused by map.map working on list of lists!

so it turns out that f.g = \x -> f (g x)

so, map.map = \f -> map (map f)

(map.map) (+1) list = (\f -> map (map f)) (+1) list = map (map (+1)) list
Everything seems already done!

I always found writing GUI code boring - always involved boilerplate code - be it, X windows, Windows, AWT ....

So, I was thinking of writing some automation in Haskell that could generate Swing code - looks like SwingML does just that - not in Haskell though.

Friday, June 05, 2009

Quick Web development with Apache and Haskell (with a slight touch of Perl)

I started learning Haskell a few months ago. It has been a personality changing
experience! Because of the blub paradox - Unfortunately, no one can be told what the Haskell Experience is. You have to feel it for yourself.

Haskell has been the most difficult computer language that I've learnt so far (C,x86 ASM, Perl, Ruby, Java) - From what I understand, my long term exposure to those imperative languages is one of the reasons why I find it difficult.

I am sure, there are many out there who have just begun their Haskell journey. So, here's a quick way in which you could develop Hakell programs that do something interesting - Web development.

Okay, I assume, you know how to setup Perl CGI in your apache web server. It works by default on the Apache installation on my RHEL5 Laptop. The idea is to use a small bridge CGI script in Perl that executes standalone Haskell files and pipes in the CGI parameters into the haskell program and gets back whatever the haskell program writes to its stdout and delivers it back to the web client.

Here's the bridge perl program -

========================
#!/usr/bin/perl

use CGI qw/:standard/;

print header;

$q=new CGI;
%params = $q->Vars;

$programName=$params{"programName"};

use FileHandle;
use IPC::Open2;

$pid = open2(*Reader, *Writer, "./$programName" );
for(keys %params){
print Writer "$_ => ".$params{$_}."\n";
}
close Writer;

@got = <Reader>;
print @got;
===========================


So, this bridge simply looks for the program name in the request parameters and then executes it with handles to it's stdin and stdout.

The program to be executed could be a regular Haskell program like this one -

=====================
import IO

main = do
getContents <- hGetContents stdin putStrLn ("You entered the following " ++ getContents) =====================

Thursday, April 01, 2004

Started a new day...Gotta finish the planned tasks....
Started posting today...

Gotta finish up some job stuffs tomorrow...

And also, I gotta work on my kernel...Its there in my yahoo mail...maybe, I can work on it at home!!!

Followers