Skip to content

Instantly share code, notes, and snippets.

@asemt
asemt / text_template_example.go
Created January 12, 2016 14:40
Stupid simple Go template example
/*
Go text template example.
References:
- https://golang.org/pkg/text/template/
- http://stackoverflow.com/questions/13765797/the-best-way-to-get-a-string-from-a-writer-in-go
- http://andlabs.lostsig.com/blog/2014/05/26/8/the-go-templates-post
- https://jan.newmarch.name/go/template/chapter-template.html
- http://nathanleclaire.com/blog/2014/07/19/demystifying-golangs-io-dot-reader-and-io-dot-writer-interfaces/
*/
http://www.jedelman.com/1/post/2014/02/common-programmable-abstraction-layer.html
http://www.jedelman.com/1/post/2014/02/the-power-of-a-programmable-abstraction-layer.htm
@asemt
asemt / IPython@2014-01-23
Created January 23, 2014 18:09
Dynamically add attributes to a Python object
class c(object):
def __init__(self, a, b):
self.a = a
self.b = b
def update(self, update_dict):
self.__dict__.update(update_dict)
c = c(1, 2)
c.a

Persist specific events into Redis datastore:

  1. Clone the Riemann Git repository (clones into directory riemann):
    $ git clone https://github.com/aphyr/riemann.git

  2. Checkout the last stable version (0.2.2 in our case):
    $ cd riemann
    $ git checkout tags/0.2.2

  3. Add Carmine dependency to riemann/project.clj:

@asemt
asemt / StateMachine.py
Created November 12, 2012 15:01
A simple, stupid (as in KISS) state maschine
class InvalidStateException(Exception):
pass
class MissingStateMachineConfigurationException(Exception):
pass
from types import DictionaryType
class StateMachine(object):