Skip to content

Instantly share code, notes, and snippets.

View brandocorp's full-sized avatar

Brandon Raabe brandocorp

View GitHub Profile
@brandocorp
brandocorp / gist:9574673
Created March 15, 2014 22:11
win32-file-stat test
irb(main):001:0> require 'win32/file'
=> true
irb(main):002:0> f = File::Stat.new('C:\Program Files')
=> #<File::Stat archive=false atime=2014-02-26 14:52:59 -0700 blksize=4096 blockdev=false blocks=1 compressed=false ctime=2009-07-13 20:20:08 -0700 dev=2 encrypted=false gid=2271478464 hidden=false indexed=true ino=281474976710716 mode=040555 mtime=2014-02-26 14:52:59 -0700 nlink=1 normal=false offline=false rdev=1478858236 readonly=true reparse_point=false size=4096 sparse=false system=false temporary=false uid=2271478464
irb(main):003:0> f.directory?
=> true
irb(main):004:0> f.writable?
=> false
irb(main):008:0> f.send(:access_check, 'C:\Program Files', 0x40000000) # GENERIC_WRITE
=> true
@brandocorp
brandocorp / handler_remote_file_cache_handler.rb
Last active August 29, 2015 14:00
Remote File Pre-Caching
require 'chef/handler'
require 'chef/rest'
require 'chef/version_constraint'
class Chef
class RemoteFile
class CacheHandler < ::Chef::Handler
attr_reader :config
@brandocorp
brandocorp / config
Created January 16, 2015 17:19
use jumphost with ssh proxy command
Host *
ControlMaster auto
ControlPath ~/.ssh/tmp/%h_%p_%r
TCPKeepAlive yes
ServerAliveInterval 30
ConnectTimeout 15
LogLevel ERROR
Host jumphost
HostName ${JUMPHOST_IP}
@brandocorp
brandocorp / monkey_patch.rb
Created January 22, 2015 18:39
Stop include_recipe directive from actually loading the recipe
# This keeps any cookbook aside from our target cookbook from actually loading recipes
class Chef
class CookbookVersion
alias_method :old_load_recipe, :load_recipe
def load_recipe(recipe_name, run_context)
old_load_recipe(recipe_name, run_context) if metadata.name == 'cookbook_name'
end
end
end
@brandocorp
brandocorp / cloud-config
Created January 28, 2015 16:22
CoreOS Setup
#cloud-config
coreos:
etcd:
discovery: https://discovery.etcd.io/660d695900f203da9f9819cf42775896
addr: $public_ipv4:4001
peer-addr: $public_ipv4:7001
fleet:
public-ip: $public_ipv4 # used for fleetctl ssh command
units:
@brandocorp
brandocorp / supervisor_cleanup.sh
Last active August 29, 2015 14:17
supervisor log cleanup
#!/bin/bash
# remove emtpy clutter
find /var/log/supervisor/ -size 0 -exec rm -f {} \;
##### Rotated Logs #####
# gzip any rollovers
find /var/log/supervisor/ -regex '.*supervisor-[A-Za-z0-9]+.log.[0-9]+' -exec gzip -f {} \;
# remove anything older than 3 days
find /var/log/supervisor/ -regex '.*supervisor-[A-Za-z0-9]+.log.*' -mtime +2 -exec rm -f {} \;
@brandocorp
brandocorp / docker-host-01.sh
Last active August 29, 2015 14:17
Elasticsearch Unicast across Docker Hosts
#!/bin/bash
#
# Docker Host 01
# eth0: 192.168.1.10
#
docker run -d \
-p 9200:9200 \
-p 9300:9300 \
#! /bin/bash
#
# ddns Apply DDNS Configuration on first boot
#
# chkconfig: 2345 09 90
# description: Applies DDNS configuration to DHCP network interfaces
#
# Source function library.
. /etc/init.d/functions
@brandocorp
brandocorp / chef_winrm.ps1
Last active August 29, 2015 14:20
Prepare server to be bootstrapped by Chef with WinRM
# Get network connections
$networkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"))
$connections = $networkListManager.GetNetworkConnections()
$connections | % {$_.GetNetwork().SetCategory(1)}
# run quick config
winrm qc -q
# allow incoming traffic from anywhere (still requires VPN connection)
netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" profile=private new enable=yes remoteip=any localip=any protocol=tcp
### Keybase proof
I hereby claim:
* I am brandocorp on github.
* I am brandocorp (https://keybase.io/brandocorp) on keybase.
* I have a public key whose fingerprint is B27E EF08 56F0 C4B4 66A4 DDA0 6501 9DAC 08D6 305D
To claim this, I am signing this object: