Skip to content

Instantly share code, notes, and snippets.

View stecman's full-sized avatar

Stephen Holdaway stecman

View GitHub Profile
@stecman
stecman / less-fix.php
Last active October 6, 2015 02:43
Script to fix vertical whitespace in LESS/CSS-like files
#!/usr/bin/env php
<?php
/**
* Fix vertical whitespace in LESS/CSS-like files
*
* This script fixes selectors that are bunched together with no spacing, and selectors
* that are bunched together with properties and have no vertical spacing. This could be
* done with sed, but the regex escaping was a pain and it's harder to document.
*
@stecman
stecman / SiteTreePermissionsExtension.php
Last active December 7, 2015 17:25
SilverStripe extension to use the permissions for SiteTree on other dataobjects
<?php
/**
* Apply the SiteTree edit/view/delete permissions/roles to any DataObject
*
* By default DataObjects are only writable by admin users, which isn't all that useful.
* The null return values indicate to the calling code in DataObject that the extended
* method shouldn't affect the outcome of the permission check.
*
* @see DataObject::extendedCan()
@stecman
stecman / _README.md
Last active March 17, 2016 21:29
Prototype: get SilverStripe database (when a beam.json configis available)

getdb prototype

This is an experimental database fetching tool for projects using SilverStripe with _ss_environment.php files for database config and Beam. A project's beam.json config is used to find SSH connection details, and the database details for that environment are read from the _ss_environment.php file on the server.

This is essentially a wrapper to build and run a shell command like this:

@stecman
stecman / slice-convert.py
Last active May 12, 2016 04:39
heyday/silverstripe-slices 0.x to 1.0 config conversion script
#!/usr/bin/env python
# YAML config conversion script for heyday/silverstripe-slices 0.x going to 1.0
#
# Comments and whitespace aren't preserved - this is more to help you out by doing
# the repeatitive part of the conversion. The converted config is written to stdout.
#
# Note that this needs a python module installed to work:
#
# $ pip install pyyaml
@stecman
stecman / ir_remote.py
Last active July 6, 2016 19:27
Raspberry PI hardwired IR remote
#!/usr/bin/env python3
# Experiment: Replacing the LED in an infrared remote with a wired connection
#
# Details of the hardware/software implementation:
#
# I've hard-wired the crappy IR remote that came with a DVB-T RTL-SDR
# dongle into a GPIO pin on the Raspberry Pi. The infrared LED in the
# remote has been removed and replaced with a wire going to GPIO 3.
#
@stecman
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
stecman / Makefile
Created July 16, 2017 19:20
Watch PS/2 keyboard signals to add extra keyboard noise with relays (AVR / Arduino)
# This makefile is set up to work with the Arduino bootloader
# Depending on your device, you may need to adjust the PROGRAMMER
# line to point to the right serial port.
#
# To use, just run "make flash" with an arduino connected
DEVICE = atmega328p
CLOCK = 8000000
PROGRAMMER = -c arduino -P /dev/ttyUSB0 -b57600
SOURCES = $(shell find -name '*.c' -or -name '*.cpp' -or -name '*.S')
@stecman
stecman / _readme.md
Last active December 26, 2017 20:47
List BTRFS subvolume and snapshot sizes like df
@stecman
stecman / .bash_profile
Created February 27, 2018 04:04
Fuzzy find (fzf) to show file from history in Git
# Show file from Git tree at a certain point in the history
function hist() {
local ref=$1
local query=$2
if [ -z $ref ]; then
echo "Please specify a ref";
return;
fi
@stecman
stecman / avr_serial_pin_pulse.c
Last active March 24, 2018 10:56
Hacked together serial-controlled pin power pulser (AVR)
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/wdt.h>
#include <stdlib.h>
#include <string.h>
void init_usart(void)
{
cli();