Skip to content

Instantly share code, notes, and snippets.

View akpoff's full-sized avatar

Aaron Poffenberger akpoff

View GitHub Profile
@akpoff
akpoff / wlan_status
Created April 18, 2016 16:10
Get the nwid of the specified wlan card or the first found
#!/bin/sh
nic="$1"
function getNwid {
ifconfig $1 | grep ieee80211 | cut -d : -f 2 | rev | cut -d ' ' -f 5- | rev | cut -d ' ' -f 3- | tr -d '"'
}
if [ ${nic:-empty} = empty ]
then
@akpoff
akpoff / network
Last active April 18, 2016 16:21
Configure wlan card under OpenBSD
#!/bin/sh
if=$1
MUTEX=/tmp/network_config.$if
if [ -f $MUTEX ]
then
echo "Wireless config for $if already in progress"
exit
@akpoff
akpoff / count_hlinks.sh
Last active July 14, 2016 23:04
Count Hard Links in a Directory
@akpoff
akpoff / replace_linux_with_openbsd
Last active January 3, 2018 15:39
Replace Linux with OpenBSD
#!/bin/sh
# For folks who will type `curl $URL | bash` without considering the consequences.
# A quick way to install OpenBSD
# BTW, I haven't tested this
echo "apt-get install curl && curl -L http://ftp.openbsd.org/pub/OpenBSD/6.2/`uname -m`/install62.fs | dd of=/dev/sda && shutdown -r"
@akpoff
akpoff / elm-lang-openbsd.md
Last active May 23, 2024 00:00
Building elm-lang on OpenBSD

Building elm-lang on OpenBSD

Requirements

  • haskell-platform
  • elm-lang BuildFromSource.hs script

Overview - OpenBSD considerations

@akpoff
akpoff / dhcpd_to_unbound
Last active July 2, 2021 06:37
dhcpd_to_unbound -- add dhcpd entries as local_data to unbound
#!/bin/sh
#
# Copyright (c) 2017, 2019 Aaron Poffenberger <akp@hypernote.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
@akpoff
akpoff / curl_imap_query_commands.md
Created January 2, 2018 17:29
curl commands to query imap servers

curl commands to query imap servers

Based on https://busylog.net/telnet-imap-commands-note/

curl options

  • -k -- don't verify certificate (optional)
  • -n -- use .netrc for username and password (optional)
  • -X -- request to send to server
@akpoff
akpoff / vc-rcs.el
Created January 27, 2018 22:13
Support for OpenBSD's OpenRCS in Emacs VC
;;; vc-rcs.el --- support for RCS version-control -*- lexical-binding:t -*-
;; Copyright (C) 1992-2017 Free Software Foundation, Inc.
;; Author: FSF (see vc.el for full credits)
;; Maintainer: Andre Spiegel <spiegel@gnu.org>
;; Package: vc
;; This file is part of GNU Emacs.
@akpoff
akpoff / expire_bruteforce.sh
Last active September 2, 2018 21:54
scan_logs_bruteforce - Add bad guys to brute force table
#!/bin/sh
# Add to crontab
# @hourly sleep $((RANDOM \% 1800)) && expire_bruteforce.sh > /dev/null
result=$(pfctl -t bruteforce -T expire 86400 2>&1)
count=$(echo $result | cut -d '/' -f 1)
if [ ${count:-0} -gt 0 ] ; then
echo $result
@akpoff
akpoff / duffs_device.py
Created August 15, 2024 05:39
Duff's Device in Python
def duffs_device(frm, count):
"""
Implement Duff's Device for copying frm in a loop-unrolled fashion.
:param frm: List or array-like object to copy frm
:param count: Number of elements to copy
"""
# Ensure we have at least one element to copy
if count <= 0: