Skip to content

Instantly share code, notes, and snippets.

View av1d's full-sized avatar
🎯
Focusing

av1d

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am av1d on github.
  • I am av1d (https://keybase.io/av1d) on keybase.
  • I have a public key ASCnM9ZPwTsyGyTjuBVj74sZ6mATlP4zCQjwsyZ3cjRFnAo

To claim this, I am signing this object:

@av1d
av1d / rtclite_sip_caller.py
Last active July 9, 2021 19:13
Quickstart guide for RTClite SIP Caller. Setup, settings, how-to. Place VoIP/SIP calls from Python. Includes example template.
# -*- coding: utf-8 -*-
from rtclite.app.sip.caller import Caller, default_options
from rtclite.std.ietf.rfc2396 import Address, URI
from rtclite.std.ietf import rfc4566
rfc4566.lineending = '\n'
import logging
logging.basicConfig(level=logging.INFO)
@av1d
av1d / typed_chars.py
Last active July 19, 2021 06:34
Update a list/buffer of typed characters on one line. Shift the list to the left one space when list exceeds desired length. Polls keyboard for input then updates display. Useful for CLI or other interfaces.
import os
import tty
import sys
import termios
# live typed-character buffer
# https://github.com/av1d
the_list = ["1", "2", "3", "4", "5"]
@av1d
av1d / json_config.py
Created August 1, 2021 05:25
Simple way to save and load lists using JSON module. Use for saving configuration settings, etc. which don't need to be edited by the user.
import json
one = "Hello"
two = 7136942066631337
three = "//#$%^&*((*&^\\"
d = [str(one), str(two), str(three)]
with open("config.json", 'w') as f:
@av1d
av1d / random_hash.py
Created August 1, 2021 05:31
Generate a random alphanumeric hash, 8 characters in length
import random
hash1 = random.getrandbits(128) #
hash2 = "%032x" % hash1 # format
hash3 = hash2[:8] # trim to 8 char
print(hash3)
@av1d
av1d / trim_list.py
Created August 1, 2021 05:33
Remove all items in a list before/up to a specific string
dataset = ['0','3','03','vm','00','a','7']
print("Unedited list: " + str(dataset))
vm_index = dataset.index("vm")
for number in range(len(dataset)):
dataset.pop(0)
if dataset[0] == "vm":
break
@av1d
av1d / sudo_rm.py
Last active August 12, 2021 16:26
Warn user when they issue sudo rm -rf, passes all other sudo commands otherwise
#!/usr/bin/env python
import os
import sys
# Warns user before issuing deadly commands with sudo.
#
# add alias to ~/.bashrc like so:
# alias sudo="/home/users/sudo_rm.py"
# then reload bashrc:
@av1d
av1d / generate_pins.sh
Created August 15, 2021 17:55
Generate voicemail PINs
#!/bin/bash
read -p " Starting number? " startnum_int
read -p " Ending number? " endnum_int
read -p " Randomize (y/n)? " randomize_bool
read -p " Pad digits (y/n)? " paddigits_bool
if [[ "$paddigits_bool" == "y" ]]
then
read -p "PIN length for padding? " pinlength_int
else
@av1d
av1d / extensions.conf
Last active August 20, 2021 19:29
Control FCEUX NES emulator via VoIP or landline/DTMF phone using Asterisk PBX
; requires FCEUX and xdotool. Map keys in FCEUX according to the letters below.
; Start - d, up - i, left - j, right -k, down - m, B - b, A - a
[NESTERIX]
exten => s,1,Answer(500)
same => n(loop),Background(press)
same => n,WaitExten()
exten => 0,1,NoOp("Dialed 0 - Pressed START on NES")
@av1d
av1d / IMA2IMG.sh
Created January 7, 2022 22:10
Convert IMA floppy disk image to IMG disk image
#!/bin/bash
# Use at your own risk.
# chmod +x IMA2IMG.sh before using.
echo -e "IMA2IMG by av1d"
echo -e "Convert IMA floppy disk image to IMG disk image\n"
echo -e "Also mounts the IMA file in /mnt/floppyIMAdisk for usage"
echo -e "https://gist.github.com/av1d/e27e72795507e1bd29d92172d76e56f5"