Skip to content

Instantly share code, notes, and snippets.

@mattfelsen
mattfelsen / sketch.pde
Last active August 29, 2015 13:57
Wall Drawing #271, Sol Lewitt, 1975
/*
Wall Drawing #271: Black circles, red grid, yellow arcs from four
corners, blue arcs from the midpoints of four sides
(ACG 195) 1975
Originally colored pencil on wall
Solomon R. Guggenheim Museum
New York
Recreated by Matt Felsen in Processing, 2014
@mattfelsen
mattfelsen / gist:10221243
Created April 9, 2014 02:40
Web-related setup on Ubuntu/AWS
Ubuntu web-related setup
# Install mysql extension for php
sudo apt-get install php5-mysql
# Enable mod_rewrite in Apache
sudo a2enmod rewrite
# Allow .htaccess to do mod_rewrite rules
# in /etc/apache2/httpd.conf or /etc/apache2/apache.conf or /etc/apache2/sites-enabled/000-default
@mattfelsen
mattfelsen / gist:10221247
Last active August 29, 2015 13:58
Installing nginx on rPi for increasing video streaming performance
# Taken from these two posts
# Note, I did not enable php support in nginx to keep things simple
# http://www.raspberrypi.org/forums/viewtopic.php?p=515259
# http://www.raspberrypi.org/forums/viewtopic.php?f=43&t=63276&p=502944&hilit=rpi+cam+web+interface+nginx#p502944
sudo apt-get install nginx
# edit nginx config
sudo nano /etc/nginx/nginx.conf
# disable gzip and logging for performance
@mattfelsen
mattfelsen / gist:69541387e4a9d610acca
Last active August 29, 2015 14:06
Raspberry Pi Related Things

SD card-related

Clone an SD card for backup

Use diskutil list to figure out which disk number the SD card is mounted as. Then:

sudo dd if=/dev/rdisk2 bs=1m | gzip > image.img.gz

Flash an image onto an SD card

@mattfelsen
mattfelsen / gist:9e0bae657104f98c2c95
Created October 13, 2014 15:58
WebSocket proxy server
var WebSocket = require('ws');
var WebSocketServer = require('ws').Server;
var client = new WebSocket('ws://localhost:7204/myo/1');
var wss = new WebSocketServer({ port: 9000 });
wss.broadcast = function(data) {
for (var i in this.clients) this.clients[i].send(data, function(){});
};
@mattfelsen
mattfelsen / setup.sh
Last active August 29, 2015 14:08
Local Projects openFrameworks New Project Setup
#!/bin/bash
#
# NOTE: The openFrameworks folder structure (particularly with regard to the projectGenerator)
# has changed since this script was written, so this will probably not work!
# (The parts about creating a new project toward the end, at least.)
#
#
# usage:
@mattfelsen
mattfelsen / gist:3b32e1dac09eb6ad3534
Created January 14, 2015 05:14
3D -> 2D on a Cylinder
float theta, x, y, z;
theta = ofDegToRad(230); // 0 -> 360
x = cylRadius * cos(theta);
y = cylHeight * -0.4; // -h/2 -> h/2
z = cylRadius * sin(theta);
ofVec3f center = cam.worldToScreen( ofVec3f(x, y, z) );
cam.end();
@mattfelsen
mattfelsen / gist:e174f032fa10fa16cfb5
Last active March 2, 2016 22:36
Useful Git Commands

Commits

Undo last commit

git reset --soft HEAD~1

Add stuff to last commit

git add file.cpp
git commit --amend
@mattfelsen
mattfelsen / software-setup.md
Last active July 27, 2016 17:19
So you got a new computer, eh?

So you got a new computer, eh?

Point & click stuff

Xcode

  • Monokai theme
  • OF Addon Plugin
  • Prefs
    • Text editing -> indentation -> prefer tabs
    • Text editing -> show line numbers, trim whitespace from empty lines
@mattfelsen
mattfelsen / gist:9dce6913b4e034045a13
Last active August 21, 2016 02:06
Useful OS X command line system stuff

Number of connected displays

system_profiler SPDisplaysDataType | grep Resolution | wc -l | sed 's/ //g'

Whether the system is sleeping or not

1 is alseep, 4 is not sleeping

ioreg -n IODisplayWrangler | grep -i IOPowerManagement | perl -pe 's/^.*DevicePowerState\"=([0-9]+).*$/\1/'

Set or check scheduled sleep/shutdown/wake settings