Skip to content

Instantly share code, notes, and snippets.

View micahscopes's full-sized avatar
🐢

Micah micahscopes

🐢
View GitHub Profile
@micahscopes
micahscopes / index.html
Created June 5, 2012 07:51 — forked from mbostock/.block
Graph from a matrix.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Linux (vers 25 March 2009), see www.w3.org">
<meta http-equiv="Content-type" content=
"text/html; charset=us-ascii">
<title>Graph from a matrix</title>
<script type="text/javascript" src=
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Linux (vers 25 March 2009), see www.w3.org">
<meta http-equiv="Content-type" content=
"text/html; charset=us-ascii">
<title>Graph from a matrix</title>
<script type="text/javascript" src=
import bge
cont = bge.logic.getCurrentController()
VertexShader = """
uniform float leftIsoclinic[ 4 ];
uniform float rightIsoclinic[ 4 ];
uniform float radius;
uniform float offset[ 3 ];
varying vec3 vNormal;
@micahscopes
micahscopes / failure.cpp
Created August 3, 2012 12:24
Sd2Card.init() is successful vs. not successful
//SD Card Library
#include <stdlib.h>
#include <stdint.h>
#include <SdFat.h>
#include <algorithm>
uint16 bufferA[40];
uint16 bufferB[40];
uint16 * incomingBuffer = bufferA;
uint16 * outgoingBuffer = bufferB;
@micahscopes
micahscopes / batch_import_obj.py
Last active April 14, 2022 11:33
Batch import a folder of Wavefront OBJ files to Blender. It used to be that you could do this with the built-in OBJ import/export script, but I've been getting an error with that. Here's a workaround.
import os
import bpy
path_to_dir = "/directory/full/of/obj/files/"
files_in_dir = os.listdir(path_to_dir)
for file_in_dir in files_in_dir:
bpy.ops.import_scene.obj(filepath=path_to_dir+file_in_dir)
@micahscopes
micahscopes / index.html
Last active February 8, 2022 16:54
A/V hybrid synth (routes pixels from a WebGL to WebAudio)
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<title>reaction diffusion space ship (a/v synth)</title>
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aPos;
attribute vec2 aTexCoord;
varying vec2 pixel;
void main(void) {
gl_Position = vec4(aPos, 1.);
@micahscopes
micahscopes / index.html
Last active August 29, 2015 14:00
rock paper scissors -> RGB -> FM modulation (WebAudio/WebGl a/v synthesis)
<html><head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<title>Rock Paper Scissor battling in RGB, FM modulating three sine waves | WebGL GPGPU + WebAudio</title>
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aPos;
attribute vec2 aTexCoord;
varying vec2 uv;
varying vec2 uv_orig;
void main(void) {
gl_Position = vec4(aPos, 1.);

Click in the open space to add a node, drag from one node to another to add an edge.
Ctrl-drag a node to move the graph layout.
Click a node or an edge to select it.

When a node is selected: R toggles reflexivity, Delete removes the node.
When an edge is selected: L(eft), R(ight), B(oth) change direction, Delete removes the edge.

To see this example as part of a larger project, check out Modal Logic Playground!

<html>
<body>
<h1>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</h1>
</body>
</html>
@micahscopes
micahscopes / squash.py
Last active February 3, 2016 06:39
flatten nested lists/tuples
squash = lambda l: reduce(lambda x,y: x+y,map(lambda e: squash(e) if isinstance(e,(list,tuple)) else [e], l), [])
squash([1,2,(3,[4,5])]) # => [1,2,3,4,5]
# an real world example ;)
"\n".join(squash([header,body,footer]))
# => <html>\n<body><h1>Hello World!</h1></body>\n</html>
# observe that the sections could be any kind of mess of nested arrays.
# but in the end, all we really care about is that they get strung together