Skip to content

Instantly share code, notes, and snippets.

View dsh0005's full-sized avatar
🆕

dsh0005

🆕
View GitHub Profile
@dsh0005
dsh0005 / addmintty.sh
Created March 29, 2022 18:58
Add terminfo definitions for mintty
#!/bin/sh
wget https://invisible-island.net/datafiles/current/terminfo.src.gz
gunzip -k terminfo.src.gz
# https://invisible-island.net/ncurses/ncurses.faq.html#big_terminfo
tic -s -1 -I -e'mintty, mintty-direct, mintty+common,
xterm+256color, kitty+setal, xterm+direct, ansi+rep,
ecma+strikeout, ecma+index, vt420+lrmm, xterm+sm+1006,
xterm+pcfkeys, xterm+tmux, ecma+italics, xterm-basic,
@dsh0005
dsh0005 / ccl.py
Last active May 18, 2022 22:02
COVID-19 Community Level Query Tool
#!/usr/bin/env python3
# encoding=utf-8
# vim: set nobomb :
from enum import IntEnum, unique
from dataclasses import dataclass, field
from typing import Optional, Tuple
from datetime import datetime, timedelta
import json
from argparse import ArgumentParser
@dsh0005
dsh0005 / pcscd
Created October 9, 2021 00:04
Custom pcscd rc file to enforce memory limits
#!/bin/sh
# PROVIDE: pcscd
# REQUIRE: LOGIN
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# pcscd_enable="YES"
. /etc/rc.subr
@dsh0005
dsh0005 / mmap_high.c
Created June 22, 2021 20:38
Allocate high addresses with mmap
#include <stdio.h>
#include <stdint.h>
#include <sys/mman.h>
int main(void){
void * const hint = (void*)~(uintptr_t)0;
const void * const reserved = mmap(hint, 1, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
printf("hint:%p\nreserved: %p\n", hint, reserved);
}
@dsh0005
dsh0005 / ouroboros.cpp
Created June 14, 2021 19:05
C++ vector ouroboros
#include <vector>
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>
int main(int argc, char **argv){
(void)argc;
(void)argv;
@dsh0005
dsh0005 / cmovtemplate.cxx
Last active August 26, 2021 16:41
CMOV cache side channel mitigation test
#include <stddef.h>
#include <stdint.h>
#include <array>
#ifdef __clang__
#define decAndCMOVmem(ctr, dst, src) \
__asm__( \
"dec\t%[count]\n\t" \
"cmovz\t{%[from], %[to]|%[to], %[from]}" \
: [to] "+r" (dst), [count] "+r" (ctr)\
@dsh0005
dsh0005 / ddns-route53
Last active June 27, 2020 16:24
ddns-route53 OpenRC init script
#!/sbin/openrc-run
command="/usr/local/bin/ddns-route53"
description="Route53 Dynamic DNS daemon"
cfgfile="/etc/ddns-route53/ddns-route53.yml"
schedule='\*/15\ \*\ \*\ \*\ \*'
command_args="--config \"${cfgfile}\" --schedule ${schedule}"
command_user="ddnsr53u:ddnsr53"
command_background=true
pidfile="/run/${RC_SVCNAME}.pid"
@dsh0005
dsh0005 / tktest.py
Last active March 31, 2023 12:39
Tkinter background threading example
#!/usr/bin/env python3
# encoding=utf-8
# vim: set nobomb:
from tkinter import *
from threading import Thread, Lock, Event
from queue import SimpleQueue
from time import sleep
from typing import List
import random
@dsh0005
dsh0005 / bitting.py
Last active December 29, 2019 00:59
Python bitting generator
#!/usr/bin/env python3
# encoding=utf-8
# vim: set nobomb:
from random import SystemRandom
from typing import List, Optional
def bitting(codes: int, macs: int, length: int, progress: Optional[List[int]]=None) -> List[int]:
if 0 == length:
@dsh0005
dsh0005 / boustrophedon.py
Last active February 21, 2019 19:21
Boustrophedonic python itertool
#!/usr/bin/env python3
# encoding=utf-8
# vim: set nobomb:
from itertools import chain, cycle, repeat
from typing import Iterable, Iterator, Reversible, TypeVar
T = TypeVar('T')