Skip to content

Instantly share code, notes, and snippets.

@neilzheng
neilzheng / OVERLAYFS
Created October 14, 2017 08:10 — forked from mutability/OVERLAYFS
readonly root via overlayfs
- install the two shellscripts into the appropriate places under /etc/initramfs-tools
- run update-initramfs
- put "overlay=yes" on the kernel command line
- reboot
With the overlay in place, the real root is mounted readonly on /ro.
Only the root fs is changed, other filesystems are mounted normally.
Remove "overlay=yes" (or change it to something other than yes) and reboot to go back to readwrite.
(This probably means that you want the commandline config to live somewhere other than on the root fs, e.g. under /boot)
@neilzheng
neilzheng / server.py
Created October 21, 2017 00:30 — forked from scturtle/server.py
python socks5 proxy server with asyncio (async/await)
#!/usr/bin/env python3.5
import socket
import asyncio
from struct import pack, unpack
class Client(asyncio.Protocol):
def connection_made(self, transport):
self.transport = transport
self.server_transport = None
#!/usr/bin/env python
import sys
import asyncio
import websockets
class Server:
def __init__(self, ws_uri, ssl_verify=True, loop=None, **wskwargs):
#!/usr/bin/env python
import sys
import asyncio
import websockets
class Server:
def __init__(self, host, port, loop=None, **kwargs):
# -*-: coding: utf-8 -*-
import asyncio
import aiohttp
import traceback
import datetime
import math
def hsize(s):
suffixs = ["B", "KB", "MB", "GB"]
# -*-: coding: utf-8 -*-
import asyncio
import aiohttp
import traceback
import datetime
import math
def hsize(s):
suffixs = ["B", "KB", "MB", "GB"]
# -*- coding: utf-8 -*-
import glob
def parse_block(f, info):
block = {}
line = f.readline().strip()
if not line:
return None
#!/usr/bin/env python
import sys
import asyncio
from aiohttp import web
class Server:
def __init__(self, host, port, loop=None, **kwargs):
#!/usr/bin/env python
import sys
import asyncio
import aiohttp
class Server:
def __init__(self, ws_uri, loop=None, **wskwargs):
@neilzheng
neilzheng / ttc2ttf.py
Created May 2, 2018 04:37 — forked from johnko/ttc2ttf.py
ttc2ttf
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#First released as C++ program by Hiroyuki Tsutsumi as part of the free software suite “Beer”
#I thought porting it to Python could be both a challenge and useful
from sys import argv, exit, getsizeof
from struct import pack_into, unpack_from
def ceil4(n):