Skip to content

Instantly share code, notes, and snippets.

View mrdmnd's full-sized avatar

Matthew Redmond mrdmnd

  • Self-Employed
  • San Francisco, CA
  • X @mrdmnd
View GitHub Profile
@mrdmnd
mrdmnd / kpbreaker.py
Created August 12, 2012 08:57
Quick bruteforcer. No results.
import sys
sys.path.append("./python-keepass/python")
from keepass import kpdb
byte_strings = [hex(x)[2:].rjust(2, '0').lower() for x in range(255)]
pass_template = "%s3b140a6ec5%sec"
num_tried = 0
for s1 in byte_strings:
for s2 in byte_strings:
tmp_pw = pass_template % (s1, s2)
num_tried += 1
@mrdmnd
mrdmnd / decklist_dl.py
Created August 26, 2012 00:26
TCG Player deck scraper
# Copyright 2012 Matt Redmond
__author__ = "mrdmnd@mit.edu"
import mechanize
from Queue import Queue, Empty
from threading import Thread
import re
queue = Queue()
break_regex = re.compile("<br>", re.IGNORECASE)
import string
# Algorithm for SMBC #2874 - the "fouriest" transform.
# Support bases 2-36.
BASE_LIST = string.digits + string.letters
def encode(integer, base):
# Stolen off the internet from somewhere,
# almost certainly guaranteed to be buggy.
base_list = BASE_LIST[:base]
@mrdmnd
mrdmnd / gist:4760746
Created February 12, 2013 07:16
My .vimrc
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'Valloric/YouCompleteMe'
@mrdmnd
mrdmnd / extract_stop_info.py
Created October 4, 2016 07:33
A short script to output ordered bus-route stop data for two routes in San Clemente, CA
import json
import requests
# Rough bounding box for San Clemente, CA
southwest = [33.351665, -117.779208]
northeast = [33.566387, -117.537489]
bbox_string = "%s,%s,%s,%s" % tuple(southwest[::-1]+northeast[::-1])
stops = []
routes = []
@mrdmnd
mrdmnd / repeat_hello.asm
Last active March 10, 2020 19:39
Small Hello World repeater
; nasm -f elf64 -g -F dwarf repeat_hello.asm && gcc -g -no-pie repeat_hello.o -o repeat_hello && ./repeat_hello 5
; Intended for use on linux x86-864 machines; to run on OS X you'd have to change the syscalls.
extern atoi
global main
section .data
message: db "Hello, world!", 0x0A
length: equ 14
err_msg: db "Wrong!", 0x0A
@mrdmnd
mrdmnd / ex1.c
Created March 20, 2020 07:43
Solutions to the first set of exercises on Pointers
#include "stdio.h"
#include "string.h"
// 6. (Implementation)
void memory_copy(void* to, const void* from, int n) {
// Need to cast from void to char so that pointer arithmetic works here.
const char* src = (const char *) from;
char* dest = (char *) to;
for (int i = 0; i < n; i++) {
@mrdmnd
mrdmnd / ex2.c
Created March 20, 2020 22:23
Solutions to the second problem set
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#define MAX_DICTIONARY_SIZE 300000
#define MAX_WORD_LENGTH 15
// We should guarantee room for a newline and null byte in our buffer.
#define BUFFER_SIZE (MAX_WORD_LENGTH + 2)
int populate_dictionary(char *filepath, char dictionary[][BUFFER_SIZE]) {
@mrdmnd
mrdmnd / bloom_filter.py
Created May 8, 2020 19:22
Homework for Friday, May 15th for ATCS
import random
class HashFamily:
def __init__(self):
self.memomask = {}
def hash_fn(self, n):
mask = self.memomask.get(n)
if mask is None:
random.seed(n)
mask = self.memomask[n] = random.getrandbits(64)
@mrdmnd
mrdmnd / wordchain.py
Last active May 22, 2020 20:38
Word Chain Homework Exercise
import sys
# Should return a set() of all words in the scrabble dictionary passed in at the given file path.
# You should implement this file loader.
def LoadWords(scrabble_dictionary_path):
pass
# Return a set() of ALL valid words from the input set `all_words` that differ by exactly one letter from `word`
# Hint: you may want to try using regular expressions here.
def FindAllNeighbors(word, all_words):