Skip to content

Instantly share code, notes, and snippets.

@m13253
m13253 / cache_sim.h
Last active Apr 4, 2022
Simple CPU L1 cache simulator to assist your operating system coursework
View cache_sim.h
/*
* This library is licensed under WTFPL version 2.
*
* May contain undiscovered bugs.
* I am willing to fix bugs but will not be responsible for them.
*
* I suggest you cross-check with another library, for example:
* https://github.com/RRZE-HPC/pycachesim
*/
@m13253
m13253 / pixart2svg.py
Last active Jul 18, 2021
Convert a pixel art into an SVG file
View pixart2svg.py
#!/usr/bin/env python3
# Convert a pixel art to SVG file
# Copyright (C) 2021 Star Brilliant
#
# 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.
#
@m13253
m13253 / csgo_address_list.py
Last active Dec 25, 2021
Generate MikroTik address list with IP addresses of CS:GO official matchmaking servers
View csgo_address_list.py
#!/usr/bin/env python3
import json
import netaddr
def main():
# Download from https://steamcdn-a.akamaihd.net/apps/sdr/network_config.json
with open('network_config.json', 'r', encoding='utf-8') as f:
network_config = json.load(f)
@m13253
m13253 / bezier-split.py
Last active Nov 23, 2020
Cubic Bézier curve splitting program
View bezier-split.py
#!/usr/bin/env python3
# Copyright (C) 2020 Star Brilliant <coder@poorlab.com>
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
import sys
@m13253
m13253 / getproxy.sh
Created Apr 10, 2020
List proxy server status on macOS
View getproxy.sh
#!/usr/bin/env bash
networksetup -listallnetworkservices | tail +2 |
while read NETWORK_SERVICE
do
echo 'Network service: '$'\e[34m'"$NETWORK_SERVICE"$'\e[0m'
networksetup -getproxyautodiscovery "$NETWORK_SERVICE" | sed 's/^/[WPAD] /'
networksetup -getautoproxyurl "$NETWORK_SERVICE" | sed 's/^/[PAC] /'
networksetup -getwebproxy "$NETWORK_SERVICE" | sed 's/^/[HTTP] /'
networksetup -getsecurewebproxy "$NETWORK_SERVICE" | sed 's/^/[HTTPS] /'
@m13253
m13253 / android-captive-portal-china-fix.sh
Created Jan 22, 2020
Change Android captive portal detection to Xiaomi's server
View android-captive-portal-china-fix.sh
adb shell settings put global captive_portal_https_url https://connect.rom.miui.com/generate_204
adb shell settings put global captive_portal_http_url http://connect.rom.miui.com/generate_204
@m13253
m13253 / mousetest.js
Created Nov 11, 2019
A mouse test program written in gjs (Gtk+ JavaScript)
View mousetest.js
#!/usr/bin/gjs
const GObject = imports.gi.GObject;
const Gdk = imports.gi.Gdk;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const MouseTest = new Lang.Class({
Name: "Mouse Test",
View transparent-x11.c
#include <X11/Xlib.h>
#include <X11/Xutil.h>
int main(int argc, char* argv[])
{
Display* display = XOpenDisplay(NULL);
XVisualInfo vinfo;
XMatchVisualInfo(display, DefaultScreen(display), 32, TrueColor, &vinfo);
@m13253
m13253 / bird-dn42-util.conf
Last active Apr 25, 2022
BIRD 2.0 utility for DN42 related operations
View bird-dn42-util.conf
# BIRD 2.0 utility for DN42 related operations
# To be used with:
# include "bird-dn42-util.conf";
# in bird.conf main configuration file.
function reset_origin (int transit; int origin)
{
bgp_path.empty;
bgp_path.prepend(origin);
bgp_path.prepend(transit);
@m13253
m13253 / init.sh
Last active Dec 2, 2021
Minimal working initramfs for BusyBox, with login
View init.sh
#!/bin/busybox sh
# 1) Download a prebuilt BusyBox binary here:
# https://busybox.net/downloads/binaries/
#
# 2) Prepare your kernel
# cp /boot/vmlinuz vmlinuz
#
# 3) Copy the files
# install -Dm0755 busybox-x86_64 initramfs/bin/busybox