Skip to content

Instantly share code, notes, and snippets.

View BobNobrain's full-sized avatar

Nikita Ivanov BobNobrain

View GitHub Profile
@BobNobrain
BobNobrain / mprun.user.css
Last active October 27, 2025 17:17
A collection of style fixes to make mobile version of APEX a bit more usable.
/* ==UserStyle==
@name Enhanced APEX Mobile
@namespace apex.prosperousuniverse.com
@version 0.1.0
@license wtfpl
@preprocessor default
==/UserStyle== */
/* App header */
.Header__header___EHTNVNS {
@BobNobrain
BobNobrain / AsyncMutex.ts
Created December 6, 2019 13:54
Async mutex
type Async<T> = T | PromiseLike<T> | Promise<T>;
// concrete case of more generic use :: (Monad m) => (m (m Top)) -> m (a -> b) -> m b
async function useAsync<T>(lock: () => Async<() => Async<unknown>>, body: () => Async<T>): Promise<T> {
const unlock = await lock();
const result = await body();
await unlock();
return result;
}
@BobNobrain
BobNobrain / Map.js
Created July 1, 2019 14:26
Map polyfill
function Map(content) {
this._keys = [];
this._values = [];
this.length = 0; // specification
if (content != null) { // null or undefined
for (var key in content) {
var pair = content[key];
this.set(pair[0], pair[1]);
}
function Class() {}
Class.extend = function (desc) {
// Реализовать данный метод
var Child = function () {
desc.constructor.apply(this, arguments);
}
Child.prototype = Object.create(this.prototype);
for (var key in desc) {
if (key === 'constructor') continue;
@BobNobrain
BobNobrain / curry.js
Created March 13, 2019 12:37
Generic JavaScript curry function (ES6+)
/**
* Generic curry function
* @param {Function} f A JS function to curry
* @param {Number | void} n Minumal argument count to call function
* @param {Array | void} bound Bound arguments
* @example
* const f = curry((a, b, c) => a + b * c);
* f(1, 2)(2) // 5
* f()(1)(2)()(2, 1000) // 5
* f(1, 2, 2) // 5
@BobNobrain
BobNobrain / augmentator.js
Last active March 4, 2019 22:17
Google Translate Augmentator
(() => {
const btn = document.createElement('div');
'tlid-input-button input-button header-button text-icon'.split(' ').map(c => btn.classList.add(c));
btn.innerHTML = '<div class="text">Вжух</div>';
btn.addEventListener('click', function transform() {
const tx = document.getElementById('source');
const lines = tx.value.split('\n');
tx.value = lines
.map(l => l.trim())
.map(l => l.endsWith('-') ? l.substr(0, l.length - 1) : l + ' ')
@BobNobrain
BobNobrain / kkl.js
Last active November 20, 2018 21:14
KKL converter
class DBN {
constructor(n) { this.n = n; }
}
class Pair {
constructor(x, y) { this.x = x; this.y = y; }
toString() { return `[${this.x}, ${this.y}]`; }
}
class BinOpr {
constructor(op) { this.name = op; }
}