Skip to content

Instantly share code, notes, and snippets.

@ygotthilf
ygotthilf / jwtRS256.sh
Last active April 26, 2025 05:11
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@jgeewax
jgeewax / configure-mailgun
Created December 7, 2015 17:59
Script to configure Postfix for Mailgun
#!/bin/bash
# Configuration for the script
POSTFIX_CONFIG=/etc/postfix/main.cf
POSTFIX_SASL=/etc/postfix/sasl_passwd
function confirm () {
read -r -p "${1:-Are you sure? [Y/n]} " response
if [[ $response == "" || $response == "y" || $response == "Y" ]]; then
echo 0;
$ = jQuery;
/*
* jQuery BBQ: Back Button & Query Library - v1.3pre - 8/26/2010
* http://benalman.com/projects/jquery-bbq-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
import pandas as pd
df = pd.DataFrame({'Name': ['Soton Central', 'Soton Airport', 'London Paddington', 'Malvern Link', 'Great Malvern', 'Oxford'],
'TLC': ['SOU', 'SOA', 'PAD', 'MVL', 'GMV', 'OXF']})
selected_stations = ['London Paddington', 'Malvern Link']
df[df.Name.isin(selected_stations)]
@ben-w-smith
ben-w-smith / gulpfile.js
Created February 26, 2016 18:34
Gulp with BrowserSync with ngrok
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var ngrok = require('ngrok');
gulp.task('default', function() {
browserSync.init({
server: {
baseDir: "./public"
}
@em-piguet
em-piguet / article2collections.sql
Created March 30, 2016 09:59
How to convert an MODX articles container to a MODX collections container...
# switch ArticlesContainer -> CollectionContainer
# the res. ID I want to migrate is 11
UPDATE `modx_site_content` SET `class_key` = replace(class_key, 'ArticlesContainer', 'CollectionContainer') WHERE id=11;
# switch class_key to go back to default document view for children
UPDATE `modx_site_content` SET `class_key` = replace(class_key, 'Article', 'modDocument') WHERE parent=11;
# Change template 49 -> 57
@mgibbs189
mgibbs189 / simple-history-log-http-requests-time.php
Created May 6, 2016 19:19 — forked from bonny/simple-history-log-http-requests-time.php
Snippet for WordPress plugin Simple History Log that logs https request made and how long each request took
<?php
/**
* To use this you first need to install the free plugin Simple History
* https://wordpress.org/plugins/simple-history/
*/
// pre_http_request is fired close before the actual request
add_filter( 'pre_http_request', function( $retval, $r, $url ) {
@ollieglass
ollieglass / kelly_colors.py
Last active November 22, 2024 17:27
Kenneth Kelly's 22 colors of maximum contrast
# theory - https://eleanormaclure.files.wordpress.com/2011/03/colour-coding.pdf (page 5)
# kelly's colors - https://i.kinja-img.com/gawker-media/image/upload/1015680494325093012.JPG
# hex values - http://hackerspace.kinja.com/iscc-nbs-number-hex-r-g-b-263-f2f3f4-242-243-244-267-22-1665795040
kelly_colors = ['F2F3F4', '222222', 'F3C300', '875692', 'F38400', 'A1CAF1', 'BE0032', 'C2B280', '848482', '008856', 'E68FAC', '0067A5', 'F99379', '604E97', 'F6A600', 'B3446C', 'DCD300', '882D17', '8DB600', '654522', 'E25822', '2B3D26']
@andymatuschak
andymatuschak / States-v3.md
Last active May 1, 2025 11:28
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@mwpastore
mwpastore / 00README.md
Last active September 30, 2024 16:00
Lightning Fast WordPress: Caddy+Varnish+PHP-FPM

README

This gist assumes you are migrating an existing site for www.example.com — ideally WordPress — to a new server — ideally Ubuntu Server 16.04 LTS — and wish to enable HTTP/2 (backwards compatibile with HTTP/1.1) with always-on HTTPS, caching, compression, and more. Although these instructions are geared towards WordPress, they should be trivially extensible to other PHP frameworks, other FastCGI backends, and even non-FastCGI backends (using proxy in lieu of fastcgi in the terminal Caddyfile stanza).

Quickstart: Use your own naked and canonical domain names instead of example.com and www.example.com and customize the Caddyfile and VCL provided in this gist to your preferences!

These instructions target Varnish Cache 4.1, PHP-FPM 7.0, and Caddy 0.10. (I'm using MariaDB 10.1 as well, but that's not relevant to this guide.)