Skip to content

Instantly share code, notes, and snippets.

View ricardobeat's full-sized avatar

Ricardo Tomasi ricardobeat

View GitHub Profile
@ricardobeat
ricardobeat / sequential-test.js
Created March 8, 2024 09:35
Sequential test based on Evan Miller's
function sequentialTest(control, treatment, sample) {
if (treatment - control >= 2.25 * Math.sqrt(sample)) {
return 'treatment wins'
} else if (control - treatment >= 2.25 * Math.sqrt(sample)) {
return 'control wins'
} else if (treatment + control >= sample) {
return 'stop test. no winner'
}
return 'continue testing'
@ricardobeat
ricardobeat / assignment.js
Created December 21, 2023 14:04
Experiment assignment for Cloudfront
const BUCKETS = 100
function toInt32(buf) {
return Math.abs(new Uint8Array(buf).slice(0,4).reduce((p,c) => p << 8 | c, 0))
}
async function hash(input){
const data = new TextEncoder().encode(input);
const buf = await crypto.subtle.digest("SHA-256", data);
return toInt32(buf)
@ricardobeat
ricardobeat / lodash-group-by-unrolled.js
Created December 19, 2023 21:53
lodash 'simple group by'
// https://github.com/lodash/lodash/blob/4.17.15/lodash.js#L9393C5-L9399C8
var groupBy = createAggregator(function(result, value, key) {
if (hasOwnProperty.call(result, key)) {
result[key].push(value);
} else {
baseAssignValue(result, key, [value]);
}
});
// https://github.com/lodash/lodash/blob/4.17.15/lodash.js#L4818C5-L4825C6
@ricardobeat
ricardobeat / Brewfile
Last active October 25, 2022 14:32
Mac CI runner
brew 'coreutils'
brew 'tmux'
brew 'jq'
brew 'htop'
brew 'wget'
brew 'tree'
brew 'aria2'
brew 'xcbeautify'
brew 'git'
@ricardobeat
ricardobeat / index.html
Created September 10, 2018 09:21
Inline event attributes benchmark
<!doctype html>
<body></body>
<script>
const events = [
'click',
'input',
'change',
'mouseenter',
'mouseleave',
@ricardobeat
ricardobeat / task.js
Last active November 4, 2020 18:02
Taks sample
const { task, read, write } = require('taks')
const _postcss = require('postcss')
const _rollup = require('rollup')
const _uglify = require('uglify-es')
const postcss = task.plugin(async function (input, output, options) {
let opts = Object.assign({ from: undefined, plugins: [] }, options)
let src = await read(input)
let { css } = await _postcss(opts.plugins).process(src, opts)
return write(output, css)
@ricardobeat
ricardobeat / task.js
Last active November 4, 2020 10:27
minimal task runner
#!/usr/bin/env node
const _tasks = {}
function task (name, fn) {
_tasks[name] = fn
}
task.run = async function (name, wait) {
if (!name) return console.warn(`Usage: node task [name]`)
if (!_tasks[name]) return console.warn(`No task named ${name}`)
@ricardobeat
ricardobeat / search.sh
Created April 10, 2017 14:47
Git: digging for lost code - unlabeled stashes etc
git fsck --no-reflogs | awk '/dangling commit/ {print $3}'| while read hash; do
echo "$hash"
git show $hash | grep -H -C4 svg
done

Simple comparison between Atomic CSS vs 'standard' CSS. Might not be representative of larger files.

results

file raw gzip
with-atomic.css 576b 325b
with-atomic.html 1183b 254b
without-atomic.css 1676b 324b
without-atomic.html 714b 199b