Wednesday, January 16, 2008

GLFW Archlinux package.

I bought SOE. And here is GLFW PKGBUILD for Archlinux:

pkgname=glfw2hs
pkgver=0.3
pkgrel=1
pkgdesc="A Haskell module for GLFW OpenGL framework. It provides an alternative to GLUT for OpenGL based Haskell programs."
url="http://haskell.org/haskellwiki/GLFW"
license=('GPL')
depends=('gcc' 'ghc' 'xorg-server')
arch=('i686')
source=("GLFW-$pkgver.tar.gz")
install=('glfw2hs.install')
md5sums=('c1cefce0573dd0237031fc3d28b4514d')
build() {
    cd "$startdir/src/GLFW-$pkgver"
    runhaskell Setup.hs configure --ghc --prefix=/usr
    runhaskell Setup.hs build || return 1
    runhaskell Setup.hs register --gen-script
    runhaskell Setup.hs unregister --gen-script
    install -D -m744 register.sh "$startdir/pkg/usr/share/haskell/$pkgname/register.sh"
    install -m744 unregister.sh "$startdir/pkg/usr/share/haskell/$pkgname/unregister.sh"
    runhaskell Setup.hs copy --destdir="$startdir/pkg"
}

This is glfw2hs.install:

HS_DIR=/usr/share/haskell/glfw2hs

post_install() {
    ${HS_DIR}/register.sh
    echo "GLFW registered"
}

pre_upgrade() {
    ${HS_DIR}/unregister.sh
}

post_upgrade() {
    ${HS_DIR}/register.sh
}

pre_remove() {
    ${HS_DIR}/unregister.sh
}
op=$1
shift

$op $*

Tuesday, January 15, 2008

Sambja: the song

Ok. Writing a song in 30 minutes.

Melody and chords: easy.

   | G/B    | Bm7    | C/B     | Bm7    |
a b  a b a e  a d a g  f# g a d  a d d b

C       | Bm/C    | Cm     | Eb  F
f# d d g  f# g a b  c g a b  c g d

mp3

Coming up with lyrics is hard: :)

Sam, be joyous again. Your precious days are near here across the nations. Rejoice now. Hail through the night. Get some sleep now. Wipe your tears away.

Wednesday, January 9, 2008

Epic year

Epoch time starts from 1970. Given a date in YYYY-MM-DD, list all dates that evaluates to 1970. For example, 2005-11-24 = 1970.

In python:
[(yyyy,mm,dd) 
    for dd in range(1,31) 
    for mm in range(1,12) 
    for yyyy in range(1970+1+1,1970+12+31) 
        if time.localtime(time.mktime((yyyy,mm,dd,0,0,0,0,0,0)))[:3] == (yyyy,mm,dd) 
            and yyyy-mm-dd == 1970]

So, 1970+12+31 = 2013

Friday, January 4, 2008

Some type system jargons

Type system jargons:

----------------------+------------------------------+-----------------------
Yes                   |                              |  No
----------------------+------------------------------+-----------------------
Manifest              |                              |  Latent
                      | explicit type declaration    |
`int a = 1`           |                              |  `a = 1`
                      |                              |
----------------------+------------------------------+-----------------------
Static                |                              |  Dynamic
                      | AST node has type            |
                      | (note AST is built during    |
                      |  compilation)                |
`a + 2`               |                              |  `a + 2`
already is Int        |                              |  is evaluated to 3
during compilation    |                              |  during runtime
                      |                              |  and gets type Int
                      |                              |
----------------------+------------------------------+-----------------------
Weak                  |                              |  Strong
                      | type coercion                |
`print 2`             |                              |  `print (String)2`
Int is automatically  |                              |  Int is explicitly
coerced to String     |                              |  converted to String
                      |                              |
----------------------+------------------------------+-----------------------
Nominative            |                              |  Structural
                      | type compatibility decleared |
                      | explicitly                   |
`class C extends B`   |                              |  `class C { x, y }`
C is compatible to B  |                              |  `class B { x }`
because it is         |                              |  C is compatible
explicitly            |                              |  to B because it
declared to extend B  |                              |  has similar
                      |                              |  structure
----------------------+------------------------------+-----------------------

Tuesday, January 1, 2008

Fate

Romans 9:11-12 The Lord said this to show that he makes his own choices and that it wasn't because of anything either of them had done.

Romans 9:14-16 Are we saying that God is unfair? Certainly not! The Lord told Moses that he has pity and mercy on anyone he wants to. Everything then depends on God's mercy and not on what people want or do.

Romans 9:18 Everything depends on what God decides to do, and he can either have pity on people or make them stubborn.

Romans 9:19-20 Someone may ask, "How can God blame us, if he makes us behave in the way he wants us to?" But, my friend, I ask, "Who do you think you are to question God? Does the clay have the right to ask the potter why he shaped it the way he did?

So, there seem to be fate and destiny, and they govern my life. I hope my fate is not to be stubborn, but to receive pity from above.