Skip to content

Instantly share code, notes, and snippets.

View thwarted's full-sized avatar
🥓
increasingly at large

Andy Bakun thwarted

🥓
increasingly at large
View GitHub Profile
@thwarted
thwarted / FOR_EACH.cmacros.h
Created September 17, 2014 00:17
a FOR_EACH C Preprocessor macro that works under both GNU CC and Visual Studio 2013/MSVC
/* all this verbosity is required for this to work reliably and predictably
* on both GCC and MSVC
*/
/* because gcc cpp doesn't recursively expand macros, so a single CALLIT
* macro can't be used in all the FE_n macros below
*/
#define FE_CALLITn01(a,b) a b
#define FE_CALLITn02(a,b) a b
@thwarted
thwarted / sshpub-to-rsa
Created June 14, 2011 09:12
converts an openssh RSA public key into a format usable by openssl rsautl (if you don't have openssh 5.6 or later with ssh-keygen PEM export format)
#!/usr/bin/env python
# with help and inspiration from
# * ASN1_generate_nconf(3) (specifically the SubjectPublicKeyInfo structure)
# * http://www.sysmic.org/dotclear/index.php?post/2010/03/24/Convert-keys-betweens-GnuPG%2C-OpenSsh-and-OpenSSL
# * http://blog.oddbit.com/2011/05/converting-openssh-public-keys.html
import sys
import base64
import struct
@thwarted
thwarted / plugins--Scout--config.py
Created March 25, 2013 22:59
Stupid and simple supybot plugin that does LDAP/AD lookups and returns phone and pager contact information. From Yelp! Hack-a-thon X, going for the "Useful" award.
###
# Copyright (c) 2013, Andy Bakun and Yelp!
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions, and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
@thwarted
thwarted / resize-java-iKVM-viewer
Last active September 15, 2022 08:59
resize-java-iKVM-viewer: find all supermicro Java iKVM Viewer windows and resize them to display all the content
#!/bin/bash
# find all supermicro Java iKVM Viewer windows and resize
# them to display all the content
#
# for reasons that are beyond sanity, this shitty closed source program
# sets the min and max window sizes to the same values, making it unresizable
# through dragging.
# this wouldn't be so bad if it actually resized the window to display all
# the content. it constantly resizes based on the resolution of the
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist>
<array>
<dict>
<key>AudioList</key>
<array>
<dict>
<key>AudioBitrate</key>
<string>320</string>
@thwarted
thwarted / libsyslogtostderr.c
Created December 17, 2012 08:53
lame attempt at redirecting syslog to stderr with LD_PRELOAD
#include <stdlib.h>
#include <stdarg.h>
void openlog(const char *ident, int option, int facility) {
return;
}
void syslog(int priority, const char *format, ...) {
va_list va;
va_start(va, format);
@thwarted
thwarted / tmux-keep-ssh-agent-socket.sh
Last active June 10, 2022 22:31
the shell function tmx will start a new, persistent (meaning you can be connected to it multiple times at the same time), with the ssh-agent connection available even if you get disconnected and reconnect
#!/bin/bash
# source this file in the shell
#
# the shell function tmx will start a new, persistent (meaning you can be
# connected to it multiple times at the same time), with the ssh-agent
# connection available even if you get disconnected and reconnect
#
# start or connect to an instance named "default"
# tmx
@thwarted
thwarted / pipe-to-dgram
Created November 19, 2014 05:38
pipe-to-dgram
#!/bin/bash
exec 3> >( while /bin/true ; do socat -t0 -T0 -u STDIN UDP:172.28.128.3:8888 ; done )
while /bin/true; do
while read line; do
echo "$line"
echo "$line" >&3
sleep 0.1
done < /vagrant/testlog
done
@thwarted
thwarted / bash-multiassign.sh
Last active June 10, 2022 22:31
defines a function `assign` that allows returning multiple values from a function/command
#!/bin/bash
# assign var1 varN... = c arg...
# execute c and assign captured values to the list of variables
#
# values can be output from c by redirecting/writing to:
# >${outvar[x]}
# >&x
# where x is the index of the variable you want to return the value
# in
@thwarted
thwarted / invoke.sh
Created December 25, 2015 22:52
some simple scripts to invoke steam as a separate user for non-robust filesystem isolation
#!/bin/bash -x
if [[ -z "$XTXAUTH" ]]; then
echo "XTXAUTH not set, was this invoked correctly?"
exit 1
fi
unset XAUTHORITY
server=$( echo "$XTXAUTH" | awk '{ print $1 }' )
xauth add $XTXAUTH