Skip to content

Instantly share code, notes, and snippets.

View sciguy16's full-sized avatar

David Young sciguy16

View GitHub Profile
@sciguy16
sciguy16 / dns-cleanup.sh
Created June 21, 2020 15:28
Certbot hooks to update a Windows DNS server
#!/bin/bash
# dns-cleanup.sh
# certbot hook to use nsupdate to send the validation to an Active Directory DNS server
nsupdate -g << EOF
update delete _acme-challenge.$CERTBOT_DOMAIN TXT
send
EOF
#include <stdio.h>
#include <stdbool.h>
#include "image.h"
void finished(wkhtmltoimage_converter * converter, int p) {
printf("Finished: %d\n", p);
}
void progress_changed(wkhtmltoimage_converter * converter, int p) {
printf("%3d\n", p);
@sciguy16
sciguy16 / solve-critters.py
Created March 20, 2018 00:19
Python script to solve the Critters challenge from InterACE 2018. It takes in a state and writes an X-PixMap image file for each step of the evolution. Written in under ten minutes right at the end of the competition.
#!/usr/bin/python3
# solve-critters.py
grid = ["bbbbbbbbbbbbbbbbbbbboobboobboobboobboobboobbbbbbbbbbbbbbbbbbbbbb",
"bbbbbbbbbbbbbbbbbobbbbbbbbbbbbbbbbbbbbbbbbbbobbbbbbbbbbbbbbbbbbb",
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
"bbbbbbbbbbbbbbbbbobbbbbbbbbbbbbbbbbbbbbbbbbbobbbbbbbbbbbbbbbbbbb",
"bbbbbbbbbbbbboboboobbbbbbbbbbobbobbbbbbbbbboobobobbbbbbbbbbbbbbb",
"bbbbbbbbbbbbbbbboobbbbbbbbbbbbbbbbbbbbbbbbbboobbbbbbbbbbbbbbbbbb",
@sciguy16
sciguy16 / router-install.sh
Created January 15, 2018 21:27
Script for automatically configuring a SmartOS zone as a router. See writeup mentioned at the top of the script.
#!/bin/bash
# SEE WRITEUP AT https://davi.dyoung.tech/index.php/posts/configuring-smartos-as-a-router-with-ospf-and-dhcp
echo "This is the mega router installer script. Yay!"
# find out whether we're a one-nic router or a two-nic router
read -p "How many nics do we have? [1/2] " nicn
case $nicn in
1)
@sciguy16
sciguy16 / dnsupdate.sh
Created January 6, 2018 21:03
script to update records on a powerdns server when called by isc-dhcpd
#!/bin/bash
# arguments are type, address, hardware, name
LOGFILE=/tmp/dns.log
SUFFIX=".clients.example.com."
APIKEY="SUPERsecretAPIkey"
APIPORT=8081
APIADDRESS="10.0.0.1"
@sciguy16
sciguy16 / find-https-debian-archives.py
Last active September 20, 2017 10:41 — forked from eighthave/find-https-debian-archives.py
Script to find official Debian mirrors that support HTTPS
#!/usr/bin/python
import urllib2
import re
import ssl
import sys
# # find generic mirrors
mirrors = urllib2.urlopen('http://www.debian.org/mirror/list')
https = []
@sciguy16
sciguy16 / puzzle.py
Created July 3, 2017 17:06
python script to exhaustively search for partitions of "123456789" and their negatives that sum to 100
#!/usr/bin/python
import itertools
def pairwise_combine(array):
for i in xrange(len(array)-1):
arr = array[:i] + [''.join(array[i:i+2])] + array[i+2:]
yield arr
array = [j for j in "123456789"]
@sciguy16
sciguy16 / convertlisting.py
Created June 26, 2017 13:53
Converts the output of ethereum-decompile into an lstlisting
#!/usr/bin/python
# Utility for converting the output of ethereum-decompile into a nice
# lstlisting format. Requires the following code somewhere before it:
# \let\othelstnumber=\thelstnumber
# \def\createlinenumber#1#2{
# \edef\thelstnumber{%
# \unexpanded{%
# \ifnum#1=\value{lstnumber}\relax
# #2%
@sciguy16
sciguy16 / edit.sh
Last active June 16, 2017 14:58
Bash script for opening latex source files from a directory
#!/bin/bash
# Sections should each have a ${section}.tex in . and a ${section} directory
# containing their subsections and other content.
function openall {
if [[ -f "$1.tex" ]] ; then
OPT="$1.tex"
else
OPT=""
@sciguy16
sciguy16 / etherconv.jl
Last active March 8, 2017 16:07
Julia program for converting values between wei, shannon, szabo, finney and ether. Written for Julia 0.6
multipliers = Dict("w" => 1, # wei
"sh" => 1000000000, # shannon
"z" => 1000000000000, # szabo
"f" => 1000000000000000, # finney
"t" => 1000000000000000000) # eth
# smallest substrings to search for that uniquely identify
function UnitToWei(st)
pos = search(st,' ') # get index of space
if pos == 0 # we are already in wei