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 / Vagrantfile.aws
Created April 1, 2014 05:28
a simplisitic Vagrantfile for use with vagrant-aws; vagrant up --provider=aws
if not ENV['AWS_ACCESS_KEY_ID'] or not ENV['AWS_SECRET_ACCESS_KEY']
puts "Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in the environment"
exit
end
Vagrant.configure("2") do |config|
config.vm.box = "dummy"
config.vm.provider :aws do |aws, override|
#aws.region = "us-west-2"
@thwarted
thwarted / notify-agent-use
Last active August 29, 2015 14:00
notify on ssh-agent use
#!/bin/bash
countfile=/tmp/agentcount.${USER}.$( date +%Y%m%d )
c=$( cat "$countfile" 2>/dev/null )
c=$(( c + 1 ))
echo $c > "$countfile"
msg="${*/Allow use of/Using}"
msg="$( echo "${msg/\?/}" | fold -w 34 )"
@thwarted
thwarted / pause
Created May 13, 2014 05:59
pause
#include <unistd.h>
void main() { pause(); }
@thwarted
thwarted / build-the-gems-i-need
Last active August 29, 2015 14:01
/usr/lib64/ruby/gems/2.1.0/gems/gem2rpm-0.10.1/templates/fedora.spec.erb that works better with ruby-2.1
#!/bin/bash
set -x
cd ~/rpmbuild/SOURCES
function doit() {
local gemname="$1"
gem2rpm --fetch $gemname --output ../SPECS/rubygem-$gemname.spec
@thwarted
thwarted / keybase.md
Created August 13, 2014 21:59
keybase.md

Keybase proof

I hereby claim:

  • I am thwarted on github.
  • I am thwarted (https://keybase.io/thwarted) on keybase.
  • I have a public key whose fingerprint is 8CC0 42B3 3D0A CE55 5BA8 7623 0317 C210 0A72 3223

To claim this, I am signing this object:

@thwarted
thwarted / syslog-ng.statsd.conf
Last active August 29, 2015 14:05
increment graphite metrics via statsd from matched syslog lines using syslog-ng
# vim:ft=syslog-ng:ai:si:ts=4:sw=4:et:expandtab
# assumes RFC5424 format and a SD-ELEMENT "x-service" in the SD-ID "origin"
# customize to taste
@define statdprefix "service.${.SDATA.origin.x-service}."
# send your log data to port 8888
source s_logdata {
udp(port(8888) flags(syslog-protocol) tags("logdata"));
@thwarted
thwarted / transmission.initd
Created September 19, 2014 17:23
control script for transmission; you'll need to roll your own settings.json
#!/bin/bash
TRHOME=$( readlink -f $( dirname $0 ) )
# mkdir -p complete config incomplete logs torrents
PIDFILE=$TRHOME/logs/transmission.pid
dostart() {
cd $TRHOME
transmission-daemon \
--config-dir $TRHOME/config \
@thwarted
thwarted / simple-iscsi-setup-in-linux.md
Created January 16, 2015 20:57
Simple ISCSI setup in Linux

Mostly gleaned from the instructions at https://wiki.archlinux.org/index.php/ISCSI_Initiator to setup the initiator.

Overview of the steps:

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

  • installed netbsd-iscsi (yum install netbsd-iscsi in my case for Centos 6.5)
  • updated the netmask in /etc/iscsi/targets to be 10.1.1.0/24.
  • 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
thwarted / zipcode.go
Created February 3, 2015 19:37
example of matching a format and returning an error in go from JSON parsing
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")
}
@thwarted
thwarted / httppause.sh
Created August 3, 2015 21:58
test case for "An error occured on select: 4" in typhoeus/ethon; start httppause and then run makerequest.rb
#!/bin/bash
if [[ "$NESTED" ]]; then
IFS=$( echo -e '\r' )
while read line; do
[[ -z "$line" ]] && break
done
sleep 10