The voice of a Technology Enthusiast

Its about time that I forced myself to throw in another post specially right after the Startup Weekend in Bangalore, India. Yeah, I was there. flew to Bangalore just for the event over the weekend with Chandika. I have to admit, it was worth every bit.

What is this Startup Weekend you ask? it is an intense 54 hour event which focuses on building a web or mobile application which could form the basis of a credible business over the course of a weekend. The weekend brings together people with different skill sets – primarily software developers, graphics designers and business people – to build applications and develop a commercial case around them. The Bangalore event was at the Microsoft office.

Despite the reputation Startup Weekend had, initially when myself and chandika set out to the event I was quite skeptical about if there was going to be enough participants or if the caliber of the crowd was going to make it challenging enough. I was worried if it was going to be a waste of a weekend than an eventful one. For us it was a weekend to break away from the post startup life we are in with Creately (still awesome!) and to re-experience the exuberant rush and energy produced in the early days of a startup.

So on thursday we went in and as the event started it was a promising crowed with the organizers making way to get started on a very busy weekend. I was stunned by the informality and counter-culture nature of the event. Even-though initially it all seemed unstructured and rebellious, it set the right spirit in the environment and among the participants. As the pitching session began I realized that almost everyone in the room had something they wanted to pitch. I was impressed by the quality of ideas that were being pitched. Even-though not many of them were very internet/cloud focused, I found quite a few interesting idea’s that I wanted to be involved in. I had initially gone in prepared to pitch an idea of mine, but by this time given the number of ideas that were being pitched I was convinced that I wanted slide into a much more executing/hacking role than my usual planning/managing role during this event.

Within few hours teams had formed and ideas had come together and people were already in intense conversations about their respective startups. The day had extended and I was too in a battle for balance in getting our startup towards victory. I was working with a energetic bunch lead by Jagat Iyer a smart, articulate and very passionate entrepreneur. Enjoyed every moment of being with the team working towards perfecting the idea of Shasthra (thats the product we were working on). This continued along with more planning and executing towards the five minute pitch that had to be done on Sunday evening. It was pressure blended with excitement and motivation amongst very little eating and sleeping. The next two days were spent meeting new peers and mentors talking and validating all aspects of the business at the meantime preparing for the final pitch. Having built a globally successful product, I was very familiar with the situations and problems we were coming across and was able to enjoy and work with the team on solving and overcoming all of it.

I was very impressed with the committed organizing team namely Pankaj, Chidambar, Gaurav and many others who were sticking along at all times making sure everything was taken care of in a timely fashion. There were talks about possibly having a Startup Weekend in Colombo this year as well. However there is nothing firm so far on this and we are looking forward to make it happen if Startup Weekend is willing to. All in all it was a splendid weekend full of energy and I can’t think of anything that was not right about it.

Startups forever!!

Recently when working on one of the features of Creately (an online collaborative diagram software) I had the need to calculate the curve length of a quadratic curve. The Flex/AS3 curves are quadratic (when you draw using the curveTo function of the Graphics class).The requirement I had was a pretty simple and straightforward one. However I didn’t find a simple straightforward piece of code that I could use to get this done. Of course there are frameworks such as Degrafa (an article on the topic) and Singularity libraries that allow you to achieve this very easily using those libraries itself. But if you are looking for just a function to get this done and not so worried about the accuracy of the calculation, the following should help. I’ve tried my best to explain this in the simplest for so that anyone can make use of it.

The most simple and naive method of calculating a curve length is to go through the curve in regular intervals and sum up the length of the line segments that are formed by the intervals. The accuracy of the curve length will vary by the frequency of the intervals. The higher the frequency the accurate and curve length would be, and the lower the frequency the more efficient your calculation will be. Depending on your requirement you can adjust the frequency when calculating the curve length. The following diagrams would further explain this (Please note that these diagrams are purely for the purpose of conceptualizing and are not accurate).

The above diagram explains the fundamental rule of a quadratic curve. Value t being a value between 0 and 1 can be used to find a point on the curve in relation to the full length of the curve. If t=0.5 (middle), the line interconnecting the middle point on line p1,cp and middle point of line cp,p2 will touch the the middle point of the curve at the middle of the formed line.

By deriving f number of regular intervals of t values (minimum being 1/f), we can form line segments along the curve that can be used to calculate the full length of  the curve. This can be done using the following two AS3 functions.

