Skip to content

Instantly share code, notes, and snippets.

@mattvonrocketstein
mattvonrocketstein / discover.ex
Last active October 1, 2016 03:48
Demo usage of ex_slp lib
#
# Demo usage of ex_slp_tk for OpenSLP based Elixir node clustering
# see the library at: https://github.com/icanhazbroccoli/ex_slp_tk
#
# To use the code below, add something like this for your application's supervisor:
#
# children = children ++ [supervisor(Discovery.Supervisor, [])]
# supervise(children, opts)
#
require Logger
@mattvonrocketstein
mattvonrocketstein / mix.exs
Created September 7, 2016 15:27
elixir and python
#
@mattvonrocketstein
mattvonrocketstein / ielixir-playbook.yml
Last active August 3, 2016 15:21
A playbook for building a jupyter notebook with IElixir
# playbook.yml
# installs ielixir/jupyter on a stand-alone docker.
# see: http://mattvonrocketstein.github.io/heredoc/ielixir-notebook-in-docker.html
- hosts: docker
become: yes
become_method: sudo
gather_facts: False
vars:
erls_url: "https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb"
ielixir_repo: "https://github.com/pprzetacznik/IElixir.git"
@mattvonrocketstein
mattvonrocketstein / fabfile.py
Last active August 3, 2016 08:24
release fabfile
# -*- coding: utf-8 -*-
import os
import sys
from fabric import api
from fabric import colors
from fabric.contrib.console import confirm
PKG_NAME = 'PKG_NAME'
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
@mattvonrocketstein
mattvonrocketstein / fabfile.py
Last active July 29, 2016 15:57
vulture fabfile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import contextlib
from fabric import api
PKG_NAME = 'MY_PKG'
VULTURE_EXCLUDE_PATHS = ['tests', ]
VULTURE_IGNORE_FUNCTIONS = ['commandline_entry_point']
@mattvonrocketstein
mattvonrocketstein / fabfile.py
Last active July 29, 2016 14:51
version_bump fabfile
# -*- coding: utf-8 -*-
import os
from fabric import api
from fabric import colors
from fabric.contrib.console import confirm
_ope = os.path.exists
_mkdir = os.mkdir
_expanduser = os.path.expanduser
_dirname = os.path.dirname
@mattvonrocketstein
mattvonrocketstein / gist:6678175
Created September 23, 2013 22:59
partition tests by type, retrieve misc. test metadata
import os, sys
import inspect
import unittest, unittest2
from django import test as dtest
import nose
def _suite2list(s):
return [x for x in _suite2iter(s)]
defmacro print(thing) do
if String.valid?(thing) do
quote bind_quoted: binding() do
IO.puts thing
end
else
quote bind_quoted: binding() do
IO.puts("#{inspect thing}")
end
end
@mattvonrocketstein
mattvonrocketstein / pyack
Created February 8, 2012 01:34
a dumb interface for getting ack data into python
""" pyack
a dumb interface for getting ack data into python
USAGE:
call it with a given search string or directory
>>> z = pyack('search_string')
>>> z = pyack('search_string directory')
>>> z = pyack('search_string directory --whatever-ack-args')
@mattvonrocketstein
mattvonrocketstein / do_when.py
Created October 13, 2010 18:27
hacky decorators for defeating annoying race conditions
""" some decorator hacks for defeating annoying race conditions """
def when(predicate, limit=100, sleep_time=1, eager=False):
""" this function is dedicated to Christopher Michael Heisel
When predicate is True, the decorated function will run
(and nevermind exactly when it was called). If the predicate
tests False for more times than <limit>, this function will
simply exit and the decorated function will never be called.