Skip to content

Instantly share code, notes, and snippets.

View anthify's full-sized avatar
💻
coding

Anthony O'Neill anthify

💻
coding
View GitHub Profile
@anthify
anthify / checkered-alpha-background.css
Created April 8, 2019 09:09
Checked Alpha Background
.chacked-alpha-background {
background-image:
-webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, #ccc), color-stop(.25, transparent)),
-webkit-gradient(linear, 0 0, 100% 100%, color-stop(.25, #ccc), color-stop(.25, transparent)),
-webkit-gradient(linear, 0 100%, 100% 0, color-stop(.75, transparent), color-stop(.75, #ccc)),
-webkit-gradient(linear, 0 0, 100% 100%, color-stop(.75, transparent), color-stop(.75, #ccc));
background-size: 30px 30px;
background-position: 0 0, 15px 0, 15px -15px, 0px 15px;
background-color: white;
}
@anthify
anthify / asyncDelay.js
Created April 8, 2019 08:20
Async Await Delay
export default time =>
new Promise(resolve => setTimeout(() => resolve(), time));
// example
import delay from '.'
const stopAndStart = async () => {
console.log('👋');
await delay(1000);
console.log('🕐, one second later');
@anthify
anthify / asyncForeach.js
Last active April 8, 2019 08:18
Async Await forEach loop
export default async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
};
// example
import forEach from '.';
const paths = [...];
@anthify
anthify / parseRGBString.js
Last active April 8, 2019 09:38
Converts RGB/RGBA string to object
// pass a rgb/rgba string value into this function i.e. rgb(0,0,0)
// and it will return an object of { r: 0, g: 0, b: 0, a: 1 }
const parseRGBString = str => {
const vals = str.substring(str.indexOf('(') + 1, str.length - 1).split(', ');
const colors = {
r: parseInt(vals[0], 10),
g: parseInt(vals[1], 10),
b: parseInt(vals[2], 10),
a: parseFloat(vals[3])
@anthify
anthify / find-dead-css.js
Created April 18, 2016 16:10 — forked from byrichardpowell/find-dead-css.js
Super simple node script to find CSS that is no longer in use. The results should be considered as safe as a global find and replace (not very), so use your judgement
var walk = require('walk');
var fs = require('fs');
var classesOrIds = [];
var viewsAndTemplates = []
var walkers = [];
var maybeUnusedClassesOrIds = [];
var compleWalkersCount = 0;
var classesToFileMap = {}
// Calback Function every time a walker ends