//Function that calculates the curve length
public function curveLength ( p1 : Point, p2 : Point, cp : Point,
	f : int ) : Number {

	var length : Number = 0;
	var step : Number = (1/f);
	var tx : Number;
	var lastPoint : Point;
	var curPoint : Point;

	for ( tx = step; tx < 1; tx += step ) {
		curPoint = interpolateCurve( p1, p2, cp, tx );
		if ( !lastPoint ) {
			length += Point.distance( p1, curPoint );
		} else {
			length += Point.distance( lastPoint, curPoint );
		}
		lastPoint = curPoint;
	}

	length += Point.distance( lastPoint, p2 );
	return length;
}

//Function to interpolate a curve on t
public function interpolateCurve ( p1 : Point, p2 : Point, cp : Point,
	t : Number ) : Point {

	var ret : Point;
	var x1 : Point = Point.interpolate( cp, p1, t );
	var x2 : Point = Point.interpolate( p2, cp, t );
	ret = Point.interpolate( x2, x1, t );

	return ret;
}

You can find a suitable f value for your purpose. To better understand this I have written a demo app that draws a given curve using both the above method and the Flex Graphics.curveTo method on top of each other. By setting different f values you can understand the difference between each curve visually. I have found 10-20 to be a decent value for f depending on the size of the curve. You can further play with this by downloading the below mxml file.

Download Curve Length Demo (Simply click on three points of the canvas to draw the curve )

The real time machine!As a Apple fanboy I have been one to explore and make use of most of the features apple products have to provide. Specifically this time I am talking about Time Machine on my MacBook Pro. A little experience I had over the weekend trying to get Lion (Apparently the most advanced desktop OS in the world… Will talk about this sometime later) on to my MBP.

First to my rant on installing Lion. So I download the whole 3.66GB over couple of days through Mac app store and then happily clicked open the install to realize that I was one of the dishonorable one’s who had to re-partition the disk to be able to get the glorious Lion on! I had Master Boot Record partitions on my disk and for OSX to install it requires a GUID partition table. So guess what.. now I have to get the whole 500GB HDD emptied out, then just change the partiton scheme, then get all the data back on and then install lion! Didn’t sound the least bit fun, but I had to pledge my loyalty to Apple (not really… Just being a geeky hipster). But I had Time Machine with me, why did I have to worry?? you’re soon gonna find out.

I have been using Time Machine to backup couple of my drives since the beginning. So I didn’t have to worry about the “important” stuff which is already backed up. So I went ahead and backed up the other data on to another HDD I had and I was all set. Ran another Time Machine backup for one last time and then went ahead with the repartitioning. So I had to boot from Snow Leopard on the disk so I can erase all my partitions to create the same set of partitions on GUID scheme. Once done, went right into “Restore from Time Machine backup” to get my “important” stuff back into the drive. The restore started as I sat there experiencing the time travelling magic. After sometime I realized that I was stuck in time (so to speak). The restore had frozen and did not progress any further. Waited for ages with no progress and tried many times with absolutely no luck. Clearly I was in a panik state and felt like I had lost my identity. While I was behaving like Tom Hanks in Cast Away, I dugg deeper to find out that my Time Machine HDD had errors on the directory structure making some parts of the data unreadable. Disk Utility could not repair the errors. So I went to the Mac disk guru Disk Warrior which managed to recover most of my data from the Time Machine backup. Went through few more hoops before I could get back to Snow Leopard to the state where I exactly was. Then installed Lion which actually took only 30 mins. So the whole disaster had cost me a whole weekend, loss of many hours of sleep, a panic attack, loss of data which I feel every now and then and a blog post.

Now the funny part is I had been backing up on Time Machine for 2 years without realizing that my disk was actually broken. And this came to my attention at the worst possible time! You would think that an advanced tool like Time Machine would make sure your backup disk is intact when making a backup, but clearly it doesn’t. This I feel is a important feature that Apple needs to include in Time Machine. To my dismay I found quite a few users who had disk problems on their Time Machine backup disk during my research in getting out of this mess. I would urge all Time  Machine users to make sure to run a Verification with Disk Utility every time you run a backup. I know I will :-/

All in all even having gone through all this I still feel that Time Machine is a wonderful service to have on your Mac. Even having gone through all the trouble I was still able to get my MBP right back to where it was only because of Time Machine.

Image from : http://murphymac.com/time-machine-some-details/

Follow

Get every new post delivered to your Inbox.

Join 221 other followers