Skip to content

Instantly share code, notes, and snippets.

View Trung0246's full-sized avatar

Trung0246

View GitHub Profile
@Trung0246
Trung0246 / functional.js
Last active November 21, 2024 05:36
Functional in JS
(function() {
var ff = {};
ff._ = Symbol("_");
ff._$ = Symbol("_$");
function thunk(fn) {
fn[ff._$] = true;
return fn;
@Trung0246
Trung0246 / code.js
Created November 13, 2024 06:19
Correct form.
var compose = (...fns) => (...args) => fns.reduceRight((res, fn) => [fn.call(null, ...res)], args)[0];
var toUpperCase = s => s.toUpperCase();
var head = arr => arr[0];
var tail = arr => arr.slice(1);
var split = s => arr => arr.split(s);
var join = s => arr => arr.join(s);
var map = fn => arr => arr.map(fn);
var filter = fn => arr => arr.filter(fn);
compose(join(". "), map(compose(toUpperCase, head)), split(" "))("hunter stockton thompson")
@Trung0246
Trung0246 / BTreeP.js
Created May 2, 2022 01:09
B-Tree+ with Insertion algorithm
function BTreePLink () {
this.data = [];
this.next = null; // If null then end of linked list
}
function BTreePNode () {
this.owe = null;
this.part = []; // If empty then leaf node
this.node = []; // If length > 0 then leaf node
}
@Trung0246
Trung0246 / nimoTVDecode.py
Created July 18, 2021 05:44
Extract stream url from data blob
from jce import types, JceStruct, JceField
# from jce.types import JceType
# from typing import Dict, Tuple
# from typing import Dict, Tuple, Optional, Type, Any
# import struct
# get the raw data blob from G_roomBaseInfo.mStreamPkg
@Trung0246
Trung0246 / simpleDirtyCoroutine.js
Last active January 24, 2017 04:14
Coroutine implementation in ES5 Javascript, same like Generator in ES6, pretty heavy(?) to process, as I never test performance before ...
//P.S: really sorry for bad English, not my first language :(
//Main coroutine class
function Coroutine(configs, condition, param, actions, workData) {
/*
Configs object: (Only have one option, really ... useless?)
{
reset: //Boolean, check if Coroutine be able to reset and iterate again,
}
*/
@Trung0246
Trung0246 / util.js
Last active November 20, 2016 07:03
A bunch of function that dirty and helpful found on stackoverflow and other sites...
var Notations = {
Short_Number_Old: 1,
Long_Number_Old: 2,
Short_Number_New: 3,
Long_Number_New: 4,
Exponential: 5,
Scientific: 6,
Engineering: 7,
};
Decimal.format = Notations.Long_Number_Old;