With breaks for coffee and snacks.

Add Nauseam

April 7th, 2010

So a quick shout out to any Javascript programmers. Please note that Javascript can’t add, multiply, subtract or divide. Let me repeat that for you: Javascript can’t add, multiply, subtract or divide.

I know it sounds implausible that the base code for all web browsers (ie. the internets) can’t do basic math. But I’ll prove it too you. Open up your “Error Console” (Firefox’s Tools->Error Console) and type the following basic math, followed by enter:

1.519+0.075

The Result:

Yep, according to Javascript, 1.519+0.0750 = 1.593999999999 (for all the math wizards out there, the correct answer is just 1.594).

I don’t want to hear those “Javascript Apologetics” out there blame something else, like the ways floating point numbers are calculated or that it’s the browser or whatever — if I were to design a programming language of any quality at all, Requirement #1 would be “can do basic math.” This imperfect result is in no way useful to me. I can’t even round it back to the right number reliably since the fractional inaccuracy isn’t consistent.

There is a solution, albeit an asinine one (since you really, really, really should NOT have to deal with this in the first place) but if you convert the number to a pure integer, do the math, and then convert it back to a decimal, then it all comes out mathematically correct.

Observe, the solution:

Math.round((1.519*Math.pow(10,3) + 0.075*Math.pow(10,3)))/Math.pow(10,3);

Yes, all of that to just add two numbers and get the correct result. To break it down:
  1. Math.pow is a way to do exponents. First argument is the base, second the exponent. So Math.pow(10,3) is the same as 10 ^ 3 (which equals 1000).
  2. The 1000 is then multiplied to each number: 1000 * 1.519 + 1000 *  0.075
  3. The result is 1519 + 75. Since these are whole integers, Javascript won’t do any fancy calculation-ruining floating point math. The result is simply 1594.
  4. Math.round will cut off any trailing decimals (though I’d recommend you just increase the precision with Math.pow instead).
  5. Now it will divide by 1000 to get it back down to a decimal: 1594 / 1000 = 1.594

There we go! We now skirt the whole floating-point error issue by using whole number arithmetic! It’s just that easy! Call now, and you all receive subtraction AND multiplication at no additional charge!

Subtraction:
function addNumbers(num1, num2, precision){
return Math.round((num1*Math.pow(10,precision) – num2*Math.pow(10,precision)))/Math.pow(10,precision);
}
Multiplication:
function multNumbers(num1, num2, precision){
Math.round((num1 * num2)*Math.pow(10,precision))/Math.pow(10,precision);
}

That is all. </rant>

-Andy


Posted in Coding, Rant | No Comments »

Spam I Am

March 24th, 2010

Like any WordPress blog, I get  a decent amount of spam comments. Even for a blog as backwoods as this, I still get a good handful every week. I covered how to set up spam controls on your wordpress blog before – but no spam filter is perfect and a few are bound to get through. I thought I’d share with you the system I’ve come up with to determine if any given comment is spam. If I had the time I’d write my own plug-in to detect and filter these, but the basic principle would go like this:

If the comment is in any way a compliment – it’s spam.

The fact is that no right-minded person would like this crap. It’s simply glaringly obvious when the comment is glowing with rave reviews that it was not written by an actual reader of your website. Here’s a few of the gems that I’ve received over the last few weeks that are so complimentary that they practically scream spam:

“Another quality post. I put in a plug for this blog at mine. So, I am sure many people forget the points you are making.”  — That’s true, many people do forget that Captain Picard finds his iPhone an ‘Amazing non-Borg extension of his human hand‘.

“Well said! If I could write like this I would be well happy. The more I see articles of such quality as this (which is rare), the more I think there might be a future for the Net. Keep it up, as it were.” — If only I could be well happy too…

“One has to ponder what the eventual final result of all of this could be – that said, impressive views yet again on this subject – and your webblog is still a first class supply of facts.” — To the spammer’s credit, this article did include a graph. However any graph whose title begins with “Pigeon vs.” is unlikely to be a first class supply of facts.

