Category: Technical

  • Paradigm shift

    Something got me thinking about how we think to handle a problem. This happened yesterday when I was watching a McGill University videocast on “Inflammation and Cancer – by Maya Saleh“. The video was interesting, technical enough, though confusing if you start focusing too much on lingo, or try to remember every acronym the speaker remembers.

    To summarize the whole video as I understand – the human body responds to any injury, disease by inflammation (soreness, heat, itch, numbness) as a self-protective measure. The amount of inflammation reaches an appropriate stage, disease is curbed, and  inflammation vanishes. In an imperfect world, there are exceptions, and this is same with inflammation. Sometimes, the inflammation worsens and why does it worsen is the point explained with over-intricate details in the videocast.

    But even with the details, all the research & effort spent on finding this, what struck to me as odd was the fact that it concludes with same point as it started with, namely the question about why does inflammation worsen? In other words, yet there is no answer.

    And this is where it got me thinking about our paradigm bias with which we approach a (or any) problem. The ultimate goal of our approach is to prevent something bad from happening through process of understanding details on why bad happens. Isn’t that the way we see things by attempting to understand, and interpret it by comparing with something tangible? Even in software (which is my main area, not medicine :-)) the pattern of thought is exactly similar. Bug prevention, disaster recovery, backup strategies … and it goes on.

    Trouble is the focus of this approach is protect from bad.

    Instead, something else got me thinking. Could this approach be changed? Say, instead of prevent could we prepare. For instance, instead of a malicious data entry corrupting our system, trying to prevent, could we detect and use this to our advantage by injecting more bad data to shutdown the system itself? This is like putting bad guys in charge of taking care of other bad guys … but the analogy may give you a wrong impression.

    I believe my thought is based on the same fundamental desire to protect, but by trying to take advantage of allowing things to happen. Instead of fighting against, fight using them.

    As another example for analogy, in outsourced IT systems, things often go against clients expectations because of clients desire to control more of the outsourced vendor process. Be it a goal to achieve cost cutting, squeeze out more work, or even the noble notion of making systems better in long run (anybody thinking “win-win”), I think the reason we aren’t succeeding in any industry with this thought paradigm.  The main players are presence of control over something, prevention of something (safe guarding interests etc).

    What if we could still have control, but in a way that doesn’t get in the way of preventing something bad to happen? Could we shift the focus from preventing bad to something inside out way of reversing this idea?

    Maybe the idea of medicine preventing inflammation by curbing some microflora, or cells, then discovering heuristically that medicine needs to improve to target something else seems a little waste of time to my appeal. That said, the promise lies if 80%-90% of disease cases being cured, while 10% are exceptions seems an accepted, un-challenged pattern in any field we see today. Majority wins, minority loses.

    I want to start fresh off with something simple, something which is already present – in nature. The moment someone claims we know something completely be it medicine or technology, that is the tipping point for me to confidently say that we are already lost going totally  someplace else. Our world, with it’s eco-system, with the human beings inhabiting it, with the environment surrounding it, with all it’s nature is designed to be self-sustainable. We have unnecessarily over-complicated everything imaginable with our falsely impressed thirst for knowledge, more so because our focus always has been finding problems, then going in circles finding answers to the same, and creating more problems that didn’t originally exist.

    I have a simple question – why hasn’t nature changed anything for so long? why are we same as many generations before have been? why don’t we see anything new in nature than what previous generations have seen? If we focus on understanding this, without trying to intervene with man-made heuristic approaches, we could have a much thorough, and guaranteed way of living in harmony with the way we humans are – imperfect yet perfect.

    I admit I am going all over the place with this. And I admit that I am not satisfied with the way things are today. There is something I sense is not fundamentally answered, and looked over.

  • Inspirational Quotes on Architecture

    Inspirational Quotes on Architecture

    Came across a wonderful book 101 Things I Learned in Architecture School by Matthew Frederick, and couldn’t resist the urge to jot down some wonderful concepts, key ideas. The book is more about architecture as in construction, buildings, but I find it useful to consider in Software Architecture in an abstract sense too.

    PS: These are open to your own interpretation in a positive sense 🙂

    • Architecture begins with an idea
    • Be more specific to increase appeal
    • Any design decision should be justified in atleast two ways
    • An architect knows something about everything. An engineer knows everything about one thing.
    • Science works with chunks of things with continuity presumed, but an artist works with continuities having chunks presumed
    • Good designers are fast on their feet
    • Good designers aren’t afraid to throw away a good idea
    • Being process oriented, not product driven
    • Seek to understand problem before chasing solutions
    • Slow to fall in love with your ideas
    • Making design investigations and decisions holistically
    • Making design decisions conditionally i.e. awareness they may not work as presumed
    • Knowing when to change
    • Accepting that anxiety comes from not knowing what to do
    • Always asking “What If …?” regardless of how satisfied you are
    • Favor improved design process over perfectly realized architecture
    • Three levels of simplicity
    • Simplicity
    • Complexity
    • Informed Simplicity aka Pattern Recognition
    • Professional experts know how to communicate their knowledge to others in everyday language
    • Less is more
    • Design in perspective!
    • No design system is or should be perfect
    • Success of masterpiece seems not to lie so much in their freedom from faults, but persuasiveness of mind
    • Forget about what you want the design to be, instead ask design what it wants to be
    • Always design a thing by considering it in it’s next larger context
    • Limitations encourage creativity
    • Problems are opportunities to be embraced not overcome
    • Just do something while waiting

    A few others that I’ve come across from known acquaintances, about character

    • Don’t wait until everything is just right.  It will never be perfect.  There will always be challenges, obstacles, and less than perfect conditions.  So what.  Get started now.  With each step you take, you will grow stronger and stronger, more and more skilled, more and more self-confident, and more and more successful.

    • Success is not final, failure is not fatal:  it is the courage to continue that counts.

    • I have not failed 1,000 times.  I have successfully discovered 1,000 ways to not make a light bulb.

    • I am a great believer in luck, and I find the harder I work, the more I have of it.

    • One-half of life is luck; the other half is discipline – and that’s the important half, for without discipline you wouldn’t know what to do with luck.

    • I don’t believe you have to be better than everybody else.  I believe you have to be better than you ever thought you could be.

    • The main thing is to keep the main thing the main thing.

    • Be miserable.  Or motivate yourself.  Whatever has to be done, it’s always your choice.

    • We come to love not by finding a perfect person, but by learning to see an imperfect person perfectly.

  • Launched Subversion SVN

    Launched Subversion SVN

    I often felt the need to have control of my own repository, as opposed to using any public ones (whether free, or not). So I decided to spend some time, and have my own subversion repository, that I launched here.
    https://www.naiksblog.info:4434/csvn/login/auth – Administration Console
    https://www.naiksblog.info:18080/svn/ – SVN repository for clients (sorry, only authorized users – only me for time being 😉
    The setup, configuration was a no-brainer using CollabNet’s Subversion Edge. It really does a splendid job of getting you up, and running with a professional subversion system in no time. Moreover, https was real easy to get started too; so no more worries about encryption over Internet, and peace of mind to focus on more important things.

    Maybe I’ll spend some time setting up trac as well, that will give me a basic environment to continue, host, and maintain my personal projects here onwards.

  • iPhone 3G/3GS SIM Unlock Guaranteed

    I unlocked my iPhone 3G to use in India using below simple steps

    Prerequisites-

    • Backup all contents of your iPhone
    • Ensure you have a wireless internet access point available (this is required while unlocking). Either create an adhoc WiFi network or do these steps where you have an accessible WiFi connection.
    • Download <a title="iPhone1,2_4 visit this web-site.2.1_8C148_Restore.ipsw” href=”http://appldnld.apple.com/iPhone4/061-9853.20101122.Vfgt5/iPhone1,2_4.2.1_8C148_Restore.ipsw” target=”_blank”>iPhone 4.2.1 firmware file
    • Download iPad 3.2.2 firmware file

    Steps to unlock iPhone 3G/3GS SIM-

    1. Connect your iPhone to iTunes, and click Shift+”Restore” button. This will prompt you to choose location of downloaded IPSW (Firmware) file.
      This will erase everything from your iPhone, and initialize it to factory settings (hence backup everything before you do this!) 

    2. Once iPhone is restored to iOS 4.2.1 in about 10-15 mins, download redsn0w rc12 (Alternate location) which is the tool we are going to use. Keep redsn0w.exe, iPhone 4.2.1 IPSW, iPad 3.2.2 IPSW files in same folder.
    3. Start redsn0w, and follow the steps (pretty much redsn0w screens are self-explanatory)
      1. Choose iPhone 4.2.1 IPSW file, redsn0w will verify and prepare contents for jailbreaking iPhone
      2. Choose “Install Cydia” (required for unlocking SIM), and “Install iPad baseband files” (required for SIM to detect your carrier) option. Other options can be selected/unselected as per your needs
      3. Shutdown your iPhone as next screen says, keep it connected to PC. And before hitting “Next” button, keep your finger on the iPhone power button ready to press, and hit “Next”
      4. Press iPhone Power button, after  3 seconds press iPhone Home button, keep both Power & Home button pressed for about 10 seconds, and then let go of Power button, keeping Home button pressed for another 5 seconds.The redsn0w screen guides you these steps, but since these are time-critical you need to keep both hands free to ensure that iPhone enters into so-called DFU (Device Firmware Update) mode, you should see your PC detecting new iPhone (DFU) mode while you perform these steps, and redsn0w should automatically move to next screen.

        In case you fail in above steps, redsn0w does not proceed. No worries, you can start from Step 1 again restoring iOS 4.2.1 via iTunes (hence it is better to download the IPSW files ahead for reuse)

      5. You need to keep connected to Internet since redsn0w uses Internet for accessing few files, before it jailbreaks, and boots your iPhone to custom iOS.
    4. Once done, rest of the steps are directly on iPhone, so when redsn0w says “Done” you can safely remove iPhone from your PC.
    5. After iPhone home screen appears, conntect to a WiFi network, and ensure you are connected to Internet (try using Safari)
    6. Lauch Cydia, and choose “Manage Sources” and choose repo666 at the bottom of the list. Adding this repository will show ultrasn0w packakge which you need to Install. Because Cydia does all of this over the Internet, you need WiFi.
      After ultrasn0w is installed, you no longer need WiFi, either disconnect it or keep it as per your needs.
    7. Once ultrasn0w is installed, shutdown iPhone, and put your new SIM
    8. Start iPhone, and within few seconds you should see your new carrier in your country, and be able to use iPhone!

    These steps are used by millions over Internet who wanted to unlock their iPhones and use them in whichever country they go. I hope you use them and leave a short note on how your experience was. I am using my iPhone without any problems, and am very happy!

  • Maintaining relationship – common friends

    I was posed a very trivial question from one of my friends recently. It picked my interest, since I could not readily solve it, and I had the inkling that there is a better, simple solution for this problem.

    The problem was, let’s say I have a table of users as below
    User's table data

    And these users have friends as below

    User's friends data or more easier to read as User's friends data

    Now, the trivial task was find common friends for users 1, and 5, hence naturally the answer should be

    User 1 : Woody’s friends, and User 5 : Andy’s friends  are

    Woody's friends and Andy's friends

    So, the question I had was what could be the best SQL query that would be return me this result?

    Woody and Andy's common friends

    I thought of 2 different SQL queries

    SELECT f.fid, u.name 'Woody and Andy\'s common friends' FROM
    (SELECT f.`fid` FROM friends f
    WHERE f.`uid` IN (1,5)
    GROUP BY f.`fid` HAVING COUNT(f.`fid`) > 1) f INNER JOIN user u ON (u.uid=f.fid)

    -or- another one was

    SELECT f.fid, u.name 'Woody and Andy\'s common friends' FROM
    (SELECT a.fid FROM
    (SELECT * FROM friends f
    WHERE f.`uid`=1) a INNER JOIN
    (SELECT * FROM friends f
    WHERE f.`uid`=5) b ON (a.fid=b.fid)) f INNER JOIN user u ON (u.uid=f.fid)

    Both seem to work, but is there any elegant way of getting common friends in a much simpler SQL query? At this moment, I logically find first SQL query more intuitive since all it does is pickup friends who appear more than once when users are 1 and 5. The second SQL query seems plain brute force approach.

  • Merging pre-sorted lists

    A while ago, I came across an interesting problem. We have 3 different sorted queues (entries were sorted by time), out of which we had to pickup the smallest time, and send the first arrived entry out of those 3 queues in sequence.

    Q1 Q2 Q3
    2 3 1
    5 4 6
    7 6 9
    8 10 11

    As you can see, all queues (Q1, Q2, Q3) are already sorted, but on application side we have to pickup entries across all queues in sorted order and process them. So the entries should be processed in 1, 2, 3, 4, 5, … 11 sequence. Frankly this is merging of already sorted lists, and a person from computer science background should already know this. But I don’t come from such background, and the solution one of my friends gave was plain amazing.

    The solution was pickup first entry from each queue, compare them, choose the smallest and process it first.

    Q1 Q2 Q3 Smallest
    2 3 1 1

    Thus, here 1 is processed first. Now pickup next entry from queue where smallest was found (Q3 in this example), so now the next comparison becomes like this

    Q1 Q2 Q3 Smallest
    2 3 6 2

    The smallest is 2, so this is processed and next entry from Q1 was picked-up

    Q1 Q2 Q3 Smallest
    5 3 6 3

    And so on… giving us

    Q1 Q2 Q3 Smallest
    2 3 1 1
    2 3 6 2
    5 3 6 3
    5 4 6 4
    5 6 6 5
    7 6 6 6
    7 10 6 6
    7 10 9 7
    8 10 9 8
    10 9 9
    10 11 10
    11 11

    A simple, and elegant solution, isn’t it? Is there any other better alternative?

  • Spring and Logback

    IoC, or DI definitely takes a perspective turnaround inside your head, but you get around it slowly.  I was playing around ways to integrate LogBack, and Spring – essentially around having Spring give me a pre-created instance of LogBack logger.

    I searched around posts, but most people seem to be against using Spring just for substituting one-line of Logback (Logger log = LoggerFactory.getLogger("LogbackTest");) to get your logger.

    I, on the other hand, was more interested in how to get Spring give me a LogBack logger instance without too much contrived hand-written code to achieve so. And with a bit of reading through Spring principles, documentation I found the way.

    Essentially, when using Logback’s LoggerFactory you have access to only a single getLogger() factory method. This is static which makes things a bit different for what Spring would call a bean – a class providing constructor, getter, setter methods. To circumvent this non-bean style, Spring provides what you call as static initializers a.k.a substitutes for constructors, which allow you to call a static method in lieu of calling a constructor on an object.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
     "http://www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
     <bean id="bean1" class="org.slf4j.LoggerFactory" factory-method="getLogger">
     <constructor-arg value="LogbackTest" />
     </bean>
    </beans>

    Now, this bean1 can be used as a regular bean inside your class

    ApplicationContext ctx = new FileSystemXmlApplicationContext("logbacktest.xml");
     Logger log = (Logger) ctx.getBean("bean1");
    
     log.debug("This is my first message");
     log.info("How about this information message");

    Throw in a logback.xml in your classpath, and viola you have a nice Spring injected dependency – log in your code, while still using Logback!