Skip to content

Instantly share code, notes, and snippets.

View stecman's full-sized avatar

Stephen Holdaway stecman

View GitHub Profile
@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 July 10, 2023 00:37
Steam auto trader

Maximum Hax

Automates the UI actions (clicks, typing) to sell Steam trading cards from the Steam web interface. To use this:

  1. Log into your Steam account in Chrome
  2. Go to [Username] -> Inventory
  3. Open the Javascript console (View -> Developer -> Javascript Console)
  4. Paste in the entire script below and press enter
  5. To start selling all trading cards in your inventory, type doHax() in the console and press enter
  6. ...
@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 / GridFieldStreamExportButton.php
Created April 5, 2016 05:20
Streamed CSV export for SilverStripe GridField
<?php
/**
* Improved GridFieldExportButton that streams CSV data to the client instead of building
* the entire CSV in memory and sending that (which doesn't work for large data sets).
*/
class GridFieldStreamExportButton extends GridFieldExportButton
{
/**
@stecman
stecman / How to Git.md
Last active July 7, 2022 03:53
How to Git

Note: this is an extract from Heyday's internal docs, written by me. Published as a Gist to share the love.

Authoring commits

We like sensible commit messages. There're a lot of good articles about writing great, useful commit messages, but here's the gist of what we like:

  • The single most important thing is: commit messages should explain why you are making the change.
  • Think, "what would future me want to know about this change?"
  • Avoid committing multiple sets of ideas/changes in the same commit: split them up.
  • Don't assume the reader understands what the original problem was.
@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 / TimerModule.h
Created August 22, 2016 22:45
React Native get relative time
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
@interface TimerModule : NSObject <RCTBridgeModule>
@end
@stecman
stecman / README.md
Last active May 13, 2019 01:03
Python interface to control https://github.com/stecman/avr-usb-status-light over USB

Requirements

Install https://pypi.python.org/pypi/libusb1

Allowing control without root privileges

# Create rule so the device can be controlled by any user
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="f055", ATTR{idProduct}=="05df", MODE="0666"' \
 | tee /etc/udev/rules.d/99-status-light.rules
@stecman
stecman / _readme.md
Last active December 26, 2017 20:47
List BTRFS subvolume and snapshot sizes like df
@stecman
stecman / Makefile
Last active February 18, 2020 13:03
ATTiny13A Button Pusher - Remember how many times a button was pushed and push it electronically on startup
DEVICE = attiny13a
CLOCK = 1200000
PROGRAMMER = -c dragon_isp
SOURCES = $(shell find . -name '*.c' -or -name '*.cpp' -or -name '*.S')
OBJECTS = $(SOURCES:.c=.o)
AVRDUDE = avrdude $(PROGRAMMER) -p t13
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
COMPILE += -I -I. -I./lib/
COMPILE += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums