Skip to content

Instantly share code, notes, and snippets.

@febret
febret / domainCalc.js
Created September 20, 2018 19:57
Blog - chart domain calc
export function createDomain(values, symmetrical, includeZero) {
const dMax = d3.max(values);
const dMin = d3.min(values);
if (symmetrical) {
const largest = d3.max([Math.abs(dMax), Math.abs(dMin)]);
return [-largest, largest];
}
if (includeZero) {
if (dMin <= 0 && dMax <= 0) {
return [dMin, 0];
@febret
febret / linecolor.js
Created May 14, 2018 15:46
D3 conditional line coloring
// Draw a line out of multiple paths crossing upper and lower bounds.
// The path definitions ensure there are no gaps between segments.
const makeLine = (data, style) => {
let cx = this.xs(fastMoment(data[0][seriesxMet]));
let cv = data[0][seriesyMet];
let coords = [{x: cx, y: this.ys(cv), s: Math.sign(cv)}];
for (let i = 1; i < data.length; i++) {
let nx = this.xs(fastMoment(data[i][seriesxMet]));
let nv = data[i][seriesyMet];
// Add bound-crossing points.
@febret
febret / Grid.jsx
Last active May 14, 2018 15:44
Blog snippets
import React from 'react';
import {isFunction} from 'lodash';
import defaultStyles from './grid.scss';
/**
* Implements a generic grid component
* @prop data - an array of data items that the grid will render
* @prop config - grid configuration object
* The configuration object has two sections
* table - contains table-wide configuration settings:
@febret
febret / stereoTest.py
Created March 19, 2016 22:31
Stereo perception test
from cyclops import *
from random import *
from math import *
l = Light.create()
l.setPosition(0, 2, 0)
l.setAmbient(Color(0.5, 0.5, 0.5, 1))
s1 = SphereShape.create(0.5, 2)
s2 = SphereShape.create(0.5, 2)
@febret
febret / oinputserver-cave2.cfg
Last active November 17, 2016 02:12
cave2 oinputserver cfg
config:
{
//serverListenIP = "127.0.0.1";
serverPort = "28000";
// VRPN Controller device for CalVR
vrpnTrackerName = "Navigation";
vrpnTrackerPort = 3894;
checkForDisconnectedClients = false;
pointer:
{
type="cylindrical";
radius=3.238;
doorWidth = 36;
xBias = 0.0278;
minY = 0.305;
maxY = 2.625;
};
@febret
febret / spinningCubeActor.py
Created December 29, 2014 02:25
Actor Basic Example
# This example creates a spinning cube every time the user right-clicks on the window.
# A custom Actor keeps track of each cube spinning.
from math import *
from euclid import *
from omega import *
from omegaToolkit import *
from cyclops import *
# The actor list is needed to avoid garbage-collecting alive actors.
actors = []
@febret
febret / spin_navigation.py
Last active August 29, 2015 14:08
A small omegalib module for spinning/zooming a 3D model.
# Keys
# - Mouse Right button + movement rotates the model
# - Mouse wheel zooms in/out
# Use
# import spin_navigation
# spin_navigation.root = [root node that you want to manipulate]
from omega import *
from euclid import *
from math import *
@febret
febret / oinputserver.cfg
Created August 14, 2014 20:01
lyra oinputserver cfg
config:
{
serverPort = "28000";
// VRPN Controller device for CalVR
vrpnTrackerName = "Navigation";
vrpnTrackerPort = 3894;
checkForDisconnectedClients = false;
@febret
febret / pickActor.py
Created August 23, 2013 01:58
Actor picking
# Actor dictionary
actors = {}
# create a custom actor class
class Pickable(Actor):
node = None
def __init__(self):
# create something
node = SphereNode.create(1,2)
node.setSelectable(True)