Skip to content

Instantly share code, notes, and snippets.

View Mause's full-sized avatar
:shipit:
Still trying to figure out what I'm doing

Elliana May Mause

:shipit:
Still trying to figure out what I'm doing
View GitHub Profile
#!/bin/bash
chown www-data:www-data /var/www/docs;
chmod go+rx -R /var/www/docs;
chmod go+rw -R /var/www/builds;
int main() {
system("chown www-data:www-data /var/www/docs;");
system("chmod go+rx -R /var/www/docs");
system("chmod go+rw -R /var/www/builds");
return 0;
}
@Mause
Mause / gist:d875f1f3c98b875a492a
Created June 8, 2015 19:05
Simple parametrized test case implementation
import unittest
from functools import wraps
def parametrized_class(klass):
for name, thing in list(vars(klass).items()):
if not hasattr(thing, 'cases'):
continue
cases = thing.cases
@Mause
Mause / gist:8f09062debae85a480d5
Created July 15, 2015 11:37
Efficient, lazy, iterator, python pairing
from itertools import chain, tee
def pairs(iterator):
"""
Returns the items in the iterator pairwise, like so;
>>> list(pairs([0, 1, 2]))
[(0, 1), (1, 2)]
"""
@Mause
Mause / gol.py
Created July 6, 2012 05:20
A silly implementation of conways game of life
"an implementation of conways game of life"
# File: gol.py
#
# Project: Conways game of life
# Component:
#
# Authors: Dominic May;
# Lord_DeathMatch;
# Mause
@Mause
Mause / sample.c
Last active October 12, 2015 10:07
Code sample for blog.
int main()
{
system("chown www-data:www-data /var/www/docs;");
system("chmod go+rx -R /var/www/docs");
system("chmod go+rw -R /var/www/builds");
return 0;
}
@Mause
Mause / csv_kml.py
Created November 4, 2012 14:53
Requires unidecode, can be got from the python package index
#!/usr/bin/env python
# -*- coding: LATIN-1 -*-
import sys
import csv
from xml.dom import minidom
from unidecode import unidecode
from xml.etree import ElementTree
from xml.etree.ElementTree import Element, SubElement, Comment
@Mause
Mause / Pipeline.py
Created April 7, 2013 04:32
Python generator pipelines demo
import types
class Pipeline(object):
def __init__(self, source):
if type(source) == types.FunctionType:
self.pipe = source()
else:
self.pipe = source
@Mause
Mause / decorator.py
Last active December 15, 2015 21:50
Decorator demo
def decorator(*arguments):
# this function recieves arguments passed to the decorator
def real_decorator(function):
# this function recieves the function we are decorating
def wrapper(*args, **kwargs):
# this function recieves the arguments intended for the function we are decorating
# print(args, kwargs)
# print(inspect.getargspec(function))
# print('args', arguments)
@Mause
Mause / gist:7559046
Created November 20, 2013 07:21
A simple inheriting dictionary implementation written in Python, with some inspiration taken from EmberJS' internals.
import collections
class InheritDict(collections.UserDict):
def __init__(self, data, parent=None):
for k, v in data.items():
if isinstance(data[k], dict):
data[k] = InheritDict(data[k], self)
super().__init__(data)