“You truly outdid yourself today. Well done” — Thanks? Frankly it’s not all that flattering if all I have to do is post a video of a keyboard cat knockoff to ‘outdo’ myself…

“For one am glad for this excellent article. Often times, the greatest content originate from the websites one may not expect. Recently, I did not give much thought to placing comments on web log posts and have left feedback even less. Looking through your powerful post, may well encourage me to take action more regularly.” — You’re too kind! I can see how an article about fake corrections to articles I never posted would be, if anything, powerful.

“Very interesting information here plenty to chew on thank you.” — Somehow I don’t think an article about a Verizon ad for Droid gave you much to digest…

“Hi all great information here and good thread to comment on. May I ask how did you think of these ideas ?” — Oh why thank you! To answer your question, I usually steal this crap from Reddit

If these guys had half a brain they’d write comments about how idiotic and wrong I am about everything – it’s a lot harder to pick those out from the real comments.

-Andy


Tags: ,
Posted in Random, Rant | No Comments »

Windoz 7 4 UR Phone

February 16th, 2010

"Golden Days" of Treo

It seems that Microsoft has finally decided to enter the Mobile market with their own OS. Oh what’s that you say? They’ve had a mobile version for years now? Oh yes, I remember now. It was that bland “mini me” copy of 2000/XP, with it’s cute little Start button, it’s cluttered home screen, it’s ‘massive’ collection of some of the worst software to ever be conceived. It replicated all the hardships of Windows in a convenient, on-the-go handheld headache.

Back in the day when “Mobile OS” meant PDA’s (not phones), I remember all the fun I had with Palm’s simplistic, minimalist PalmOS. It made a casual device feel, well, supremely casual. I remember the clean white sheets laced with playful colors on my Handsprings, the slick stylings of the menus on my Clié. Thinking back even further to the powerhouse that was the Apple Newton -  a device so ahead of it’s time, so feature rich than even it’s modern equivalents don’t exceed it functionally – I recall hours wasted playing games, taking notes in classes, even downloading programs straight from the internet. In 1994.

What I remember of Windows Mobile was an unnavigable sea of horrid software, a clunky port of Win2000’s already unimaginative interface, and the inevitability of freezing, crashing, and force-quitting whatever you managed to get running on the retched thing.

The lack of good software wasn’t really the programmer’s fault, however. I remember having to write a program on the platform, nothing too complex mind you, simple data entry with a server-side back end. Getting code to run on it was like a dream … in which I was being constantly beaten over the head with a splintery baseball bat. It’s a shock people bothered coding on it at all.

There’s a reason it’s popularity has dropped year over year and why the devices running it were the first PDA’s to die off and disappear. There was plenty of room for Windows Mobile to grow, but instead they lost ground to a (at the time) comparatively feature-poor RIM Blackberry, whose terrible click-wheel interface, dreadful setup and unreliable syncing stand as a testament to exactly how much worse Windows Mobile really was. When you boil down the argument to it’s most basic form, there is really only one reason Windows Mobile died off:

It sucked.

Not even the most dedicated fanboys have carried the flame. If there ever was a time for it to be born again from the ashes – what with Apple, RIM, and Palm gobbling up all the nooks and crannies in the booming mobile market – this is it.

And so it has been reborn, as the blogosphere is raving, and “Everything is Different”! All I can say is thank god. I hated how complex and frustrating Mobile Windows has been. It’s going to be cleaner, sexier, and so much simpler. So, please tell me, what did they call this revolution?

Windows Phone 7 Series.

Seriously? You’re going with that? That phrase barely makes sense … It sounds like something you’d see spelled out accidentally in magnetic fridge-poetry. Maybe they forgot to name it, and this morning when they wrote the press release, Balmer just started spouting words. “Oh what’s it called? It’s … uhm, windows … ph-phone, yes that’s it, windows phone .. the number seven …. er, series.”

