Skip to content

Instantly share code, notes, and snippets.

View florabtw's full-sized avatar

Flora Moon florabtw

View GitHub Profile
@florabtw
florabtw / Translate.js
Last active August 6, 2021 22:23
Run with `node Translate.js hello`
// TKK = hours since epoch
var window = {
TKK: parseInt(new Date().getTime() / 1000 / 60 / 60)
};
var t = "a";
var dd = ".";
var Vb = "+-a^+6";
var Tb = "+";
var Ub = "+-3^+b+-f";
@florabtw
florabtw / TL.js
Last active December 17, 2015 06:55
Extracted from obfuscated Google Translate JavaScript. The result of TL(a) is REQUIRED to interact with Google Translate's TTS engine.
// TKK = hours since epoch
var window = {
TKK: parseInt(new Date().getTime() / 1000 / 60 / 60)
};
var t = "a";
var cb = "&";
var mf = "=";
var k = "";
var dd = ".";
@florabtw
florabtw / Derangement
Created February 7, 2014 05:35
Iterative derangements / subfactorials using BigDecimals and BigIntegers in Java
public BigInteger derangement(int num) {
if (num == 0) {
return BigInteger.ONE;
}
BigDecimal sum = BigDecimal.ZERO;
for (int i = 0; i <= num; i++) {
BigDecimal fact = new BigDecimal(factorial(i));
BigDecimal toAdd = BigDecimal.valueOf(Math.pow(-1, i)).divide(fact, MathContext.DECIMAL128);
sum = sum.add(toAdd);