Skip to content

Instantly share code, notes, and snippets.

@peisenhower
peisenhower / nexus backup
Last active August 20, 2018 19:36
Script to backup nexus server, programatically re-index and offload backup to s3 bucket
@ECHO ON
SET OUT_PATH=C:\nexus-backup\nexus_backup_%date:~4,2%%date:~7,2%%date:~10,4%.zip
SET NEXUS_BACKUP="C:\Program Files (x86)\Altium\Altium NEXUS Server\Tools\BackupTool\avbackup.exe"
@rem Backing up nexus server
%NEXUS_BACKUP% backup -z %OUT_PATH%
@peisenhower
peisenhower / aws-dynamo-batch-delete.js
Created July 16, 2018 13:00
AWS script for batch deleting data out of dynamodb using dynamoose
#!/usr/bin/env node
const dynamoose = require('dynamoose');
dynamoose.setDefaults({create: false });
let schema = new dynamoose.Schema({
key: {
type: String,
required: true,
@peisenhower
peisenhower / serial-port.sh
Created July 13, 2018 13:22
wrapper for py-serials miniterm for logging serial ports and quick opening. Must make folder on path ~/Documents/serial-logs for logging to work. Add snippet to .bashrc
alias ports='python -m serial.tools.list_ports'
goofy() {
local logfile=~/Documents/serial-logs/two3-$1-$(date '+%F-%H:%M').log
echo "Logging $1@115200 to $logfile"
python -m serial.tools.miniterm $1 57600 -e --raw | tee $logfile
}
serial() {
local logfile=~/Documents/serial-logs/$1-$(date '+%F-%H:%M').log
@peisenhower
peisenhower / mysql-harmless.sql
Created August 31, 2017 19:22
mysql transaction and rollback to test database modifications
BEGIN;
INSERT INTO teams
(name, uuid)
VALUES
('inner-transaction', UNHEX(REPLACE(UUID(), '-','')));
select * from teams;
@peisenhower
peisenhower / windows-setup.bat
Last active October 22, 2018 21:36
windows setup
:: power shell only
:: chocolatey
Set-ExecutionPolicy AllSigned; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
:: scoop
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
@peisenhower
peisenhower / ubuntu-setup.sh
Last active November 9, 2017 19:24
ubuntu quick start script installing applications for fresh install
#!/usr/bin/env bash
EMAIL='[email protected]'
NAME='full name'
sudo apt install curl git
# Sublime
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
@peisenhower
peisenhower / remove-merge.sh
Created June 27, 2017 12:56
remove merged branches
git branch --merged | egrep -v "(^\*|master|development)" | xargs git branch -d
@peisenhower
peisenhower / motor.py
Created May 30, 2017 21:25
motor commands over serial
#!/usr/bin/env python
# python 3
from serial import Serial
import time
import argparse
from threading import Thread
class Command():
@peisenhower
peisenhower / quick-filter.js
Created May 30, 2017 20:27
node quick filter, run in node REPL
const fs = require('fs');
/* Load sample data */
sample = require('./junk.sample.json');
/* filter data down */
filtered = sample.filter((x) => x.color == 'blue' && x.gain == 'high');
/* save data to file */
fs.appendFile('output', JSON.stringify(filtered));
@peisenhower
peisenhower / cyclical.h
Created May 19, 2017 19:10
cyclical structure definition in c header
struct external_interrupt_s;
typedef void (*external_callback_func)(struct external_interrupt_s *interrupt, GPIO_PinState state);
typedef struct external_interrupt_s
{
GPIO_TypeDef *port;
uint32_t pin;
external_callback_func callback;