Discuss Scratch
- Thermodynamical
- Scratcher
44 posts
Contribute To An Open Source Project
Hey AT'ers,
I am requesting assistance for my first open source project, Gobo.cf. Gobo.cf is a URL shortener for Scratch projects, users, studios, and discuss links. I am mainly looking for assistance in the area of aesthetics for the project, as I am not very good with web design.
I hope some of you will check it out!
Link: GitHub
Psst, this is also an easy way to get a PR for Hacktoberfest.
I am requesting assistance for my first open source project, Gobo.cf. Gobo.cf is a URL shortener for Scratch projects, users, studios, and discuss links. I am mainly looking for assistance in the area of aesthetics for the project, as I am not very good with web design.
I hope some of you will check it out!
Link: GitHub
Psst, this is also an easy way to get a PR for Hacktoberfest.
- Thermodynamical
- Scratcher
44 posts
Contribute To An Open Source Project
If you have any ideas for the project you can suggest those too!!
- badatprogrammingibe
- Scratcher
500+ posts
Contribute To An Open Source Project
Links are already short enough for regular use.
- MegaApuTurkUltra
- Scratcher
1000+ posts
Contribute To An Open Source Project
eh, things like Links are already short enough for regular use.https://scratch.mit.edu/projects/137835837/ is kinda long.
https://gobo.cf/p/9KLOf might be a little better (here using /p/ for project and converting base 10 ID to base 62)
Last edited by MegaApuTurkUltra (Oct. 22, 2018 23:13:43)
$(".box-head")[0].textContent = "committing AT crimes since $whenever"
- Thermodynamical
- Scratcher
44 posts
Contribute To An Open Source Project
This is a good idea for shortening the links further. Do you mind creating an issue for this in the official repository?eh, things like Links are already short enough for regular use.https://scratch.mit.edu/projects/137835837/ is kinda long.
https://gobo.cf/p/9KLOf might be a little better (here using /p/ for project and converting base 10 ID to base 62)
- Thermodynamical
- Scratcher
44 posts
Contribute To An Open Source Project
Bump.
We are still looking for contributors!
We are still looking for contributors!
- space_elephant
- Scratcher
500+ posts
Contribute To An Open Source Project
Wouldn't base 75 be better?eh, things like Links are already short enough for regular use.https://scratch.mit.edu/projects/137835837/ is kinda long.
https://gobo.cf/p/9KLOf might be a little better (here using /p/ for project and converting base 10 ID to base 62)
It uses all chars allowed on URLs:
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$-_.+!*'()
- MegaApuTurkUltra
- Scratcher
1000+ posts
Contribute To An Open Source Project
possibly, but I am not really a fan of symbols in permalinks tbh. Maybe just alphanumeric and dash, underscore, period?Wouldn't base 75 be better?eh, things like Links are already short enough for regular use.https://scratch.mit.edu/projects/137835837/ is kinda long.
https://gobo.cf/p/9KLOf might be a little better (here using /p/ for project and converting base 10 ID to base 62)
It uses all chars allowed on URLs:
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$-_.+!*'()
Last edited by MegaApuTurkUltra (Dec. 11, 2018 20:38:54)
$(".box-head")[0].textContent = "committing AT crimes since $whenever"
- xn--cr8h
- New to Scratch
48 posts
Contribute To An Open Source Project
agreed, but not period - it's too small and could be confusing. plus alphanumeric and underscore and hyphen make for base 64, which is a nice, round factor of 2 that makes computers happypossibly, but I am not really a fan of symbols in permalinks tbh. Maybe just alphanumeric and dash, underscore, period?Wouldn't base 75 be better?eh, things like Links are already short enough for regular use.https://scratch.mit.edu/projects/137835837/ is kinda long.
https://gobo.cf/p/9KLOf might be a little better (here using /p/ for project and converting base 10 ID to base 62)
It uses all chars allowed on URLs:
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$-_.+!*'()
rip scratch forums 2007-2017
- LuckyLucky7
- Scratcher
1000+ posts
Contribute To An Open Source Project
Since when do computers have feelings? Nobody even knows if computers have feelings or not…agreed, but not period - it's too small and could be confusing. plus alphanumeric and underscore and hyphen make for base 64, which is a nice, round factor of 2 that makes computers happypossibly, but I am not really a fan of symbols in permalinks tbh. Maybe just alphanumeric and dash, underscore, period?Wouldn't base 75 be better?eh, things like Links are already short enough for regular use.https://scratch.mit.edu/projects/137835837/ is kinda long.
https://gobo.cf/p/9KLOf might be a little better (here using /p/ for project and converting base 10 ID to base 62)
It uses all chars allowed on URLs:
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$-_.+!*'()
Last edited by LuckyLucky7 (Dec. 12, 2018 00:49:33)
- LuckyLucky7
- Scratcher
1000+ posts
Contribute To An Open Source Project
I have gathered up a base64 generator:
Source: https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
(function(window){
"use strict";
var log = Math.log;
var LN2 = Math.LN2;
var clz32 = Math.clz32 || function(x) {return 31 - log(x >>> 0) / LN2 | 0};
var fromCharCode = String.fromCharCode;
var originalAtob = atob;
var originalBtoa = btoa;
function btoaReplacer(nonAsciiChars){
// make the UTF string into a binary UTF-8 encoded string
var point = nonAsciiChars.charCodeAt(0);
if (point >= 0xD800 && point <= 0xDBFF) {
var nextcode = nonAsciiChars.charCodeAt(1);
if (nextcode !== nextcode) // NaN because string is 1 code point long
return fromCharCode(0xef/*11101111*/, 0xbf/*10111111*/, 0xbd/*10111101*/);
// https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
if (nextcode >= 0xDC00 && nextcode <= 0xDFFF) {
point = (point - 0xD800) * 0x400 + nextcode - 0xDC00 + 0x10000;
if (point > 0xffff)
return fromCharCode(
(0x1e/*0b11110*/<<3) | (point>>>18),
(0x2/*0b10*/<<6) | ((point>>>12)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | ((point>>>6)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/)
);
} else return fromCharCode(0xef, 0xbf, 0xbd);
}
if (point <= 0x007f) return inputString;
else if (point <= 0x07ff) {
return fromCharCode((0x6<<5)|(point>>>6), (0x2<<6)|(point&0x3f));
} else return fromCharCode(
(0xe/*0b1110*/<<4) | (point>>>12),
(0x2/*0b10*/<<6) | ((point>>>6)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/)
);
}
window["btoaUTF8"] = function(inputString, BOMit){
return originalBtoa((BOMit ? "\xEF\xBB\xBF" : "") + inputString.replace(
/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g, btoaReplacer
));
}
//////////////////////////////////////////////////////////////////////////////////////
function atobReplacer(encoded){
var codePoint = encoded.charCodeAt(0) << 24;
var leadingOnes = clz32(~codePoint);
var endPos = 0, stringLen = encoded.length;
var result = "";
if (leadingOnes < 5 && stringLen >= leadingOnes) {
codePoint = (codePoint<<leadingOnes)>>>(24+leadingOnes);
for (endPos = 1; endPos < leadingOnes; ++endPos)
codePoint = (codePoint<<6) | (encoded.charCodeAt(endPos)&0x3f/*0b00111111*/);
if (codePoint <= 0xFFFF) { // BMP code point
result += fromCharCode(codePoint);
} else if (codePoint <= 0x10FFFF) {
// https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
codePoint -= 0x10000;
result += fromCharCode(
(codePoint >> 10) + 0xD800, // highSurrogate
(codePoint & 0x3ff) + 0xDC00 // lowSurrogate
);
} else endPos = 0; // to fill it in with INVALIDs
}
for (; endPos < stringLen; ++endPos) result += "\ufffd"; // replacement character
return result;
}
window["atobUTF8"] = function(inputString, keepBOM){
if (!keepBOM && inputString.substring(0,3) === "\xEF\xBB\xBF")
inputString = inputString.substring(3); // eradicate UTF-8 BOM
// 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx
// 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx
return originalAtob(inputString).replace(/[\xc0-\xff][\x80-\xbf]*/g, atobReplacer);
};
})(typeof global == "" + void 0 ? typeof self == "" + void 0 ? this : self : global);
function b64EncodeUnicode(str) {
// first we use encodeURIComponent to get percent-encoded UTF-8,
// then we convert the percent encodings into raw bytes which
// can be fed into btoa.
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
function toSolidBytes(match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
b64EncodeUnicode('✓ à la mode'); // "4pyTIMOgIGxhIG1vZGU="
b64EncodeUnicode('\n'); // "Cg=="
function Base64Encode(str, encoding = 'utf-8') {
var bytes = new (TextEncoder || TextEncoderLite)(encoding).encode(str);
return base64js.fromByteArray(bytes);
}
- space_elephant
- Scratcher
500+ posts
Contribute To An Open Source Project
It's a power of two. Not a factor. The factors of two are one and two. A number is a power of two if it is one, or another power of two, times two.agreed, but not period - it's too small and could be confusing. plus alphanumeric and underscore and hyphen make for base 64, which is a nice, round factor of 2 that makes computers happypossibly, but I am not really a fan of symbols in permalinks tbh. Maybe just alphanumeric and dash, underscore, period?Wouldn't base 75 be better?eh, things like Links are already short enough for regular use.https://scratch.mit.edu/projects/137835837/ is kinda long.
https://gobo.cf/p/9KLOf might be a little better (here using /p/ for project and converting base 10 ID to base 62)
It uses all chars allowed on URLs:
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$-_.+!*'()
In this case we can't do much about usernames (usernames already use 0-9 a-z A-z - _) i.e.
gobo.cf/u/space_elephant/
rather than
https://scratch.mit.edu/users/space_elephant/
- MegaApuTurkUltra
- Scratcher
1000+ posts
Contribute To An Open Source Project
<code>
I think you're misunderstanding. We don't need a general base64 encoder, we need a specific one that works on this specific URL-safe alphabet (no +, /, = ) and works on numbers, not arbitrary text. I made one here (CC0)
const alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"; function matuBase64(i) { let out = ""; if (i == 0) { out = alphabet[0]; return out; } while (i > 0) { let rem = i % 64; i = Math.floor(i / 64); out = alphabet[rem] + out; } return out; } function matuEsab64(s) { let out = 0; for (let i = 0, b = 1; i < s.length; i++) { out += alphabet.indexOf(s[s.length - i - 1]) * b; b = b * 64; } return out; }
http://jsfiddle.net/5gt0vh9e/1/
Now for usernames you could try doing something fancy like huffman coding with a predetermined table for English letter frequencies etc but it would give you marginal benefit probably
Last edited by MegaApuTurkUltra (Dec. 12, 2018 20:21:31)
$(".box-head")[0].textContent = "committing AT crimes since $whenever"
- Jonathan50
- Scratcher
1000+ posts
Contribute To An Open Source Project
You could just go I think you're misunderstanding. We don't need a general base64 encoder, we need a specific one that works on this specific URL-safe alphabet (no +, /, = ) and works on numbers, not arbitrary text. I made one here (CC0)
…
http://jsfiddle.net/5gt0vh9e/1/
function matuBase64(i) { let out = ""; if (i == 0) return alphabet[0]; while (i > 0) { out = alphabet[i & 63] + out; i >>= 6; } return out; }
Not yet a Knight of the Mu Calculus.
- space_elephant
- Scratcher
500+ posts
Contribute To An Open Source Project
<code>
I think you're misunderstanding. We don't need a general base64 encoder, we need a specific one that works on this specific URL-safe alphabet (no +, /, = ) and works on numbers, not arbitrary text. I made one here (CC0)const alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"; function matuBase64(i) { let out = ""; if (i == 0) { out = alphabet[0]; return out; } while (i > 0) { let rem = i % 64; i = Math.floor(i / 64); out = alphabet[rem] + out; } return out; } function matuEsab64(s) { let out = 0; for (let i = 0, b = 1; i < s.length; i++) { out += alphabet.indexOf(s[s.length - i - 1]) * b; b = b * 64; } return out; }
http://jsfiddle.net/5gt0vh9e/1/
Now for usernames you could try doing something fancy like huffman coding with a predetermined table for English letter frequencies etc but it would give you marginal benefit probably
function fromB64(value) { const chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_"; num = 0; track = 0; while (track<value.length) { num = (num << 6) | chars.indexOf(value[track]); track ++; } return num; } function toB64(value) { if (value == 0) return '0'; const chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_"; var flipped = []; while (value > 0) { flipped.push(chars[value & 0x3f]); value >>= 6; } var result = []; while (flipped != []) { result.push(flipped.pop()); } return result; }