Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# Try to determine how much RAM is currently being used per program.
# Note per _program_, not per process. So for example this script
# will report RAM used by all httpd process together. In detail it reports:
# sum(private RAM for program processes) + sum(Shared RAM for program processes)
# The shared RAM is problematic to calculate, and this script automatically
# selects the most accurate method available for your kernel.
# Licence: LGPLv2
const f = () => {
let e = document.querySelector('.shadow');
e = e && e.previousSibling;
e = e && e.previousSibling;
e = e && e.innerText;
e = e && e.split(/[\s\{]/ig).filter(e => e).shift();
e = e && document.querySelector(e);
e && e.remove();
e = document.querySelector('[data-metrika="film_card"]');
const barHeight = 72;
const list = document.querySelectorAll('a h3');
let index = 0;
list[index].classList.add('selected');
document.body.addEventListener('keydown', e => {
if (e.keyCode === 38 || e.keyCode === 40) { e.preventDefault(); }
});
const peakBounce = (interval, count) => {
let iCount = 0;
let stack = [];
setInterval(() => {
const part = stack.splice(0, count);
part.forEach(fn => fn())
iCount = part.length;
}, interval);
return (fn, ...a) => {
if (typeof fn !== 'function') {return}
@romasan
romasan / kp-get.js
Last active November 21, 2020 21:56
let kp = {};
kp.getViewedListFromEl = el => {
return [...el.querySelectorAll('.item')]
.filter(e => !e.classList.contains('itemAct'))
.filter(e => e.children[0].tagName === 'DIV')
.map(({children: [i, film, date]}) => ({
i: Number(i.innerText),
film,
viewdate: date.innerText
@romasan
romasan / prng.js
Created September 20, 2020 00:15 — forked from blixt/prng.js
A very simple, seedable JavaScript PRNG. NOTE: Please read comments on why this is not a good choice.
// NOTICE 2020-04-18
// Please see the comments below about why this is not a great PRNG.
// Read summary by @bryc here:
// https://github.com/bryc/code/blob/master/jshash/PRNGs.md
// Have a look at js-arbit which uses Alea:
// https://github.com/blixt/js-arbit
/**
(() => {
let e = document.createElement('button');
e.innerText = 'split';
e.style = `
position: absolute;
right: 0px;
bottom: 0px;
z-index: 1;
border: 1px solid #000000;
`;
let count = 0;
const f = (value, t = Math.floor(100 + Math.random() * 100)) => () => new Promise(resolve => {
console.log(`start: ${value} count: ${++count}`);
setTimeout(() => {
console.log(`end: ${value} count: ${--count}`);
resolve(value);
}, t);
});
const pool = [ f('A'), f('B'), f('C'), f('D'), f('E'), f('F'), f('G') ];
import { append, curry, ifElse, includes, without } from 'ramda'
export const toggleItemInList = curry((value, list) => ifElse(includes(value), without([value]), append(value))(list))