Skip to content

Instantly share code, notes, and snippets.

@hodgesmr
hodgesmr / tweet_delete.py
Created November 22, 2022 16:03
delete tweets with tweepy
import json
import tweepy
# 1. Download your twitter archive
# 2. fix the first line of tweets.js to be proper json
# 3. Get twitter API creds
# 4. fix all the SETMEs in here
# 5. run this
import sys
# Prints a list of digits to stdout
def emit(digits: list[int], newline:bool = False) -> None:
for i in digits:
print(i, end='')
if newline:
print()
@hodgesmr
hodgesmr / compile_python.sh
Last active December 12, 2020 00:29 — forked from scott-hsieh/.sh
Compile Python 3.8.6 on MacBook with Big Sur
CPPFLAGS="-I$(brew --prefix zlib)/include -I$(brew --prefix bzip2)/include" && \
CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix readline)/include" && \
LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" && \
pyenv install -v 3.8.6
@hodgesmr
hodgesmr / Makefile
Created January 28, 2016 16:13
make-america-great-again
.PHONY: america great again
SHELL := /bin/bash
america:
@touch .
great:
@touch .
again:
@echo "Nah."
@hodgesmr
hodgesmr / hijacking_flask_routing_for_fun_and_profit.py
Last active June 19, 2023 19:39
Automatically register Flask routes with and without trailing slash. This way you avoid the 301 redirects and don't have to muddy up your blueprint with redundant rules.
"""Flask Blueprint sublcass that overrides `route`.
Automatically adds rules for endpoints with and without trailing slash.
"""
from flask import Blueprint, Flask
class BaseBlueprint(Blueprint):
"""The Flask Blueprint subclass."""
"""
You have a bunch of plane tickets from a recent multi-stop trip you took.
You dropped the tickets and they all got shuffled up.
Write some Python that takes the list of shuffled tickets
Where each ticket is in the format of (source, destination)
and reconstruct your trip. Output each city you were in, in chronological order.
"""
ticket_list = [ ('lax', 'ewr'), ('ord', 'jfk'), ('mia', 'ord'), ('cvg', 'sfo'), ('jfk', 'lax'), ('ewr', 'atl'), ('sfo', 'mia')]
@hodgesmr
hodgesmr / keybase.md
Created June 16, 2014 19:53
keybase.md

Keybase proof

I hereby claim:

  • I am hodgesmr on github.
  • I am hodgesmr (https://keybase.io/hodgesmr) on keybase.
  • I have a public key whose fingerprint is 0811 0F3B CAF8 8427 5E48 26A7 085E BEBD 1A07 CE65

To claim this, I am signing this object:

@hodgesmr
hodgesmr / MergeSort.swift
Last active August 29, 2015 14:02
An implementation of Merge Sort in Swift
func mergeSort(numbers: Int[], left: Int, right: Int) {
if right > left {
let splitIndex = (left + right) / 2
mergeSort(numbers, left, splitIndex)
mergeSort(numbers, splitIndex+1, right)
var result = Int[]()
var nextLeft = left
var nextRight = splitIndex + 1
@hodgesmr
hodgesmr / zen-commit.sh
Created September 14, 2013 03:12
Use the GitHub Zen API to generate git commits
A=$(curl https://api.github.com/zen -s) && git commit -m "$A"
@hodgesmr
hodgesmr / pins.rb
Created February 21, 2013 20:34
Print all possible 4-digit PINs
(0..9).each { |h| (0..9).each { |i| (0..9).each { |j| (0..9).each { |k| print "#{h}#{i}#{j}#{k}\n"}}}}