Skip to content

Instantly share code, notes, and snippets.

View lattera's full-sized avatar

Shawn Webb lattera

View GitHub Profile
@lattera
lattera / flate.c
Created August 25, 2014 19:41
[de/in]flate stream
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <zlib.h>
#include <sys/mman.h>
@lattera
lattera / re0_up.zsh
Created February 10, 2015 05:55
Script to bring re0 up on my laptop
#!/usr/local/bin/zsh
runit="true"
while [ ${runit} = "true" ]; do
ps wwaux | grep dhclient | grep -q re0
if [ ${?} -eq 0 ]; then
breakout="false"
while [ ${breakout} = "false" ]; do
breakout="true"
@lattera
lattera / iwm.zsh
Last active August 29, 2015 14:22
#!/usr/local/bin/zsh
firmware="iwm3160fw"
driver="if_iwm"
wlandev="wlan0"
ifdev="iwm0"
ipv6="yes"
if [ ${UID} -gt 0 ]; then
echo "Run this as root, you idiot. Run ALL THE THINGS as root and you'll be perfectly safe."
@lattera
lattera / portsbuild.log
Created June 2, 2015 02:16
2015-06-01 OPNSense ports build log
ARCH=amd64
CDROM=/tmp/images/OPNsense-201506012201_OpenSSL-cdrom-amd64.iso
CONFIG_PKG=/usr/local/etc/pkg/repos/OPNsense.conf
CONFIG_XML=/usr/local/etc/config.xml
COREDIR=/usr/core
CPUS=8
HOME=/root
IMAGESDIR=/tmp/images
LABEL=OPNsense
LC_CTYPE=
@lattera
lattera / pkgmount.zsh
Created June 26, 2015 08:31
Package mount
#!/usr/local/bin/zsh
repo=""
thing=""
usage() {
cat<<EOF
USAGE: ${0} -r <repo> -t <syncdir>
-r <repo>: repository (eg, /pkg/hardenedbsd-11-current-amd64)
-t <syncdir>: sync directory (eg, sync1)
#!/usr/local/bin/zsh
amt="${1}"
if [ -z "${amt}" ]; then
echo "USAGE: ${0} [+-]amt"
exit 1
fi
mixer vol ${amt}
laptop-dev-01[shawn]:/home/shawn/tmp $ cat dlopen.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <dlfcn.h>
int main(int argc, char *argv[])
{
@lattera
lattera / exportvms.zsh
Created August 27, 2015 15:46
Mass export VirtualBox VMs
#!/bin/zsh
set -e
vms=("Jenkins" "GitLab" "Test VM")
date=$(date '+%F')
if [ ! -d ${date} ]; then
mkdir -p exports/${date}
fi
#!/usr/local/bin/zsh
echo '{ "version": 1 }'
echo '['
echo '[]'
while true; do
cat <<EOF
,[
{
"name": "battery",
root@:~ # ps wwaux | grep sshd
root 55516 0.0 0.0 12664 1804 - Is 17:27 0:00.07 /usr/sbin/sshd
root 90018 0.0 0.1 6488 2284 0 S+ 17:28 0:00.15 grep sshd
root@:~ # procstat -v 55516
PID START END PRT RES PRES REF SHD FLAG TP PATH
55516 0x15d820000 0x15d867000 r-x 71 78 2 1 CN-- vn /usr/sbin/sshd
55516 0x15d877000 0x15d879000 rw- 2 0 1 0 C--- vn /usr/sbin/sshd
55516 0x15d879000 0x15d881000 rw- 8 8 1 0 C--- df
55516 0x1f0a0c000 0x1f0a24000 r-x 24 27 12 0 CN-- vn /libexec/ld-elf.so.1
55516 0x1f0a24000 0x1f0a2c000 rw- 8 8 1 0 C--- df