Skip to content

Instantly share code, notes, and snippets.

Stephen Holdaway stecman

View GitHub Profile
@stecman
stecman / YahooHistoricStockApi.php
Last active Oct 13, 2016
PHP classes to get stock data from various Yahoo finance APIs
View YahooHistoricStockApi.php
<?php
/**
* Get historic stock symbol information from Yahoo
*
* Based on https://code.google.com/p/yahoo-finance-managed/wiki/csvHistQuotesDownload
*/
class YahooHistoricStockApi
{
@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 / README.md
Last active Dec 20, 2018
Pushover notification CLI script
View README.md

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

Installation

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

@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 / bash-completion.patch
Last active Dec 21, 2016
Enable BASH completion for Composer
View bash-completion.patch
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
stecman / RestController.php
Last active Mar 7, 2019
Generic REST controller for use in the Phalcon PHP framework
View RestController.php
<?php
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
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 / index.htm
Last active Nov 19, 2015
CSS3 playing cards with flexbox
View index.htm
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Cards</title>
<link href="http://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
@stecman
stecman / monday-for-week.php
Last active Feb 3, 2019
Reliable PHP function to return Monday for week
View monday-for-week.php
/**
* Find the starting Monday for the given week (or for the current week if no date is passed)
*
* This is required as by default in PHP, 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
* @return \DateTime
*/
You can’t perform that action at this time.