Skip to content

Instantly share code, notes, and snippets.

View jiphex's full-sized avatar

James Hannah jiphex

View GitHub Profile
@jiphex
jiphex / libvirtsnapshot.rb
Created April 30, 2013 11:53
Thing to add the missing method "create_snapshot" to the libvirt ruby domain bindings. Both the libvirt and builder libraries are in debian packages (apt-get install ruby-{libvirt,builder})
require 'libvirt'
require 'builder'
class Libvirt::Domain
def create_snapshot(sdesc=nil)
builder = Builder::XmlMarkup.new
snapshot_xml = builder.domainsnapshot do |ds|
if sdesc
ds.description(sdesc)
end
@jiphex
jiphex / recipe.md
Last active December 15, 2015 12:09
Almost Perfect Chicken Curry

Almost Perfect* Chicken Curry

*work-in-progress

Ingredients

  • 500g Chicken thigh fillets, chopped
  • 2x Peppers
  • A couple of cloves of garlic (frozen is fine)
  • 1x Cans chopped tomatoes
/**
* Determines which Filesystem Method to use.
* The priority of the Transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets (Via Sockets class, or fsockopen())
*
* Note that the return value of this function can be overridden in 2 ways
* - By defining FS_METHOD in your <code>wp-config.php</code> file
* - By using the filesystem_method filter
* Valid values for these are: 'direct', 'ssh', 'ftpext' or 'ftpsockets'
* Plugins may also define a custom transport handler, See the WP_Filesystem function for more information.
*
@jiphex
jiphex / emailinspect.py
Created August 28, 2012 13:44
Email html parser thingy
#!/usr/bin/env python
import sys
import email.parser
import base64
if(len(sys.argv) < 2):
print "No email file specified!"
sys.exit(1)
p = email.parser.Parser()
@jiphex
jiphex / printerstatus.rb
Created August 21, 2012 13:02
Xerox Workcenter printer status thingy
#!/usr/bin/env ruby
require 'snmp'
# usage: printerstatus.rb printer.host.name community.name
# no output unless error, returns zero if status is ok
SNMP::Manager.open(:Host=>ARGV[0],:Community=>ARGV[1]) do |manager|
resp = manager.get(["SNMPv2-SMI::mib-2.43.18.1.1.8.1.1"])
resp.each_varbind do |varbind|
exit(0) if varbind.value.to_s == "noSuchInstance"
@jiphex
jiphex / upgdiff.rb
Created July 10, 2012 13:36
CentOS Yum Upgrade Diff script
# upgdiff.rb
#
# Prints the change in versions that will happen if "yum upgrade" is
# run on this CentOS/RHEL server, and if any of the upgrades will come
# from third party repositories.
#
# For example:
#
# [root@server] $ ruby upgdiff.rb
# yum-utils: 1.1.16-14.el5.centos.1 ==> 1.1.16-21.el5.centos
@jiphex
jiphex / nginx.conf
Created January 13, 2012 23:16
Nginx smart app deployment
#user nobody;
worker_processes 1;
#error_log logs/error.log;
error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
@jiphex
jiphex / checkdns.rb
Created November 17, 2011 10:15
Bruteforce multi DNS resolver
#!/usr/bin/env ruby
# DNS Bulk Resolver
#
# Resolves all the domains in the file argv[0], and www.$(each)
# Uses the resolv.conf file specified below (googledns.conf)
# Will hammer your DNS servers, be cautious.
# Creates a thread for each line in the file, be cautious.
# Be safe.
require 'resolv'
@jiphex
jiphex / purge.rb
Created November 14, 2011 10:13
Ruby Varnish Purge Script
#!/usr/bin/env ruby
# Ruby varnish purger
require 'net/http'
module Net
class HTTP::Purge < HTTPRequest
METHOD='PURGE'
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = true
@jiphex
jiphex / barload.py
Created October 27, 2011 13:34
Generate a rolling bar graph of load average
#!/usr/bin/env python
import time
import sys
CEILING=10
WIDTH=80
def get_loadavg():
f = open('/proc/loadavg','r')
line = f.read()