I'm starting to really really appreciate what Pete has been saying all along... I always thought I understood, but now the pain is 10x greater...


0 comment(s) | link to this entry | edit this entry

Stay tuned... A radical change will happen to this space between now and the end of the year... =) Please don't expect any new posts between now and then, tho... ;)


2 comment(s) | link to this entry | edit this entry

Knowledge and productivity are like compound interest. Given two people of approximately the same ability and one person who works ten percent more than the other, the latter will more than twice outproduce the former. The more you know, the more you learn; the more you learn, the more you can do; the more you can do, the more the opportunity... Given two people with exactly the same ability, the one person who manages day in and day out to get in one more hour of thinking will be tremendously more productive over a lifetime.

A step at a time. A pebble at a time. Making a difference.


0 comment(s) | link to this entry | edit this entry

I've got myself not one, but two new toys for the holidays... *smirk* Although, the ultimate toy would have been the Wii... I'll wait until it gets DVD playback cuz I'm lame like that.


0 comment(s) | link to this entry | edit this entry

Iwata: I really get the sense of it starting up smoothly. But ever since we settled on the development concept for Wii, the two of us have constantly stressed to the development team that we should be aiming for a three second load-up time. We haven't got there yet though, have we?

Miyamoto: Not yet. It takes longer than I thought it would to go from the Channels to the Wii Menu, or from one Channel to another. It bothers me a bit that it's slower than the time it takes to flick between channels on a TV. I really want to get working on making everything faster when the system is updated. But even now, when you compare it to the load-up time on a computer, it's extremely fast, but I'm still not completely satisfied. If we could just get it even a little closer to the speed of flicking between channels on a TV...

Crack open that whip and get'em Engineers hackin'!! You know you want sub-3 seconds boot time!!! You can't be comparing it to a friggin PC!!??? Don't look below you, look up!!! C'mon, Nintendo!!!!


0 comment(s) | link to this entry | edit this entry

So I'm trying to understand more about electrical engineering. I found myself constantly desiring the knowledge, so I just had to find an excuse to motivate myself. I failed to blog about it, but I started this off by fixing my broken drum machine which had a cracked board (just had to use a bit of solder to "jump over" the crack and let current flow. It was a quick 15 minutes job with Jeff guiding me. Now I'm all cocky, of course. =) I'm basically looking around my home for things I can either fix or modify... *SMIRK*

The first obvious choice was my PS2. I have a PS1 and a PS2. PS1 is a Japanese import which is meant to allow me to play all the Japanese games I have (which is a lot). The problem is that the console is dying a slow death. So I want to mod my PS2 so that it can do everything the PS1 can do. =) I purchased the duo GT3 modchip and I'm taking 30 minutes or so a day getting it isntalled on my PS2. So far the hardest part of the whole deal was opening up the damn PS2. -.-;. Here are some photos of the process so far. Got lots more to solder!


0 comment(s) | link to this entry | edit this entry

I came across a rather earth-shattering little blib of news release today.

Miscommunication and a lack of cross-cultural understanding can hinder the effectiveness of global sourcing, according to the results of a study released today by Accenture.

Are they running out of news to release?


0 comment(s) | link to this entry | edit this entry

One of the things I'd like to finish up before the end of the year is my independent studies thesis for my MBA. God knows I've been putting it off for years... Well, so I've begun collecting potential references for it, and have also started a blog titled End-User Revolution. If you have any interest in the subject matter (you can read about the general idea of what I mean by end-user revolution here) or know of references that I should be reading up on, do drop me a note on the blog!


3 comment(s) | link to this entry | edit this entry

One of the biggest gripes I have with opensource/freeware software distributions is that not a lot of them seem to give much thought to producing compact software (i.e. small memory footprint and compact code - as in compiled code, not lines of code). I'm ashamed to admit that one of my own contributions also fall under this criteria given its dependency to wxPython. I'm guessing that it's mostly because we're lazy and want to just get something that works out the door quickly. Recently, I was looking for a light-weight RSS reader, because Sharpreader keeps crashing, hogging memory, among other things. I searched for "light-weight RSS reader" and found one called "Feed Reader" that said the following:

One of the main goals of Feedreader architecture is to keep its footprint small. Say goodbye to bloat: installation file is under 3.5MB.

