Skip to content

Instantly share code, notes, and snippets.

t d h smith tdhsmith

  • Midwestern US
Block or report user

Report or block tdhsmith

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tdhsmith
tdhsmith / OLGS_CA_game_inventory_hack.user.js
Created Oct 18, 2017
Very rough userscript to expose exact inventory data on Canadian games retailers BGB and 401G
View OLGS_CA_game_inventory_hack.user.js
// ==UserScript==
// @match https://store.401games.ca/*
// @match https://www.boardgamebliss.com/*
// ==/UserScript==
const is401 = document.location.host.indexOf("401") > -1;
function getProduct() {
try {
if (is401) {
const wrapper = document.getElementById("ProductJson-product-template");
@tdhsmith
tdhsmith / sever.js
Last active Jan 18, 2017
websocket-monitor opcode test server
View sever.js
const http = require('http');
const WebSocket = require('ws');
// you'll need to npm install ws (tested on v1.1.1, which was the default as of this writing)
const wss = new WebSocket.Server({
port: 3001
});
wss.on('error', console.error);
wss.on('listening', () => console.log("* WS server ready"));
@tdhsmith
tdhsmith / GC-solver-4.js
Created Oct 4, 2016 — forked from anonymous/GC-solver-4.js
Thrown-together solver for a geocaching puzzle
View GC-solver-4.js
var magic = ["equals(caret(175.4, 203.9), caret(gt(37.8, 16.3), 19.5))",
"equals(equals(caret(gt(88.7, 66.4), 101.5), caret(72.3, 39.5)), 37.8)",
"equals(equals(equals(caret(22009.9, 10101.8), 7228.7), 368.7), gt(4138488.0, 4020319.0))",
"equals(caret(2066.8, 668.8), caret(12.9, gt(122.1, 8.4)))",
"equals(equals(caret(9999.9, 10375.2), caret(777.7, 37.9)), gt(96.8, 33.0))",
"equals(equals(equals(caret(98765.7, 3777.5), 667.7), 268.3), caret(586728.2, 412841.8))"];
// unambiguous "caret(22009.9, 10101.8) = 7228.7 = 368.7 = gt(4138488.0, 4020319.0)", ?
// "(98765.7 ^ 3777.5) = 667.7 = 268.3 = (586728.2 ^ 412841.8)" ?
@tdhsmith
tdhsmith / RequiredXorRuleProvider.php
Last active Apr 14, 2016
Laravel Validator rule extension for 'required_xor'
View RequiredXorRuleProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\Arr;
use Illuminate\Support\ServiceProvider;
use InvalidArgumentException;
use Validator;
class RequiredXorRuleProvider extends ServiceProvider
{
@tdhsmith
tdhsmith / jwtauth_user_refs.dot
Last active Feb 10, 2016
Simplified flow for default user model interactions in JWTAuth
View jwtauth_user_refs.dot
# http://www.graphviz.org/content/cluster
digraph G {
rankdir = LR;
splines = line;
subgraph cluster_package {
subgraph cluster_0 {
color=blue;
node [style=filled];
label = "JWT";
@tdhsmith
tdhsmith / pre-commit
Created Nov 17, 2015
Git pre-commit username check
View pre-commit
#!/bin/bash
if [[ -z "$(git config user.name)" ]]; then
echo "Git username must be defined to commit!"
echo "(Are you running inside Vagrant/Homestead?)"
echo
exit 1
fi
@tdhsmith
tdhsmith / index.js
Last active Nov 16, 2015
Usemin Generic Steps
View index.js
'use strict';
var path = require('path');
// a generic flow step where each file is processed independently
// from the inDir to the outDir (this doesn't have a 'last case')
// (borrowed from the default uglify task)
exports.independentFlow = function (context, block) {
var config = {files: []};
context.inFiles.forEach(function (filename) {
var infile = path.join(context.inDir, filename);
@tdhsmith
tdhsmith / index.html
Last active Feb 5, 2016
JWTAuth Token Flow Diagram
View index.html
<html>
<head>
<title>Token Diagram for tymon/jwt</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
@tdhsmith
tdhsmith / dabblet.css
Last active Aug 29, 2015
Nth-of-type and compound selectors demo
View dabblet.css
/**
* Nth-of-type and compound selectors demo
*/
p.third:nth-of-type(3) {
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
}
@tdhsmith
tdhsmith / gifiterate.py
Last active Jun 4, 2018 — forked from BigglesZX/gifextract.py
Generator to iterate over frames in an animated GIF, correctly handling palettes and frame update modes
View gifiterate.py
import os
from PIL import Image
'''
I searched high and low for solutions to the "extract animated GIF frames in Python"
problem, and after much trial and error came up with the following solution based
on several partial examples around the web (mostly Stack Overflow).
There are two pitfalls that aren't often mentioned when dealing with animated GIFs -
firstly that some files feature per-frame local palettes while some have one global
You can’t perform that action at this time.