Skip to content

Instantly share code, notes, and snippets.

Michael Floering hangtwenty

Block or report user

Report or block hangtwenty

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hangtwenty
hangtwenty / easy_repr_mixin.py
Last active Aug 29, 2015
A mixin that gives an OK default for `__repr__`. Format is like "ClassName(attributeA='foo', attributeB='bar', propertyA='baz', propertyB='quux')" where each of those values is the `repr()` of the value.
View easy_repr_mixin.py
class EasyReprMixin(object):
""" A mixin that gives an OK default for `__repr__`.
I mix this into classes with instances that are static after creation,
i.e. with properties telling you about their contents. Wrappers for
data usually.
"""
def __repr__(self):
attributes = [
@hangtwenty
hangtwenty / harmonics.py
Last active Aug 29, 2015
Method to multiply (?) two sequences in certain way, that may be useful in generating sets of harmonic frequencies.
View harmonics.py
""" Functions to "multiply" sequences in peculiar way. Intended for use in generating sets harmonic frequencies.
.. moduleauthor:: hangtwenty
A friend of mine was wondering how to do something like this so I just had fun coming up with a solution.
I may use it in Supercollider or something if I can figure out how to glue Python and SC together.
"""
def flat_product_of_sequences(seq1, seq2):
""" Given two flat lists of integers, return this program's particular kind of product of them.
@hangtwenty
hangtwenty / install_jce_policy_jars.sh
Last active Aug 29, 2015
install Java Cryptography Extensions (unlimited JCE)
View install_jce_policy_jars.sh
# ABOUT: https://en.wikipedia.org/wiki/Java_Cryptography_Extension
# AUTHOR: gist.github.com/hangtwenty
# PREREQUISITE:
# Download jce_policy*.zip from Oracle:
# - Java 8: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
# - Java 7: http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
unzip $HOME/Downloads/jce_policy*.zip -d $HOME/Downloads/jce_policy_jars
jre_path="$JAVA_HOME/jre"
dest="$jre_path/lib/security"
@hangtwenty
hangtwenty / printSystemProperties.java
Created Jul 16, 2015
print system properties in Java
View printSystemProperties.java
Properties p = System.getProperties();
Enumeration keys = p.keys();
while (keys.hasMoreElements()) {
String key = (String)keys.nextElement();
String value = (String)p.get(key);
System.out.println(key + ": " + value);
}
@hangtwenty
hangtwenty / docker-guide.md
Last active Dec 2, 2015
Docker: from zero to multi-container setups
View docker-guide.md

Docker: from zero to multi-container setups

I've hacked some Docker. Here are the resources that were most essential for me.

What is Docker?

Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications. Consisting of Docker Engine, a portable, lightweight runtime and packaging tool, and Docker Hub, a cloud service for sharing applications and automating workflows, Docker enables apps to be quickly assembled from components and eliminates the friction between development, QA, and production environments. As a result, IT can ship faster and run the same app, unchanged, on laptops, data center VMs, and any cloud.

@hangtwenty
hangtwenty / prepareImageGallery
Last active Dec 16, 2015
A little script I used to take all images in a folder and generate two sizes of it - one thumbnail size, one large-but-not-too-large. For use in an online image gallery. This is still raw and could certainly be refactored a bit, but it gets the job done. This script generated the images for the gallery on FloeringPlastering.com. DEPENDS ON Image…
View prepareImageGallery
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# This script walks all images in current directory and all of its subdirectories
# (and so on). Two copies of each image are made, one of the size specified
# by --large and one of the size specified by --thumb. The copies are saved in
# a subdirectory named according to size, adjacent to the original file.
# For example, given the following structure:
#
# my_images/
@hangtwenty
hangtwenty / tiny_colored_bash_prompt.sh
Created May 9, 2013
Tiny colored prompt. I don't love it, but I've been using it for a while anyways. Best feature is that it is colorized based on the exit status of the previous command.
View tiny_colored_bash_prompt.sh
#########################################
## Prompt stylization and history sync ##
#########################################
bash_prompt_command() {
# Grab exit status of previous command
RTN=$?
prevCmd=$(prevCmd $RTN)
# Save and reload the history after each command finishes
@hangtwenty
hangtwenty / logging_subprocess.py
Last active Dec 22, 2015 — forked from bgreenlee/logging_subprocess.py
Variant of subprocess.call that accepts a logger instead of stdout/stderr
View logging_subprocess.py
import subprocess
import select
from logging import DEBUG, ERROR
def call(popenargs, logger, stdout_log_level=DEBUG, stderr_log_level=ERROR, **kwargs):
"""
Variant of subprocess.call that accepts a logger instead of stdout/stderr,
and logs stdout messages via logger.debug and stderr messages via
logger.error.
@hangtwenty
hangtwenty / livecoding-audio-and-visuals.md
Last active May 5, 2016
Some notes on Livecoding audio and visuals; centerpiece to a workshop at Dadaconf 0.1
View building-borderlands.md
title date description categories tags
Building Borderlands Granular on Ubuntu 12.04 LTS
2012-10-23
music
linux
music
linux
synth
granular

##What Borderlands is

You can’t perform that action at this time.