Wow, small footprint was one of the goals, and the binary still comes out to 3.5MB (since they said under, I suppose it's possible that it's only 1KB)? I don't mean to pick on this application, cuz for all I know it's a great application and every single byte is necessary. It just gave me a chuckle to find a bold statement on its front page saying that a 3.5MB file was lightweight. ^^;


0 comment(s) | link to this entry | edit this entry

I hate the chain rule... Gotta love the quotient rule, product rule and the power rule, tho... Oh, and Maple pown3s


0 comment(s) | link to this entry | edit this entry

Few years back I had read Guido's entry on writing a nice "main" for python. When optparse came out for python 2.3 I had revised it and have been using the exact same code for of main for a long long time now... I find myself copying/pasting the same shit all the time so I thought I'd put it here for copying/pasting. Maybe others would find it interesting?

The code is as follows. You'd need to modify _USAGE, _OPTIONS, run, and perhaps the exception handling when calling run. Other than that you should be able to use this as is.

How do you guys write your main?


###############################################################################
#
###############################################################################
import sys
import traceback
from optparse import OptionParser


###############################################################################
#
###############################################################################
_USAGE = """
%prog param1 param2 --option1=value
"""

_OPTIONS = (
    (("--option1",),
     {"action" : "store",
      "type" : "string",
      "dest" : "option1",
      "help" : "this is an option",
      "default": "default value"
      }),
    )
               

###############################################################################
#
###############################################################################
class Usage(Exception):
   
    def __init__(self, msg):
        self.msg = msg


###############################################################################
#
###############################################################################
def run(param1, param2, in_repos=None):
    pass
    

###############################################################################
#
###############################################################################
def main(argv=None):
    if argv is None:
        argv = sys.argv

    try:
        parser = OptionParser(usage=_USAGE)

        for (t, d) in _OPTIONS:
            apply(parser.add_option, t, d)
        
        try:
            (opts, args) = parser.parse_args(argv[1:])
        except SystemExit:
            
            raise
        # ---------------------------------------------------------------------
        except:
            traceback.print_exc()
            
            raise Usage("Unhandled exception")
        # ---------------------------------------------------------------------
        else:
            try:

                return apply(run, args, opts.__dict__)
            # -----------------------------------------------------------------
            except SystemExit:

                raise
            # -----------------------------------------------------------------
            except:
                traceback.print_exc()

 
    except Usage, e:
        print >> sys.stderr, e.msg        

        return 2


###############################################################################
#
###############################################################################
if __name__ == "__main__":
    sys.exit(main())


1 comment(s) | link to this entry | edit this entry

So today I had to write a quick script on Darwin(i.e. MacOS X) that was to run a command line app and interact with it. Basically what would happen is that the command line would run and it would prompt the user to enter a password. At first the viscious hack involved writing a dead simple C extension to python that simluated a key press (i.e as if a human being really hit the key on a keyboard) -- I would've liked to just use python, but the ioctl module was not available for the platform. The python extension wrapper is ugly, so I'll just show you a command line version of what I did.


#include <sys/ioctl.h>

int main(int argc, char* argv[])
{
        char *cmd, *nl = "\n";
        int i, fd = 0; // stdin

        if (argc > 1) {
                cmd = argv[1];

                for (i= 0; cmd[i]; i ++) {
                        ioctl(fd, TIOCSTI, cmd + i);
                }

                ioctl(fd, TIOCSTI, nl);
        }

        return 0;
}

