Skip to content

Instantly share code, notes, and snippets.

View Summertime's full-sized avatar
😳
programming

Andrew C. H. McMillan Summertime

😳
programming
View GitHub Profile
#!/usr/bin/env python
import os
import ctypes
from ctypes import CDLL
import sys
import random
import string
from errno import EEXIST
# C stuff
libc = CDLL('libc.so.6', use_errno=True)
#!/usr/bin/env python
from functools import wraps
class Interpolation:
def __init__(self, getvalue):
self.getvalue = getvalue
def eager_tag(func):
@wraps(func)
def wrapper(*args):
#!/usr/bin/env python
# Novel code (of which there is almost none) is under The Unlicense
# the C# runtime code this file copies from is
# https://github.com/dotnet/runtime/blob/5535e31a712343a63f5d7d796cd874e563e5ac14/LICENSE.TXT
# The decompiled C# code this file copies parts from is owned by https://x.com/eggHatcherGame
# And is unfortunately used here without permission.
import json
import sys
import io
@Summertime
Summertime / README.md
Last active March 19, 2023 11:22
Bash Book

Bash Book

@Summertime
Summertime / processing.bash
Last active November 23, 2022 11:57
Bunch of functions to make things easier
#!/usr/bin/env bash
p () {
declare USAGE="${FUNCNAME[0]} [-h] [-0] [--] [ARGS ...]"
declare NL='\n'
declare -i OPTIND=1
while getopts h0 OPT; do
case "$OPT" in
'h')printf 'Usage: %s\n' "$USAGE";return;;
'?')printf 'Usage: %s\n' "$USAGE">&2;return 1;;
APPNAME=exchange.sh
p () { printf '%s\n' "$@";}
: "${XDG_CACHE_HOME:=$HOME/.cache}"
cachedget () {
URL=$1
CACHEDIR="$XDG_CACHE_HOME/$APPNAME/curl/GET-$(base64 -w0 <<< "$URL")"
mkdir --parents "$CACHEDIR"
curl -sS \
const filters = [
/^Running script with [0-9]+ thread\(s\), pid [0-9]+ and args/,
]
function findProp(propName) {
// stolen from talamond
for (let div of eval("document").querySelectorAll("div")) {
let propKey = Object.keys(div)[1];
if (!propKey)
continue;
@Summertime
Summertime / growloop.js
Last active December 31, 2021 16:26
bitburner scripts
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array
}
/** @param {NS} ns **/
export async function main(ns) {
let args = ns.flags([
@Summertime
Summertime / bmark.sh
Last active November 22, 2021 17:31
benchmarking HTML vs JSON
#!/usr/bin/env bash
DATADIR=$(pwd)
TEMPDIR=
trap 'cd ~;rm -fr -- "$TEMPDIR"' EXIT
TEMPDIR=$(mktemp -d)
cd -- "$TEMPDIR"
mkdir {html,json}{-compressed,-dictionary,}