Skip to content

Instantly share code, notes, and snippets.

@jpignata
Forked from sebastien-p/LICENSE.txt
Created June 17, 2014 15:56
Show Gist options
  • Select an option

  • Save jpignata/d6f28c74b1340af69f3f to your computer and use it in GitHub Desktop.

Select an option

Save jpignata/d6f28c74b1340af69f3f to your computer and use it in GitHub Desktop.
function (
a, // Positive integer
b, // placeholder for result
c // placeholder for modulo
) {
for (b = ""; ~~a > 0;)
b = String.fromCharCode(((c = a % 62) > 9 ? c > 35 ? 29 : 87 : 48) + c) + b,
a /= 62;
return b || "0";
}
function(a,b,c){for(b="";~~a>0;)b=String.fromCharCode(((c=a%62)>9?c>35?29:87:48)+c)+b,a/=62;return b||"0"}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Sebastien P. https://twitter.com/#!/_sebastienp
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "base62 encode",
"description": "A JavaScript implementation of base62 encode.",
"keywords": [
"base62",
"encode",
"integer",
"number"
]
}
<!DOCTYPE html>
<title>Foo</title>
<div>Expected value: <b>agEoLQ</b></div>
<div>Actual value: <b id="ret"></b></div>
<script>
// write a small example that shows off the API for your example
// and tests it in one fell swoop.
var myFunction = function(a,b,c){for(b="";~~a>0;)b=String.fromCharCode(((c=a%62)>9?c>35?29:87:48)+c)+b,a/=62;return b||"0"};
document.getElementById("ret").innerHTML = myFunction(9407378038)
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment