Skip to content

Instantly share code, notes, and snippets.

View bengolder's full-sized avatar

Ben Golder bengolder

  • Oakland, CA, USA
  • 00:47 (UTC -07:00)
View GitHub Profile
@bengolder
bengolder / gist:1001720
Created June 1, 2011 03:07
Useful Vim Commands
" The movement commands I use the most, besides h,j,k,l
{ or } " move forward or backward by paragraphs
( or ) " move forward or backward by sentences
W, w, B, b, E, e "These all move by words, if capitalized, it only uses whitespace to divide words.
"W/w moves to the beginning of the next word, B/b moves to the beginning of the
"previous word, and E/e moves to the end of the current/next word
_, $ " move to beginning(_) and end($) of line
gg "go to the top of the file
G " go to the end of the file
<number>G " go to line <number>
@bengolder
bengolder / gist:1019295
Created June 10, 2011 17:23
Grasshopper File and Geometry Import Script
import Rhino
# for accesssing GH classes
import clr
clr.AddReference("Grasshopper")
from Grasshopper.Kernel.Data import GH_Path
from Grasshopper import DataTree
@bengolder
bengolder / gist:1019860
Created June 10, 2011 21:57
layer_tree Grasshopper Python script
import Rhino
import scriptcontext
import System.Collections.Generic as SCG
# for accesssing GH classes
import clr
clr.AddReference("Grasshopper")
from Grasshopper.Kernel.Data import GH_Path
from Grasshopper import DataTree
@bengolder
bengolder / gist:1032493
Created June 17, 2011 22:22
Grasshopper File and Geometry Export Script
import System
import System.Collections.Generic as SCG
import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
from Rhino.FileIO import FileWriteOptions, FileReadOptions
def addRhinoLayer(layerName, layerColor=System.Drawing.Color.Black):
"""Creates a Layer in Rhino using a name and optional color. Returns the
import System
import Rhino
from scriptcontext import doc
tol = 0.001
class Brick(object):
@bengolder
bengolder / gist:1054969
Created June 29, 2011 21:05
Grasshopper Drain Boid Script
import Rhino
class DrainBoid(object):
def __init__(self, point3d, surface, stepsize=0.5, maxsteps=None, tolerance=0.001):
self.start = point3d
self.pos = self.start
result, self.u, self.v = surface.ClosestPoint(self.pos)
self.surface = surface
self.stepsize = stepsize
self.points = [self.start]
@bengolder
bengolder / gist:1055797
Created June 30, 2011 07:24
parsing Gernot's Construction Data
import os
import xlrd
'''
Look at the data format for d3.js here:
https://gist.github.com/1049893
'''
class Node(object):
def __init__(self, name, index):
@bengolder
bengolder / data.json
Created June 30, 2011 08:56
Data for Gernot
{"nodes":[
{"name":"Steel","index":0},
{"name":"Critical Studs, Heads of Wall","index":1},
{"name":"Kickers & Soffits","index":2},
{"name":"Ceilings","index":3},
{"name":"Ceiling Compression Posts","index":4},
{"name":"HVAC","index":5},
{"name":"Fire Sprinkler Mains","index":6},
{"name":"Waste & Vent","index":7},
{"name":"Fuel Oil","index":8},
@bengolder
bengolder / gist:1057297
Created June 30, 2011 21:34
Least Cost Path on mesh using NetworkX in Rhino
# import the sys and os libraries for adding modules
import sys
import os
# import the Rhino library
import Rhino
# manually write out the path to the folder
# where networkx is stored, as a list of strings
pathbits = [
@bengolder
bengolder / gist:1058187
Created July 1, 2011 09:46
TileStache Config Example
{
"cache": {
"name": "Disk",
"path": "/tmp/stache",
"umask": "0000",
"dirs": "portable"
},
"layers": {
"lots": {
"provider": {