[ create a new paste ] login | about

Link: http://codepad.org/lojd8zLH    [ raw code | output | fork ]

Ruby, pasted on Aug 1:
puts("Here is what the Sass unique-id() function should return")

def unique_id
  require 'securerandom'
  String.new("u" + SecureRandom.hex(16))
  rescue LoadError
    options = {}
    options[:last_unique_id] ||= begin
                           min = 9500000000000000000
                           max = 10000000000000000000
                           range = max - min
                           rand(range) + min
                          end
    options[:last_unique_id] = options[:last_unique_id].succ
    String.new("u"+options[:last_unique_id].to_s(16))
  end

$i = 0
$num = 10

while $i < $num  do
    puts unique_id()
    $i += 1
end


Output:
1
2
3
4
5
6
7
8
9
10
11
Here is what the Sass unique-id() function should return
u84ec5b4cdecd4299
u871ec9c6e6049323
u8865b8a8e572e4e8
u85f6c40bb775eff2
u8868f6a1f716d29f
u89cf1fa575a7a765
u89184d7511933cd3
u8a7287c699a82902
u8547f4133644af4c
u86fb16af4800d46b


Create a new paste based on this one


Comments: