Skip to content

Instantly share code, notes, and snippets.

@calvingiles
calvingiles / specialist_function_factory.py
Created May 21, 2014 14:58
specialist function factory
def specialist_function_factory(func, *s_args, **s_kwargs):
def specialist_func(*args, **kwargs):
all_args = s_args + args
all_kwargs = dict(list(s_kwargs.items()) + list(kwargs.items()))
return func(*all_args, **all_kwargs)
return specialist_func
@calvingiles
calvingiles / Theming-Slack-OSX.md
Last active January 10, 2019 11:17 — forked from DrewML/Theming-Slack-OSX.md
Theming Slack for OSX

Theming Slack for OSX

So, you love Slack, but you hate applications with large white backgrounds? Why not use Dark Mode!

Unfortunately, Slack does not have a Dark Mode, although it's on their list of possibilities.

But, don't fret - there is a solution! Because the slack native desktop apps are just wrappers around a web app, we can inject our own CSS to customize the application to our liking.

How to (OSX Only)

@calvingiles
calvingiles / graph_set.py
Created June 10, 2016 17:29
Pure python methods for modelling simple graphs and building a set of disjoint graphs edge by ende
class Graph(object):
def __init__(self, nodes, edges=None):
self.nodes = nodes
self.edges = set()
self.add_edges(edges or set())
def __hash__(self):
return hash(frozenset(self.edges)) + hash(frozenset(self.nodes))
def __repr__(self):
@calvingiles
calvingiles / data-science-environment-fig.yml
Last active May 26, 2016 07:24
fig.yml for setting up a data science environment
notebooks:
command: echo created
image: busybox
volumes:
- "~/Google Drive/notebooks:/notebooks"
data:
command: echo created
image: busybox
volumes:
- "~/Google Drive/data:/data"
@calvingiles
calvingiles / ai_il.py
Created December 19, 2013 19:50
auto-incrementor and infinate list
"""
>>> I = ai(start=0, step=1)
>>> I()
0
>>> I()
1
>>> J = ai(start=0, step=1)
>>> J()
0
>>> I()
@calvingiles
calvingiles / ai_il.py
Created December 19, 2013 19:50
auto-incrementor and infinate list
"""
>>> I = ai(start=0, step=1)
>>> I()
0
>>> I()
1
>>> J = ai(start=0, step=1)
>>> J()
0
>>> I()
@calvingiles
calvingiles / ipp.py
Created December 19, 2013 19:30
i++
# Auto-incremented number, starting at 0.
# Relies on function defualts being evaluated only once and lists being mutable.
def ipp(__i=[-1]):
'''This is a dirty hack'''
__i[0] += 1
return __i[0]
@calvingiles
calvingiles / GCD.py
Last active December 30, 2015 07:19
Return the greatest common denominator of a and b.
def GCD(a, b):
if b:
return GCD(b, a % b)
return a
@calvingiles
calvingiles / kmeans_ex_log.r
Created October 7, 2013 19:12
log scaling of k-means example
library(stats)
library(ggplot2)
set.seed(1)
# for our first example, let's create some synthetic easy-to-cluster data
d <- data.frame()
d <- rbind(d, data.frame(x=1 + rnorm(20, 0, 0.1), y=1 + rnorm(20, 0, 0.1), label=as.factor(rep(1, each=20))))
d <- rbind(d, data.frame(x=1 + rnorm(20, 0, 0.1), y=3 + rnorm(20, 0, 0.1), label=as.factor(rep(2, each=20))))
d <- rbind(d, data.frame(x=3 + rnorm(20, 0, 0.1), y=1 + rnorm(20, 0, 0.1), label=as.factor(rep(3, each=20))))
d <- rbind(d, data.frame(x=3 + rnorm(20, 0, 0.1), y=3 + rnorm(20, 0, 0.1), label=as.factor(rep(4, each=20))))