We’re off to a fantastic start.

It’s clear from the name alone that Microsoft has really spent the time to drastically simplify the experience for their end users. NOT. Let me see, since we didn’t spend any time picking the name, they must have spent all of it revamping the interface. You know, really tearing down all their preconceptions and starting from square one.

Well, looking at the new home screen (on the right), I think they took the “square one” thing far too literally:

Left: Old and busted. Right: New hotness.

It’s hard not to improve on the word-vomit of Windows Mobile 6, really. So let’s see, with <do I have to type it? Ugh…> with Windows Phone 7 Series you can see at a glance:

  1. How many phones you have (in this case, 2)
  2. Your collection of canoeing pictures from StockPhotos.com
  3. An animated GIF of the logo for Xbox Live
  4. A mosaic of your ex’s from Facebook

It astounds me how Microsoft always puts emphasis on shear quantity of features over the slightest thought to real usability. Now instead of word-vomit, we  have what I will coin as colored-squares-vomit. This interface is literally assaulting me with color and 90° angles.

While it tip-toes on a ingeniously simple getup, it still manages to miss the mark on what people will probably use it for. A link to my Xbox profile taking up precious home screen real estate? There is literally no reason for me to want to check my Xbox profile anywhere, anytime other than when I’m on the Xbox. I just don’t get why this is cool. You can already look this crap up online, not that it was particularly interesting to begin with. And it made the home screen?

Ok so let’s move on, we’ve got photos, social portals, solitare:

Nothing to big to complain about here. I can’t really say I’m excited about a photo collection on my phone, I guess welcome to the 21st century on that one. I love the idea that I can simultaneously spam Facebook, MySpace, and Twitter at the same time. God knows I love redundancy. The Games section looks pretty sparse, and I am not liking that it’s bookended by ‘Spotlight’ ads on either side. Bleh.

Now let’s get onto the really important part of any mobile platform these days: the internet!

Oh for the love of all that is holy – it’s running f#@%ing Internet Explorer. Blog post over. Seriously, I can’t believe I didn’t see this coming. I honestly thought the only people that still used IE these days were the last 3 AOL users and companies with Stalinist IT departments. Get ready to hate the web all over again!

The only way I think it could be worse is if they integrated it tightly with Bing…

-Andy


Tags: , , , , , , , , , ,
Posted in News, Rant | No Comments »

Engage!-ing

February 2nd, 2010

Patrick Stewart and his take on the iPhone:

  • Amazing non-Borg extension of his human hand
  • Perfect for people who hate making phone calls
  • Can determine weather at Heathrow Airport from Starbase 117
  • Great for looking up that one forgotten line of Shakespeare
  • Games will be the end of us all

-Andy


Tags: , , , , , , , ,
Posted in Rant | 1 Comment »

The iPad Revolution

January 31st, 2010

Here’s the thing – Apple has been doing this for a very long time. If you find yourself saying “Oh the iPad sucks – it doesn’t have blank OR blank …What does it even do? Why would ANYONE possibly need this?!?” … then I’m sorry to say you still don’t get it.

I’ve been hearing these same old tired arguments since 1990 – when people didn’t understand why you’d want a computer that didn’t run Windows. They didn’t understand what you could do with a Mac – “Without Windows how can you _____ (fill in with something from 1990’s software library)??” I won’t lie – the fact was that Windows back then 1) had a much wider set of software available for it, 2) was a lot cheaper, and 3) could be a lot faster. So why would anyone purchase a Mac?

If here, in 2010, you still can’t answer that question, even if you do prefer Windows to this day – then you’d really missed their company philosophy entirely. And that’s a big deal considering how large an influence Apple has in the computer industry these days.

