Skip to content

Instantly share code, notes, and snippets.

View bwbaugh's full-sized avatar

Wesley Baugh bwbaugh

View GitHub Profile
class InterruptableRegion(object):
def __init__(self, signum_list=None):
if signum_list is None:
signum_list = [signal.SIGINT]
self.signum_list = signum_list
self.reset()
def __enter__(self):
self.reset()
@bwbaugh
bwbaugh / tor-install-guide.md
Created April 19, 2015 22:50
Install guide for Tor and Polipo.
@bwbaugh
bwbaugh / server-name-wordlist-mnemonic.txt
Last active May 18, 2023 11:09
Server name wordlist (mnemonic)
# Original blog post: <https://mnx.io/blog/a-proper-server-naming-scheme/>
# Original word list: <http://web.archive.org/web/20091003023412/http://tothink.com/mnemonic/wordlist.txt>
# Sample usage: `curl <gist> | tail --lines +4 | shuf | head --lines 1`
acrobat
africa
alaska
albert
albino
album
alcohol
@bwbaugh
bwbaugh / nginx.conf
Last active August 29, 2015 14:16 — forked from oroce/nginx.conf
user www-data;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
sendfile on;
@bwbaugh
bwbaugh / server-setup-guide.md
Last active November 26, 2023 07:44
Guide to set up a new VPS

Guide to set up a new VPS

This guide was written while setting up an Unbuntu VPS. There may be some differences when setting up a different distro.

Initial steps as root

Do some basic setup as the root user, which should mainly consist of

@bwbaugh
bwbaugh / twitter-available-usernames.py
Last active December 17, 2015 05:29
Find unknown, suspended, or deleted screen names of a certain length. For @_milesokeefe.
from __future__ import division
import itertools
import json
import tweepy
# Configuration.
USERNAME_LENGTH = 3
SAVE_FNAME = 'twitter_usernames.txt'
@bwbaugh
bwbaugh / twitter-names.py
Last active December 17, 2015 05:29
Generating possible Twitter usernames of a certain length (in this case, 3). For @_milesokeefe
lower = [chr(x) for x in range(ord('a'), ord('z') + 1)]
# >>> lower
# ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
# 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
digits = [str(x) for x in range(10)]
# >>> digits
# ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
characters = lower + digits + ['_']
@bwbaugh
bwbaugh / classify.py
Created April 25, 2013 21:03
Detecting a Specific Watermark in a Photo with Python Get example training and testing images here: <http://bwbaugh.com/stack-overflow/16222178_watermark.tar> Stack Overflow question: <http://stackoverflow.com/questions/16222178/detecting-a-specific-watermark-in-a-photo-with-python-without-scipy>
# Copyright (C) 2013 Wesley Baugh
"""Tools for text classification.
Extracted from the [infer](https://github.com/bwbaugh/infer) library.
"""
from __future__ import division
import math
from collections import defaultdict, namedtuple, Counter
from fractions import Fraction
@bwbaugh
bwbaugh / example-output.md
Last active December 7, 2022 12:18
Generate a randomly connected graph with N nodes and E edges.

Example output

Minimum number of edges

python random_connected_graph.py -p -g names.gml names.txt

Console

@bwbaugh
bwbaugh / word_ similarity.py
Last active June 4, 2020 19:52
Determine if two (already lemmatized) words are similar or not.
def sim(word1, word2, lch_threshold=2.15, verbose=False):
"""Determine if two (already lemmatized) words are similar or not.
Call with verbose=True to print the WordNet senses from each word
that are considered similar.
The documentation for the NLTK WordNet Interface is available here:
http://nltk.googlecode.com/svn/trunk/doc/howto/wordnet.html
"""
from nltk.corpus import wordnet as wn