Skip to content

Instantly share code, notes, and snippets.

@delputnam
delputnam / collections_sort.rb
Last active January 29, 2023 15:38
This is a liquid filter for Jekyll that will sort collections based on arbitrary yaml front matter variables.
# collections_sort.rb
#
# Sort Jekyll collections items based on arbitrary yaml front matter variables.
#
# example usage:
#
# if you want to sort a collection based on a yaml variable of "order":
#
# {% assign filtered_events = site.my_collection | collection_sort: 'order' %}
#
@delputnam
delputnam / gist:8213bbe304b9ffbdcfc28f5d6b083e8c
Last active December 15, 2022 19:29
Remove all unison .tmp files
find . -name "*.unison.tmp" -delete
@delputnam
delputnam / TextColor.swift
Created June 25, 2016 12:27
Determine if a UIColor is light or dark
// Returns black if the given background color is light or white if the given color is dark
func textColor(bgColor: UIColor) -> UIColor {
var r: CGFloat = 0.0
var g: CGFloat = 0.0
var b: CGFloat = 0.0
var a: CGFloat = 0.0
var brightness: CGFloat = 0.0
bgColor.getRed(&r, green: &g, blue: &b, alpha: &a)
@delputnam
delputnam / .editorconfig
Last active July 1, 2020 18:09
Del's phpstorm .editorconfigfile
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
tab_width = 4
trim_trailing_whitespace = true
ij_continuation_indent_size = 8
@delputnam
delputnam / wordpress_post_exists.php
Last active August 4, 2018 09:22
Quick check to determine if a WordPress post exists using the post_name (slug) and post_type (defaults to 'post'). Returns the post ID if found, or 0 (zero) if not found.
/**
* Determine if a post exists based on post_name and post_type
*
* @param $post_name string unique post name
* @param $post_type string post type (defaults to 'post')
*/
function post_exists( $post_name, $post_type='post' ) {
global $wpdb;
@delputnam
delputnam / jetpack-test.php
Last active January 23, 2018 20:16
A simple WordPress plugin to allow testing of Jetpack's Related Posts module
<?php
/**
* @package Jetpack_Test
* @version 1.0
*/
/*
Plugin Name: Jetpack Test
Description: Allows certain Jetpack modules that would otherwise require a connection to WordPress.com to be run in a local development environment.
Author: Del Putnam
svn status --ignore-externals | grep ! | tr -s ' ' | cut -d ' ' -f2 | xargs svn rm

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -outform PEM -pubout -out public.pem
@delputnam
delputnam / gist:497ee68b4f2df9301ba4eb9753fb0b0f
Created May 10, 2017 14:32
svn remove unversioned files
svn status | grep ^\? | cut -c9- | xargs -d \\n rm -r