Archive for the 'Geekiness' Category

The bond counter: Peanut version

Monday, July 25th, 2005

Inspired by the whole NKF saga and mrbrown’s very amusing last entry in SNE108, I’ve rewritten the bond countdown timer to give the amount payable in peanuts (locally defined currency, where one peanut == S$600,000).


<script type=""text/javascript">

function formatAsPeanuts(mnt) {
mnt -= 0;
mnt = (Math.round(mnt*1000000))/1000000;
return mnt;
} // modified from http://www.rgagnon.com/jsdetails/js-0076.html

/*

BOND COUNTER: PEANUT VERSION

Simple script that writes out a line of text with how many days of bond left to go, and how much it's worth right now if paid up. E.g. "1870 days and 0.82241 peanuts left to go". Extremely depressing.

Variables to change:

enddate:
The end date of the bond, assuming a full (4/6/8-year) bond.

enddate_discount:
The end date of the bond assuming it's completed. Applies only to those who serve full-time NS and have half of that counted towards the bond (usually 10 months).

startdate:
First day of work.

bond:
Bond value with interest and LD. Assumes a linear depreciation of an already-compounded bond value with liquidated damages. The amount signed on the contract can be used as a rough estimate.

OPTIONAL -- nowdate:
Change to a date in the future e.g.
nowdate = new Date("June 20, 2009");
to see how much to pay at that point of time.

*/

var enddate = new Date("June 20, 2011");
var enddate_discount = new Date("August 20, 2010");
// Uncomment this following line if end date is fixed:
// enddate_discount = enddate;
var startdate = new Date("June 20, 2005");
var bond = 500000;
bond = bond / 600000; // convert to peanuts

var nowdate = new Date();
ms1 = enddate_discount - nowdate;
days = Math.floor(ms1 / 86400000); // converts from milliseconds to days

document.write(days);
document.write(" days and ");

total = enddate - startdate;
ms2 = enddate - nowdate;
rem = formatAsPeanuts(ms2 / total * bond);

document.write(rem);
document.write(" peanuts left to go");

</script>

Technorati Tags:

Oscilloscope TV

Wednesday, July 20th, 2005

A photo, to loosen the rigidity of all these text posts.

Saw this while in Korea — a TV channel seemingly* entirely dedicated to displaying the output of an oscilloscope. Scintillating.

* My sampling frequency was once every 8 hours over a 12-hour time frame, so fine, I might be mistaken.

The “links for” posts

Tuesday, July 12th, 2005

So del.icio.us, the geekily ugly-cool bookmarking tool, has a pretty interesting automatic link-posting feature that I’ll be trying out for a few days. Alternatives like DailyDelicious and YADD require “hitting” the links to work properly, which seems rather inconvenient to me (even with cron jobs and all easily set up on laptop).

I’ll see how this goes before I decide to keep it or not.

The new Javascript countdown timer

Saturday, July 9th, 2005

I got a couple of requests for a version of the bond countdown timer that’d work with Blogger or any other non-self-hosted blogging system.

Here it is, with comments and all too. See, two years of teaching programming style haven’t gone down the drain. Much.

<script type=""text/javascript">

function formatAsMoney(mnt) {
    mnt -= 0;
    mnt = (Math.round(mnt*100))/100;
    return (mnt == Math.floor(mnt)) ? mnt + '.00'
              : ( (mnt*10 == Math.floor(mnt*10)) ?
                       mnt + '0' : mnt);
} // from http://www.rgagnon.com/jsdetails/js-0076.html

/*

Simple script that writes out a line of text with how many days
of bond left to go, and how much it's worth right now if paid up.
E.g. "1870 days and $496250.40 left to go". Extremely
depressing.

Variables to change:

enddate:
The end date of the bond, assuming a full (4/6/8-year) bond.

enddate_discount:
The end date of the bond assuming it's completed. Applies only
to those who serve full-time NS and have half of that counted
towards the bond (usually 10 months), or teachers whose NIE term
isn't counted unless they complete the bond.

startdate:
First day of work.

bond:
Bond value with interest and LD. Assumes a linear depreciation
of an already-compounded bond value with liquidated damages.
The amount signed on the contract can be used as a rough estimate.

OPTIONAL -- nowdate:
Change to a date in the future e.g.
nowdate = new Date("June 20, 2009");
to see how much to pay at that point of time.

*/

var enddate = new Date("June 20, 2011");
var enddate_discount = new Date("August 20, 2010");
// Uncomment this following line if end date is fixed:
// enddate_discount = enddate;
var startdate = new Date("June 20, 2005");
var bond = 500000;

var nowdate = new Date();
ms1 = enddate_discount - nowdate;
days = Math.floor(ms1 / 86400000); // from millisecs to days

document.write(days);
document.write(" days and ");

total = enddate - startdate;
ms2 = enddate - nowdate;
rem = formatAsMoney(ms2 / total * bond);

document.write("$");
document.write(rem);
document.write(" left to go");

</script>

To use, copy and paste the entire section into anywhere you want the words "x days and $y left to go" to show up, making sure to customise the variables for your own situation — bond value and the start and end dates. If there’s an error, let me know by email or on the comments.

Enjoy :)

DRM roll: Here are words. Eat.

Monday, June 6th, 2005

So that last post on Friday, where I ended by concluding that everyone should switch to Mac because of the new evil-sounding hardware DRM on Intel chips? Oh dear.

On the same day, CNet broke news confirming a previous rumour heard all over the net: Apple to ditch IBM, switch to Intel chips, an announcement that will apparently be made at the WWDC on Monday afternoon PST (that’s tomorrow morning SGT). Next, the Wall Street Journal followed suit with their report on the same topic (no link because no WSJ subscription), citing confirmation from trusted sources. The Inquirer has apparently gotten independent confirmation of this information as well.

