Skip to content

Instantly share code, notes, and snippets.

View pwenzel's full-sized avatar

Paul Wenzel pwenzel

View GitHub Profile
@pwenzel
pwenzel / Makefile
Created February 6, 2014 17:12
This gist accompanies https://github.com/pwenzel/fswatch-makefile. It shows how one might build a tiny build system for a website using a Makefile.
# Example Makefile for compiling CSS and Javascript in watched folder
PHONY: optimize
css:
@cat assets/css/normalize.css assets/css/app.css > public/assets/all.css
@echo Built all.css
js:
@cat assets/js/jquery.js assets/js/jquery.cookie.js assets/js/app.js > public/assets/all.js
@pwenzel
pwenzel / config.yaml
Created May 5, 2014 15:25
~/.config/beets/config.yaml
directory: /Volumes/BigMedia/Beets
library: /Volumes/BigMedia/Beets.blb
import:
move: no
copy: yes
write: yes
paths:
default: $albumartist - $album%aunique{}/$track $title
singleton: $albumartist - Singles/$artist - $title
comp: $album%aunique{}/$track $artist - $title
@pwenzel
pwenzel / attr_fix_cptr.php.diff
Created December 8, 2014 02:29
Fix Unescaped Title Attributes in plugin Custom Post Types Relationships (CPTR)
diff --git a/wp-content/plugins/custom-post-types-relationships-cptr/cptr.php b/wp-content/plugins/custom-post-types-relationships-cptr/cptr.php
index 2d82e17..853a51d 100644
--- a/wp-content/plugins/custom-post-types-relationships-cptr/cptr.php
+++ b/wp-content/plugins/custom-post-types-relationships-cptr/cptr.php
@@ -136,7 +136,7 @@ function cptr_category_selector() {
if (!empty($relations)) :
foreach($relations as $relation) :
$post = get_post($relation);
- echo "<div title='" . $post->post_title . "' class='thepost' id='post-".$post->ID ."'>
+ echo "<div title='" . esc_attr($post->post_title) . "' class='thepost' id='post-".$post->ID ."'>
@pwenzel
pwenzel / trinkup
Last active August 29, 2015 14:11 — forked from ei-grad/trinkup
#!/bin/bash
#
# trinkup - TRivial INcremental bacKUP script
#
# Licensed under DWTFYWWI license, but recommended to be used before drinkup.
#
set -e
if ! which rsync >/dev/null; then
* Script to record and tag spotify tracks, by Lloyd Moore *)
(* Make sure you are already recording in Audio Hijack Pro with a session called 'spotifySession' *)
tell application "Spotify"
set currentTrack to (current track)
set trackName to (name of currentTrack)
tell application "Audio Hijack Pro"
set theSession to my getSession()
end tell
repeat
@pwenzel
pwenzel / date_examples.sh
Created May 19, 2011 20:03
Examples of Date In Shell Script
# backup_060403.tar.gz
tar -czf backup_$(date +%y%m%d).tar.gz
# test_20110519-150054.jpg
mv example.jpg test_$(date +%Y%m%d-%H%M%S).jpg
# test_1305835327.jpg (timestamp)
mv example.jpg test_$(date +%Y%m%d-%H%M%S).jpg
@pwenzel
pwenzel / conditional_ssl_rewrite
Created December 12, 2011 18:34
Conditional SSL Rewrite for Certain Directory Paths
RewriteEngine on
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{REQUEST_URI} !^/facebook_app
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# This lets traffic that isn’t on port 443 (ssl) and isn't at /facebook_app/*
# and redirects it to the same path, but with SSL. This essentially lets stuff in
# /facbeook_app/* slide through over ssl or non-ssl, but nothing else.
@pwenzel
pwenzel / php_caching_snippet.php
Created January 5, 2012 22:35
PHP Caching Snippet adapted from Peter Karman
<?php
// Sample Usage
$uri_to_fetch = 'http://example.tld/path/to/uri';
$cache_on = true;
$cache_key = md5( $uri_to_fetch );
$cache_ttl = 60 * 15; // 15 minutes
$cache_file = '/tmp/example.tld/'.$cache_key;
if (file_exists($cache_file) &&
@pwenzel
pwenzel / save_screenshot.rb
Created February 29, 2012 21:35
Capture Screenshot With Selenium Webdriver
require 'rubygems'
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :ie
driver.get "https://www.google.com"
driver.save_screenshot("./screen.png")
@pwenzel
pwenzel / git-deploy.php
Created April 7, 2012 02:35
Automated Deployments from Bitbucket/Github Service Hook
<?php
# Automated Deployments from Bitbucket/Github Service Hook
# Graciously borrowed from: http://brandonsummers.name/blog/2012/02/10/using-bitbucket-for-automated-deployments/
date_default_timezone_set('America/Chicago');
class Deploy {
/**
* A callback function to call after the deploy has finished.