Skip to content

Instantly share code, notes, and snippets.

View ashhitch's full-sized avatar
💭
Slinging Divs

Ash Hitchcock ashhitch

💭
Slinging Divs
View GitHub Profile
@jeromecoupe
jeromecoupe / webstoemp-gulpfile.js
Last active May 13, 2025 15:54
Gulp 4 sample gulpfile.js. For a full explanation, have a look at https://www.webstoemp.com/blog/switching-to-gulp4/
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@mateuspontes
mateuspontes / migrate-fish-history-to-zsh.py
Created April 7, 2018 19:57
Migrate fish history to zsh shell (python 2.7)
import os
import re
def fish_to_zsh(cmd):
return (cmd.replace('; and ', '&&')
.replace('; or ', '||'))
with open(os.path.expanduser('~/.zsh_history.test'), 'a') as o:
with open(os.path.expanduser('~/.local/share/fish/fish_history')) as f:
for line in f:
@atinux
atinux / async-foreach.js
Last active April 2, 2025 11:34
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@addyosmani
addyosmani / workbox.md
Last active January 20, 2024 16:14
Workbox recipes

Workbox runtime caching recipes

Your Service Worker script will need to import in Workbox and initialize it before calling any of the routes documented in this write-up, similar to the below:

importScripts('workbox-sw.prod.v1.3.0.js');
const workbox = new WorkboxSW();

// Placeholder array populated automatically by workboxBuild.injectManifest()
@td0
td0 / VSCode-custom.css
Last active August 30, 2018 22:13
vscode-styles for operator mono, fira code ligatures, and oceanic next italic
div.window-title, div.panel-header div.title, a.editor-status-mode,
div.results-group, span.quick-open-entry-description>span.monaco-highlighted-label:first-child,
.input, div.column.when span,
.Equinusocio-vsc-material-theme-themes-Material-Theme-Palenight-json .mtk12,
.Equinusocio-vsc-material-theme-themes-Material-Theme-Palenight-json .mtk9,
.Equinusocio-vsc-material-theme-themes-Material-Theme-Palenight-json .mtk4,
.Equinusocio-vsc-material-theme-themes-Material-Theme-Palenight-json .mtk3.mtki.detected-link,
.Equinusocio-vsc-material-theme-themes-Material-Theme-Palenight-json span.mtk11.mtki,
.Tyriar-theme-sapphire-theme-bright-json .mtk6,
.zhuangtongfa-Material-theme-themes-OneDark-Pro-json .mtk6,
@tnog
tnog / customer_registration_email_alert.php
Created March 30, 2017 05:08
WooCommerce: Send a custom admin email when a new customer creates a new account.
<?php
namespace Your\Custom\Namespace;
/**
* Send a custom admin email when a new customer creates a new account.
* @param integer $user_id The ID of the user whose data should be retrieved.
* @return [type] [description]
*/
function customer_registration_email_alert( $user_id ) {
@amboutwe
amboutwe / yoast_seo_opengraph_change_image_size.php
Last active October 28, 2024 06:15
Code snippet to change or remove OpenGraph output in Yoast SEO. There are multiple snippets in this code.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change size for Yoast SEO OpenGraph image for all content
* Credit: Yoast Development team
* Last Tested: May 19 2020 using Yoast SEO 14.1 on WordPress 5.4.1
* Accepts WordPress reserved image size names: 'thumb', 'thumbnail', 'medium', 'large', 'post-thumbnail'
* Accepts custom image size names: https://developer.wordpress.org/reference/functions/add_image_size/
*/
@0x6a68
0x6a68 / index.js
Created November 7, 2016 09:56
fractal programmatically
const fractal = require('@frctl/fractal').create()
require('./setup')(fractal)
const server = require('./server')(fractal, {
port: 4000,
sync: true,
watch: true,
syncOptions: {
files: [
'files-i-want-to-watch-also.css',
@sonicoder86
sonicoder86 / auth-guard.ts
Last active August 9, 2016 13:11
Upgrading to the new Angular 2 router - part 11
// auth-guard.ts
import { Injectable } from '@angular/core';
import {
CanActivate,
Router,
ActivatedRouteSnapshot,
RouterStateSnapshot
} from '@angular/router';
import { AuthService } from './services/auth/auth.service';