Skip to content

Instantly share code, notes, and snippets.

View u8sand's full-sized avatar

Daniel J. B. Clarke u8sand

View GitHub Profile
@u8sand
u8sand / update-repo.sh
Last active January 20, 2017 03:35
Maintain an updated custom archlinux user repository of local packages (e.g. AUR)
#!/bin/bash
name=sandrepo
remote=sand-pi:/home/sandrepo/http
repo="$name.db.tar.gz"
pkgext=.pkg.tar.xz
blacklist=/home/u8sand/Programs/Utils/blacklist
function update {
cd "$1"
for p in $(pacman -Qqm | grep -vf "$blacklist"); do
@u8sand
u8sand / packages.both
Last active August 25, 2016 14:27
Packages for my custom archlive iso
alsa-firmware
arch-install-scripts
atom
b43-fwcutter
baka-mplayer
base-devel
btrfs-progs
cdrkit
clamav
clonezilla
@u8sand
u8sand / backup.sh
Last active March 5, 2022 23:36
My ArchLinux system backup script; pacman tricks for system files, whitelisting for everything else. Paired with git for config git-lfs for files.
#!/bin/bash
wd=$(pwd)
#remote=root@host
run() {
local ret
if [ $remote ]; then
ssh $remote "$@" >&1;
else
@u8sand
u8sand / masquerade_as_mac.sh
Created April 2, 2016 02:36
El-Capitan Mac OS X VM Oracle Virtualbox configuration
#!/bin/bash
vm="OSX"
VBoxManage modifyvm $vm --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata $vm "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata $vm "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata $vm "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Mac-F2238BAE"
VBoxManage setextradata $vm "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata $vm "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
@u8sand
u8sand / draw.py
Last active August 25, 2016 14:28
python matplotlib wrapper object for inline usage
'''
Draw module does everything through the draw function.
Usage:
from framework.draw import draw
# anything you would have put in different places for matplotlib
# one line
draw(title='Exponential', xlabel='t', ylabel='$e^t$',
kind='plot', y=np.exp(range(10)))
# multiline
@u8sand
u8sand / ipython_startup.py
Last active August 25, 2016 14:24
My ipython startup profile
#!/bin/python
# 00-imports.py
import os
import re
import json
import numpy as np
import pandas as pd
import scipy as sp
from matplotlib import pyplot as plt
@u8sand
u8sand / scp2csv.py
Created April 4, 2016 16:01
Simple conversion from Multisim Oscilloscope output file (scp) to csv
#!/bin/python
import sys
for i in sys.stdin:
if i.find('--------------------------------------------') != -1:
break
for l in sys.stdin:
print(','.join(l.split()))
@u8sand
u8sand / test_util.py
Last active February 2, 2018 13:59
Allows dict access via path list (e.g. path_set(d, [1,2,3], 5) == d[1][2][3]=5)
from util import *
from unittest import TestCase
class TestUtil(TestCase):
def test_path_set(self):
self.assertEquals(
path_set({}, 'a', 'b'),
{'a': 'b'},
'Basic create')
self.assertEquals(
@u8sand
u8sand / fs.sh
Created August 17, 2016 00:26
Create a big raw file that can be treated as a disk
fs=ext4
function create {
fallocate -L $1 "$fs"
mount
dev=$(cat "$fs.lock")
mkfs -t ext4 $dev
fsck -t ext4 $dev
umount
}
@u8sand
u8sand / start_notebook.sh
Created August 25, 2016 14:51
Remote iPython Notebook Configuration + Script
#!/bin/bash
conf=config.py
cert=mycert.pem
port=9999
if [ ! -f $conf ]; then
if [ ! -f $cert ]; then
openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout "$cert" -out "$cert"
fi