Skip to content

Instantly share code, notes, and snippets.

View HarryR's full-sized avatar
🏴‍☠️
My time travel machine is stuck at 60 seconds per minute

HaRold HarryR

🏴‍☠️
My time travel machine is stuck at 60 seconds per minute
View GitHub Profile
@HarryR
HarryR / jquery.lazyload.js
Created February 15, 2011 17:59
Updated version of lazyload which isn't O(n) and handles reloading mid-page etc.
/*
* Lazy Load - jQuery plugin for lazy loading images
*
* Copyright (c) 2007-2009 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Project home:
* http://www.appelsiini.net/projects/lazyload
@HarryR
HarryR / easyhs.hpp
Created May 13, 2011 14:52
Easy interface to HandlerSocket for QT
#ifndef EASYHS_HPP_
#define EASYHS_HPP_
#pragma once
#include <handlersocket/hstcpcli.hpp>
#include <QList>
#include <QVariant>
#include <QRunnable>
#include <QObject>
#include <QMetaProperty>
@HarryR
HarryR / derpfs.py
Created July 19, 2011 19:51
PyFilesystem driver for GridFS
#!/usr/bin/env python
# based on the tahoelafs project
# requires modification to pyfilesystem for mknod etc.
# but provides enough to extract a minimal linux install
# and then chroot into it :)
import pymongo
import gridfs
import os
import fs
import math
@HarryR
HarryR / sdapi.py
Created August 9, 2011 13:31
Ultra-minimal serverdensity api
"""
The server density API is so easy with a shake of jsonpath :)
Example:
groups = sdapi.call('servers/listGroups', '$..groups')
web_server_ids = sdapi.call('servers/getByGroup', '$..serverId', group='Web')
For a jsonpath reference, try: http://code.google.com/p/jsonpath/wiki/Javascript
"""
@HarryR
HarryR / ruby.pp
Created August 26, 2011 18:28
Manage Ruby Gems from puppet
class packages::ruby {
package{
['ruby','rubygems','ruby-dev']:
ensure => present;
}
}
define rubygem(
$version = ""
) {
@HarryR
HarryR / Makefile
Created September 23, 2011 01:38
Download & setup mongodb
# -----------------
# include mongo-options
MONGO_ARCH := i686
MONGO_VERSION := 2.0.0
MONGO_OS := linux
MONGO_MD5 := 573d8da35806fa3fc5db3305a644852e
# -----------------
MONGO_DIR = mongodb-$(MONGO_OS)-$(MONGO_ARCH)-$(MONGO_VERSION)
TARBALL = $(MONGO_DIR).tgz
@HarryR
HarryR / zmqstub.c
Created September 23, 2011 13:34
zmq & libevent stub
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <libgen.h>
#include <signal.h>
#include <err.h>
#include <assert.h>
#include <zmq.h>
@HarryR
HarryR / ProcNetNetstat.py
Created September 28, 2011 22:16
/proc/net/netstat plugin for ServerDensity.com
class ProcNetNetstat:
def __init__(self, agentConfig, checksLogger, rawConfig):
pass
def run(self):
dat = {}
for line in open('/proc/net/netstat','r').readlines():
line = line.split()
name = line[0]
line.remove(name)
@HarryR
HarryR / sd-ip.py
Created October 17, 2011 14:38
Retrieve IP of a server from ServerDensity
#!/usr/bin/env python2.7
import sys
import user
from serverdensity.api import SDApi, SDServiceError
api = SDApi(getattr(user, 'serverdensity_domain'),
getattr(user, 'serverdensity_username'),
getattr(user, 'serverdensity_password'),
getattr(user, 'serverdensity_api_key'))
@HarryR
HarryR / LinuxProcSysFs.py
Created October 27, 2011 09:54
ServerDensity plugin to graph open file handles
#!/usr/bin/env python
class LinuxProcSysFs:
def __init__(self, agentConfig, checksLogger, rawConfig):
self.agentConfig = agentConfig
self.checksLogger = checksLogger
self.rawConfig = rawConfig
def run(self):
x = open('/proc/sys/fs/file-nr', 'r').readline().split()
return {