Don’t agree? Then answer me this: How many iPods have you owned so far? If it’s more than 1 … you should really get it. You purchased a product that was probably less-feature rich than competitors at the time (no radio, locked to iTunes, shorter battery life, battery wasn’t swappable, etc.). Why would you do such a thing? The answer is a lot less convoluted than most people admit. It wasn’t what it did, it was how you could use it. Plain and simple – more is less, less is more. Apple time and time again releases products with serious competitive shortcomings when you look at a straight-up feature list, but somehow they gain popularity to the point where they actually define new industry standards for usability.

You might be inclined to think the iPad is no iPod – that it’s uniquely crippled, so let’s take a moment to review. Here is what people said, what Apple fanboys nontheless, said about the original iPod in 2001:


“Gee! an mp3 player with a [hard drive]!” – ooh wow

“$400 for an Mp3 Player! … [It] wont sell, and [will] be killed off in a short time…and it’s not really functional.” - elitemacor

“Any way you spin this it is:
1. Not revolutionary. …
2. A bad fit. …
3. Without a future.” - Meetoo

[via MacRumors]

The iPad is exactly the same kind of product as the iPod was. It’s even got the same reviews. And it is going to be successful for the same reasons. It takes something really rather complex (a whole computer) and boils it down to a uniquely simplistic, casual medium. If you think about the average users out there – many don’t really understand their computers, not entirely. They tolerate them. People don’t really need a nest of files and folders, control panels and installers, device managers and drivers – they just need basic internet access, a way to view and hear their media, and maybe few simple games. The rest is really just trees obscuring the forrest.

Jason McC. Smith of The Microsoft Blog does a pretty good job explaining this:

“Windows and the Mac are, really, just two variants of the same theme: a geek machine. Consumers recognize they don’t need a pro-level machine, so they buy something cheap – but it’s just a badly hobbled pro machine, not a consumer machine.”
[via seattlepi]

Even as a developer, after I get home from work, I don’t really need a Core 2 Duo MBP with 512 MB of VRAM to just browse Reddit. Or even to write these blog entries. I especially don’t need a short battery life, a 6 lb. footprint, and a screaming 100° processor while just watching some TV, or eating a bowl of cereal in the morning. My iPhone would be perfect for these times – if it weren’t too small to browse, or too slow to handle it.

This is where the iPad fits a lot of our lives very nicely. It brings casual computing to the mainstream, in a way that leverages the usability of the iPhone with the size and power of an actual computer. I really think the iPad will spark a whole new era of simple, clean computing, in much the same way the iPod revolutionized MP3 players. In a sea of increasingly convoluted, complex computer systems, Apple has once again rethought the concept entirely, and come up with something that will, in all likelihood, be surprisingly convenient and fun to use.

No one needed an iPod – they were fine with CD’s. No one needed an iPhone – they were fine with their Blackberry’s. No one needed a MacBook – they were fine with their Dells.

And now more than half the laptops on campuses are Macs, everyone and their mother has an iPhone, and most people have owned a half dozen iPods in the short decade they’ve been around. Give it time, wait for the initial shock to wear off and the traditional resistance to die down, and I’d bet you’ll start seeing these things show up in the hands of those you’d least expect.

They called the iPod the “revolution in your pocket” – the iPad is simply the revolution on your desk.

-Andy


Tags: , , , , , ,
Posted in News, Rant | 5 Comments »

Dvorak

January 21st, 2010

So for no particular reason I’ve decided to learn  an alternative keyboard layout known as Dvorak (as opposed to Qwerty). The Dvorak layout reduces the amount of movement for your fingers and purportedly can actually improve your typing speeds. I even switched the keys on my keyboard to the traditional Dvorak layout:

Dvorak!

Dvorak was designed back in the 30’s, but the big push to make it common didn’t start until the computer age, as the typewriter was phased out and the original reasons for using Qwerty weren’t applicable anymore.

