Skip to content

Instantly share code, notes, and snippets.

View gswallow's full-sized avatar

Greg Swallow gswallow

  • Indianapolis, IN, USA
View GitHub Profile
class WindowsLogWatcher < Scout::Plugin
needs 'win32/file'
OPTIONS = <<-EOS
log_path
name: Log path
notes: Full path to the log file
term:
default: "[Ee]rror"
name: Search Term
@gswallow
gswallow / gist:5586747
Last active September 24, 2020 10:02
Find netmask / network address / broadcast address / supposed gateway from an IP/cidr pair
cidr2mask() {
local mask=""
local netaddr=""
local bcast=""
local gateway=""
local full_octets=$(($2/8))
local partial_octet=$(($2%8))
ipparts=($(echo $1 | tr "." "\n"))
79 def step_down(host, seconds)
80 connection = connect(host)
81 if is_master?(connection)
82 admin = connection['admin']
83 cmd = BSON::OrderedHash.new
84 cmd['replSetStepDown'] = seconds
85 begin
86 admin.command(cmd, :check_response => true)
87 rescue Mongo::OperationFailure => e
88 raise "Could not step down. Perhaps MongoDB isn't healthy? (server said: #{e})"
#!/bin/bash
# Customize this
domain="indigobio.com"
ns1="8.8.8.8"
ns2="4.2.2.2"
ndots="2"
usage() {
echo
DEBUG: Using configuration from /Users/gswallow/.chef/knife.rb
DEBUG: value for config item bootstrap:
DEBUG: value for config item vsphere_host: localhost
DEBUG: value for config item vshere_path:
DEBUG: value for config item vsphere_port: 8443
DEBUG: value for config item vsphere_nossl:
DEBUG: value for config item vsphere_user: gswallow
DEBUG: value for config item vsphere_pass: fffff
DEBUG: value for config item vsphere_insecure: true
DEBUG: value for config item vsphere_dc:
cmd /c powershell.exe -command "$webClient = New-Object System.Net.WebClient ; $webClient.DownloadFile('https://www.itefix.no/i2/sites/default/files/Copssh_3.1.4_Installer.zip', $env:TEMP + '\Copssh_3.1.4_Installer.zip')"
cd %TEMP%
cmd /c powershell.exe -command "$shell = new-object -com shell.application ; $zip = $shell.NameSpace($env:TEMP + '\Copssh_3.1.4_Installer.zip') ; foreach($item in $zip.items()) { $shell.Namespace($env:TEMP).copyhere($item) }"
cmd /c copssh_3.1.4_Installer.exe /u=SVCCopSSH /p="user" /S
cmd /c "%PROGRAMFILES(x86)%\icw\bin\copsshadm.exe" --command activateuser --user user --shell /bin/bash
cmd /c netsh advfirewall firewall add rule name="SSH" protocol=TCP dir=in localport=22 action=allow enable=yes
c:\program files(x86)\icw\bin\sh.exe
export PATH=/bin
@gswallow
gswallow / parted-preseed.cfg
Created August 27, 2013 19:03
My working partman config for debian installer
# Set up LVM on the first/only disk.
d-i partman-auto/method string lvm
d-i partman-auto/choose_recipe select boot-root
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
# Set the name of the created volume group.
d-i partman-auto-lvm/new_vg_name string vg00
# being thrown into partman's guided size dialog.
@echo off
REM http://webcache.googleusercontent.com/search?q=cache:SjoPPpuQxuoJ:www.tcm.phy.cam.ac.uk/~mr349/cygwin_install.html+install+cygwin+ssh+commandline&cd=2&hl=nl&ct=clnk&gl=be&source=www.google.be
cmd /c powershell.exe -command "$webClient = New-Object System.Net.WebClient ; $webClient.DownloadFile('http://cygwin.com/setup-x86_64.exe', $env:TEMP + '/cygwin-setup-x86_64.exe')"
REM go to a temp directory
cd %TEMP%
REM run the installation
cmd /c cygwin-setup-x86_64.exe -N -n -q -P openssh,openssl,cygrunsrv,rebase,libintl8,libiconv2,libcygncursesw -s http://cygwin.mirrors.pair.com
# Passing along a search query with string interpolation from a role doesn't work.
# Try setting it here, instead.
env = "chef_environment:#{node.chef_environment}"
if node['elasticsearch'].has_key?('discovery')
role = "role:#{node['elasticsearch']['discovery']['role']}" unless node['elasticsearch']['discovery']['role'].nil?
end
if node['elasticsearch'].has_key?('cluster')
@gswallow
gswallow / gist:6906062
Created October 9, 2013 18:43
kludgey unicorn worker killer
#!/usr/bin/env ruby
# == Simple Daemon
#
# A simple ruby daemon that you copy and change as needed.
#
# === How does it work?
#
# All this program does is fork the current process (creates a copy of
# itself) then exits, the fork (child process) then goes on to run your
# daemon code. In this example we are just running a while loop with a