This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); } | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
let e = document.createElement('button'); | |
e.innerText = 'split'; | |
e.style = ` | |
position: absolute; | |
right: 0px; | |
bottom: 0px; | |
z-index: 1; | |
border: 1px solid #000000; | |
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { append, curry, ifElse, includes, without } from 'ramda' | |
export const toggleItemInList = curry((value, list) => ifElse(includes(value), without([value]), append(value))(list)) |