Skip to content

Instantly share code, notes, and snippets.

View 0xDBFB7's full-sized avatar

Daniel Correia 0xDBFB7

View GitHub Profile
{
"extractor": {
"twitter": {
"archive": "/home/arthurdent/archive.db",
"cookies": {
"auth_token": ""
},
"syndication": true,
"logout": true,
"replies": true,
@0xDBFB7
0xDBFB7 / restic.sh
Created February 12, 2022 19:11
Script to perform restic backup on an LVM volume without it filling up
# <add spaces to keep out of bash hist> export RESTIC_PASSWORD=""
# run this command with sudo -E ./restic.sh
########
lvcreate -L 20G -s -n backup-snapshot /dev/new_root/lv0 || exit 1
mount /dev/new_root/backup-snapshot /home/arthurdent/NAS/backup-snapshot || exit 1
export B2_ACCOUNT_ID="XXXXXXXXXX"
@0xDBFB7
0xDBFB7 / gaussian_pulses.py
Created February 12, 2021 19:52
Normalized gaussian and first gaussian derivative pulses
# see http://www.cse.yorku.ca/~kosta/CompVis_Notes/fourier_transform_Gaussian.pdf
# http://www.sci.utah.edu/~gerig/CS7960-S2010/handouts/04%20Gaussian%20derivatives.pdf
def normalized_gaussian_pulse(t,fwhm):
sigma = fwhm/2.355
return exp(-((t**2.0)/(2.0*(sigma**2.0))))
def normalized_gaussian_derivative_pulse(t,fwhm):
sigma = fwhm/2.355
return (exp((1.0/2.0) - (t**2.0)/(2.0*sigma**2.0))*t)/sigma
@0xDBFB7
0xDBFB7 / gauge.py
Created October 22, 2019 23:58
Python script to control BPG400 vacuum gauges
#python3 script to decode the output from an Inficon BPG400 high vacuum gauge
#or, as I prefer to call it, the BFG
#Call like python3 gauge.py SERIALPORT h
# for human readable output, or without h for
# csv-compatible.
#yittrium oxide filament!
# 0 Length of data string 7 (Set value)
# 1 Page number 5 (For BPG400)
# 2 Status - Status byte
@0xDBFB7
0xDBFB7 / induction.py
Created October 10, 2019 05:01
A simple Laplace solver for PHYS2231
#python3 induction.py
import numpy as numpy
import math
import matplotlib.pyplot as plt
SIZE_X = 128
SIZE_Y = 256
LENGTH_SCALE = 0.01#meters/node
2019-01-10
attended
2019-01-17
attended
2019-01-31
attended
2019-02-07
attended
2019-02-28
attended
@0xDBFB7
0xDBFB7 / generate.py
Last active December 23, 2018 22:07
A little ATTiny MIDI player script
from mido import MidiFile
mid = MidiFile('onmyown1.mid')
NOTE_NUMBER = 129
NOTE_DURATION_THRESHOLD = 30
freqs = []
times = []
for i, track in enumerate(mid.tracks):
print('Track {}: {}'.format(i, track.name))
@0xDBFB7
0xDBFB7 / tapered_helix.py
Last active June 9, 2024 20:55
Tapered helix thread mill g-code generator
#Need a G-code tapered helix, like a SPTM thread milled NPT thread? This is that.
#Designed for linuxcnc, but you can just change the template G code to whatever you need.
#WARNING! Be careful with this script. Always dry run generated code.
#all dims. in mm.
import math
import numpy as np
res = 0.01 #how accurate do you want the path to be
thread_pitch = 1.81356 #pretty obvious.
thread_depth = 13.71600 #how deep do you want the hole to be threaded
@0xDBFB7
0xDBFB7 / download.py
Created September 4, 2017 18:53
MicroPython socket-only file download routine with cert pinning and hashing
#DESIGNED FOR MICROPYTHON
server_dict = [{"address": "test.com","fingerprints":[bytearray('adlfasdfekre3r2309234902302lqkejroi23ro239842342304')]}] #list of possible servers and accepted keys
def download_file(server_dir,filename,server_index=0,block_size=512): #Boneless file downloader
#typical socket stuff
s = socket.socket()
s.settimeout(60)
ai = socket.getaddrinfo(server_dict[server_index]['address'], 443) #FIXME: This will probably do a dns lookup every time - probably shouldn't.
addr = ai[0][-1]