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
# 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
#!/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: |
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
// 137 char mandelbrot code golf | |
// collaboration by myself and others on a programming discord server | |
y=40,x;main(i){for(;y--;puts(""))for(x=170;x--;printf(L" .'-+=%@#"+i/12))for(typeof(0.i)z=i=0;cabs(z)<2&i++<99;z=z*z-x/50.+y/20.i+1+1i);} | |
// 130 char, lower-detail: | |
y=40,x;main(i){for(;--y;puts(""))for(x=170;x--;printf(L" *"+i/99))for(typeof(0.i)z=i=0;cabs(z)<2&i++<98;z=z*z-x/50.+y/20.i+1+1i);} | |
// compiler: gcc, may need -lm |
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
// brainf interpreter code golf | |
// collaboration by some folks on discord and myself | |
#include <stdio.h> | |
#define r(c) ;i++;goto w;case c: | |
i;t[99];s;p=1024;char b[2048];main(int j,char**a) { | |
fread(b,1,p,fopen(a[1],"r")); | |
w: switch(b[i]) { | |
r(45) b[p]-- | |
r(43) b[p]++ | |
r(60) p-- |
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 <cmath> | |
#include <cassert> | |
#include <type_traits> | |
template<typename T> int sign(T t) { | |
return t < 0 ? -1 : 1; | |
} | |
template<typename T> class range { | |
typedef typename std::make_signed<T>::type ST; |
OlderNewer