Monday, August 27, 2007

Interchangeable Parts

Excerpt from "Holding a Program in One's Head":
One of the defining qualities of organizations since there have been such a thing is to treat individuals as interchangeable parts. This works well for more parallelizable tasks, like fighting wars. For most of history a well-drilled army of professional soldiers could be counted on to beat an army of individual warriors, no matter how valorous. But having ideas is not very parallelizable. And that's what programs are: ideas.

Friday, August 24, 2007

Scalene triangles puzzle

Yesterday, God Plays Dice posed a scalene triangle puzzle:

Given a right triangle with integer sides, show that there is another integer-sided scalene triangle with a 60 degree angle and 1.5 times the perimeter of the given triangle.

Isabel posted the solution, but it involved getting several examples and making conjectures from them about the scalene-60 triple. Since I dislike the production of conjectures from data, and strongly prefer derivations from first principles, here is my detailed solution:

Consider scalene-60 triangles, there is one angle bigger than 60 degrees and one smaller. (Total is 180)
Say the side opposite 60 is z.
Let the smaller one be x=z-a, and the bigger one be y=z+b where both a and b are positive.
From triangle inequalities, you get

Then using cosine rule: x2 + y2 - xy = z2

Plug stuff in and simplify like crazy,
z(a-b) = (a2 + b2 + ab)

If a=b, then this becomes a=b=0, the equilateral triangle.
As the RHS is strictly non-zero, a>b.

Simplifying, z = (a-b) + 3ab/(a-b)

(z-a, z, z+b) generates all such tuples! The only condition on a,b is that (a-b) must divide 3ab.

Now (a-b) divides a if and only if (a-b) divides b.
(Proof: x divides a and x divides a-b, therefore x must divide b, now set x = a-b)

So we can scale a and b by (a-b) and get another triple.

In other words, it is enough to consider the two cases: a-b = 1, and a-b = 3.

Actually, we have parametrized all possible scalene-60 triples:
With a-b=3, we get one sequence and another with a-b=1

As an aside, this is an interesting picture:
If you draw a 60 degree angle and mark off 8 on one arm, use that endpoint to draw an arc of radius 7, it will intersect the other arm at 2 places -- at 3 and at 5. The angles correspond to arccos(1/7) and 180-arccos(1/7)

Coming back to the puzzle, all right triangles can be parametrized as (m2 - n2 , 2mn, m2 + n2 ) or a scalar multiple thereof, where m and n are co-prime and have opposite parity.
The perimeter is 2m(m+n).

1.5 times perimeter is 3m(m+n)

Can we map this to the scalene-60s?

Let us see. Try the first sequence: a-b=3
gives us z = b2 + 3b + 3 for triangle (z-a, z, z-b)
with perimeter 3z-3 = 3(z-1) = 3(b+2)(b+1)

Looks similar to what we want!

Now it is just a matter of fiddling with the definitions of (m,n) and (z,a,b) to get the common parametric form:
Right triple is (m2 - n2, 2mn, m2 + n2)
Scalene-60 is (m2 - n2, m2 + mn + n2, m2 + 2mn)
[Substitute b=(m-n)/n; and scale the triple (z,a,b) by n]

We are home and have a sequence of scalene-60 triangles left over!

Wednesday, August 22, 2007

The US employment based immigrant visa system

  • It is advisable to not change jobs except after all but one stages are approved, and the last one (Form I-485) has been pending for 6+ months.
  • For Indian and Chinese-born persons, it is imperative to apply in EB1 classification, the so-called "PhD category", from an established R&D department of a bigger company.
  • All other categories have queues pending several (2-5) years.
  • Mexico is impossibly backlogged (10+ years) except for persons with advanced degrees.
  • Philippines has some issues as well.
  • For nationals born in any other country, it is merely a procedural matter.
  • Family based immigrant visas are hopelessly backlogged for all nationals.
There now you can hold your own in any immigration related conversation.

Tuesday, August 21, 2007

Using sunrocket gizmo as an almost free telephone

Sunrocket, which was the 2nd largest VoIP provider in the US recently declared itself dead. So I was left with a phone adapter that was now effectively an expensive paperweight.

After some internet searches, I found a way to convert it to an almost free landline. Details follow.

I had the Innomedia Gizmo, which I first unlocked as follows:

