Skip to content

Instantly share code, notes, and snippets.

View niccai's full-sized avatar

Nick Cairns niccai

View GitHub Profile
@niccai
niccai / check-package.txt
Last active July 12, 2018 20:12
Look through your "Projects" dir for a particular dependency and version
for packagejson in $(find ~/Projects -name 'package.json' -path '*node_modules/eslint-scope/*'); do jq '.version' $packagejson | grep '3.7.2' 1>/dev/null; if [[ $? == "0" ]]; then echo $packagejson; fi; done
@niccai
niccai / dedupe-array.js
Created May 15, 2018 17:25
Dedupe items in an array
const originalArray = [3,3,26,3,3,26,26];
const dedupedArray = [...new Set(originalArray)];
console.log(dedupedArray);
// [3, 26]
@niccai
niccai / postcss-bootstrap.txt
Created April 27, 2018 19:08
A cli command for installing PostCSS modules that give you the critical parts of Sass functionality
npm i --save-dev autoprefixer css-mqpacker cssnano postcss-automath postcss-cli postcss-for postcss-import postcss-initial postcss-mixins postcss-nested postcss-normalize postcss-sass-color-functions postcss-simple-vars postcss-svg
@niccai
niccai / fill-viewport-relative-child.css
Created March 3, 2017 19:05
Fill Viewport with Relative Child #tags: css
/* http://codepen.io/Mest/pen/oKBIu?editors=1100 */
* {
box-sizing: border-box;
}
html,
body,
.parent-div {
height: 100%;
$bezier: cubic-bezier(.215, .61, .355, 1);
transition: opacity .3s $bezier;
@niccai
niccai / hexToRGB.js
Last active December 4, 2015 20:10
Takes in a hex value and converts it to RGB.
hexToRGB (hex) {
if (!hex) {
return '';
}
// remove the hash
hex = hex.replace('#', '');
// if shorthand, expand it
if (hex.length < 6) {
@niccai
niccai / lodash-node-templateSettings
Last active April 16, 2021 20:14
Changing lodash/underscore template settings in Node.js to use Mustache style braces
// Client side, you typically see the template style changed to {{ }} like so...
_.templateSettings = {
interpolate : /\{\{(.+?)\}\}/gim,
evaluate: /\{\#(.+?)\#\}/gim
};
/*
However, in Node.js, this causes issues when trying to render a template.
Likely, you haven't paid too much attention to the fact that you are setting
@niccai
niccai / command.js
Last active December 27, 2015 13:19
Backtick Refresh CSS
/*
Original by Paul Irish and Modified from
http://www.paulirish.com/2008/how-to-iterate-quickly-when-debugging-css/
*/
(function() {
var i, a, aLength, s;
a = document.getElementsByTagName('link');
aLength = a.length;
for (i=0; i < aLength; i++) {