This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re, re_h_mod | |
p1=re.compile(r'test\s+stuff') | |
p2=re.compile(r'test\h+stuff') | |
print('p1', p1) | |
print('\t', p1.match('test \t stuff')) | |
print('\t', p1.match('test \n stuff')) | |
print() | |
print('p2', p2) | |
print('\t', p2.match('test \t stuff')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sre_parse | |
h_rep, = sre_parse.parse(r'[^\S\n\v\f\r\u2028\u2029]') | |
def sre_parse_escape(source, escape, state): | |
if escape == r'\h': | |
return h_rep | |
else: | |
return original_sre_parse_escape(source, escape, state) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import colorsys, sys | |
def bold(text): | |
return f'\x1b[1m{text}\x1b[21m' | |
def italics(text): | |
return f'\x1b[3m{text}\x1b[23m' | |
class color: | |
black = lambda text: f'\x1b[30m{text}\x1b[38m' | |
red = lambda text: f'\x1b[31m{text}\x1b[38m' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ansi_standalone, sys | |
ansi_standalone.install_colored_stdout_retabulator() | |
def F2(): | |
with sys.stdout.indented: | |
print('This is F2') | |
print('We had two lines to say today') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void uart_send_data(volatile void* data, int length) { | |
dma_channel_reset(DMA1, DMA_CHANNEL4); | |
dma_set_peripheral_address(DMA1, DMA_CHANNEL4, (uint32_t) &USART1_DR); | |
dma_set_memory_address(DMA1, DMA_CHANNEL4, (uint32_t) data); | |
dma_set_number_of_data(DMA1, DMA_CHANNEL4, length); | |
dma_set_read_from_memory(DMA1, DMA_CHANNEL4); | |
dma_enable_memory_increment_mode(DMA1, DMA_CHANNEL4); | |
dma_set_peripheral_size(DMA1, DMA_CHANNEL4, DMA_CCR_PSIZE_8BIT); | |
dma_set_memory_size(DMA1, DMA_CHANNEL4, DMA_CCR_MSIZE_8BIT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from socket import * | |
import struct | |
#Open a file (opens itself now) | |
this_script = open(__file__, 'r') | |
#List of file descriptors to send | |
fd_list = [this_script.fileno()] | |
#Prepare ancillary data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AUTO_DELETE = False #Change this to True to delete the socket before usage in case it was never cleaned up for some reason | |
import socketserver, os, struct | |
from socket import * | |
class my_handler(socketserver.StreamRequestHandler): | |
def handle(self): | |
print('New request!', self.request) | |
while True: | |
msg, ancdata, flags, addr = self.request.recvmsg(1024, 1024) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess, base64, sys, time, struct, zlib | |
debug = False | |
#added stuff from https://android.googlesource.com/platform/system/bt/+/master/tools/scripts/btsnooz.py | |
def get_snoop(): | |
p = subprocess.Popen(('adb', 'shell', 'dumpsys', 'bluetooth_manager'), stdout=subprocess.PIPE) | |
stdout, stderr = p.communicate() | |
extract = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/sys/bus/acpi/drivers/battery/PNP0C0A:00/power_supply/BAT0 | |
#See https://i.imgur.com/yuVyiW7.png for picture of the böp this controls | |
import sys, serial, time | |
min_voltage = 3.5 | |
max_voltage = 3.8 | |
interval = 300 #Every 5 minutes | |
def read_num(filename): | |
with open(filename, 'r') as infile: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
lib = ctypes.CDLL('libblkid.so') | |
lib.blkid_new_probe_from_filename.argtypes = (ctypes.c_char_p,) | |
lib.blkid_new_probe_from_filename.restype = ctypes.c_void_p | |
lib.blkid_free_probe.argtypes = (ctypes.c_void_p,) | |
lib.blkid_do_probe.argtypes = (ctypes.c_void_p,) |