Skip to content

Instantly share code, notes, and snippets.

View wjmazza's full-sized avatar

Walter Mazza wjmazza

  • Amazon Web Services
  • Los Angeles, CA
View GitHub Profile
@wjmazza
wjmazza / google-sheets-colour-preview.js
Last active April 19, 2024 06:15 — forked from Pathoschild/google-sheets-color-preview.js
A Google Sheets script which adds colour preview to cells. When you edit a cell containing a valid CSS hexadecimal colour code (like #000 or #000000), the background colour will be changed to that colour and the font colour will be changed to the inverse colour for readability.
/*
This script is meant to be used with a Google Sheets spreadsheet. When you edit a cell containing a
valid CSS hexadecimal colour code (like #000 or #000000), the background colour will be changed to
that colour and the font colour will be changed to the inverse colour for readability.
To use this script in a Google Sheets spreadsheet:
1. go to Tools » Script Editor » Spreadsheet;
2. erase everything in the text editor;
3. change the title to "Set colour preview on edit";
#/usr/bin/env bash
# Originally based on https://gist.github.com/sindresorhus/7996717
# by Sindre Sorhus (sindresorhus.com)
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
if git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD | grep --quiet -E "package.json";
then
echo ">>> package.json file has changed <<<"
echo "Deleting current node_modules folder (rm -rf ./node_modules)"
@wjmazza
wjmazza / yturlparser.js
Last active August 29, 2015 14:18
[JavaScript] YouTube URL Parser
/**
* Validates and parses a YouTube URL
*
* Credits:
* https://gist.github.com/jlong/2428561
* http://stackoverflow.com/a/22763925/3819103
*
* TODO:
* Add "attribution_link" in type checking
* Add "playlist" in type checking
@wjmazza
wjmazza / parseDecimal.js
Last active August 29, 2015 14:05
parseDecimal - returns number value to the right of the decimal point (en-US)
// not tested for localized usage, developed for en-US
function parseDecimal(numberVal) {
var modValue = numberVal % 1, // returns modulous of number
wholeNumber = numberVal - modValue, // returns the whole number
wholeNumberLength = wholeNumber.toString().length, // amount of digits in number
decimalLength = numberVal.toString().length - wholeNumberLength - 1, // amount of digits after decimal (-1 for decimal itself)
decimalNumber = Math.round(modValue * Math.pow(10,decimalLength)); // fix decimal places to original length and remove decimal point
return decimalNumber;
}