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
# 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: |
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
// 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}; |
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
# 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)] |
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 | |
import json | |
import random | |
example_data = """ | |
[ | |
{ | |
"type": "range", | |
"name": "myRange", | |
"range_begin": "1.2.3.4", |
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 | |
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) |
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
for file in * | |
do | |
if [[ "${file}" =~ (.*)%20(.*) ]] | |
then | |
mv "$file" "$(echo $file | sed "s/%20/ /g")" | |
fi | |
done |