Category Archives: Geek

Building a GPA Calculator in Angular.js

I’m awed almost daily by the simplicity and elegance of Angular.js. By eliminating all of the DOM access syntax we’ve come to take for granted in jQuery and friends, and by giving any element on the page a live, two-way data binding relationship with your business logic, Angular lets you create anything from simple widgets to full-on Single Page Applications with the fewest lines of code possible.

I recently created a live GPA calculator as part of a large SPA I’m working on in my day job, but have boiled it down to its bare essence for this widget demo. Try changing the dropdown options here and watch the GPA calculation change in real-time:

View html | View script

In this example, we assume that a student’s current course load comes in over the wire with course names and units. We iterate over the course set and, for all courses being taken for a letter grade, multiply the numeric weight of a predicted grade by the number of units. Those scores get added up, then divided by the total number of units. When a new grade estimate is selected from a dropdown, we need to recalculate the whole aggregate. Let’s step through it.
Continue reading

Notes on the Death of Google Reader

So everyone’s going apeshit over the impending death of Google Reader. Can we keep a bit of perspective on this please?

- We loved and used RSS before Google Reader, and we’ll continue to love and use RSS long after it’s gone.

- Google Reader is just another RSS client. OK, its community integration features were unique, but as a pure client, there always have been, and will always continue to be, lots of far superior alternatives.

- This has nothing to do with “the death of open standards.” Nothing is happening to the RSS standard, for godssake.

- What do you expect from free software? A lifetime commitment?

I’ll grant that the big problem here is that Reader has become the default backing store for other clients. In fact, my favorite RSS client by far, Reeder, uses Google Reader as a storage and sync mechanism. Hopefully, Reeder will act quickly to enable other aggregators to fill that role, or to let us add feeds independently of a central aggregator. If it doesn’t, I’ll find one that does. Because, after all, that’s what all RSS aggregators did before Reader existed.

It’s not that big of a loss. RSS lives.

Thank God they spared Orkut.

Update: Reeder has already stated that they’ll live on after the death of Reader.

Here are 50+ Reader replacements either working now or on the horizon.

Lion’s Broken Color Picker

One of two mystifying downgrades that come with OS X Lion / Mountain Lion* is the fact that all traces of hex values have been removed from the Digital Colorimeter. For hundreds of thousands of web developers, obtaining hex values is the only purpose of Colorimeter, and I suspect that web developers are the bundled app’s main users. This one is a total head-scratcher. Hopefully the change is a bug, not a feature, and it’ll be back someday.

Meanwhile, if you’re looking for a workable free replacement, check out this simple Colors app. Not quite as elegant, but gets the job done just fine.

color-picker-os-x-lion

* The other mystifying downgrade in Mountain Lion is the “snooze” feature in iCal alerts. You used to be able to set a snooze to be re-reminded a few hours later, or the day before, or whatever you like. Now your only option is to acknowledge the alert and dismiss it, so the daily GTD workflow for bazillions of users is completely broken. What went through the heads of the designers removing this critical feature is anyone’s guess.

Spam Training on cPanel for Desktop Mail Clients

This is primarily a guide for administrators of cPanel hosting systems, though tech-savvy cPanel users with shell access will be able to use this technique as well.

Users of webmail systems like GMail, Yahoo, etc. are accustomed to having a “Mark as Spam” button in the interface. Clicking the button tells the server that the selected message is spam, to prevent similar messages from showing up in the inbox again. So how can administrators of standard cPanel-based hosting systems provide similar functionality?
Continue reading

Best Mac Upgrade Ever

A couple months ago, upgraded my wife’s old Mac Mini to a 13″ MacBook Air with SSD, and was stunned at how it blew my 3-yr-old MacBook Pro out of the water, performance-wise. Having 8GB rather than 4GB was part of it, but the real clincher was the fact that it shipped with an SSD drive rather spinning platters. I had read about the huge performance gains that solid state gets you, but was unprepared for just how great it feels to work in all-RAM environment. No more waiting 45 seconds for Photoshop to launch (four seconds, anyone?). No more feeling the crunch as you’re trying to start that Skype conference while both Backblaze and Spotlight indexing are competing for swap space.

Continue reading

Tweetbot Bookmarklet for Chrome

Despite a few quibbles, I’ve pretty much fallen in love with the desktop Twitter client Tweetbot. But the one thing I really missed from the official Twitter for Mac client was a good browser bookmarklet for Chrome, so I could start a new tweet from the current web page’s URL and document title.

I did find one referenced in this review, but it was DoA in Chrome – does nothing when clicked. With a bit of monkeying around, I’ve modified it to get along with Chrome:

javascript:window.location='tweetbot:///post?text='+encodeURIComponent(document.title)+encodeURIComponent(' ')+encodeURIComponent(window.location.href)

