Skip to content

Instantly share code, notes, and snippets.

@tancredi
tancredi / package-version-bump.sh
Last active January 17, 2021 17:39
Semver bump-tag-commit
#!/usr/bin/env bash
set -e
###
# Bump and tag a Node.js module
#
# Assuming 'x.x.x' semver format automatically parses the current package.json
# version, bumps it depending on provided major / minor / patch strategy,
# overrides the 'version' field on the package.json file, adds a git tag and
@tancredi
tancredi / paste-me-in-the-console.js
Created November 22, 2018 14:28
Export / Import GitHub tags (browser script)
function rgbToHex(color) {
const [ r, g, b ] = color.substring(4, color.length - 1).split(', ');
return '#' + [ r, g, b ].map(x => {
const hex = parseInt(x).toString(16);
return hex.length === 1 ? '0' + hex : hex
}).join('');
}
@tancredi
tancredi / browser.js
Last active February 14, 2018 10:03
Pointer-events IE polyfill (vanilla JS)
/**
* Browser utility
*
* Exports utility methods to detect browser types and versions from userAgent
*/
/**
* Returns true if is IE browser equal or below given version
*
* @param {Number} version
#!/bin/bash
###################################################################
## Usage: ./indent_4_to_2_spaces.sh lib/**/*.js www/css/**/*.css ##
###################################################################
echo Re-indenting ${$#-2} files from 4 to 2 spaces...
for (( i=1; i<=$#; i++ )); do
sed -e 's/^/~/' -e ': r' -e 's/^\( *\)~ /\1 ~/' -e 't r' -e 's/~//' ${!i} > ${!i}.tmp && mv ${!i}.tmp ${!i}
'strict mode'
const fs = require('fs')
const path = require('path')
/**
* Re-prefix utility
*
* Usage: re-prefix [ dir ] [ prefix ] [ new_prefix ]
* E.g. re-prefix ./icons soc- social-icon-
@tancredi
tancredi / sublime-text-logo.svg
Last active October 28, 2020 05:32
SublimeText simplified logo (SVG)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tancredi
tancredi / job-titles-analysis.md
Last active August 29, 2015 14:21
Workshape.io Job Titles Analysis Results

Results

title seniority stack idiosyncratic descriptor
lead developer / product a... X
sr. c# wpf developer who l... X X X
full-stack engineer X
test analyst X
data engineer X
qa with a bit of ba hands ... X
@tancredi
tancredi / grid-system.scss
Created March 16, 2015 14:24
SCSS responsive grid generator mixin
@mixin grid-column ($span, $cols: 12) {
width: ($span * 100 / $cols) * 1%;
}
@mixin grid-offset ($span, $cols: 12) {
margin-left: (($span * 100) / $cols) * 1%;
}
@mixin grid-system ($cols: 12, $gutter: 20px, $child: '.col', $off: '.off', $all-columns: true, $separate: '-', $breakpoint: 650px) {
@include clearfix();
@tancredi
tancredi / long-shadow.styl
Created March 16, 2015 14:21
Long shadow Stylus mixin
// Stylus version of SCSS mixin from http://codepen.io/awesomephant/pen/mAxHz
long-shadow(type = 'box', base-color = rgba(#000, .2), length = 100, fadeout = true, skew = false, direction = 'right')
shadow = ''
if !skew || type == 'text'
if direction == 'right'
for i in (0..length - 1)
shadow = shadow + i + 'px ' + i + 'px 0 ' + base-color + ','
@tancredi
tancredi / mirror-ascii-art.js
Created May 1, 2014 16:46
Quick node.js script to mirror ASCII art horizontally
var fs = require('fs');
var charsMap = [
[ '/', '(', '>' ],
[ '\\', ')', '<' ]
];
function run () {
var args = parseArgs(),
text = normalise(fs.readFileSync(args.src, 'utf8'));