Skip to content

Instantly share code, notes, and snippets.

View henrysher's full-sized avatar
💭
I may be slow to respond.

Henry Huang henrysher

💭
I may be slow to respond.
View GitHub Profile
@henrysher
henrysher / Pocket2
Created November 10, 2012 09:51
Make the pocket able to save HTTPS URL
javascript: (function () {
var d = document,
l = d.location;
m = l.protocol + '//getpocket.com/save?url=' + encodeURIComponent(l.href);
with(window.open(m)) {
}
})();
@henrysher
henrysher / windows.h__.js
Created November 19, 2012 06:07
windows.h.js INFINITY
var ffi = require('ffi'),
ref = require('ref'),
Struct = require('ref-struct'),
Library = require('./Library'),
Type = ref.Type,
NULL = ref.NULL,
isNull = ref.isNull;
var groups = ['libs', 'types', 'structs', 'callbacks', 'enums'];
[Solarized Dark]
text(bold)=839496
magenta(bold)=6c71c4
text=839496
white(bold)=fdf6e3
green=859900
red(bold)=cb4b16
green(bold)=586e75
black(bold)=073642
red=dc322f
== Rules ==
On Infrastructure
-----------------
There is one system, not a collection of systems.
The desired state of the system should be a known quantity.
The "known quantity" must be machine parseable.
The actual state of the system must self-correct to the desired state.
The only authoritative source for the actual state of the system is the system.
The entire system must be deployable using source media and text files.
== Rules ==
On Infrastructure
-----------------
There is one system, not a collection of systems.
The desired state of the system should be a known quantity.
The "known quantity" must be machine parseable.
The actual state of the system must self-correct to the desired state.
The only authoritative source for the actual state of the system is the system.
The entire system must be deployable using source media and text files.
roles = []
if ',' in options.role:
for role in options.role.split(","):
if role not in ICS_ROLES:
print "this role %s is not valid..." % (role)
sys.exit(0)
roles.append(role)
elif options.role not in ROLES:
print "this role %s is not valid..." % (options.role)
sys.exit(0)
import time
class Retry(object):
default_exceptions = (Exception)
def __init__(self, tries, exceptions=None, delay=0):
"""
Decorator for retrying function if exception occurs
tries -- num tries
exceptions -- exceptions to catch
# coding: utf-8
from __future__ import division
import re
import os
import time
import bottle
from xml.dom.minidom import parseString
from math import *
helpstr = '''\
@henrysher
henrysher / a.py
Created July 9, 2013 04:44
one test sample for pydiff
#!/usr/bin/env python
#
import os
def test(records):
pass
# vim: tabstop=4 shiftwidth=4 softtabstop=4
@henrysher
henrysher / userdata_base64.py
Last active December 23, 2015 05:49
userdata_base64.py
#!/usr/bin/env python
import os
import sys
import base64
import simplejson
def usage():
print >> sys.stderr, 'Usage: %s {f_userdata} {f_spot_configuration}' % (
os.path.basename(sys.argv[0]))