Skip to content

Instantly share code, notes, and snippets.

View scarpent's full-sized avatar
🙀
Lions and tigers and bears, oh my!

Scott Carpenter scarpent

🙀
Lions and tigers and bears, oh my!
View GitHub Profile
@scarpent
scarpent / better-twitter
Last active September 13, 2021 14:49
Better Twitter: Greasemonkey/Tampermonkey script to hide stuff you don't want to see
// ==UserScript==
// @name Better Twitter
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove unwanted stuff (promoted, other people's likes, ...)
// @author Scott Carpenter
// @match https://twitter.com/
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.githubusercontent.com/scarpent/ba8e369f1187fa990b98d1f58b2c013d/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js
// @grant none
@scarpent
scarpent / waitForKeyElements.js
Last active July 24, 2017 15:16 — forked from BrockA/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
@scarpent
scarpent / pre-commit
Created March 31, 2017 19:24 — forked from acdha/pre-commit
Git pre-commit hook which runs various code linters. Install this to .git/hooks/pre-commit inside your favorite repos
#!/usr/bin/env PYTHONIOENCODING=utf-8 python
# encoding: utf-8
"""Git pre-commit hook which lints Python, JavaScript, SASS and CSS"""
from __future__ import absolute_import, print_function, unicode_literals
import os
import subprocess
import sys
@scarpent
scarpent / MyBot.py
Last active February 27, 2017 14:16
Halite.io Bot. Earlier version submitted to public tournament and this one used for internal Nerdery tournament.
import operator
import time
from collections import namedtuple
from statistics import stdev, mean
import hlt
from hlt import EAST, NORTH, SOUTH, STILL, WEST, Move, Square
# uses:
# https://github.com/erdman/alt-python3-halite-starter/blob/master/hlt.py
@scarpent
scarpent / colors.sh
Last active August 29, 2015 14:06 — forked from sumpygump/colors.sh
#!/bin/bash
#
# This file echoes a bunch of color codes to the
# terminal to demonstrate what's available. Each
# line is the color code of one forground color,
# out of 17 (default + 16 escapes), followed by a
# test use of that color on all nine background
# colors (default + 8 escapes).
#
http://abc.com/#/contact
http://abc.com/#/contact?asdf=asdfr
http://abc.com/#/contact/?asdf=asdfr
http://abc.com/#/contact
http://abc.com/#/?sadfasd=asdf
http://abc.com/#/contact
/contact/?
/{required}/?
function getNextSequenceNumber($sequenceName)
{
global $wpdb;
$wpdb->query($wpdb->prepare(
"
INSERT INTO table_name
(seq_name, seq_num)
VALUES (%s, LAST_INSERT_ID(1))
ON DUPLICATE KEY UPDATE seq_num = LAST_INSERT_ID(seq_num + 1);
@scarpent
scarpent / regex_tester.py
Last active December 16, 2015 11:38
For testing regular expressions.
import re
red = '\033[0;31m'
cyan = '\033[0;36m'
no_color = '\033[0m'
def replace(pattern, string, replace='__'):
regextester(pattern, string, replace)
def vreplace(pattern, string, replace='__'):