To install: Copy the code above to your clipboard. Create a new bookmark (of any page) and edit its properties. Paste over the URL with the contents of your clipboard. Save, and Bob’s your uncle!

Full-Screen Album Art in iTunes

If there’s one thing that bums me out, it’s an MP3 without big beautiful cover art. Like all y’all old-school LP guys, having high-quality album cover art on full display is part of the listening experience.  I’ve just spent the past couple years digitizing my entire LP and CD collections, then tracking down the best-possible cover art for every single one of the 5,000+ albums I ended up with — even if it meant photographing or scanning covers by hand.

With all that work done, I wanted to find a good way to display cover art on the Mac as cleanly as possible, without the clutter of other app windows in the way, and ideally without turning to 3rd-party software.

At first, I thought CoverFlow would be the One True Way, but  in practice, CoverFlow can’t be trusted. I find it constantly gets stuck on a cover, and no amount of toggling the “Now Playing / Selected” widget or switching between List View and CoverFlow view will coax it out of its rut.

Here’s the recipe I came up with – let me know if you have a better one:

0) Make sure all of your music has the highest-quality album art possible :) CoverScout is an awesome tool if you want to automate/simplify the process somewhat.

1) Make sure the Now Playing / Selected preview window is showing by clicking the disclosure triangle at the bottom left.

2) Double-click on the album cover to open it in a new, detached window (never knew you could do that, amiright?)

3) Use Mission Control to move that window to a new desktop. If you’re not already using multiple desktops, just drag the detached cover art window to a blank space near the top of Mission Control.

4) Switch to the new desktop and maximize the Now Playing window.

Now, to see your full-screen album art quickly, just switch to the other desktop. There are several ways to do this quickly in OS X, but I prefer either the three-finger sideswipe (if you have a laptop or trackpad) or Ctrl+Arrow[Left/Right].

Yes, there’s a small bit of setup, but since Mountain Lion restores all windows to their previous state after a reboot, you never have to do it again.

BTW, the cover art display isn’t just pretty – it’s functional too. Hover over the art and a controller will appear, giving you full scrub / skip / pause control, and letting you see the name of the current track and album.

Bonus: Remote Control
The really bad-ass thing is that you don’t have to do this from the Mac where the iTunes library lives – if you have a media server Mac that’s separate from the one you do your work on, you can run it all on a  by remote control, via iTunes Home Sharing.  I do my work on a MacBook Pro from the living room, which talks to iTunes on a Mac Mini server in the office which houses the music collection. The MacBook’s instance of iTunes in turn sends its output via AirPlay to an AirPort Express connected to the stereo across the living room from me. It’s a big crazy triangle, but the experience is completely smooth and user friendly (much nicer than the old VNC solution I used to use). If you would prefer to use a VNC client, I can’t recommend Jolly’s highly enough – the elastic screen feature is trippy, but does an amazing job of compensating for the fact that you might be controlling a huge monitor from a small one.

Comparing Javascript frameworks

It’s almost bewildering to see how many different (contrasting) opinions there are out there. After reading the post, check out the comments.

There are disagreements on which approach is the most performant, on whether using a custom collection of libraries (more flexible but more work) or a more complete framework (less flexible but less work) makes mores sense. There is disagreement over whether a whole site should be a Single Page Application, or just a section of a site. In fact, there’s disagreement over what constitutes the difference between a “site” and an “application” to begin with. There’s disagreement on whether client-side or server-side DOM-building is faster.

But the thing that struck me the most was this: The article starts with the premise:

“It’s no longer good enough to build web apps around full page loads and then “progressively enhance” them to behave more dynamically.”

but as one commenter astutely points out:

“… unless you happen to be github or 37signals, in which case you can easily build apps and progressively enhance to be fast and responsive ….”

I’m personally in the latter camp – it may just be a matter of habit, but I see the most logic in building traditional server-side DOM and then using “sprinkle on top” JS to enhance functionality where needed. I know I’m part of a slowly shrinking group of developers who haven’t bought into the 100% Javascript thing, but the “server first” approach does seem (to me) to give the best combination of  ease of development, graceful degradation, SEO, and performance.

But I’m ready and willing to have my philosophy tweaked on this – all I need is an example of how JS-based DOM creation can be as fast, easy, and performant as it is in Django, while still giving easy access to deep data traversals, model methods, and permissions (without jumping through time-costing hoops).

Today I begin my exploration of Rails in ernest. It’s becoming apparent that Rails has evolved in this direction more quickly than Django by building REST directly into the framework (Django is more about extremely DRY data modeling and it’s awesome auto-generated internal API).

So much to think about, so much cool stuff to explore.

http://blog.stevensanderson.com/2012/08/01/rich-javascript-applications-the-seven-frameworks-throne-of-js-2012/

Google+: View post on Google+