RSS Feed
  1. Crazy Monkey Defense, my journey so far

    April 25, 2013 by roguejs

    I’ve started kickboxing since 2 months ago (March 2013), and yesterday was my official graduation from the rookies class into the e-core class. During this time, I visited several other Muay Thai gyms as well as a kickboxing gym, and ended up with Crazy Monkey instead. Why?

    First of all, I had a list of criteria when it comes to choosing a martial sports. Number one, it must eventually have full contact sparring. The classes should be structured to eventually lead there. Second, it must be bullshit-less. If an instructor comes to me and says “hey, I can teach you a few self defense moves like right now”, I’d walk away. Or if somebody comes up and claims “oh, we don’t do full contact because our moves are too deadly”, I’d walk too. Lastly, it must have great people who are there to learn and enjoy the class, not to go there to be tortured and slapped around by sadistic instructors on a power trip.

    I stopped searching after taking my CMD introductory class, by Adrian Tan. Suffice to say, my bullshit detector stayed silent the whole class, and by the end of the class I was sold. What I wanted to learn was simple – the basics of a stand up game, the right forms and the reasoning behind them. I got a glimpse of all that in the introductory class.

    The fees are alright, to be honest. I couldn’t afford to do both standup and BJJ yet, so I decided to go fully standup so I have less to drill for, and add in BJJ once I get my physical conditioning up so I don’t waste time being winded and useless. At least that was the plan.

    The first few classes were brutal for these soft programmer legs. I chose an orthodox stance (although in hind sight I probably should have started with southpaw, since my left leg was stronger than my right) and the first few line drills killed my right calf. I started out with jabs and a simple jab-cross, but those were enough to keep me occupied for a few classes.

    Who knew throwing a proper jab with a cross follow up can be so difficult?

    The rotation of the arm, the shifting of weight, the step-in, the whipping motion to transfer energy from the legs to the hands, and above all this, you actually have to hit the target. The more I learn in CMD, the less delusions I have about my chances of survival in a real fight. I am far less inclined to get into a real fight now.

    The biggest takeaway however, is the CM 1 defense. The Muay Boran-styled blocks, once I got the hang of it, is tight enough to let me deflect most of the shots thrown at me during sparring. That gave me confidence to sit through a flurry with a clear mind, ready to think of what to do next. I think the CMD system’s greatest allure is this confidence building basic defense that every rookie learns in their first class, instead of say, bobbing and weaving, which is already ridiculously hard to pull off during light contact sparring, what more in a real fight?

    One other thing that I almost forgot to mention is that CMD Malaysia seem to have really pleasant peeps in general. No knowledge was sacred, no techniques were saved for the privileged few. The trainers Dan, Adrian, Patrick, Vince, etc were all very generous with tips and help, and those who showed up during Open Mats were all super nice people. No assholes detected so far.

    I’m happy to see myself getting fitter, and getting into a proper routine – CMD classes, morning/evening runs, and bi-weekly Open Mats sessions. It’s helped instill some discipline into me, and raise my energy and confidence levels so now I’m far more inclined to take on challenges in my own work too.

    In e-core I will be learning more of the standup game, and I can’t wait for the next class. Once my finances have settled, I’ll be taking up BJJ too, as well as adding one more fitness class to my weekly schedule, and move one step closer to my goal – to get ready for full contact!


  2. Remembering the feeling of dreaming

    February 28, 2013 by roguejs

    I went to WebcampKL last night, and boy I must say, I’m glad to be back. I’m glad too, that the first speaker was Vishen, owner of Mindvalley, and an extra-ordinary guy indeed. He gave a talk about space, Peter Diamandis, Elon Musk, and stuff, which is unimportant, because the only takeaway I got from that talk was this: Malaysians think too small.

    Right in the nuts.

    It’s not like I never started my own business. I did it once, with Genesis Culture, and even managed to get it quite far. To be honest, if I had spent more time looking for funding, right now I could be still be running that business. But no, we closed it down, and moved on. That wasn’t the point though. The point was why did I wanted to start a business in the first place.

    1. To own my own business
    2. To not work for anybody else
    3. To make a good living through the business

    Wow. Just wow. How stupid all 3 reasons were, in hindsight! Now that I look back, those should never had been my motivation to quit my job. Those 3 are consequences of running a successful business. They are hardly the reason why a business is started in the first place.

    That talk got me thinking, how big is my own dreams? Then I realized, fuck, I’m a small thinker. I don’t actually want to change the world. I’m too afraid to do that, because… why? Honestly, the more I think about it, the less reason I can find to convince myself to stay small. I mean think about it:

    I am a software engineer

    Let that sink in. Go on. Let that sink in. Nothing yet? Let me rephrase:

    I create shit with code

    What’s preventing me from writing a Google? A facebook? Broken down, they are code. They can be made. They can be replicated, or created. But that’s not the point. The point is that I have the tools to create, but not the mentality to use this talent to create something wicked big. I am artificially constraining myself on the basis of “being real”. Sure, one needs to be grounded when making decisions and taking risks, but have I grounded myself so much that I’ve forgotten how is it to fly?

    I agree with Vishen. It’s time to think big. It’s time to tell yourself, hey, you’re not as small as you think you are. You could be bigger, if only you let yourself to.


  3. Code debt

    January 23, 2013 by roguejs

    This will be a quick one. I talked about code debt the other day with another developer, which led me to write this post about it. Code debt is not something that many developers will know, but it is definitely one that most of us are already experiencing.

    How code debt happens

    Ever written a piece of code and then adding a comment saying // TODO: Refactor this later!? How many of us went back and refactored it once our code gets into production? Most likely what happens is the next case/bug comes in and you’re off chasing another goal. The problem with rushed code like these is that it creates a debt in your system. And like all debts, interest will start to pile up the longer you go without paying it back.

    The best programs are pure. Purity is defined in a system where code is organized where they should. Controller logic stays in the controller, view logic stays in the view, business logic stays in the model, etc. Or in distributed systems, each app perform one service and one service alone. But when business requirements necessitate rushing code to make stuff work, often times this begins the downward spiral of your program, where bad code breeds more bad code.

    Code debt lead to more debt

    Code debt always lead to more debt down the line. A piece of stray hack-ish code will some day become a crucial part of the system that you cannot remove it without risking system failures. Worse, since it was written without any planning beforehand, the same logic could have been required by another part of the system, and the only way to achieve that is to copy and paste it there. This multiplies your debt. It aslo multiplies your interest, since now not only you have bad code in two places, you have bad code in two places where they cannot be easily removed.

    How to reduce code debt?

    Like all debt, it can be prevented. But we’re not here to talk about that. The only way to reduce code debt is to refactor it. However, I need you to think of refactoring as throwing good money to chase the bad. It’s not financially sound, but sometimes it needs to be done. Refactors do not usually make business sense. You spend money to basically no nothing of business value. Regardless of what business owners think though, I see refactoring as the only way to pay back code debt. The person doing the refactor however, have to make sure the refactor do not introduce more code debt.

    Conclusion

    While I mention refactoring to pay back code debt, I need to reinforce the idea that coding is not just slapping language syntax into a file and calling it a day. Never call yourself a programmer and only concern yourself with just writing code. Learn software architecture. Learn software engineering. Learn how to structure a system so that code debt can be isolated (distributed systems). Learn how to use TDD/BDD to reduce the risk of refactoring breaking stuff. Learn the discipline to constantly employ these time consuming practices (careful engineering and TDD/BDD) even in crunch times.

    That’s all for today’s rant.


  4. Team’s reaction to work

    January 27, 2012 by roguejs

    Here’s how we responded to our CTO’s announcement.

    PS: In case you’re wondering, this was staged. Not with our CTO’s foreknowledge though. :P


  5. My new bash prompt

    December 22, 2011 by roguejs

    Had some fun playing around with custom bash prompts, and managed to fix a bug resulting from my previous attempt. Here’s how it looks like right now:

    That’s right, that’s me flipping you the bird. smug

    Articles I read to make this happen:


  6. Now I know why MOSTI wants CPB 2011

    December 12, 2011 by roguejs

    TIL that the government have a bad habit of hiring complete morons to work on their websites. Things that the private sector seem to be immune from.

    Do this my friends, type mosti.gov.my into your address bar without the “www” before it, and press enter. Enjoy your infinite redirect loop. Now do this: click view source.

    <script language="Javascript">
    window.location = ''
    </script>
    

    Ready? HAHAHAHAHAHAHAHAHAHAHAHAH HAHAHAHAHAHHAHHAH HAHAHAHHAHAHAHA HAHAHAHAHAHHA HHAHAHAHAHAHAH AHHAHAHAHAHHA HAHAHAHAHAHHA HHAHAHAHAHAHAH AHHAHAHAHAHHAHAHAHAHAHAHHA HHAHAHAHAHAHAH AHHAHAHAHAHHAHAHAHAHAHAHHA HHAHAHAHAHAHAH AHHAHAHAHAHHAHAHAHAHAHAHHA HHAHAHAHAHAHAH AHHAHAHAHAHHAHAHAHAHAHAHHA HHAHAHAHAHAHAH AHHAHAHAHAHHAHAHAHAHAHAHHA HHAHAHAHAHAHAH AHHAHAHAHAHHAHAHAHAHAHAHHA HHAHAHAHAHAHAH AHHAHAHAHAHHA

    On a sidenote, if you are a Malaysian engineer, do read the latest draft of the incredibly stupid Computer Professionals Bill 2011:

    http://www.mosti.gov.my/mosti/images/stories/pdf/2011/ruu_bcpm_v17.pdf

    Edit: There is a document that is collated by IT professionals as we speak right now in preparation for tomorrow’s public hearing of the proposed act. Do join in the conversation!

    Edit: As of 14 Dec 2011, this problem has been rectified. Took them 24 hours to fix a one liner in htaccess. Good job!


  7. Awesome drawing programing online

    December 8, 2011 by roguejs

    Damn, I found this online drawing canvas and it totally kicks ass. In minutes with just my mouse, I created these:

    Some sphinx thing, and …

    A bird?

    Best part about this is that I’m no artist. No, seriously. Anyway, go check out this fun drawing tool!


  8. Malaysian Government trolling the IT industry?

    December 8, 2011 by roguejs

    Is our dear Malaysian Government trolling our IT industry with a bill to eventually prevent non degree holders from being employed, or forcing entrepreneurs to have professional certifications before being able to start a business?

    Bill Website

    Screenshot or it didn’t happened:

    Clicking on the “Feedback” button takes me to Google. What the fuck am I supposed to do? Google for “Morons”?


  9. OAuth is the future for us

    December 8, 2011 by roguejs

    In our latest rewrite of edgɘyo, we made a decision early in the implementation phase to rely on OAuth providers for login and authentication. Given that this is the 7th re-implementation of the same software, I’ve written/integrated 6 authentication already, and honestly speaking I’m quite tired of reimplementing the wheel.

    The gist is this – if you are operating a web service/app that is not seeking to create a brand new market or take over the world, integration should be the key to your app’s success.

    I would argue that Instagram would not have succeeded had it not integrated with Facebook; or that smartphones would be pointless had they not integrated with Twitter, Facebook, and other social services. Most users begin their internet life through a social service nowadays. It’s their window to the rest of the internet world, and to re-implement the whole authentication system would be foolish if your webapp is not an app that seeks to do that (as in, being the fulcrum of your user’s entire internet existence).

    As of now, we have integrated with Twitter, Facebook, Angel List, Github and Linked In, and planning to add in Google, Dropbox and Tumblr.

    This of course, creates an ecosystem issue where with so many providers to choose from, our users might forget what provider they initially logged in from.

    Organizing the OAuth spaghetti

    Our current solution is a 3 step process which we hope to mitigate this problem to an extend:

    1. Make users create a username and provide an e-mail address upon signing-up through any provider
    2. The system takes the username->email combo to check if there’s already another such combo registered with another provider
    3. If found, the user has the option to send a “Join Account” link to that user and e-mail address

    At this point the user can log in again using the original provider, and he will see a notification on his dashboard asking to join the accounts. Upon authorizing it, the user will now be able to log in via either accounts.

    Having said that, obviously our technical implementation is far more complex than just that.

    OAuth is ridiculously easy

    The real point of this article is that I personally believe OAuth should be part of every web developer’s toolkit. Implement a pet project using OAuth, try it out, deploy it, and know how to play around with the protocol. OAuth is the future, there’s no doubt of it.

    On my side, I absolutely love everyauth. It just works™. We implemented all our current OAuth providers easily in less than 2 hours, with the majority of time spent setting up app accounts in the respective providers rather than writing code.

    Here’s how our everyauth code looks like:

    'use strict';
    module.exports.make = function make(deps) {
        if (undefined === deps) throw new Error('No dependency injected');
        var auth = {
            callbackError : function callbackError(req, res) {
                res.redirect('/error/401');
            },
            touchUser : function touchUser(session, accessToken, accessTokExtra, metadata) {
                var db;
                db = deps.db;
                return { user : 'soggie' };
            },
            init : function init() {
                var eauth, config;
                eauth   = deps.eauth;
                config  = deps.config;
                // Setup github oauth
                eauth.github
                    .appId(config.github.appId)
                    .appSecret(config.github.appSecret)
                    .handleAuthCallbackError(auth.callbackError)
                    .findOrCreateUser(auth.touchUser)
                    .redirectPath('/dashboard')
                    .scope('user');
                // Setup linkedIn oauth
                eauth.linkedin
                    .consumerKey(config.linkedIn.consumerKey)
                    .consumerSecret(config.linkedIn.consumerSecret)
                    .handleAuthCallbackError(auth.callbackError)
                    .findOrCreateUser(auth.touchUser)
                    .redirectPath('/dashboard');
                // Setup twitter oauth
                eauth.twitter
                    .consumerKey(config.twitter.consumerKey)
                    .consumerSecret(config.twitter.consumerSecret)
                    .handleAuthCallbackError(auth.callbackError)
                    .findOrCreateUser(auth.touchUser)
                    .redirectPath('/dashboard');
                // Setup facebook oauth
                eauth.facebook
                    .appId(config.facebook.appId)
                    .appSecret(config.facebook.appSecret)
                    .handleAuthCallbackError(auth.callbackError)
                    .findOrCreateUser(auth.touchUser)
                    .redirectPath('/dashboard');
                // Setup angellist oauth
                eauth.angellist
                    .appId(config.angellist.appId)
                    .appSecret(config.angellist.appSecret)
                    .handleAuthCallbackError(auth.callbackError)
                    .findOrCreateUser(auth.touchUser)
                    .redirectPath('/dashboard');
            }
        }
        return auth;
    }
    

    Ridiculously simple eh? Sorry that I removed all line spacings in that code snippet. My markdown plugin doesn’t play nice with my syntax highlighter.

    Anyway, much love to OAuth, and the node community. Signing out now!

    PS: I noticed that most of the services I mentioned are all OAuth 2. The “OAuth” termed here is an umbrella term I use to refer to all OAuth (both 1 and 2) implementations in general.

    PSPS: I blogged further about 5 Reasons Why Startups Should Use OAuth in the edgɘyo blog too.


  10. Removing C-styled comments using Javascript

    December 2, 2011 by roguejs

    In the course of writing norris-json, I wrote a simple piece of code to remove C-styled comments from JSON strings, which should work just as well for any projects. It’s not perfect, and if I missed anything please open an issue in my github repo.

    function _removeComments(str) {
        // Remove all C-style slash comments
        str = str.replace(/(?:^|[^\\])\/\/.*$/gm, '');
        // Remove all C-style star comments
        str = str.replace(/\/\*[\s\S]*?\*\//gm, '');
        return str;
    }
    

    Check out the tests folder to see my test cases, and do let me know if there are cases that I did not manage to cover with them.

    Thanks!