Skip to content

Instantly share code, notes, and snippets.

View thattomperson's full-sized avatar

Thomas Albrighton thattomperson

View GitHub Profile
@thattomperson
thattomperson / swap-external-displays
Created February 13, 2023 04:46
npm install -g zx; brew install displayplacer;
#! /usr/bin/env zx
// Parse the output of displayplacer list to a javascript object
async function getCurrentConfig() {
return (await quiet($`displayplacer list`)).stdout
.split('\n\n')
.filter(screen => screen.startsWith('Persistent'))
.map(screen => {
return screen
.split('\n')
@thattomperson
thattomperson / gls
Created September 6, 2021 00:44
LS suffixed with the git branch the folder is checked out to
#!/bin/bash
BLUE='\e[0;34m'
WHITE='\e[1;37m'
for ITEM in *
do
GIT_BRANCH=$([ -d $ITEM/.git ] && git --work-tree=$ITEM --git-dir=$ITEM/.git rev-parse --abbrev-ref HEAD || echo ' -')
LS_DIR=$(CLICOLOR_FORCE=1 ls -G $@ -d $ITEM)
printf '%b %s\n' "${LS_DIR}" $GIT_BRANCH;
@thattomperson
thattomperson / Symfony1TinkerwellDriver.php
Created July 27, 2020 00:01
Symfony 1 Tinkerwell Driver
<?php
class Symfony1TinkerwellDriver extends TinkerwellDriver
{
public function canBootstrap($projectPath)
{
return file_exists($projectPath . '/config/ProjectConfiguration.class.php');
}
@thattomperson
thattomperson / [post-commit]-update-hooks.js
Last active November 16, 2023 05:24 — forked from maxmarkus/pre-commit-hook-merge-conflicts.sh
My Everyday Git hooks `nix-shell -p nodejs_18 --run "curl -L gist.githubusercontent.com/thattomperson/7a8127ac306bb2e58c24ba16a521b621/raw/%255Bpost-commit%255D-update-hooks.js | node"`
#! /usr/bin/env nix-shell
`
#! nix-shell --packages nodejs_18 -i node
`
const https = require('https');
const path = require('path');
const fs = require('fs');
const util = require('util');
const readline = require('readline')
@thattomperson
thattomperson / getTag.sh
Last active April 7, 2017 03:34
Return the first pokemon (or any list) that hasn't been used for a tag yet
#! /bin/sh
pushd `dirname $0` > /dev/null
lines=`cat tags.txt`;
allTags=()
while read -r line; do
allTags+=("$line")
done < tags.txt
@thattomperson
thattomperson / exmaple.com
Created April 1, 2015 02:22
nginx config
# read more here http://tautt.com/best-nginx-configuration-for-security/
# don't send the nginx version number in error pages and Server header
server_tokens off;
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
# https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
add_header X-Frame-Options SAMEORIGIN;
@thattomperson
thattomperson / checkIfInArray.asp
Last active August 29, 2015 14:10 — forked from gwobcke/checkIfInArray.asp
Classic ASP Check If In Array
<%
Function in_array(element, arr)
in_array = False
dim i
For i=0 To Ubound(arr)
If arr(i) = element Then
in_array = True
Exit Function
End If
Next
@thattomperson
thattomperson / chat1
Last active August 29, 2015 14:08
chat
<div id="chat-messages" style="height: 432px;"><div class="message" data-cid="4684278-06eb17f3f0"><i class="icon icon-chat-ambassador"></i><div class="timestamp" style="display: block;">3:05pm</div><span class="from ambassador clickable">Fungus </span><span class="text">&nbsp;@DJ Nikki J whoa whoa whoa</span></div><div class="message" data-cid="3981366-c391896877"><i class="icon icon-chat-manager"></i><div class="timestamp" style="display: block;">3:05pm</div><span class="from staff clickable">RaptorJeebus </span><span class="text">&nbsp;work*</span></div><div class="message" data-cid="4684278-b1bc114feb"><i class="icon icon-chat-ambassador"></i><div class="timestamp" style="display: block;">3:05pm</div><span class="from ambassador clickable">Fungus </span><span class="text">&nbsp;cookies are enough</span></div><div class="message" data-cid="4104660-1acce0ca33"><div class="timestamp" style="display: block;">3:05pm</div><span class="from clickable">DJ Nikki J </span><span class="text">&nbsp;bahahahaha i am kid
window.onerror = function (message, filename, lineno, colno, error) {
if (error) {
$.post('https://dps-pub.slack.com/services/hooks/incoming-webhook?token=YOUR TOKEN', {payload: JSON.stringify({
text: '@ThatTomPerson: \n' + error.stack
})});
}
};
(function (a, b) {
a.keydown(function (e) {
if( e.target.type !== 'text') {
switch (e.which) {
case 37: // left
Search.pagination.prev();
break;
case 39: // right
Search.pagination.next();
break;