Skip to content

Instantly share code, notes, and snippets.

View michaelbartnett's full-sized avatar

Michael Bartnett michaelbartnett

View GitHub Profile
@michaelbartnett
michaelbartnett / svfilter.m
Created November 30, 2011 21:52
svfilter from last dst lab hw
function svfilter(cutoff, Q)
% lowpass
[lpf_b, lpf_b] = fir1(10, cutoff, 'low');
% highpass
[hpf_b, hpf_b] = fir1(10, cutoff, 'high');
% bandpass
% For bandpass coefficients, the order is half of the passed in order parameter (has to be an even order beacuse of poles and zeroes)
@michaelbartnett
michaelbartnett / kb_boilerplate.pde
Created March 29, 2012 00:44
Boilerplate to get some slightly more useful keyboard input functions in Processing
import java.util.HashMap;
HashMap<Integer, Boolean> CodedKeys = new HashMap<Integer, Boolean>();
HashMap<Character, Boolean> CharKeys = new HashMap<Character, Boolean>();
void keyPressed() {
if (key == CODED) {
CodedKeys.put(keyCode, true);
} else {
CharKeys.put(key, true);
@michaelbartnett
michaelbartnett / DrawTerrain.cs
Created November 10, 2012 19:44
Generate flat terrain meshes in Unity by hand
using UnityEngine;
using IEnumerator=System.Collections.IEnumerator;
[RequireComponent(typeof(MeshRenderer))]
[RequireComponent(typeof(MeshFilter))]
[ExecuteInEditMode]
public class DrawTerrain : MonoBehaviour
{
public int rows = 3;
public int columns = 3;
@michaelbartnett
michaelbartnett / .gitattributes
Created November 10, 2012 21:24
Git meta files for a Unity Project
*.meta -diff
*.asset -diff
*.unity -diff
@michaelbartnett
michaelbartnett / Point.cs
Last active December 11, 2015 06:28
Value type enumerable line plotter
/// <summary>
/// Struct representing a 2D integral point.
/// Has GetHashCode and Equals methods, so you can use this in a
/// dictionary for sparse coordinate maps and other collections.
///
/// Supports addition and subtraction.
///
/// Point p0 = new Point(3, 4);
/// Point p1 = new Point(-5, 6);
/// Point p3 = p1 - p0; // => [-8, 2]
@michaelbartnett
michaelbartnett / mgeutils.py
Created January 17, 2013 22:18
mgeutils makes MongoEngine more fun to use ;P
"""mgeutils module
Decorators and convenience functions for using mongoengine
"""
from __future__ import unicode_literals
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import logging
@michaelbartnett
michaelbartnett / WebLite.cs
Created January 26, 2013 10:42
Simple wrapper class to make Unity's WWW class less awful to use.
using UnityEngine;
using System;
using System.Collections;
using System.IO;
using System.Text;
/// <summary>
/// Bare minimum wrapper for UnityEngine.WWW.
///
@michaelbartnett
michaelbartnett / ListExtensions.cs
Created March 4, 2013 21:37
Useful IList Extensions for C#/.Net
using System;
using System.Collections.Generic;
public static class ListExtensions
{
public static TList Populate<TList, TElem>(this TList list, TElem defaultValue) where TList : IList<TElem>
{
for (int i = 0; i < list.Count; i++) {
list[i] = defaultValue;
}
@michaelbartnett
michaelbartnett / MultiArray.cs
Created March 10, 2013 01:42
Wraps 1d C# arrays in a class via which you can easily index via 2D. Will add 3D later.
namespace Eppy
{
using System;
using System.Collections;
using System.Collections.Generic;
public class MultiArray2D<T> : IEnumerable<T>, IEnumerable
{
public int Width { get; private set; }
public int Height { get; private set; }
@michaelbartnett
michaelbartnett / gist:5509424
Created May 3, 2013 14:26
Output of HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install python3 2>&1
$ HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install python3 2>&1
==> Downloading http://python.org/ftp/python/3.3.1/Python-3.3.1.tar.bz2
Already downloaded: /Users/michaelbartnett/Library/Caches/Homebrew/python3-3.3.1.tar.bz2
tar xf /Users/michaelbartnett/Library/Caches/Homebrew/python3-3.3.1.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/python3/3.3.1 --enable-ipv6 --datarootdir=/usr/local/Cellar/python3/3.3.1/share --datadir=/usr/local/Cellar/python3/3.3.1/share --enable-framework=/usr/local/Cellar/python3/3.3.1/Frameworks
./configure --prefix=/usr/local/Cellar/python3/3.3.1 --enable-ipv6 --datarootdir=/usr/local/Cellar/python3/3.3.1/share --datadir=/usr/local/Cellar/python3/3.3.1/share --enable-framework=/usr/local/Cellar/python3/3.3.1/Frameworks
checking build system type... x86_64-apple-darwin10.8.0
checking host system type... x86_64-apple-darwin10.8.0
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit