Skip to content

Instantly share code, notes, and snippets.

View Snawoot's full-sized avatar

Snawoot

View GitHub Profile
@Snawoot
Snawoot / nullable.py
Last active October 9, 2019 14:39
Proxy for Python objects which allows nullable items and attributes
#!/usr/bin/env python3
from abc import ABC, abstractmethod
class NullableProxy(ABC):
@abstractmethod
def __getitem__(self, key):
""" Overloaded brackets """
@abstractmethod
[user@dt1 ~]$ ~/venvs/pyperformance/bin/pyperformance compare results/py3-slim.json results/py3-alpine.json
py3-slim.json
=============
Performance version: 0.9.1
Report on Linux-5.2.11-200.fc30.x86_64-x86_64-with-debian-10.0
Number of logical CPUs: 2
Start date: 2019-09-10 04:57:20.849603
End date: 2019-09-10 05:22:03.190521
@Snawoot
Snawoot / restart-usb-wifi.sh
Created September 4, 2019 12:10
Shell script to restart USB wifi adapter on Linux
#!/bin/sh
for device in $(ls /sys/bus/usb/devices/*/product) ; do
dir="$(dirname "$device")"
if [ "$(cat "$device")" = "802.11n NIC" ] ; then
port="$(basename "$dir")"
echo Restarting "$port"...
echo "$port" > /sys/bus/usb/drivers/usb/unbind
sleep 2
echo "$port" > /sys/bus/usb/drivers/usb/bind
import asyncio
from collections import deque
class Ratelimit:
def __init__(self, rate, loop=None):
self._loop = asyncio.get_event_loop() if loop is None else loop
self._delay = 1. / rate
self._last_released = 0
self._waiters = deque()
self._release_scheduled = False
From 3627951693d3e40b5d263ca567ef990edf7b7c2f Mon Sep 17 00:00:00 2001
From: Linn Crosetto <[email protected]>
Date: Tue, 5 Apr 2016 11:49:05 -0600
Subject: Disallow unsigned kernels if UEFI Secure Boot is enabled
If UEFI Secure Boot is enabled and kernel signature verification fails, do not
boot the kernel. Before this change, if kernel signature verification failed
then GRUB would fall back to calling ExitBootServices() and continuing the
boot.
diff --git a/postfix_mta_sts_resolver/responder.py b/postfix_mta_sts_resolver/responder.py
index 841210d..80e79b9 100644
--- a/postfix_mta_sts_resolver/responder.py
+++ b/postfix_mta_sts_resolver/responder.py
@@ -158,7 +158,7 @@ class STSSocketmapResponder(object):
async def handler(self, reader, writer):
# Construct netstring parser
- self._decoder = pynetstring.Decoder()
+ decoder = pynetstring.Decoder()
#!/usr/bin/env python3
import ctypes
import datetime
import time
import multiprocessing
import itertools
libc = ctypes.CDLL('libc.so.6')
This file has been truncated, but you can view the full file.
This file has been truncated, but you can view the full file.
@Snawoot
Snawoot / build-efitools-1.9.2.sh
Last active May 14, 2019 17:59
Builds efitools-1.9.2 on Fedora 30. Run it in source directory.
#!/bin/sh
make CRTOBJ=crt0-efi-x64.o \
LDSCRIPT=elf_x64_efi.lds \
LDFLAGS='-nostdlib -L /usr/lib64/gnuefi -shared -Bsymbolic $(CRTOBJS) -L $(CRTPATH) -L /usr/lib -L /usr/lib64 -L /usr/lib/gnuefi -L /usr/lib64/gnuefi -T $(LDSCRIPT)' \
INCDIR='-I$(TOPDIR)include -I/usr/include/efi -I/usr/include/efi/x64 -I/usr/include/efi/protocol' && \
sudo make install