Skip to content

Instantly share code, notes, and snippets.

@inhji
Created October 22, 2013 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inhji/7097180 to your computer and use it in GitHub Desktop.
Save inhji/7097180 to your computer and use it in GitHub Desktop.
Helpers
###
http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
###
String::hashCode = ->
hash = 0
return hash if @length is 0
while i < @length
c = @charCodeAt(i)
hash = ((hash<<5) - hash) + char
hash = hash & hash
hash
###
http://stackoverflow.com
###
Object::count = ->
that = this
count = 0
for property of that
count++ if that.hasOwnProperty(property)
count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment