Skip to content

Instantly share code, notes, and snippets.

View contivero's full-sized avatar

Cristian A. Ontivero contivero

View GitHub Profile

To use stylelint to lint SCSS files, install stylelint:

npm install stylelint --save-dev

and install stylelint-scss:

npm install stylelint --save-dev

Stylelint expects a default config called .stylelintrc, which is a JSON, although a .stylelintrc.yaml in YAML can also be used. Below is a "sensible" (at least for me) config.

JPG

mozjpeg allows optimizing the compression, losslessly recompressing an image.

mozjpeg input.jpg > output.jpg

Depending on how it's installed, the executable might be called jpegtran instead of mozjpeg. To convert other formats to jpg, use cjpeg, or the convert command from imagemagick, followed by mozjpeg.

There is also guetzli, but I never got good results with it.

@contivero
contivero / .bashrc
Last active November 15, 2019 11:22
# Git
alias go="git checkout"
alias gor="git checkout release"
alias god="git checkout develop"
alias gom="git checkout master"
alias gs="git s"
alias gc="git commit"
alias gca="git commit --amend"
[user]
email = [email protected]
name = Cristian A. Ontivero
[alias]
# Get current branch name (used in other aliases)
branch-name = rev-parse --abbrev-ref HEAD
# Undo commit
uc = reset --soft HEAD~1
static const int modinv[PRIME] = { /* modular multiplicative inverses */
0, 1, 129, 86, 193, 103, 43, 147, 225, 200, 180, 187, 150, 178, 202, 120,
241, 121, 100, 230, 90, 49, 222, 190, 75, 72, 89, 238, 101, 195, 60, 199,
249, 148, 189, 235, 50, 132, 115, 145, 45, 163, 153, 6, 111, 40, 95, 175,
166, 21, 36, 126, 173, 97, 119, 243, 179, 248, 226, 61, 30, 59, 228, 102,
253, 87, 74, 234, 223, 149, 246, 181, 25, 169, 66, 24, 186, 247, 201, 244,
151, 165, 210, 96, 205, 127, 3, 65, 184, 26, 20, 209, 176, 152, 216, 46, 83,
53, 139, 135, 18, 28, 63, 5, 215, 164, 177, 245, 188, 224, 250, 44, 218,
116, 124, 38, 113, 134, 159, 54, 15, 17, 158, 140, 114, 220, 51, 85, 255, 2,
172, 206, 37, 143, 117, 99, 240, 242, 203, 98, 123, 144, 219, 133, 141, 39,
@contivero
contivero / hashtable_sizes.c
Created December 28, 2015 11:07
prime hashtable sizes
/* Values tested with haskell's isPrime function from the arithmoi-0.4.1.3 library */
unsigned long tablesize[] = { /* from highest 8-bit prime to highest 58-bit prime */
509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262139, 524287,
1048573, 2097143, 4194301, 8388593 , 16777213 , 33554393 , 67108859 ,
134217689, 268435399, 536870909, 1073741789, 2147483647, 4294967291,
8589934583, 17179869143, 34359738337, 68719476731, 137438953447,
274877906899, 549755813881, 1099511627689, 2199023255531, 4398046511093,
8796093022151, 17592186044399, 35184372088777, 70368744177643,
140737488355213, 281474976710597, 562949953421231, 1125899906842597,
@contivero
contivero / validate-minify-pre-commit
Last active August 29, 2015 14:03
pre-commit git hook for validation and minification of staged html files
#!/bin/sh
# Script to validate htmls, minify them, and minify css before commiting
# Exits on validation failure. Minified files, and any other website resource
# needed is copied into $DIR_TO_COPY
readonly HTML_COMPRESSOR_PATH="$(git config hooks.htmlcompressor)"
readonly YUI_COMPRESSOR_PATH="$(git config hooks.yuicompressor)"
readonly DIR_TO_COPY=minified-site #path into which to copy files
readonly VALIDATOR="tidy"