Skip to content

Instantly share code, notes, and snippets.

View tdlm's full-sized avatar

Scott Weaver tdlm

View GitHub Profile
@tdlm
tdlm / keybase.md
Last active August 29, 2015 13:57
keybase verification

Keybase proof

I hereby claim:

  • I am tdlm on github.
  • I am tdlm (https://keybase.io/tdlm) on keybase.
  • I have a public key whose fingerprint is CF54 CAAA E550 7D3C 1A56 E99F D58D 79CB CD0F F0C4

To claim this, I am signing this object:

#!/bin/sh
secure_delete_files_for_tag_after_seconds () {
if [ -z "$1" ]; then
echo "-Parameter 1 required: Tag"
return 0
fi;
if [ -z "$2" ]; then
@tdlm
tdlm / pastebin.lua
Last active January 11, 2018 00:47
PasteBin shortcut for Hammerspoon
-- View your api_dev_key here: http://pastebin.com/api
local PASTEBIN_API_DEVELOPER_KEY = ""
-- Generate your api_user_key here: http://pastebin.com/api/api_user_key.html
local PASTEBIN_API_USER_KEY = ""
-- This makes a paste public or private, public = 0, unlisted = 1, private = 2
local PASTEBIN_API_PASTE_PRIVATE = "1"
--[[
@tdlm
tdlm / url_shortener.lua
Last active March 29, 2019 12:08
URL Shortener shortcut for Hammerspoon
-- Requires an API Access Token from Bit.ly
local BITLY_API_ACCESS_TOKEN = ""
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "S", function()
local board = hs.pasteboard.getContents()
if board:match("^https?://") then
local response = hs.http.asyncGet(
"https://api-ssl.bitly.com/v3/shorten" ..
"?access_token=" .. BITLY_API_ACCESS_TOKEN ..
local GITHUB_API_PATH = "https://api.github.com"
local GITHUB_API_USER = ""
local GITHUB_API_TOKEN = ""
local GITHUB_REPOS = {
"tdlm/os-x-self-destruct"
}
local rate_limit_percentage
local menu_bar_refresh_time = 60
#!/usr/bin/python
import urllib2
import time
import RPi.GPIO as GPIO
from time import sleep
PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
'use strict';
var request = require('request'),
csv = require('fast-csv'),
validUrl = require('valid-url'),
baseRequest = request.defaults({
followRedirect: false,
followAllRedirects: false
});
#!/bin/bash
echo "Commencing Vocativ Base Setup as user: $USER"
cd /srv/www/
echo "Setting permissions..."
sudo touch /var/log/php5-fpm.log
echo "Copying vagrant ssh settings to root..."
@tdlm
tdlm / ttfb.sh
Created September 12, 2016 19:29
Command to take average time-to-first-byte for a given URL
#!/usr/local/bin/bash
total=0.000
ttfbs=()
for i in `seq 1 5`
do
ttfb=$(curl -s -o /dev/null -w "%{time_starttransfer}" "$1")
total=$(scale=3;echo "$total+$ttfb" | bc)
done
@tdlm
tdlm / processizer
Last active November 4, 2016 23:25
The idea of processizer is to list all running processes on the Mac and display the man page description inline. If there is no man page description, eventually this process would reach out to an external API and try to find a match, which it would cache locally. Holistically, the idea is to know what's running on your system.
#!/usr/bin/env bash
function get_process_description {
local __page=$(MANWIDTH=200 man "$@" 2>&1 | col -bx)
local __desc=$(echo "$__page" | pcregrep -M -o2 '(DESCRIPTION)\n(.*)' | sed -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba')
if [[ -z "$__desc" ]]; then
return 2
else