Skip to content

Instantly share code, notes, and snippets.

View bioshazard's full-sized avatar
🎯
Focusing

Joe bioshazard

🎯
Focusing
View GitHub Profile
# In case you wanted to parse `smart -A ...`
smartAttributesPattern = "".join([
"\n *", # Ignore: Potential whitespace in front of ID#
"([0-9]+)", # Capture: ID# field
"[^A-Z]+", # Ignore: Whitespace before the ATTRIBUTE_NAME
"([a-zA-Z_\-]+)", # Capture: ATTRIBUTE_NAME field
"[^0-9a-fx]+", # Ignore: Whitespace before the FLAG
"([0-9a-fx]+)", # Capture: FLAG field
"[^0-9]+", # Ignore: Whitespace before the VALUE
"([0-9]+)", # Capture: VALUE field
import hug, threading, subprocess, uuid
"""
# Requires,
yum install -y rh-python36-python rh-python36-python-pip
/opt/rh/rh-python36/root/bin/pip3 install hug
# Run with,
/opt/rh/rh-python36/root/bin/hug -f straceinject.py -ho 127.0.0.1 -p 1337
"""
@bioshazard
bioshazard / readBytes.py
Created December 26, 2018 17:13
Read super large byte by byte. Useful for when logs are full of null byte or CRAZY long lines.
# Read super large byte by byte. Useful for when logs are full of null byte or CRAZY long lines.
import time, sys
def readBytes(filename, stopAt=0):
# Byte by Byte
linecnt = 0
charlist = []
with open(filename, "rb") as f:
@bioshazard
bioshazard / DoxygenConfigDrupalCallGraph.txt
Created February 19, 2019 20:30
Doxygen relies on a config file. This is how I generate a callgraph for a drupal module I was exploring. Also had to install i686 version of graphviz to get a functional Dot command.
[root@cac80a94d574 html]# diff mydoxygenconfig.original mydoxygenconfig | grep ">"
> OUTPUT_DIRECTORY = /var/www/html/doxygenout
> EXTRACT_ALL = YES
> EXTRACT_PRIVATE = YES
> EXTRACT_PACKAGE = YES
> EXTRACT_STATIC = YES
> EXTRACT_LOCAL_METHODS = YES
> FILE_PATTERNS = *.php *.inc *.module
> RECURSIVE = YES
> HAVE_DOT = YES
occuranceCount = { }
# TY http://algo.pw/algo/64/python <3
class AhoNode:
def __init__(self):
self.goto = {}
self.out = []
self.fail = None
def aho_create_forest(patterns):
# Per https://docs.docker.com/install/linux/docker-ce/centos/
# Which should just be a single copy-paste resource
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
@bioshazard
bioshazard / strace-pgrep-list.sh
Created October 8, 2019 16:32
Generate list of PIDs in a format ready for strace
#!/bin/bash
echo -p $(pgrep $1 | tr '\n' '%' | sed 's@%$@@g;s@%@ -p @g')
---
# EXAMPLE: ansible-playbook -i inventory/local-vagrant/hosts --diff reboot.yml -e reboot_hosts=utility,dev,sandbox
- hosts: "{{reboot_hosts}}"
become: yes
# Reboot one at a time to enable play failure if any don't come back
serial: 1
tasks:
- debug:
msg: "Rebooting {{inventory_hostname_short}}"

GunDB VueJS Notes

vue-gun

// Initialize gun
import Gun from 'gun'
// localStorage.clear()
var gun = new Gun(['https://mypeer.hostname:8765/gun'])
#!/bin/bash -e
# Generates a detached tmate session, perfect to debug pipelines in-line
tmate -S /tmp/tmate.sock new-session -d
tmate -S /tmp/tmate.sock wait tmate-ready
tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}'
tmate -S /tmp/tmate.sock wait-for new-session