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 / sociagram.py
Created April 24, 2014 12:32
Sociagram Python API
class SociagramApi(object):
"""
Ported over from Sociagrams really shoddy Zend based API client (lololol, many fails, very 'enterprise')
"""
def __init__(self, key=None, secret=None):
self.api_url = 'https://api.sociagram.com/v1'
self.key = settings.SOCIAGRAM_API_KEY if key is None else key
self.secret = settings.SOCIAGRAM_API_SECRET if secret is None else secret
(* Copyright © 2014 G Roberts. All Rights Reserved *)
namespace MiniForum.Model
open System
open System.Threading.Tasks
open MiniForum
open MiniForum.Model
open Fredis
@HarryR
HarryR / SockJS.hx
Created October 1, 2014 14:01
SockJS externs for Haxe/JS
typedef SockJS_Options = {
@:optional var debug: Bool;
@:optional var devel: Bool;
@:optional var server: String;
@:optional var protocols_whitelist: Array<String>;
};
extern class SockJS {
// Constants
static inline var CONNECTING: Int = 0;
@HarryR
HarryR / callback.hx
Created October 1, 2014 14:02
Callback type which allows either one Dynamic arg, or no args
abstract Callback(Dynamic->Void) from Dynamic->Void {
inline function new(f)
this = f;
public inline function invoke(data:Dynamic):Void
(this)(data);
@:from static function fromNiladic(f:Void->Void):Callback
return new Callback(function (x) f());
}
@HarryR
HarryR / tree.py
Last active August 29, 2015 14:17
Hashed tree with 4bit levels and random distribution
__all__ = ('treedel', 'treemap', 'treeadd')
from hashlib import sha1
def hashname(*args):
hashed = sha1()
for arg in args:
hashed.update(str(arg))
return hashed.hexdigest()
@HarryR
HarryR / xinitrc.sh
Created June 14, 2015 00:48
simplicity
#!/bin/sh
xrandr --output ...
i3status &
xfce4-session &
exec i3
@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 / 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 = ""
) {