Nathan Firth

  • Archive
  • RSS

JavaScript Weirdness

I was just listening to the lightning talk by Gary Bernhardt from CodeMash 2012 and he brought up some really interesting (and funny) points about JavaScript.

For example:

» [] + [];
””

» {} + {};
NaN

» [] + {};
[object Object]

» {} + [];
0

So why is it that if you add two empty Arrays you get an empty string, but if you add two objects you get “not a number”. Array + Object is an Object but Object plus Array is 0???

    • #javascript
    • #weirdness
  • 10 hours ago
  • Permalink
  • Share
    Tweet

JavaScript: Clock Angle Problem

Earlier today I was presented with the problem of calculating the degrees between the hour hand and the minute hand of an analog clock. At first this seemed like a fairly complicated task, however after playing with it for a bit the solution became apparent. But now after looking up the answer on Google I feel really embarrassed on how easy the solution really is.

It’s amazing how complicated you can make a solution, when most of the time it can be solved so easily once you have the basic logic worked out.

Solution:

// h = 1..12, m = 0..59
function angle(h,m) {
hAngle = 0.5 * (h * 60 + m);
mAngle = 6 * m;
angle = Math.abs(hAngle - mAngle);
angle = Math.min(angle, 360 - angle);
return angle;
}

    • #JavaScript
    • #Math
    • #angle
    • #clock
    • #clock angle problem
    • #problem
  • 20 hours ago
  • Permalink
  • Share
    Tweet

Socialite.js

JavaScript for implementing social sharing buttons asynchronously. Support for Twitter, Google+, Facebook and LinkedIn

    • #social
    • #sharing
    • #socialite.js
    • #socialite
    • #javascript
    • #jquery
    • #js
    • #plugin
    • #facebook
    • #twitter
    • #google+
    • #linkedin
  • 4 days ago
  • Permalink
  • Share
    Tweet

The wooden spoon trick is even funnier in Icelandic. Friggin hilarious!!!

    • #woode
    • #spoon
    • #trick
    • #prank
    • #funny
    • #video
    • #wooden spoon
  • 4 days ago
  • Permalink
  • Share
    Tweet

Wow just wow! This video makes me wanna go snowboarding soo bad right now. But seriously when did snowboarding get this crazy???? Riders: Nick Dirks and Jed Anderson

    • #snowboarding
    • #snowboard
    • #nick dirks
    • #jed anderson
  • 1 week ago
  • Permalink
  • Share
    Tweet

Selectable Table Rows with Keyboard Navigation

Selectable Table Rows with Keyboard NavigationRecently I was working on a project where we needed to display a multi-select input. Very quickly it became apparent that the traditional select box would not work since the information we were presenting would need to be displayed in multiple columns and support pagination. The common sense answer was to display the information in a table however after some searching I realized there were no good plugins for selecting multiple table rows. The other requirement was to duplicate the functionality of a drop down and add in keyboard controls (shift click, ctrl click, etc.) so I set out to write my own.

So far I’m pretty happy with it, there are still some issues I need to work out but for the most part it’s a solid plugin. The plugin itself adds just the ability to select table rows with keyboard controls… however how that data gets there, or what you do with that information is up to you. I’ve added support for three callbacks:

  • on select (single click)
  • double click (or “Enter” key)
  • on change

And it supports the following keyboard controls:

  • Ctrl + Click
  • Shift + Click
  • Shift + Ctrl + Click
  • Shift + Up|Down Keys
  • Up|Down Keys
  • Enter (to select)

I’ll be uploading it to GitHub in the next day or so. I would love to get some feedback. Please check out the demo here: http://dev.nathanfirth.com/jquery-tableselect/

    • #jquery
    • #plugin
    • #jquery plugin
    • #table rows
    • #selectable table rows
    • #keyboard controls
    • #keyboard navigation
    • #jquery tables
  • 1 week ago
  • Permalink
  • Share
    Tweet

Alright, the video I shot and edited for @robcarona has finally been released.

  • 1 week ago
  • Permalink
  • Share
    Tweet
This past weekend was a lot of fun, I had the opportunity to film and edit the music Video titled “Beautiful” for Rob Carona. It’s the first time I’ve had the opportunity to create a music video, and as a web developer the opportunities to explore other forms of creative expression are not as frequent as I would like. The shoot itself could have been better coordinated, as we did not have a story board and most of the shots where rather spontaneous. However, I don’t think you will be able to tell from looking at the video. I think it turned out excellent for a video that was shot, edited and produced in less than two days. I’m still recovering from the lack of sleep, but it was a very rewarding experience and look forward to doing it again sometime.
I will post the link to the YouTube video shortly.
Pop-upView Separately

This past weekend was a lot of fun, I had the opportunity to film and edit the music Video titled “Beautiful” for Rob Carona. It’s the first time I’ve had the opportunity to create a music video, and as a web developer the opportunities to explore other forms of creative expression are not as frequent as I would like. The shoot itself could have been better coordinated, as we did not have a story board and most of the shots where rather spontaneous. However, I don’t think you will be able to tell from looking at the video. I think it turned out excellent for a video that was shot, edited and produced in less than two days. I’m still recovering from the lack of sleep, but it was a very rewarding experience and look forward to doing it again sometime.

I will post the link to the YouTube video shortly.

    • #rob carona
    • #music video
    • #canon 7d
    • #music
    • #band
    • #video shoot
  • 1 week ago
  • 1
  • Permalink
  • Share
    Tweet
Character is not made in a crisis, only exhibited
  • 2 weeks ago
  • Permalink
  • Share
    Tweet

About

I'm an internet entrepreneur, web developer, designer, lover of Jesus from San Diego. Originally from Sweden. I have a beautiful wife, and two amazing kids.
Follow @nathanfirth

loading tweets…

  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco but customized by Nathan Firth.

Powered by Tumblr