Wikipedia has an excellent article explaining the design:

  • For maximum speed and efficiency, the most common letters and digraphs should be the easiest to type. This means that they should be on the home row, which is where the fingers rest, and under the strongest fingers.
  • The least common letters should be on the bottom row, which is the hardest row to reach.
  • The right hand should do more of the typing, because most people are right-handed.
  • Digraphs should not be typed with adjacent fingers.
  • Stroking should generally move from the edges of the board to the middle. An observation of this principle is that, for many people, when tapping fingers on a table, it is easier going from little finger to index than vice versa. This motion on a keyboard is called inboard stroke flow.[3]

Dvorak is already feeling a lot more comfortable than Qwerty, learning curve aside. Considering Qwerty was invented just to keep typewriters from jamming and not for ease-of-use, the quirks of the layout become readily apparent after just a couple days with Dvorak. Qwerty is laid out so you almost never type on the same side left or right nor the same row top to bottom from letter to letter. In Dvorak the vowels are all on the home row to the left, and the common letters H, T, N, and S on the right. About half the time your fingers don’t even have to leave the home row to type the whole word.

While it does take a lot of practice up front, but I’m starting to get the hang of it. It’s actually been an interesting learning experience. The hard part isn’t so much learning where each individual letter has moved – but rather retraining the sort of engrained patterns of typing I’m used to. Words like “google” or “therefore” have a sort of  rhythm for me in Qwerty, and it’s difficult to learn a different pattern. What’s also odd is that words that I don’t seem to have a rhythm for yet (like “distinct”) have a good rhythm in Dvorak.

If you’d like to try it yourself, check out http://learn.dvorak.nl/. The tutorial lets you test out the layout without actually changing the keyboard settings.

You can also switch a normal keyboard to the Dvorak layout, in all operating systems. On a Mac, type “International” in Spotlight, and select the International System Pref. Under Input Menu, find Dvorak in the list and check the box. If you also check “Show input menu in menu bar”, you can toggle back between regular qwerty (U.S.) and Dvorak on the fly.

Happy hunting!

-Andy


Tags: , , ,
Posted in Random | 1 Comment »

Play Keyboard Dog Off, Keyboard Cat

January 21st, 2010

Keyboard Pug has met his match:

[via dailywhat]

-Andy


Tags: , ,
Posted in Random | No Comments »

I Think I’m Invisible…

January 19th, 2010

Foreign TV is so hilarious. In this clip two identical twins play a trick on some unsuspecting people who can’t seem to see their reflection in the mirror.

It’s funny because their clothes are different from my clothes!

[via reddit]

-Andy


Tags: , ,
Posted in Random | No Comments »

You Sure You Exist?

January 6th, 2010

I love this – someone wrote to The Consumerist that Comcast refuses to reactivate their service because they aren’t actually sure if they exist:

“Yesterday, our service stopped and that happened again. Only this time, Comcast has decided that *we don’t exist.* Therefore, they will not take the hold off our account until they send someone (in 4-5 business days) out to confirm that we exist.”

Perhaps in a metaphysical sense it’s a valid question. Do I even exist? Does anyone actually exist? Apparently, Comcast isn’t certain of the answer either – but thankfully they’ll be able to figure it out if you could just give them 4-5 business days.

In all seriousness though, couldn’t they just check Google Maps? I’d bet you could Street View them. Consumerist writer Meg Marco has an excellent point too:

“Also, did anyone suspect that Comcast had an ontology department? We didn’t. Anyone have their direct line?”

[via consumerist]

-Andy


Tags: , ,
Posted in News | No Comments »

What Happened America? You Used to Be Cool.

January 6th, 2010

Gotta love the Daily Show, they never let Fox New’s rhetoric fall through the cracks. John Oliver tries to help us figure out which of the ‘Golden Years’ their reporters keep referring to:

You know Fox News, I miss polio too, we all do. It’s also good to know that the Brits think Fox News is as much of a joke as we do:

via [reddit, reddit]

-Andy


Tags: , , , ,
Posted in News | No Comments »