Skip to content

Instantly share code, notes, and snippets.

@gordonbrander
gordonbrander / dom.js
Last active November 6, 2022 09:18
Dom from simple VDOM
const dom = ({tag='div', attributes={}, styles={}, classes=[], text=null, children=null}) => {
const el = document.createElement(tag)
el.className = classes.join(' ')
for (let [key, value] of Object.entries(attributes)) {
if (value) {
el.setAttribute(key, value)
}
}
@gordonbrander
gordonbrander / hollywood-vs-sw.md
Last active July 21, 2019 20:12
Hollywood vs Software
@gordonbrander
gordonbrander / webvr-daydream.md
Last active January 31, 2023 22:21
How to get WebVR working with Daydream

How to get WebVR working with your brand-new Daydream View & Pixel.

  1. Update Daydream app to latest (Play Store)
  2. Update Chrome app to latest (Play Store)
    • Tip: if you're feeling brave, download Chrome Canary instead. Better perf and new features.
  3. Update Google VR Services (Play Store)
  4. Open chrome://flags/#enable-webvr
    • Click "Enable"
  5. Open chrome://flags/#enable-vr-shell
    • Set dropdown to "Enabled"
@gordonbrander
gordonbrander / vendor_all_the_firmware.py
Last active March 24, 2017 15:11
Vendor all openag firmware in one fell swoop
"""
This script fetches the latest master of all of the openag firmware repositories, then removes the `.git`, etc.
"""
import subprocess
import argparse
from os import path
LIBS = set((
"https://github.com/OpenAgInitiative/openag_firmware_module.git",
"https://github.com/OpenAgInitiative/rosserial_arduino_libs.git",
@gordonbrander
gordonbrander / general_greens.json
Last active February 9, 2017 09:22
General Greens
{
"_id": "general_greens",
"recipe_format": "phased",
"version": "1.0",
"optimization": [
"general purpose"
],
"date_created": "2017-02-08",
"author": "openag",
"stages": [
@gordonbrander
gordonbrander / memoize.py
Last active December 20, 2016 23:36
memoize.py
class Memoize:
"""
Memoize a function based on the arguments passed in. Example::
@Memoize
def foo(x, y): return x + y
"""
def __init__(self, f):
self.__function = f
self.__cache = {}
@gordonbrander
gordonbrander / phase_recipe.yml
Last active February 8, 2017 06:20
Phase Recipe
# Implementation ideas:
# run this past sentient to verify vector based approach is better than timeseries
# get better nutrient data from gen hydro catalogue
# run this past Arielle to see if this is a good default basil recipe
# check this against Dan's grow data to verify this is a good default basil recipe
# evaluate plausability of auto-generating this recipe format from Dan's grow data
# run this past x10 people on the team to see if this is an intuitive way to create recipes
# ask people on the forum if they like this method of creating recipes?
# Why is this idea interesting?
@gordonbrander
gordonbrander / long_test_recipe.json
Created September 8, 2016 20:23
long_test_recipe
{
"_id": "long_test_recipe",
"format": "simple",
"operations": [
[
0,
"air_temperature",
25
],
[
@gordonbrander
gordonbrander / food_computer_1.0.json
Last active August 30, 2016 18:04
food_computer_1.0.json
{
"firmware_module": [
{
"_id": "ds18b20_1",
"type": "ds18b20",
"environment": "environment_1",
"arguments": [4],
"outputs": {
"temperature": {"variable": "water_temperature"}
}
@gordonbrander
gordonbrander / multimethods.lua
Last active August 29, 2023 14:34
Lua multimethods
--[[
Lua multimethods. Inspired by Clojure's multimethods.
How to use it:
local Multi = require('multimethods')
-- Create a new multimethod and use isa as dispatch function.
-- This will dispatch on first argument by type.
local foo = Multi.create(isa)