Skip to content

Instantly share code, notes, and snippets.


Josh Mills trueheart78

View GitHub Profile
trueheart78 / fs-monitor.rb
Last active Aug 29, 2015
A simple ruby script to monitor filesizes during a large transfer. Setup to run through cron. Requires the mandrill-api gem to be installed, as well as a mandrill API key in your enviroment in MANDRILL_APIKEY
View fs-monitor.rb
require 'mandrill'
files = ["mh-files-wo-lb-20141026_0009.tar.gz","mh-files-lb-only-20141026_0009.tar.gz"]
files.each do |f|
if File.exist?(f)
size = File.stat(f).size
gb = 1024 ** 3
mb = 1024 ** 2
status = "#{size / gb} gb (#{size / mb} mb)"
puts "File #{f} - as of #{}:\n"
View sludgehammer.user.js
// ==UserScript==
// @name SludgeHammer
// @namespace gamerswithjobs
// @description Replaces marketing speak with English
// @exclude /github/
// @author Chris Doggett
// ==/UserScript==
// Special thanks to Jeremy Banks at
var load,execute,loadAndExecute;load=function(a,b,c){var d;d=document.createElement("script"),d.setAttribute("src",a),b!=null&&d.addEventListener("load",b),c!=null&&d.addEventListener("error",c),document.body.appendChild(d);return d},execute=function(a){var b,c;typeof a=="function"?b="("+a+")();":b=a,c=document.createElement("script"),c.textContent=b,document.body.appendChild(c);return c},loadAndExecute=function(a,b){return load(a,function(){return execute(b)})};
View apache-access-log-parser.rb
#!/usr/bin/env ruby
# Helpful link:
require 'date'
line_count = 0[0]).readlines.each do |line|
line_count += 1
result = /^(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}).*\[(.*)\].*(GET|HEAD|POST|PUT|DELETE|TRACE|CONNECT)\s(.*)\"\s(\d+)\s(\d+)(.*)$/.match(line)