Skip to content

Instantly share code, notes, and snippets.

@mbajur
mbajur / .md
Created April 29, 2016 07:16
How to create small, unique tokens in Ruby

How to create small, unique tokens in Ruby

That is is basically a "fork" of blog article i'm constantly returning to. It seems that the blog is down:

My choice: Dave Bass’s rand().to_s() trick

Dave Bass proposed this which I picked up for my implementation (here for an 8-chars token):

@tallclouds
tallclouds / resultados.rb
Created November 7, 2012 04:05 — forked from axelrivera/resultados.rb
Resultados Elecciones de Puerto Rico en Ruby
#!/usr/bin/env ruby
# You should run `gem install httparty` first
require 'httparty'
def comma_numbers(number, delimiter = ',')
number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, "\\1#{delimiter}").reverse
end