-
-
Save jpignata/d6f28c74b1340af69f3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "base62 encode", | |
| "description": "A JavaScript implementation of base62 encode.", | |
| "keywords": [ | |
| "base62", | |
| "encode", | |
| "integer", | |
| "number" | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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