Then things got weird when the password prompt showed up arbitrary number of times depending on the argument used for the command line app. So I needed a way to read in from the terminal and only type the password when it was explicitly asked for. At first I just used popen to get access to the stdin, stdout, stderr to see if I can read the prompt in, but it seemed like the command line was writing directly to the terminal... =( So I essentially had to find a way to somehow create a terminal-like environment, run the command line in that and intercept the output it's piping to the terminal. After some asking around and googling I noticed that the pty module had its own fork function that forked a child process inside a pseudo-terminal which it returned the file descriptor of! So the hack came out as such:

import sys
from pty import fork
from fcntl import fcntl, F_SETFD, FD_CLOEXEC, F_GETFD
from os import execvp, close, read, fdopen, pipe, write, waitpid

__MAX_BUF_SIZE = 1024

def my_func(cmd, prompt, type_this, ack=None):
    """
    @type cmd: sequence
    @type prompt: string
    @type type_this: string
    @type ack: string
    """
    
    (r_fd, w_fd) = pipe() # synch pipe
    old_fd = fcntl(w_fd, F_GETFD)
    fcntl(w_fd, F_SETFD, old_fd | FD_CLOEXEC)

    (pid, fd) = fork()

    if pid == 0:
        # child process
        execvp(cmd[0], cmd)
        # ---------------------------------------------------------------------
    else:
        close(w_fd)

        # wait for the child process to run
        if not fdopen(r_fd).read():
            buf = ""
            n = len(prompt)

            while 1:
                s = read(fd, n)
                
                if s == prompt:
                    write(fd, type_this)
                elif ack != None and s == ack:
                    # an ack for the password (i.e. "\r\n" is typically echoed)
                    pass
                elif s:
                    if not buf:
                        n = __MAX_BUF_SIZE # raise amount of read we do

                    buf = "%s%s"%(buf, s)
                else:
                    break
                
         # wait for child process to finish running
         waitpid(pid, 0)     
         close(fd)
     
         return buf

if __name__ == "__main__":
    print my_func("/usr/bin/cmd arg1 arg2".split(" "), 
    "Password: ", 
    "myeasilycrackablepassword\n",
    "\r\n")
    

There you have it. Just thought I'd blog about it, since I couldn't find anything immediately on the net... So if you want to interact with terminal apps by reading its output and typing in some input, this should give you a good start. Hope that helps!


1 comment(s) | link to this entry | edit this entry

I've been using 43things.com for some time now and have watched them grow into 43places.com, 43people.com, then a complete refresh of allconsuming.net ... These guys are taking advantage of the Web medium very well. They're sprinkling just the right amount of technical mumbo jumbo, they're also reaping big on the self-promotional nature of the internet generation and on top of that, they're linking all these information quite nicely on technical level. Great job guys! Can I get some stock??!! ;)


0 comment(s) | link to this entry | edit this entry

So the conference did get better on the second day with more focus on the semantic Web. The big topic these days seem to be ontologies, and although my main research focus at work isn't directly related to ontologies, I do deal with them on a regular basis since we use them for creating information architecture for various research projects. Plus there are others at work (Hi Dom~) who do work extensively with ontologies. Oh, and I thought the professor who ran a tutorial on the overview of ontologies for the semantic Web was quite good. There's a session on Web services today which I hope would be as good.

It wasn't all great, though... The most disappointing part was that a lot of the interesting paper presentations were cancelled because the presenters just didn't show up... And there were way too many ocassions like this to the point where I became somewhat disturbed at the fact that I really wasn't getting enough out of this experience. =( I wonder if this is common in the world of conferences... The other problem I noticed was that given the international nature of this particular conference (something like representatives from 30 different countries), the language barrier was high in many instances. Often times you'd have absolutely no idea what they were saying so you just sit there hoping that everything will be spelled out on the slides. Other times, questions would get misanswered because the presenter would not really understand the question, and, of course, the person who asked the question would try paraphrasing a couple of times and eventually just nod at whatever answer they get and give up.

Amidst the positives and the negatives it's without a doubt that it is always refreshing to see what other people are doing and to get feedback on what we're doing. Can't really put a dollar value on fresh perspectives, ya know. ;) So no gripes about that! A'ight I'll be back in da 'burgh soon!


0 comment(s) | link to this entry | edit this entry

Can't say that I'm completely satisfied with the quality of presentations I've been able to attend, but then again, it's only the first day... As a matter of fact, it looks like there are some interesting presentations at the CI 2005 conference which is co-hosted at the same time in the same location. What I might do later is attend some of their sessions where they talk about AI-related stuff that sound interesting (not that I have a deeply rooted interest or understanding of AI, but "Framework for Executing Computational Intelligence Over Distributed Embedded Nodes" just sounds sooo much cooler than "Load Balancing Grid Computing Middleware", naw mean?

As for my presentation, I think it was decently received, but the audience size was pretty damn small and I didn't get many questions... so I either completely butchered the presentation or they were in need of some serious caffein (You see... I was the first guy to present in the conference). I did get to capture my presentation in video format, so I'll try putting it up when I get back. A'~~~ighty, this fro-sportin' geek is gonna go back and try to blend and schmooze with the l33t professors of the world now. ;)


0 comment(s) | link to this entry | edit this entry

Want some more? Dig in to the archive for past entries.