Skip to content

Instantly share code, notes, and snippets.

View floer32's full-sized avatar

Michael Floering floer32

  • 16:46 (UTC -07:00)
View GitHub Profile
@floer32
floer32 / easy_repr_mixin.py
Last active August 29, 2015 13:55
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.
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 = [
@floer32
floer32 / harmonics.py
Last active August 29, 2015 13:56
Method to multiply (?) two sequences in certain way, that may be useful in generating sets of harmonic frequencies.
""" 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.
@floer32
floer32 / install_jce_policy_jars.sh
Last active August 29, 2015 14:25
install Java Cryptography Extensions (unlimited JCE)
# 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"
@floer32
floer32 / printSystemProperties.java
Created July 16, 2015 23:50
print system properties in 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);
}
@floer32
floer32 / prepareImageGallery
Last active December 16, 2015 13:38
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…
#!/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/
@floer32
floer32 / tiny_colored_bash_prompt.sh
Created May 9, 2013 16:43
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.
#########################################
## 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
@floer32
floer32 / logging_subprocess.py
Last active December 22, 2015 00:39 — forked from bgreenlee/logging_subprocess.py
Variant of subprocess.call that accepts a logger instead of stdout/stderr
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.
@floer32
floer32 / livecoding-audio-and-visuals.md
Last active May 5, 2016 04:02
Some notes on Livecoding audio and visuals; centerpiece to a workshop at Dadaconf 0.1
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

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>colorPalette</key>
<dict>
<key>ArchiveExpectationsBarBottomColor</key>
<dict>
<key>a</key>
<real>0.20000000000000001</real>