Skip to content

Instantly share code, notes, and snippets.

View gswallow's full-sized avatar

Greg Swallow gswallow

  • Indianapolis, IN, USA
View GitHub Profile
@gswallow
gswallow / gist:7104983
Last active December 26, 2015 05:59
Quick & dirty mongodb stats
#!/usr/bin/env ruby
require 'rubygems'
require 'mongo'
include Mongo
info = Array.new
counts = [ 0 ]
sizes = [ 0 ]
# File generated by Chef. Do not edit by hand.
<% unless node.platform_family =~ /windows/ -%>
127.0.0.1 localhost
<% end -%>
<%= "#{sprintf("%-15s%3s%-32s%4s%-s", @node.ipaddress, " ", @node.fqdn, " ", @node.hostname)}" %>
<% @hosts.sort { |a,b| a.hostname <=> b.hostname }.each do |h| -%>
<% unless h.ipaddress == @node.ipaddress -%>
<%= "#{sprintf("%-15s%3s%-32s%4s%-s", h.ipaddress, " ", h.fqdn, " ", h.hostname)}" %>
<% end -%>
unless Chef::Config[:solo]
case node.platform_family
when "windows"
file = "#{node['kernel']['os_info']['system_directory']}\\drivers\\etc\\hosts"
else
file = "/etc/hosts"
end
members = search(:node, "chef_environment:#{node.chef_environment}").to_a
@gswallow
gswallow / get-newest.sh
Created October 23, 2013 21:14
Ever want to get the latest versions of your cookbooks to include them in your environment manifests?
#!/bin/bash
spaces=${1:-0}
if [ "$[$spaces-$spaces]" -ne "0" ]; then
spaces=0
fi
i=0
while [ $i -lt $spaces ]; do
begin="$begin "
I have an mzconvert process that crashes. shows up as "having stopped working" in Windows. But the "responding" attribute of the process object is "true."
foreach ($sample in (Get-ChildItem -Path $holdfolder | Where-Object { $_.Name -match "(.d|.wiff)$" })) {
$samplefolder = $holdfolder + "\" + $sample
try {
Start-Process -FilePath 'c:\Program Files (x86)\indigobiosystems\adr\mzconvert\mzconvert.exe' -ArgumentList "-f $samplefolder -d $holdsfolder\test"
} catch {
write-host "Caught an exception:" -ForegroundColor Red
write-host "Exception Type: $($_.Exception.GetType().FullName)" -ForegroundColor Red
@gswallow
gswallow / run
Last active December 27, 2015 02:29
make running knife easier
#!/bin/bash
user="indigo_chef"
#pass='xxx'
################################################################################
# Parse arguments
################################################################################
ARGS=`getopt se:r:w $* 2> /dev/null`
@gswallow
gswallow / gist:7253370
Created October 31, 2013 17:10
haz a sad
10.120.18.142 [2013-10-31T13:10:06-04:00] FATAL: Chef::Exceptions::Win32APIError: template[c:/hosts2] (ascent-common::hostsfile line 13) had an error: Chef::Exceptions::Win32APIError: The operation completed successfully.
10.120.18.142 ---- Begin Win32 API output ----
10.120.18.142 System Error Code: 0
10.120.18.142 System Error Message: The operation completed successfully.
10.120.18.142 ---- End Win32 API output ----
@gswallow
gswallow / gist:7255968
Created October 31, 2013 19:53
How much lava collects in valleys?
#!/usr/bin/env ruby
points = [ 1, 2, 1, 4, 1, 3, 2, 9, 7, 5, 10, 1, 2, 1, 2, 1 ]
l_max = 0
r_max = 0
l_lava = 0
r_lava = 0
lava = 0
l_peak = 0
# tzdata
tzdata tzdata/Areas select America
tzdata tzdata/Zones/Etc select UTC
tzdata tzdata/Zones/America select Indiana/Indianapolis
America/Indiana/Indianapolis