Skip to content

Instantly share code, notes, and snippets.

@ph1ee
ph1ee / diffeq
Last active November 6, 2022 09:39
diffeq
#include <iostream>
#include <cstdint>
using namespace std;
int foo(int *coefficient, int coi, uint64_t n) {
if (n == 0) {
return 0;
}
@ph1ee
ph1ee / chargen.py
Last active May 14, 2022 02:29
a simple tool to generate and validate chargen stream
#!/usr/bin/env python3
import sys
import time
from enum import Enum
asciistr = r"""!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}"""
class State(Enum):
@ph1ee
ph1ee / territory.py
Created January 18, 2022 12:21
a territory game for the yearly lucky draw
#!/usr/bin/env python3
import pdb
import copy
from tkinter import *
from tkinter import Tk, Canvas, Frame, BOTH, LEFT, RIGHT
from functools import cmp_to_key
from collections import namedtuple
import random
@ph1ee
ph1ee / conv-exported-pdu.py
Last active April 23, 2021 08:18
Remove the exported PDU layer and replace the IPv6 source/destination addresses from a pcap file
#!/usr/bin/env python3
import sys
from scapy.utils import rdpcap, wrpcap
from scapy.all import IPv6, UDP
def main():
packets = []
@ph1ee
ph1ee / stair.py
Created January 23, 2021 07:33
stair climbing simulation
#!/usr/bin/env python3
import argparse
import random
from turtle import Screen, Turtle
class Player:
def __init__(self, index, num_of_players):
self.index = index
@ph1ee
ph1ee / filecut.py
Last active June 18, 2020 14:47
filecut is a tool to extract a chunk of bytes within a binary file
#!/usr/bin/env python3
import sys
import os
def main(infile, extent):
try:
begin, end = extent.split("-")
size = end - begin
@ph1ee
ph1ee / bitcmp.c
Last active June 18, 2020 13:37
inspired by hexcmp, bitcmp is a tool to view `cmp -l` output in bitwise form
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/*
* E.g.,
* cmp -l <(dd if=/dev/urandom count=1) \
* <(dd if=/dev/urandom count=1) \
* | bitcmp -o
@ph1ee
ph1ee / plot-decision-tree.py
Created February 28, 2020 15:59
visualize tree-like text file
#!/usr/bin/env python3
import pydotplus
from uuid import uuid4 as uuid
import sys
import re
class Node:
def __init__(self, attr):
@ph1ee
ph1ee / discard.py
Last active January 10, 2020 07:29
simple discard daemon
#!/usr/bin/env python3
import socketserver
class TCPHandler(socketserver.StreamRequestHandler):
def handle(self):
while self.rfile.read(1):
pass
@ph1ee
ph1ee / ptime.c
Last active May 15, 2019 09:03
print time periodically
#define _DEFAULT_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
char outstr[200];
int usec = 100;