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 May 12, 2024 08:09
Pushover notification CLI script

Send Pushover notifications from the command line

Notify is a utility for sending push notifications via Pushover from the command line. It can be run manually, but is most useful for sending notifications from shell scripts, cron jobs, and long running tasks.

Pushover screenshot


To install, copy the contents of notify.php to somewhere on your computer, and make it executable:

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 / bash-completion.patch
Last active December 21, 2016 20:42
Enable BASH completion for Composer
diff --git a/composer.json b/composer.json
index 718b067..cebec32 100644
--- a/composer.json
+++ b/composer.json
@@ -27,7 +27,8 @@
"seld/jsonlint": "1.*",
"symfony/console": "~2.3",
"symfony/finder": "~2.2",
- "symfony/process": "~2.1"
+ "symfony/process": "~2.1",
stecman / RestController.php
Last active August 17, 2022 15:20
Generic REST controller for use in the Phalcon PHP framework
use Phalcon\Mvc\Controller;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\DispatcherInterface;
use Phalcon\Mvc\Model\CriteriaInterface;
use Phalcon\Mvc\ModelInterface;
use Phalcon\Mvc\View;
abstract class RestController extends Controller
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 / index.htm
Last active August 9, 2019 17:02
CSS3 playing cards with flexbox
<!DOCTYPE html>
<meta charset="utf-8">
<link href="" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="style.css">
stecman / monday-for-week.php
Last active June 24, 2022 10:13
Reliable PHP function to return Monday for week (pre-PHP 7.1)
* Find the starting Monday for the given week (or for the current week if no date is passed)
* This is required as strtotime considers Sunday the first day of a week,
* making strtotime('Monday this week') on a Sunday return the adjacent Monday
* instead of the previous one.
* @param string|\DateTime|null $date
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