Skip to content

Instantly share code, notes, and snippets.

View fogleman's full-sized avatar

Michael Fogleman fogleman

View GitHub Profile
@fogleman
fogleman / draw.go
Created February 17, 2016 22:32
Drawing in Go?
package main
import (
"image"
"image/draw"
"image/png"
"os"
"github.com/golang/freetype/raster"
"golang.org/x/image/math/fixed"
@fogleman
fogleman / dla2.go
Created February 2, 2016 20:23
Diffusion-Limited Aggregation
package main
import (
"fmt"
"image"
"image/color"
"image/png"
"math/rand"
"os"
)
@fogleman
fogleman / dla.go
Created February 2, 2016 03:42
Diffusion Limited Aggregation
package main
import (
"fmt"
"math"
"math/rand"
"github.com/ungerik/go-cairo"
)
@fogleman
fogleman / makeblock-xy-plotter.md
Last active February 24, 2016 18:05
Getting Started with the Makeblock XY Plotter 2.0

Assembly is straightforward but takes a while. Comes with all the tools you need. Everything is metric. I recommend labeling the screw packets before starting so you know which size is which.

I ended up tightening the drive belts after initial assembly, which is tough to do. I used vise grips to help.

I also added a couple washers (of my own) to the pen mechanism to reduce slop. On either side of the arm that raises / lowers the pen.

There are two software packages, one is Windows only (Benbox) and the other is cross-platform (mDraw). I've only used mDraw. Each ships with its own firmware I think.

Their software is crappy but good enough as a starting point. It's easy to roll your own software in any language that can connect to the serial port. Baud rate is 115200.

@fogleman
fogleman / timer.py
Created January 14, 2016 23:06
Simple Timer App
import bisect
import math
import random
import time
import wx
FONT = 'Courier'
MAX_SECONDS = 60 * 10
class Panel(wx.Panel):
@fogleman
fogleman / dragon.py
Created December 30, 2015 16:36
Dragon Curve with Turtle Graphics (Python)
import turtle
def turn(i):
left = (((i & -i) << 1) & i) != 0
return 'L' if left else 'R'
def curve(iteration):
return ''.join([turn(i + 1) for i in range(2 ** iteration - 1)])
if __name__ == '__main__':
@fogleman
fogleman / thing.scad
Created September 14, 2015 12:36
Thing
module pill() {
difference() {
hull() {
sphere(10, $fn=36);
translate([40, 0, 0])
sphere(10, $fn=36);
}
translate([0, 0, 14])
hull() {
sphere(5, $fn=36);
@fogleman
fogleman / main.go
Created August 21, 2015 00:54
Go 1.5 Crash
package main
import (
"fmt"
"log"
"github.com/go-gl/gl/v2.1/gl"
"github.com/go-gl/glfw/v3.1/glfw"
"github.com/ungerik/go-cairo"
)
@fogleman
fogleman / fabmo.py
Created July 12, 2015 00:14
Fabmo API Wrapper
import json
import requests
import sys
HEADERS = {'content-type': 'application/json'}
class Fabmo(object):
def __init__(self, host, port=9876):
self.url = 'http://%s:%s' % (host, port)
@fogleman
fogleman / merge.py
Created May 1, 2015 15:58
Sum Dictionary Tuples
import operator
def merge(dicts):
result = {}
keys = reduce(operator.or_, [set(d) for d in dicts])
for key in keys:
values = [d[key] for d in dicts if key in d]
result[key] = tuple(reduce(operator.add, x) for x in zip(*values))
return result