Skip to content

Instantly share code, notes, and snippets.

View rubenlozano's full-sized avatar

Ruben Lozano rubenlozano

View GitHub Profile

Keybase proof

I hereby claim:

  • I am rubenlozano on github.
  • I am rubiks (https://keybase.io/rubiks) on keybase.
  • I have a public key ASCv6rVJn_oQ5NOYV-VJ2-BjEt-NXD19Vtncerr4DQHeJgo

To claim this, I am signing this object:

# Write a method that will return the appropriate currency representation of a string.
def to_currency(amount)
dollars, decimal_point, cents = amount.to_f.round(2).to_s.partition(".")
dollars = dollars.reverse.scan(/.{3}|.+/).join(",").reverse
dollars.insert(0, "$")
cents.insert(-1, "0") if cents.length < 2
@rubenlozano
rubenlozano / gist:4521689
Last active July 26, 2021 13:39
Running JavaScript in OS X terminal
There is a javascript console, called JSC, in:
/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc
JSC is not in the shell PATH by default, to fix that:
$ sudo ln /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /usr/local/bin
Note that you'll have to use debug() instead of the conventional console.log() in your script to see any output.