Tuesday, August 31, 2010

Soul Burn !


Monday, January 21, 2008

Bee


Bee
Originally uploaded by LoopZilla
Testing out flickr's blog this button.

Monday, March 12, 2007

Why I prefer JQuery to prototype/script.aculo.us?

Because it's more pipe friendly, more powerful to traverse the DOM tree and last but not least more maintainable.

  1. pipe friendly: Like unix pipe, you could select amazing complicated elements using chains of filters like this: $("a").addClass("test").show().html("foo");
  2. powerful DOM traversal: Still use for(var i=0;i to loop through your list and do something to the parent elements? That's so quaint compared to this $("div#nav span").parents("p").attrs({'font-weight':'bold'}). Image what could be done by combining this with "chinas of filters"!!
  3. maintainable:I was totally blowed away when I first saw jquery's selector syntax. Simple it is, but it allows we use the same CSS/XPath selector syntax in javascript. Combine this with "DOM traversing" parents, prev, sibling and "Filters" like lt(5), eq(0), gt(4), contains and you could do magic with only one line of code. Yet more readable. CodeEye also mentions a couple of very nicely constructed, highly readable selector here and a very nice, neat FAQ page built using jquery at here.
Yes, do everything with one line of code and make the code more readable. This is the magic of jquery.

Friday, March 09, 2007

Jeff Hawkings, the author of On Intelligence and founder of Palm,
founded this new company called "Numenta". To quote Slashdot [1]:
"Numenta's goal is to build a software model of the human brain
capable of face recognition, object identification, driving, and other
tasks currently best undertaken by humans. "

Yesterday they released the first version of their free development
platform and the source code for their algorithms to anyone who wants
to download it. [3] Even better, Numenta offers a three week, one
hour webcast for FREE. [2]. Go and register it if you are interested.

I've been dreaming of applying his theory into use for a long time,
but just don't have the time/money to build something. Now the time
has come. :-)

Alex

1. http://developers.slashdot.org/article.pl?sid=07/03/06/220213
2. http://www.numenta.com/htm-jumpstart-subscribe.php
3. http://www.numenta.com/for-developers/software.php

Wednesday, March 07, 2007

How to ignore .svn directories in grep?

This has bothered me for a while. A google search shows two popular implementations to work around this: using grep's --exclude parameter or use find to filter out the hidden directories. I chose the --exclude parameter approach since it is pretty neat and easy to integrate into my own bash environment by defining an alias.

Here is the alias definition in my ~/.bash_profile

alias g="egrep --exclude=\*.svn\* -r -n "

Thursday, February 15, 2007

Password-less login for dreamhost
It turned out to be fairly easy once I figured out the right manual to refer to. Here are what I've done.

  • Concise guide to Passwordless Authentication for Windows users
  • Add a "putty.exe" shortcut on your quick start bar with `C:\Tools\putty.exe -load "dreamhost"`
  • Auto start Pageant.exe

Sunday, January 28, 2007

How to add reddit.com button to your blogger account?

I'm using the new blogger classic template. So YMMV. But the basic idea should be the same.

  • Go to "Edit Template"->"Edit HTML",
  • Expand all widgets HTML code by checking "Expand Widget Templates"
  • Scroll down to near the bottom, replace<div class="'post'">
    <a name="'data:post.id'/"></a>
    with
    <div class="'post'"><a name="'data:post.id'/">
    </a><a name="'data:post.id'/">
    <script>reddit_url='<data:post.url/>';</script>
    <script language="javascript" src="http://reddit.com/button.js?t=1"></script></a>

Javascript tags generator: A MUST have for serious Ajax developers using vim

The following python script could build tags file for your javascript files. It's still version 0.0.1, but it does support extracting most methods and class definitions. Here are a list of the syntax it supports for now. If you find this script misses something, please let me know and I'll add them for you.

Supported Syntax

# - functions
# * function info(msg) {
# * info: function(msg) {
# - classes
# * var logger = {

Usage
#   jstags.py logger.js
# ls *.js | jstags.py
# find ./ -name *.js | jstags.py

Source code

#! /usr/bin/env python
#
# jstags.py
#
# Create a tags file for javascript programs, usable with vi.
#
# Benefit:
# Just in case you haven't used tags in vim, you could jump
# to class/function definition using and jump back
# using . Once you start using tags, you can no longer
# live with it.

import sys, re, os
tags = [] # Modified global variable!

def main():
if sys.stdin: files = [s.strip() for s in sys.stdin.readlines()]
else: files = sys.argv[1:]
for filename in files: parse_file(filename)

fp = open('tags', 'w')
fp.write("!_TAG_FILE_FORMAT\t2\n")
fp.write("!_TAG_FILE_SORTED\t1\n")
fp.write("!_TAG_PROGRAM_AUTHOR\tAlex Dong\n")
fp.write("!_TAG_PROGRAM_VERSION\t0.0.1\n")
fp.write("!_TAG_PROGRAM_URL\thttp://thetruedelight.blogspot.com/2007/01/javascript-tags-generator-must-have-for.html\n")


tags.sort()
for s in tags: fp.write(s)

patterns = { re.compile('\s*var\s*(\w+)\s*=\s*{'):'c',
re.compile('\s*function\s*(\w+)\s*\('):'f',
re.compile('\s*(\w+)\s*\:\s*function\s*\('):'f'
}

def parse_file(filename):
fp = open(filename, 'r')
while 1:
line = fp.readline()
if not line: break

for pattern in patterns.keys():
m = pattern.match(line)
if m:
c = m.group(0)
n = m.group(1)
s = "%s\t%s\t/^%s/;\"\t%s\n" % (n, filename, c, patterns[pattern])
tags.append(s)

fp.close()

if __name__ == '__main__':
main()