Skip to content

Instantly share code, notes, and snippets.

@bugventure
bugventure / base58.js
Created September 13, 2016 15:06
Base58 encode/decode a decimal number
var alphabet = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
var base = alphabet.length; // base is the length of the alphabet (58 in this case)
// utility function to convert base 10 integer to base 58 string
function encode(num) {
var encoded = '';
while (num){
var remainder = num % base;
num = Math.floor(num / base);
encoded = alphabet[remainder].toString() + encoded;
@mortehu
mortehu / zip-test.cc
Last active May 23, 2022 12:00
C++ zip
#include <cstdio>
#include <list>
#include <vector>
#include "zip.h"
int main() {
std::vector<int> one{{1, 11}};
auto two = [] { return std::vector<short>{{2, 22}}; };
const std::list<float> three{{3, 33}};