Skip to content

Instantly share code, notes, and snippets.

View e-mihaylin's full-sized avatar
🏠
Working from home

Eugene Mihaylin e-mihaylin

🏠
Working from home
View GitHub Profile
//Extend the String object with toBase64() and fromBase64() functions
String.prototype.toBase64 = function () {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
let result = '';
let i = 0;
while (i < this.length) {
let a = this.charCodeAt(i++) || 0;
let b = this.charCodeAt(i++) || 0;
let c = this.charCodeAt(i++) || 0;
const hammingWeight = v => {
v = v - (v>>1 & 0x55555555);
v = (v & 0x33333333) + (v>>2 & 0x33333333);
return ((v + (v>>4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
function SumBigNumbers (a, b) {
var res = '', c = 0;
a = a.split('');
b = b.split('');
while (a.length || b.length || c) {
c += ~~a.pop() + ~~b.pop();
res = c % 10 + res;
c = c > 9;
}
return res;