Skip to content

Instantly share code, notes, and snippets.

View chtzvt's full-sized avatar
🧿
If the fool would persist in his folly he would become wise.

Charlton Trezevant chtzvt

🧿
If the fool would persist in his folly he would become wise.
View GitHub Profile
@chtzvt
chtzvt / spamkiller_lighttpd.conf
Last active August 29, 2015 14:19
Spam Crawler/Referrer Blocker for Lighttpd
Moved to https://github.com/ctrezevant/everlasting-botstopper!
//Nasty bot catcher adapted from https://github.com/ctrezevant/node-form-inspector
//Loads our dependencies.
var http = require('http');
var url = require('url') ;
var qs = require('querystring');
var fs = require('fs');
//On what port should the server run?
var PORT = 8082;
@chtzvt
chtzvt / notify.sh
Last active September 7, 2015 15:09
linux-boot-notify
# Boot email notification by Charlton Trezevant
# Version 3.0
###SETUP:
# Just paste it right in to /etc/rc.local
# Note that this depends on having mailx and postfix installed.
# See below for more info.
###DEPENDENCIES
# This script requires mailx and postfix to be installed.
@chtzvt
chtzvt / sort.sh
Last active August 29, 2015 14:21
episorter
# Get num of episodes in the current directory by
# Searching for files that contain 'Episode' in the name.
EP=`ls | grep -i 'Episode' | wc -l`
# Get current season from the name of the directory we're currently in
# This assumes that episodes are in directories by episode, like so:
# /path/to/TV Show/Season 1/
SEASON=`pwd | grep -o '[0-9]*'`
# Initialize the variable we'l be using for the while loop.
I=1
@chtzvt
chtzvt / README
Last active October 23, 2017 19:43
Generate Baneposts quickly and easily using C.
Moved to: https://github.com/ctrezevant/bane
@chtzvt
chtzvt / apush-scraper.sh
Last active September 24, 2015 23:49
A script I used to scrape my APUSH textbook from Google's cache.
echo "Downloading APUSH book..."
# Initialize total downloaded count.
DLT=0
echo "Creating downloads directory (./apush-dl)"
# Create downloads directory and redirect stderr to /dev/null (in case the directory already exists).
mkdir ./apush-dl/ 2>/dev/null
# There are 32 chapters.
@chtzvt
chtzvt / roids.js
Created October 8, 2015 22:10
A bot I used to cast votes for my high school's football coach.
/*
Roids.js by Charlton Trezevant - 2015
This is a bot I used to cast votes for my high school's Football coach.
It is written specifically for that poll, and in the interest of keeping the skiddies away
I will leave it to you to reverse-engineer PollDaddy.
Enjoy!
*/
// The Request library is an excellent HTTP library. Install it with "npm install request".
var request = require('request');
@chtzvt
chtzvt / fizzbuzz.js
Created October 15, 2015 23:46
FizzBuzz example
// Test the divisibility of numbers from 1-100.
for (var i = 1; i <= 100; i++) {
// Is the number evenly divisible by both 3 and 5?
if((i % 3 === 0) && (i % 5 === 0)){
console.log('fizzbuzz');
// No? Then let's see whether it's divisible by 3.
} else if(i % 3 === 0) {
console.log('fizz');
// Still no? Let's try 5, then.
} else if (i % 5 === 0){
@chtzvt
chtzvt / smokey.conf
Last active December 30, 2017 21:00
This bit of lighttpd configuration is what I use to stop image hotlinking, while also ensuring that search engines and social media can still access images.
###Hotlinking madness :^)
$HTTP["host"] =~ "charltontrezevant\.com" {
$HTTP["referer"] !~ "charltontrezevant|ctis\.me|google|bing|facebook|twitter|reddit|ycombinator|Skype|Slack" {
$HTTP["useragent"] !~ "Google|msnbot|FlipBoard|Bing|Yahoo|Facebook|Yandex|twitter|Slack|Skype" {
$HTTP["url"] =~ "\.jpeg|\.jpg|\.png|\.gif|\.bmp" {
$HTTP["url"] !~ "hotlinking\.png" {
url.redirect = ("" => "https://www.charltontrezevant.com/resources/images/hotlinking.png")
}
}
}
@chtzvt
chtzvt / pocket_export.rb
Last active June 4, 2022 05:02
Simple script to save your entire Pocket list (unread + archived) in PDF form.
=begin
Pocket Export.rb
My first 'real' Ruby script (hello world)!
More info here: http://blog.ctis.me/2015/12/archiving-your-pocket-articles-with-ruby.html
DEPENDENCIES:
pocket_export requires the following gems:
curb
nokogiri