Skip to content

Instantly share code, notes, and snippets.

View grandadmiral-thrawn's full-sized avatar

Fox Peterson grandadmiral-thrawn

  • Hire me?
  • Vancouver, wa
View GitHub Profile
<canvas></canvas>
<div></div>
@grandadmiral-thrawn
grandadmiral-thrawn / d3-gauge.js
Created February 14, 2018 21:51
from codepen.io d3-gauge
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.d3Gauge=n()}}(function(){return function n(t,e,r){function i(u,a){if(!e[u]){if(!t[u]){var c="function"==typeof require&&require;if(!a&&c)return c(u,!0);if(o)return o(u,!0);var l=new Error("Cannot find module '"+u+"'");throw l.code="MODULE_NOT_FOUND",l}var s=e[u]={exports:{}};t[u][0].call(s.exports,function(n){var e=t[u][1][n];return i(e?e:n)},s,s.exports,n,t,e,r)}return e[u].exports}for(var o="function"==typeof require&&require,u=0;u<r.length;u++)i(r[u]);return i}({1:[function(n,t,e){"use strict";function r(n,t){return this instanceof r?(this._el=n,this._opts=i(o,t),this._size=this._opts.size,this._radius=.9*this._size/2,this._cx=this._size/2,this._cy=this._cx,this._preserveAspectRatio=this._opts.preserveAspectRatio,this._min=this._opts.min,this._ma
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.xtend=e()}}(function(){return function e(n,r,o){function t(i,u){if(!r[i]){if(!n[i]){var d="function"==typeof require&&require;if(!u&&d)return d(i,!0);if(f)return f(i,!0);var p=new Error("Cannot find module '"+i+"'");throw p.code="MODULE_NOT_FOUND",p}var a=r[i]={exports:{}};n[i][0].call(a.exports,function(e){var r=n[i][1][e];return t(r?r:e)},a,a.exports,e,n,r,o)}return r[i].exports}for(var f="function"==typeof require&&require,i=0;i<o.length;i++)t(o[i]);return t}({1:[function(e,n,r){function o(){for(var e={},n=0;n<arguments.length;n++){var r=arguments[n];for(var o in r)t.call(r,o)&&(e[o]=r[o])}return e}n.exports=o;var t=Object.prototype.hasOwnProperty},{}]},{},[1])(1)});
@grandadmiral-thrawn
grandadmiral-thrawn / detecthover.js
Created November 25, 2017 23:01
detect hovering in js
(function() {
var matchfunc = null, prefixes = ["","ms","moz","webkit","o"], i, m;
for(i=0; i<prefixes.length; i++) {
m = prefixes[i]+(prefixes[i] ? "Matches" : "matches");
if( document.documentElement[m]) {matchfunc = m; break;}
m += "Selector";
if( document.documentElement[m]) {matchfunc = m; break;}
}
if( matchfunc) window.isHover = function(elem) {return elem[matchfunc](":hover");};
else {
@grandadmiral-thrawn
grandadmiral-thrawn / install.sh
Created August 1, 2017 10:10
install tools for a new mac
#!/usr/bin/sh
# scripts here are from http://blog.coldflake.com/posts/Minimal-Development-Setup-for-Mac-OS/#useful-apps. Find this to be a good setup for all.
# install brew package manager
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# install cask (makes apps of some brew)
brew install caskroom/cask/brew-cask
@grandadmiral-thrawn
grandadmiral-thrawn / install.sh
Created July 31, 2017 09:38
tensor-flow install python3.4 + with conda and gpu
#!/usr/bin/bash
# assumes you have conda as your python.
# can replace tensorflow with tensorflow-gpu
# if you've aliased paython3 to python, and pip3 to pip, stop you madness, google is trying to help you and you're forcing the installer to behave weird
conda update setuptools
curl https://bootstrap.pypa.io/ez_setup.py -o - | python
# prior to this installation, I had used, but they didn't work:
# pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.2.1-cp35-cp35m-win_amd64.whl
# pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.2.1-cp35-cp35m-win_amd64.whl
@grandadmiral-thrawn
grandadmiral-thrawn / enemy.swift
Created December 31, 2016 20:26
enemy animations from RW tutorials that are not implemented in production
// The RW tutorials with game kit show a variety of useful "enemy" functions. Want a simple place to grab from without opening the PDF later.
func spawnEnemy() {
// basic enemy positioning
let enemy = SKSpriteNode(imageNamed: "enemy")
enemy.position = CGPoint(
x: size.width + enemy.size.width/2,
y: CGFloat.random(
min: playableRect.minY + enemy.size.height/2,
max: playableRect.maxY - enemy.size.height/2))
@grandadmiral-thrawn
grandadmiral-thrawn / parse-example.swift
Created December 31, 2016 12:36
Node Websocket and native JSON parsing in Swift for socket.io type sockets
// This should go in your main ViewController or GameViewController. Some sockets want it in AppDelegate.swift. Using Starscream Socket here.
func websocketDidReceiveMessage(socket: WebSocket, text: String) {
//print("Received text: \(text)")]
// decode data
var data = text.data(using: .utf8)!
// data is like {message: "hi", data: "[{"tagId": "long number here", ...},{"tagId": "long number here"}]"}
if let parsedData = try? JSONSerialization.jsonObject(with: data) as! NSDictionary {
// value of the "data" key is actually array
let arrayed = parsedData["data"] as! NSArray
//check that it's array
@grandadmiral-thrawn
grandadmiral-thrawn / part-of-ViewController.swift
Last active December 24, 2016 02:22
Ray Wenderlich iOS tutorial 3; Swift has type inference
// In the View Controller the function can either declare variables upon instantiation
// or locally in the function
// But what's cooler is that you can set the function for that variable following declaration with a type specificfunction
// Like the variable difference shown here
@IBAction func showAlert() {
// we don't have to do local instance:
//var difference: Int
// instead Swift just knows
difference = currentValue - targetValue