Skip to content

Instantly share code, notes, and snippets.

View lewisxy's full-sized avatar

lewisxy

  • University of Washington
View GitHub Profile
@lewisxy
lewisxy / csftool.py
Created August 24, 2023 00:03
Tools to convert CSF files into JSON (and vice versa), to aid translation of RA2/YR mods
# MIT License
#
# Copyright (c) 2023 lewisxy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@lewisxy
lewisxy / main.rs
Last active October 28, 2021 23:17
TCP proxy PoC
// testing
// 1. open server on 127.0.0.1:7979
// $ nc -l -k 127.0.0.1 7979
// 2. connects to 127.0.0.1:7878
// $ nc 127.0.0.1 7878
// proxy is close when either side closed the connection
use std::io::prelude::*;
use std::net::{TcpListener, TcpStream, Shutdown, SocketAddr};
# License: no license / public domain
# puzzle: https://www.youtube.com/watch?v=N3JL3z4e2Qs
import heapq
# graph g, start s, end t
def dijkstra(g, s, t):
prev = [-1 for _ in range(101)]
dist = [float("inf") for _ in range(101)]
@lewisxy
lewisxy / randIP.py
Created December 24, 2019 05:29
select random IP from a specified range
#!/bin/python3
import json
import random
example_data = """
[
{
"type": "range",
"name": "myRange",
"range_begin": "1.2.3.4",
@lewisxy
lewisxy / split.py
Created December 3, 2019 22:04
Split a file into smaller pieces
#!/bin/python3
import sys
# This program splits a file into smaller files of given size
if len(sys.argv) == 3:
fname = sys.argv[1]
osize = int(sys.argv[2])
try:
with open(fname, 'rb') as f:
f.seek(0, 2)
@lewisxy
lewisxy / rename.sh
Created July 8, 2019 05:56
Shell script that replace all files with "%20" back to space in current directory
for file in *
do
if [[ "${file}" =~ (.*)%20(.*) ]]
then
mv "$file" "$(echo $file | sed "s/%20/ /g")"
fi
done