Skip to content

Instantly share code, notes, and snippets.

View theonlypwner's full-sized avatar
:octocat:
doing something other than writing a status

Victor theonlypwner

:octocat:
doing something other than writing a status
View GitHub Profile
@theonlypwner
theonlypwner / dupdetect.py
Last active March 20, 2016 01:08
Duplicate File Detection
#!/usr/bin/env python
# Duplicate File Detection
__copyright__ = "Copyright (C) 2016 Victor Zheng"
__licence__ = "GNU GPL v3"
# Based on https://github.com/IanLee1521/utilities/blob/master/utilities/find_duplicates.py
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@theonlypwner
theonlypwner / maxpng.py
Last active February 23, 2016 22:24
Maximum (sized) PNG generator
#!/usr/bin/env python
# Maximum PNG generator
__copyright__ = "Copyright (C) 2016 Victor Zheng"
__licence__ = "GNU GPL v3"
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@theonlypwner
theonlypwner / randompng.py
Last active August 25, 2023 09:58
Random PNG generator
#!/usr/bin/env python
# Random PNG generator
__copyright__ = "Copyright (C) 2016 Victor Zheng"
__licence__ = "GNU GPL v3"
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@theonlypwner
theonlypwner / dl.py
Created January 30, 2016 02:53
Multiple File Downloader
import urllib.request
FILES_TO_DOWNLOAD = """
google.com
example.com
"""
for line in FILES_TO_DOWNLOAD.splitlines():
if not line:
continue
@theonlypwner
theonlypwner / ip_fix.php
Created January 10, 2016 00:26
PHP IP Fix behind Reverse Proxies (CloudFlare and Varnish)
<?php
// fix CloudFlare/Varnish IPs
function transform_cf(&$ip){
if(!isset($_SERVER['HTTP_CF_CONNECTING_IP']))
return;
$cf_cidrs = array(
"103.21.244.0/22",
"103.22.200.0/22",
"103.31.4.0/22",
@theonlypwner
theonlypwner / dfamin.py
Last active December 5, 2015 21:20
DFA Minimizer (partial)
# States
Q = frozenset('abcdef')
# Alphabet (input symbols)
Sigma = frozenset([0, 1])
# Transition Function (Q x Sigma -> Q)
delta = {
('a', 0): 'b',
('a', 1): 'c',
('b', 0): 'a',
('b', 1): 'd',
@theonlypwner
theonlypwner / main.c
Last active December 5, 2015 04:07
FSM Verifier
#include <stdio.h>
#define MAXSEARCHLEN 9
#define FAST 0
const char next_state[] = {
2, 2, 2, 5, 6, 2, 2, 0,
1, 3, 4, 3, 3, 4, 4, 0,
};
@theonlypwner
theonlypwner / resistorforce.py
Created November 3, 2015 18:06
Inefficient Resistor Combination Minimizer
# Inefficient resistor solver
# it's also incomplete
# Licensed under GPL 3
# settings
target = 9960
tolerance = target * 0.005
depth = 3
available_resistors = [
@theonlypwner
theonlypwner / MATH.py
Created January 10, 2015 16:10
4*MATH=HTAM
# N*[MATH]=[HTAM]
# MATH -> ABCD
# N(1000A+100B+10C+D)=1000D+100C+10B+A
# (1000N-1)A+10(10N-1)B=10(10-N)C+(1000-N)D
count = [0] * 9
for N in range(1, 10):
for A in range(10):
for B in range(10):
for C in range(10):
for D in range(10):