Skip to content

Instantly share code, notes, and snippets.

@andfinally
andfinally / promotions.json
Last active March 22, 2024 12:42
API test
[
{
"date_from_gmt": "2024-02-14 00:00",
"date_to_gmt": "2024-05-01 22:59",
"format": "notice",
"style": "info",
"pages": [
{ "page": "wc-admin", "path": "/extensions", "tab": "" },
{ "page": "wc-admin", "path": "/extensions", "tab": "extensions" },
{ "page": "wc-admin", "path": "/extensions", "tab": "themes" }
@andfinally
andfinally / promotions.json
Created March 21, 2024 10:53
API test – empty response
[]
@andfinally
andfinally / promotions.json
Last active March 18, 2024 15:22
API test – expired items
[
{
"date_from_gmt": "2024-02-14 00:00",
"date_to_gmt": "2024-03-17 22:59",
"format": "notice",
"style": "info",
"pages": [
{ "page": "wc-admin", "path": "/extensions" },
{ "page": "wc-admin", "path": "/extensions", "tab": "extensions" },
{ "page": "wc-admin", "path": "/extensions", "tab": "themes" }
@andfinally
andfinally / bookmarket-copy-doc-title-url.js
Last active July 11, 2022 12:14
Bookmarklet to copy document title and URL
// One-line version: create a bookmark with this content
// javascript:( function() { const jsIssueTitle = document.querySelector( '.js-issue-title' ); const title = jsIssueTitle ? jsIssueTitle.textContent : document.title; const blob = new Blob( [ `<a href="${ document.location.href }">${ title }</a>` ], { type: "text/html" } ); const clipboardItem = new ClipboardItem( { [ "text/html" ]: blob } ); navigator.clipboard.write( [ clipboardItem ] ); } )();
// Long version - only included here for legibility use the one-line version prefixed with `javascript:`
( function() {
// Get GitHub issue/PR title
const jsIssueTitle = document.querySelector( '.js-issue-title' );
const title = jsIssueTitle ? jsIssueTitle.textContent : document.title;
const blob = new Blob( [ `<a href="${ document.location.href }">${ title }</a>` ], { type: "text/html" } );
@andfinally
andfinally / greasemonkey-$-alias
Last active July 8, 2022 13:54
Greasemonkey script – adds $ and $$ aliases for querySelector and querySelectorAll
// ==UserScript==
// @name Make $ and $$ aliases for document.querySelector and document.querySelectorAll
// @version 1
// @description Creates aliases for document.querySelector and document.querySelectorAll
// @author andfinally
// @match https://github.com/*
// @match https://woocommerce.test/*
// @match https://*.woocommerce.com/*
// @grant none
// ==/UserScript==
@andfinally
andfinally / GitHub - click to copy link to PR or issue
Last active July 1, 2022 09:26
Greasemonkey script for GitHub pull requests and issues. Adds icon after title which, if clicked, copies the markup for a link to the PR to the clipboard
@andfinally
andfinally / .htaccess
Last active November 23, 2020 02:01
Barebones Backbone Router example for an Apache site with a local URL like http://local5/backbone-router.
# html5 pushstate (history) support:
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L,QSA]
</ifModule>
@andfinally
andfinally / font.js
Last active October 20, 2020 20:37
Cache webfont in localStorage
/**
* Adapted from https://gist.github.com/hdragomir/8f00ce2581795fd7b1b7
* This version tries to load the font from localStorage. If it's not there it simply adds a link to the stylesheet
* and ajaxes the contents in on load. This makes an extra request. But adding the stylesheet link renders quicker than
* waiting for a response to the ajax request and then injecting the contents into a style tag, hopefully minimising the
* FOUT you get when you view http://www.theguardian.com/ and http://www.smashingmagazine.com.
*/
(function () {
"use strict";
// Once cached the css file is stored on the client forever. To invalidate the cache change this URL.
@andfinally
andfinally / calypso-anybar-handler.sh
Last active April 25, 2018 17:22 — forked from mcsf/calypso-anybar-handler.sh
Calypso AnyBar handler
#!/bin/bash
PORT="${PORT:-1738}"
DONE_COLOR="${DONE_COLOR:-"green"}"
PROGRESS_COLOR="${PROGRESS_COLOR:-"orange"}"
INITIAL_COLOR="${INITIAL_COLOR:-"white"}"
BUILD_ERROR_COLOR="${BUILD_ERROR_COLOR:-"red"}"
TEST_ERROR_COLOR="${TEST_ERROR_COLOR:-"purple"}"
HAS_ERROR=0
import gulp from 'gulp';
import sass from 'gulp-sass';
import babel from 'gulp-babel';
import sourcemaps from 'gulp-sourcemaps';
import es from 'event-stream';
import rename from 'gulp-rename';
import uglify from 'gulp-uglify';
const sassOpts = {outputStyle: 'compressed', errLogToConsole: true};