Now, Think Secret or Mac World getting a couple of rumours wrong before every major Apple announcement is one thing, but CNet and Wall Street Journal reporting rumours as news? Jon Gruber at Daring Fireball started off highly skeptical before Friday, changed his tune a little after considering the reliability of the sources over the weekend, and remained unsure of the news (no technical specifications leaked whatsoever, oddly convenient timing of the leak) after — though, in conclusion, he seems to think Apple is moving to Intel PowerPC and not x86.

That’d almost make sense, except Intel has never made PPC, and how would they spring up manufacturing plants to rival IBM’s in a year? Even if they could, would this help Apple get those faster chips that are purportedly the reason behind their break from IBM (re: Steve Jobs announcing over a year ago that 3GHz G5’s were on their way and being proven wrong by IBM’s inability to churn out new chips fast enough, or cool enough)? What about the ridiculous costs? (All these points being ones that Gruber has already brought up, actually.)

CNet posted a follow-up report that the Intel-Apple coupling could woo Hollywood, mentioning the possible distribution of Hollywood movies online through Apple’s well-established iTunes DRM model as a possible template. The article doesn’t mention why Intel is crucial to this, apart from how Intel has “expended extensive energy to woo Hollywood to IT technologies*” — why can’t Apple apply their DRM model with their current IBM PPC chips, after all? Isn’t it a software issue?

A natural conclusion, then, could be that the two announcements are linked: Intel announcing new x86 chips with DRM, and Apple making its move to these chips to take advantage of it. Movie-swapping probably isn’t the only reason for such a move that could potentially alienate all kinds of developers, but it seems like possible evidence that Apple will be switching to Intel x86 and not Intel PPC.

Ah, what the hell. Switch or no, x86 or PPC, I’ll just wait for the outcry tomorrow morning.

* “Information Technology technologies”, apparently.

DRM roll please

Friday, June 3rd, 2005

Oh great:

Intel quietly adds DRM to new chips

So the processor will potentially be able to handle digital rights management (DRM) and prevent “unauthorised copying and distribution of copyrighted materials”, using Microsoft’s laid-out DRM scheme. Far more insidious than labelled copy-protected music CDs which prevent copying music to the computer (even in legit cases like transferring to an iPod), this new feature wasn’t even announced at the launch of Intel’s new dual-core Pentium D.

Apparently AMD will be following suit, too, so all your x86 processor are belong to the recording industry / movie industry / Microsoft. Switch!

Safari RSS hackery

Sunday, May 1st, 2005

Thanks to Nigel, I managed to get OS X Tiger pretty early (an hour after its launch — the amount of time to get from campus to SF). Set it to Archive and Install, then went out for the night and it was nice and installed by the time I got back (at 2am, stuffed full of In-N-Out, desperately needing sleep but unable to resist the urge to tinker with the new OS).

While trying things out in Tiger, I noticed a couple of nice changes in Safari RSS, and hacked something up to get it to behave. Thought I’d share them.

First, Safari now seems to support Cmd-Opt-Arrow for switching between tabs, in addition to Cmd-Shift-Arrow. At least, this seems to be the case, since my user-defined Cmd-Opt-Arrow shortcuts in the keyboard shortcut preference panes are gone, yet the shortcut still works. A spillover from my previous install, perhaps?

Second, and this one I thoroughly approve: double-clicking in the empty tab bar in Safari now creates a new tab, a la Firefox. Yay! I’d been wanting this feature forever.

Finally, and this one’s a bit complicated: Even though Safari RSS has actual “customisable” toolbar icons now (right click, customise instead of changing from the menu), it’s still lacking a “New Tab” button. Unfortunately, the old tip I’d used on how to make the “Add Bookmark” button into a “New Tab” button didn’t work any more, because of the new toolbar architecture.

This is how to fix it (disclaimer: the method here worked for me and I make no guarantees that it’ll work for you, even if it should. Don’t blame me if your shiny new OS X goes to bits because of this):

  1. Backup Safari.
  2. Install Xcode (from the OS X DVD). A bit overkill for that one button, yes*.
  3. Open Safari’s package contents (right-click, show package contents)
  4. Navigate into Contents, Resources, English.lproj
  5. Open ToolbarItems.nib (double clicking should open with Interface Builder)
  6. In the “ToolbarItems.nib (English)” window, double click on “First Responder”
  7. Press Cmd-Shift-I to bring up the Inspector window, if it’s not already open
  8. In the Inspector window, press Cmd-1 to make sure you’re looking at “Attributes”. Click on Add, and create a new item called “newTab” (without quotes)
  9. In the “Toolbar Items” window, click on one of the “torn pictures” and press Cmd-Shift-I to bring up the Inspector window if it’s not already open
  10. Select the one nearest the address bar (this should correspond to the placement in the “customise toolbar” menu), this is the “Add Bookmark” button
  11. Press Cmd-2 or choose “Connections”. Select “newTab” and click “Change Action” or simply double-click on it; there should be a round pushbutton icon next to it now.
  12. Save, quit and test.
  13. If it works, yay! If not, ummm, it wasn’t my fault. I hope you remembered step 1.

* I suppose I could email you the changed file if you wanted. No guarantees it’ll work, of course.

Everyone else who reads this blog and doesn’t share my childish glee about installing the new OS X: I’ll write about my trip soon, really…

Technology Press Releases This Week

Sunday, April 10th, 2005

Hitachi introduces “perpendicular recording” with an all-singing, all-dancing ensemble of… bits. Very, very amusing — if only all technology press releases were like this.

9884671601381992
Get Perpendicular! (via Engadget)