Skip to content

Instantly share code, notes, and snippets.

View stecman's full-sized avatar

Stephen Holdaway stecman

View GitHub Profile
stecman / silverstripe-assets-fixer.php
Last active August 29, 2015 13:56
Update records in SilverStripe's File table that point to non-existent files
* # SilverStripe Assets Fixer
* Interactive script to update file records in a SilverStripe site database.
* ## How it works
* For each File record in the database where Filename doesn't exist, the basename
stecman / .bash_profile
Last active August 29, 2015 14:01
Project folder switcher BASH function
# Change to a site directory
# A site might be anything, but this was written to jump to web roots.
# Minimum config is to change the WEB_DIR variable. Adapted for drop-in
# use from the `site` function originally by @pieterv for @heyday
# Usage: site <dir> [path-within-dir]
stecman /
Last active August 29, 2015 14:02
Disk usage change notification utility - Python
#!/usr/bin/env python3
# Disk usage watcher:
# A script that reports changes to disk usage between runs (for mounted devices)
# Written for use on Linux systems.
# When the percentage change for a device is greater than USAGE_CHANGE_NOTIFY_THRESHOLD,
# a line will be printed for that device. If the change is not greater than the threshold,
# nothing will be printed for that device. Output looks like this:
stecman / style.css
Last active August 29, 2015 14:06
Passnote CSS
* Compiled CSS for Passnote
* Download this file to public/css/style.css if you don't want to compile the project's LESS:
* # Download using cURL
* $ curl -o public/css/style.css
* # or download using wget
stecman / phalcon-namespace-render.php
Last active August 29, 2015 14:14
Namespace-aware template rendering for Phalcon PHP
use Phalcon\Events\Event;
use Phalcon\Mvc\Application;
use Phalcon\Mvc\User\Plugin;
use Phalcon\Mvc\View;
* Namespaced template rendering for the Phalcon PHP framework
stecman /
Created February 21, 2015 22:32
Hack lang: Sublime Text 3 plugin to copy fully qualified class name to clipboard using hh_client
from subprocess import Popen, PIPE, STDOUT
import json
import sublime, sublime_plugin
hhclient_use: copy fully qualified class name to clipboard
Copy the full class name at the current cursor position (or first class in the file)
to the clipboard. Requires the hh_client command line program to provide a JSON formatted
outline of the code in the focused buffer.
stecman /
Last active August 29, 2015 14:17
Save yourself the expense of buying cupcakes for the dev team
# Make sure all untracked _ss_environment.php files use SS_SEND_ALL_EMAILS_TO
# Save yourself the expense of buying cupcakes for the dev team
function is_tracked() {
local filename="$1"
stecman /
Last active August 29, 2015 14:18
Convert folders named d1, d2, d3, etc into git repository
#!/usr/bin/env python
# Convert "versioning" with folders called d1, d2, d3.. into a git repository in the directory
# containing those folders. Written for use on *nix systems for people who weren't using version
# control software for a long time.
import os
import re
import time
import sys
stecman / beam-shell-profile.bash
Created August 14, 2015 22:29
Beam shell helpers
# Helper shell functions and completions for use with Beam
# Print the .beamlog file for a beam target.
# Target defaults to live if not given
# usage: whatsup [target]
function whatsup() {
local server="${1-live}";
stecman / php-server-helper-shell-profile.bash
Last active August 30, 2015 11:28
Shell helper function for starting PHP dev servers
# Run a PHP dev server on the first available port starting at 8000
function serve()
local port=8000
# Try ports until an unused one is found
while nc -z localhost $port > /dev/null; do ((port++)); done;
echo -e "\033[44m>> Listening on port $port <<\033[0m"
php -S "$port" "$@";