Skip to content

Instantly share code, notes, and snippets.

View sampotts's full-sized avatar

Sam Potts sampotts

View GitHub Profile
#!/bin/bash
# Tips
# http://derickbailey.com/2014/12/27/how-to-start-nginx-on-port-80-at-mac-osx-boot-up-log-in/
# https://gist.github.com/ogrrd/5824274
# http://stackoverflow.com/questions/16002268/prevent-nginx-504-gateway-timeout-using-php-set-time-limit
# http://serverfault.com/questions/189940/how-do-you-restart-php-fpm
PHP_VERSION='56';
DOT_VERSION='5.6';
@sampotts
sampotts / sprite.js
Last active May 14, 2017 05:47
This will fetch a remote SVG sprite and then store in local storage meaning next time it is pulled from local storage while the XHR occurs, preventing the flash of no icons. It could obviously be extended to pull from local storage all the time based on a version of the SVG sprite.
// ==========================================================================
// SVG sprite loading and caching
// This file should be at the top of the body to avoid a flash
// Usage: loadSprite('https://cdn.com/path/to/sprite.svg', 'sprite-id');
// The second argument is optional but prevents loading twice
// ==========================================================================
(function() {
window.loadSprite = function(url, id) {
if (typeof url !== "string") {
// Async load a script with a callback
(function () {
function async(u, c, a) {
var d = document;
var t = 'script';
var o = d.createElement(t);
var s = d.getElementsByTagName(t)[0];
o.src = u;
if (typeof a === 'object') {
// ==========================================================================
// tab-focus.js
// Detect keyboard tabbing
// ==========================================================================
(function() {
var className = "tab-focus";
// Remove class on blur
document.addEventListener("focusout", function(event) {
<html lang="fr">
<head>
<title>Isto é um teste</title>
</head>
<body>
<p>Aqui está um texto em francês</p>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<path d="M12,0C5.383,0,0,5.383,0,12s5.383,12,12,12s12-5.383,12-12S18.617,0,12,0z M12,2c5.176,0,9.446,3.954,9.949,9h-4.567
L15,15.764l-6-12L5.382,11H2.051C2.554,5.954,6.824,2,12,2z M12,22c-5.176,0-9.446-3.954-9.949-9h4.567L9,8.236l6,12L18.618,13
@sampotts
sampotts / previous_shutdown_cause
Created April 7, 2018 08:00 — forked from smashism/previous_shutdown_cause
searching for shutdown causes
log show --predicate 'eventMessage contains "Previous shutdown cause"' --last 24h
// ==========================================================================
// Simple color manipulation library
// ==========================================================================
const clamp = (input = 0, min = 0, max = 255) => {
return Math.min(Math.max(input, min), max);
};
const regex = new RegExp(/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/, 'i');
@sampotts
sampotts / array-closest.js
Last active July 3, 2018 03:20
Find the closest number in an array of numbers, with ceil and floor rounding options
// Rounding methods for .closest()
const closestRounding = {
none: 0,
ceil: 1,
floor: 2,
};
export { closestRounding };
/**
* Get the closest value in an array
<div data-embed="cart">
<script type="text/props">
{
"storeId": 13,
"colors": {
"buttons": {
"background": "#f9b642",
"text": "#ffffff"
},
"checkout": {
@sampotts
sampotts / markdown.css
Created June 2, 2021 05:07
Custom Markdown Theme
@import "https://cdn.potts.es/fonts/fakt-pro.css";
@import "https://cdn.potts.es/fonts/basier-circle-mono.css";
html {
font-size: 100%;
}
/* Basic reset */
h1,
h2,