Skip to content

Instantly share code, notes, and snippets.

@disolovyov
Created June 3, 2011 13:10
Show Gist options
  • Select an option

  • Save disolovyov/1006306 to your computer and use it in GitHub Desktop.

Select an option

Save disolovyov/1006306 to your computer and use it in GitHub Desktop.
# Re: https://gist.github.com/1005723
Spine.guid = ->
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace /[xy]/g, (c) ->
r = Math.random() * 16 | 0
v = if c is 'x' then r else r & 3 | 8
v.toString 16
.toUpperCase()
# Should compile to:
#
# Spine.guid = function() {
# return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
# var r, v;
# r = Math.random() * 16 | 0;
# v = c === 'x' ? r : r & 3 | 8;
# return v.toString(16);
# }).toUpperCase();
# };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment