Skip to content

Instantly share code, notes, and snippets.

Andy Bakun thwarted

Block or report user

Report or block thwarted

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
thwarted / qbselect.go
Created Mar 2, 2017
an experimental query builder that might make it easier to create safe SQL using prepared statements w/ support for variable length IN expressions
View qbselect.go
package qb
import (
func placeHolders(howmany int) (s string) {
s = "?"
for ; howmany > 1; howmany-- {
s += ",?"
thwarted /
Created Dec 25, 2015
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
server=$( echo "$XTXAUTH" | awk '{ print $1 }' )
xauth add $XTXAUTH
thwarted /
Last active Aug 27, 2015
defines a function `assign` that allows returning multiple values from a function/command
# 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 /
Created Aug 3, 2015
test case for "An error occured on select: 4" in typhoeus/ethon; start httppause and then run makerequest.rb
if [[ "$NESTED" ]]; then
IFS=$( echo -e '\r' )
while read line; do
[[ -z "$line" ]] && break
sleep 10
thwarted / zipcode.go
Created Feb 3, 2015
example of matching a format and returning an error in go from JSON parsing
View zipcode.go
type ZipP4 string
func (z *ZipP4) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, *z)), nil
func (z *ZipP4) UnmarshalJSON(b []byte) (err error) {
if z == nil {
return errors.New("ZipP4: UnmarshalJSON on nil pointer")

Mostly gleaned from the instructions at to setup the initiator.

Overview of the steps:

server1 is serving the targets and has IP desktop1 is initiator. Both machines are in the subnet.

  • installed netbsd-iscsi (yum install netbsd-iscsi in my case for Centos 6.5)
  • updated the netmask in /etc/iscsi/targets to be
  • created the empty file that would be the backing store for the target with dd if=/dev/zero of=/tmp/iscsi-target0 bs=1024 count=100000 (this matches what's in the sample config in /etc/iscsi/targets)
thwarted / portserve
Created Nov 19, 2014
portserve - simple script used to test haproxy healthcheck settings
View portserve
if [[ "$2" ]]; then
msg="serving port $1"
size=$( echo "$msg" | wc -c )
read request
while /bin/true; do
read x
if [[ "$x" == "" ]]; then
View pipe-to-dgram
exec 3> >( while /bin/true ; do socat -t0 -T0 -u STDIN UDP: ; done )
while /bin/true; do
while read line; do
echo "$line"
echo "$line" >&3
sleep 0.1
done < /vagrant/testlog
thwarted / transmission.initd
Created Sep 19, 2014
control script for transmission; you'll need to roll your own settings.json
View transmission.initd
TRHOME=$( readlink -f $( dirname $0 ) )
# mkdir -p complete config incomplete logs torrents
dostart() {
transmission-daemon \
--config-dir $TRHOME/config \
thwarted / FOR_EACH.cmacros.h
Created Sep 17, 2014
a FOR_EACH C Preprocessor macro that works under both GNU CC and Visual Studio 2013/MSVC
View FOR_EACH.cmacros.h
/* 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
You can’t perform that action at this time.