Skip to content

Instantly share code, notes, and snippets.

View brito's full-sized avatar
πŸ€”

brito brito

πŸ€”
View GitHub Profile
@brito
brito / dabblet.css
Last active April 4, 2019 23:26
Seasonal palette
/* Seasonal palette*/
body {
background: linear-gradient(to right,
hsl(217, 78%, 58%) 0,
hsl(59, 84%, 78%) 22%, /* spring equinox */
hsl(40, 91%, 61%) 49%, /* summer solstice */
hsl(18, 66%, 45%) 73%, /* autumn equinox */
hsl(217, 78%, 58%) 99%); /* winter solstice */
display:flex; height:100vw;
margin:0;
// eg (buy_load|free_bee|no_signal)
topicWords = '('+ ['buy load', 'free bee', 'no signal'].join('|') +')';
// eg (but|however|already)
complexWords = '('+ ['but', 'however', 'already'].join('|') +')';
maxWordsBetween = 2;
// eg 'in there '
maybeWordsBetween = '('+ `(\\W+\\w+){0,${maxWordsBetween}}` + ')';
@brito
brito / timewave.js
Last active December 14, 2018 21:28
for browser console funsies
/** in an era of public availability of source code, is explicit credit still necessary? */
//codegolf.stackexchange.com/a/79490/69502
continuous_fraction = f = (n,d) => n%d ? [r=(n/d)|0,...f(d,n-r*d)] : [n/d]
fill = (ch,n) => Array(n).fill(ch).join('')
bars = n => console.debug(fill('|', Math.abs(n)), n, fill(' ', Math.pow(Math.random(),-2)|0))
interval =
//stackoverflow.com/a/18123985/811330
function removeDiacritics (str) {
return [
{'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},
{'base':'AA','letters':/[\uA732]/g},
{'base':'AE','letters':/[\u00C6\u01FC\u01E2]/g},
{'base':'AO','letters':/[\uA734]/g},
{'base':'AU','letters':/[\uA736]/g},
{'base':'AV','letters':/[\uA738\uA73A]/g},
{'base':'AY','letters':/[\uA73C]/g},
@brito
brito / timebeat.js
Last active September 24, 2018 16:07
number generator from continuous fraction of timestamp
//codegolf.stackexchange.com/a/79490/69502
continuous_fraction = f = (n,d) => n%d ? [r=(n/d)|0,...f(d,n-r*d)] : [n/d]
bars = n => console.debug(n, Array(n).fill('|').join(''))
interval =
setInterval(() => {
requestAnimationFrame(() => {
now = new Date
a = ~now
@brito
brito / Catalog.js
Last active December 26, 2023 22:36
function __SMOKE_TEST__Catalog(){ console.log(
Catalog([{a:1, b:2}, {b:4, c:7, d:0}, {a:0, b:2}])
)}
/*
β”Œβ”€β”β”Œβ”€β”β”Œβ”¬β”β”Œβ”€β”β”¬ β”Œβ”€β”β”Œβ”€β”
β”‚ β”œβ”€β”€ β”‚ β”œβ”€β”€β”‚ β”‚ β”‚β”‚ ┬
β””β”€β”˜β”΄ β”΄ β”΄ β”΄ β”΄β”΄β”€β”˜β””β”€β”˜β””β”€β”˜ 18w40*/
function Catalog(items){
return ([].concat(arguments)).reduce(catalog, {});
@brito
brito / autoformat.gs.js
Last active June 8, 2018 01:48
An autoformat script for Google Sheets: set font, freeze header + column, rotate headers for numeric columns
var FONT = {
FAMILY: 'Inconsolata',
SIZE: 10
};
function onOpen() {
var menuTitle = 'Autoformat',
caption = [FONT.FAMILY, FONT.SIZE].join(' '),
functionName = 'autoformat'
SpreadsheetApp.getUi().createMenu(menuTitle).addItem(caption, functionName).addToUi() }
@brito
brito / confusion.js
Created March 10, 2018 04:28
Confusion Matrix for gSheet
/*
Calculates the Confusion Matrix for a range: [id, name, P, N, TP, TN, FP, FN]
@customfunction
*/
function matrix(sheet) {
var values = SpreadsheetApp.getActiveSpreadsheet().getRange(sheet).getValues(),
// headers = values.slice(0,1),
headers = 'id,name,P,N,TP,TN,FP,FN'.split(','),
data = values.slice(1),
results = data
#!/usr/bin/env bash
#########################
echo "Name this new tool like a Class, eloquent command or clear imperative verb"
read
mkdir $REPLY
cd $REPLY
echo "Created directory $REPLY"
#########################
@brito
brito / .npm-init.js
Last active October 27, 2017 06:01
const USER = process.env.USER
, NAMESPACE = `@${USER}`
, NAME = encodeURIComponent(require('path')
.basename(process.cwd())
.trim()
.toLowerCase()
.replace(/^_|\./, '')
//npmjs.com/package/validate-npm-package-name
// .replace(/[^~)('!*]/g, '')
.replace(/node|js/, '')