Skip to content

Instantly share code, notes, and snippets.

View 7yl4r's full-sized avatar

Tylar 7yl4r

View GitHub Profile
@7yl4r
7yl4r / gist:d551ce280fce059bbbd7
Last active August 29, 2015 14:01
svg text wrapping with javascript and d3

I read plenty of other implementations on how to do this, but didn't care for any of them so here is my take on a drop-in solution for svg text wrapping.

usage

// set up your "text box" element however you want (without any text yet):
var textX = 150;
var textEl = techtree.treeSVG.append('text')
    .attr('x',textX)
@7yl4r
7yl4r / test PC #1 info
Last active August 29, 2015 14:14
test PC nfo
### OS ###
(lubuntu)
Distributor ID: Ubuntu
Description: Ubuntu 14.04 LTS
Release: 14.04
Codename: trusty
### browser ###
Chromium 37.0.2062.120 (Developer Build 281580) Ubuntu 14.04
OS Linux
@7yl4r
7yl4r / gist:3944a2d750697ddadabb
Created April 9, 2015 18:53
noflo square wave generator component?
noflo = require 'noflo'
exports.getComponent = ->
c = new noflo.Component
c.inPorts.add 'low', (event, payload) =>
@low = payload
c.inPorts.add 'high', (event, payload) =>
@high = payload
@7yl4r
7yl4r / gist:646e9c9e45764fd6be0c
Last active August 29, 2015 14:19
HBM noflo component base
noflo = require 'noflo'
exports.getComponent = ->
c = new noflo.Component
c.description = "base human-behavior-model component to build onto"
c.icon = "question"
# base in ports which all HBM components should have
@inPorts =
average: new noflo.Port 'number'
@7yl4r
7yl4r / gist:5003cca10d1a293a46d0
Created April 15, 2015 20:54
Vertical Align CSS
/* from http://zerosixthree.se/vertical-align-anything-with-just-3-lines-of-css/ */
/* works IE9+ */
/* parent of centered element (not _required_, just prevents blur in case of 1/2 pixel placement */
.parent-element {
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
}
@7yl4r
7yl4r / noflo.json
Last active August 29, 2015 14:20
noflo HBM
{
"properties": {
"name": "main",
"environment": {
"type": "noflo-browser",
"content": "probe reading:\n<div style=\"position: absolute; top:1.5em; right:0;\">\n <-0\n <div style=\"position: relative; top:180px; right:0;\">\n <-200\n </div>\n</div>\n<br><br>\n<canvas id=\"plot-canvas\" width=\"200\" height=\"200\"></canvas>\n<div>\n t=0days . . .\n <span style=\"position: absolute; right: 2em\">\n . . . 100days \n </span>\n</div>\n"
},
"icon": ""
},
@7yl4r
7yl4r / gist:b4cf4c76ee6b1b6f6510
Created May 16, 2015 19:58
CA Perfect Hash function?
input = "0 1 0" # example input bits
neighborhood_w = len(input) # 3
possible_states = 2^len(input)
# rule = neighbor-count mapped to indexes of original input [0,1,0], thus f(0) = input[0], etc
# edges do not wrap, padded w/ 0s
neighbor_count = "1 1 1"
public class WeaponListener implements BaseComponentListener {
@Override
public void run(BaseComponent comp, BaseComponentMessage msg, ListenableData data) {
ShootToMessage shootTo = (ShootToMessage) msg;
WeaponComponent wc = (WeaponComponent) comp;
// access to the player position
float x = data.x;
float y = data.y;
@7yl4r
7yl4r / runAllLayers.py
Last active August 29, 2015 14:24
Golly run all layers simultaneously
"""
Runs all layers simultaneously useful for viewing stacked layers.
Author: Tylar Murray (murray.tylar@gmail.com), 2015.
"""
import golly as g
import time
while True:
for layer_n in range(g.numlayers()):
@7yl4r
7yl4r / javascript-stack.md
Created September 29, 2015 06:30
toolkit notes

=== Unit Testing - Mocha ===

example use: HBM-PoC

.travis.yml

language: node_js node_js:

  • 0.10 script: npm test notifications: email: on_success: change # default: change