Skip to content

Instantly share code, notes, and snippets.

Stephen Holdaway stecman

View GitHub Profile
@stecman
stecman / silverstripe-assets-fixer.php
Last active Aug 29, 2015
Update records in SilverStripe's File table that point to non-existent files
View silverstripe-assets-fixer.php
<?php
/**
* # 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
stecman / .bash_profile
Last active Aug 29, 2015
Project folder switcher BASH function
View .bash_profile
# 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]
WEB_DIR=/var/www/
@stecman
stecman / du-watch.py
Last active Aug 29, 2015
Disk usage change notification utility - Python
View du-watch.py
#!/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
stecman / style.css
Last active Aug 29, 2015
Passnote CSS
View style.css
/**
* Compiled CSS for Passnote
* https://github.com/stecman/passnote
*
* Download this file to public/css/style.css if you don't want to compile the project's LESS:
*
* # Download using cURL
* $ curl https://gist.githubusercontent.com/stecman/c60a7b645104c565a517/raw/style.css -o public/css/style.css
*
* # or download using wget
@stecman
stecman / phalcon-namespace-render.php
Last active Aug 29, 2015
Namespace-aware template rendering for Phalcon PHP
View phalcon-namespace-render.php
<?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
stecman / hhclient_use.py
Created Feb 21, 2015
Hack lang: Sublime Text 3 plugin to copy fully qualified class name to clipboard using hh_client
View hhclient_use.py
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
stecman / dev_spam_fix.sh
Last active Aug 29, 2015
Save yourself the expense of buying cupcakes for the dev team
View dev_spam_fix.sh
#!/bin/bash
#
# 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
stecman / d2git.py
Last active Aug 29, 2015
Convert folders named d1, d2, d3, etc into git repository
View d2git.py
#!/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
View beam-shell-profile.bash
# Helper shell functions and completions for use with Beam
# https://github.com/heyday/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
stecman / php-server-helper-shell-profile.bash
Last active Aug 30, 2015
Shell helper function for starting PHP dev servers
View php-server-helper-shell-profile.bash
# 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 "0.0.0.0:$port" "$@";
You can’t perform that action at this time.