This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
from scapy.all import * | |
import binascii | |
conf.checkIPaddr=False | |
display = False | |
def run_dhcp_transaction(requestMAC, hostname, interface="eth0"): | |
localmac = get_if_hwaddr(interface) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Filter black and white images from a directory | |
# walk the photos/ directory and copy bw photos | |
# to the bw/ directory. | |
# Runs in parallel to help with analyzing large | |
# batches of photos. | |
import colorsys | |
import multiprocessing | |
import os | |
import shutil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Couple quick utilities | |
// compute the average of an array | |
function average(data) { | |
let sum = 0; | |
for(let i = 0, l = data.length; i < l; i++) | |
sum += data[i]; | |
return sum / data.length; | |
} | |
// compute the variation of an array | |
function variation(data) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Include "memory_tracker.h" in every source file where you want to track allocations. | |
The memory tracker header should come after all other includes. | |
Include -DMEMORY_DEBUG in the build to enable memory tracking. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <string> | |
template<typename... T> std::string stringf(T... args) { | |
int length = snprintf(0, 0, args...); | |
if(length < 0) assert(("invalid arguments to stringf", false)); | |
std::string str(length, 0); | |
snprintf(str.data(), length + 1, args...); | |
return str; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# definition recursive ackermann | |
def A(m, n): | |
if m == 0: | |
return n + 1 | |
elif n == 0: | |
return A(m - 1, 1) | |
else: | |
return A(m - 1, A(m, n - 1)) | |
# non-recursive ackermann |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import shutil | |
import sys | |
import random | |
def pick_random(src, dest, N): | |
all_files = [] | |
for path, dirs, files in os.walk(src): | |
for f in files: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a program to filter photos with ifunny watermarks. | |
# I wrote this script for personal use to separate saved ifunny memes from other photos on my phone. | |
# The script is fully parallelized and is able to make good use of technologies like Intel | |
# hyperthreading because substantial program time is spent in IO. Bottleneck will be IO. | |
# | |
# Watermark false positive rate appears to be < 1/500 | |
# Watermark false negative rate appears to be ~ 1/500 | |
# False positive / negative rate checked with manual spot check sample size = 500. | |
# | |
# Rifkin 2020 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
# Script to parse minecraft server logs and add up users' playtime. | |
# Usage: python3 playtime.py path/to/logs | |
# | |
# Rifkin 2020 | |
import datetime | |
import gzip | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
def main(): | |
filedict = {} | |
for path, dirs, files in os.walk(sys.argv[1]): | |
for f in files: | |
full_path = os.path.join(path, f) | |
l = full_path.lower() | |
if l not in filedict: |
OlderNewer