Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
import time
n = 10000000
t0 = time.time()
l = range(n)
@ehmo
ehmo / base62.go
Last active August 29, 2015 14:22
Implementation of an URL shortener using base62 encoding in Go
package main
import (
"fmt"
"strings"
)
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
// Integer power: compute a**b using binary powering algorithm
>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'en_US')
'en_US'
>>> = locale.format("%d", 123456789, grouping=True)
123,456,789
>>> locale.setlocale(locale.LC_ALL, 'sk_SK')
'sk_SK'
>>> locale.format("%d", 123456789, grouping=True)
123 456 789

Keybase proof

I hereby claim:

  • I am ehmo on github.
  • I am turek (https://keybase.io/turek) on keybase.
  • I have a public key whose fingerprint is 97D9 5F5C 45AF 0D22 AF72 8CA8 6D15 F112 A4FE 9431

To claim this, I am signing this object: