Skip to content

Instantly share code, notes, and snippets.

Avatar

Gordon Brander gordonbrander

View GitHub Profile
@gordonbrander
gordonbrander / preload.js
Last active Apr 8, 2018
Preload images with promises
View preload.js
// Tip: use with await.
// const preloaded = await preloadAll(['img1.jpg', 'img2.jpg'])
export const preload = src => new Promise((resolve, reject) => {
const img = new Image()
img.onload = resolve
img.onerror = reject
img.src = src
})
View frame.js
// Promise for an animation frame.
// Tip: use with `await`.
export const frame = () => new Promise(requestAnimationFrame)
@gordonbrander
gordonbrander / dom.js
Last active Mar 26, 2020
Dom from simple VDOM
View dom.js
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 Jul 21, 2019
Hollywood vs Software
View hollywood-vs-sw.md
@gordonbrander
gordonbrander / webvr-daydream.md
Last active Aug 20, 2018
How to get WebVR working with Daydream
View webvr-daydream.md

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 Mar 24, 2017
Vendor all openag firmware in one fell swoop
View vendor_all_the_firmware.py
"""
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",
View general_greens.json
{
"_id": "general_greens",
"recipe_format": "phased",
"version": "1.0",
"optimization": [
"general purpose"
],
"date_created": "2017-02-08",
"author": "openag",
"stages": [
View 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 = {}
View phase_recipe.yml
# 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?
View long_test_recipe.json
{
"_id": "long_test_recipe",
"format": "simple",
"operations": [
[
0,
"air_temperature",
25
],
[
You can’t perform that action at this time.