Innomedia devices from sunrocket come with SNMP enabled. The community strings is private. The admin password OID is SNMPv2-SMI::enterprises.3354.
So we browse this and change it. Download GETIF
1 - After you start the tool enter the IP address of you device in Host Name field, say
2 - Change the Read community to private (default is public)
3 - Click on start
4 - click on MBrowser tab
5 - St the bottom of the window you will see 3 fields that you can enter values in.
The first field is the OID enter .
The second field is the type. Change it to string
The 3rd field is the value. Enter any value you want (That's the new password).
6 - Click on the set button

Make sure:
1. Firewall is NOT blocking port 161. Be sure to enable that port.
2. Be sure WAN is connected to internet connection, LAN directly to the machine you are trying to SNMP from.
3. Browse to and use admin and the password you just set!

Next use the unlocked gizmo with Gizo Project and Grand Central as a VoIP phone.
  1. Sign up for a Gizmo Project (note the SIP number) and
  2. Sign up for a Grand Central account (this is the new telephone number).
  3. Setup the unlocked Sunrocket Gizmo device to work with Gizmo Project
    1. Disable Provisioning. Go to IP Network-> Provisioning Setting. Uncheck the Enable Provisioning box.
    2. Setup your SIP Proxy. Go to VOIP->SIP Proxy. Use the settings in this image. got cut off on this.
    3. Change your User Account. Go to VOIP->User Account. Your user ID is your Gizmo Project SIP number with the one before it. Your password is your gizmo project password. Image.
    4. Test Setup Setup your gizmo so that it is directly connected to the internet. The order should be modem - gizmo - router. If you want to put your gizmo after your router, you will need to forward UDP ports 5004, 5005, and 64064 to your voip gizmo, and enable QoS in the router. If you use a static IP for the gizmo, you will also have to set the DNS servers in the Gizmo.
  4. Finally, Setup Grand central to forward calls to your gizmo project account.
If you have your Gizmo project program running on the PC, you may have trouble receiving calls.

When I accept a call, it tells me to press 1/2/3/4, when I do that, it does nothing. Keypad does not seem to work, but it works with my cell phone. Here is the fix for this issue:
1) Telnet into your gizmo and enter the login and password of the gizmo (obviously case sensitive)
2) Press C2 and make sure RFC2833 (SDP and 2833 packets) is ALWAYS OFF, Otherwise press 0 (zero) to turn it off.
3) Press Cs
4) Look for Use SIP INFO for DTMF = Yes
5) If it says no, then press c to change settings.
5.1) Look for 18. SIP INFO for DTMF
5.2) Press 18 to set it to yes
5.3) Press y at the prompt -- Use SIP INFO for transmitting DTMF digits?[y/n]
5.4) Press w to write setting to Flash
6) Power cycle the gizmo

You should now be able to accept GC calls and negotiate menus anywhere else, e.g., VM using th etouch tone keypad. Remember to set your phone to use tone dialing (not pulse).

Activating the second line on the gizmo:
1) Telnet into your gizmo and enter the login and password of the gizmo (obviously case sensitive)
2) Press Mp
3) Follow the on-screen prompts to activate both lines
4) Power cycle the gizmo

Voila! Free incoming calls forwarded via Grand Central and outgoing calls at 1.9c/min via Gizmo Project.
Connecting to the gizmo when it is behind a router -- use a static IP, say, for the gizmo. In this case, also set correct DNS servers on the Gizmo, especially when changing ISP, otherwise it won't work! Alternatively:
Say "ipconfig" on a network machine to find the address, say, of the default gateway/router.
Get the DHCP table from the router and lookup the Gizmo's IP address. The gizmo registers itself as "000XXX0XX4XX". Say this is for instance.
Use that IP address to get the management page for the Gizmo.

Tuesday, August 07, 2007

Large vs. small companies.

Most large organizations are similar -- it just takes forever to get anything done and you have to negotiate with (beg of?) several people. Things are inefficient. Things move slowly. People don't care one way or the other most of the time.

This is not a defect in the system. Rather it is intentional. Reason (well, my hypothesis) -- large corps are merely trying to stay in business, not necessarily trying to innovate constantly. Their existence is not threatened every day. Accordingly they are optimized for continuity / stability than for efficiency / churn.

Startup life is arguably better -- you get to discuss strategy more than you get to do so as a corporate employee, (but orders of magnitude less than the founders and executive management). Eg: Today the CEO and two of us were talking about the business model of another startup, over lunch. That is typical.

As romantic as a startup sounds, for the founders it is actually a lot of infrastructure activity and for research-y types, often boring -- sales, marketing, fund raising, coding, tech work, hiring. Marc Andreessen has has a wonderful blog series on Silicon Valley startup culture.

However, for the employees, the work itself is far more focused than a corporate job, so you won't get diversity in what you do. The agenda is set in stone by the business plan and the CTO and there is no scope to budge an inch outside of that.

Instead, stay in a corporate job, and use the corporate setup to your best advantage -- get your immigration sorted out, read, travel, get some continuing education or personality development courses, pick up new skills or hobbies. That'll keep you excited and reduce your boredom.. :)

Here is an interesting thought -- On the Dilbert blog, recently Scott Adams recommended trying to get in the top quartile of the population in 2+ different things and then co-relate them, thus making a niche for oneself. He was in the top quartile of three things -- comedy and cartoon/drawing and knowledge of business culture. In any of the individual areas 25% of the people are better than him but in the intersection (Dilbert cartoon strip) he is easily in the top 1%.