Skip to content

Instantly share code, notes, and snippets.

View tshaddix's full-sized avatar

Tyler Shaddix tshaddix

View GitHub Profile
@tshaddix
tshaddix / SnapPositionHelper.cs
Last active November 19, 2020 01:32
Oculus uses a property called `snapOffset` in its sample framework to help snap a holdable object to a position in a hand whenever it is grabbed. This is handy, but the way it is implemented is pretty janky and uses a local rotation of the hand before applying the transformation. If you use something like an Oculus Quest, it takes way too long t…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SnapPositionHelper : MonoBehaviour
{
public OVRGrabber hand;
public Transform snapOffset;
void Update()
@tshaddix
tshaddix / DataClient.js
Last active November 17, 2016 17:27
FlowType MySql DataClient
// @flow
// @author tyler
import mysql from 'mysql';
import type {IConfigReader} from '../ConfigReader';
export type TDataRow = *;
export type TDataClientType = 'mysql' | 'sqlite3';
@tshaddix
tshaddix / ed.js
Last active March 31, 2016 14:59
The simplest service strictifier ever
import Joi from 'joi';
import _ from 'lodash';
import {
BadRequestError
} from './errors';
const _promisedValidate = (msg, schema) => {
return new Promise((resolve, reject) => {
Joi.validate(msg, schema, {
@tshaddix
tshaddix / app-errors.es6.js
Last active January 18, 2016 19:29
App errors for JS applications that loosely match the specs of JSON API.
import util from 'util';
class AppError {
constructor(message) {
Error.call(this);
Error.captureStackTrace(this, this.constructor.name);
this.name = this.constructor.name;
this.message = message;
}
@tshaddix
tshaddix / param.go
Created September 4, 2014 19:34
Gorilla Mux param decoder for tshaddix/parcel package. Decodes params into struct fields and allows for slice population based on deliminator.
package pogs
import (
"net/http"
"reflect"
"strings"
"github.com/gorilla/mux"
"github.com/tshaddix/parcel/encoding"
)
@tshaddix
tshaddix / ns-cents.js
Created May 29, 2014 17:31
Angular cents directive for validation
/**
* Created by tyler on 5/1/14.
*/
(function(){
'use strict';
angular.module('fsApp')
.directive('nsCents', [function () {
@tshaddix
tshaddix / upload-controller.js
Last active February 21, 2018 22:33
Busboy + GridFS + Express4
var Busboy = require('busboy'),
Grid = require('gridfs-stream'),
mongoose = require('mongoose'),
router = module.exports = require('express').Router();
var gfs = new Grid(mongoose.connection.db, mongoose.mongo);
router
.get('/:item/receipt/info', function(req, res, next){
gfs.files.find({
@tshaddix
tshaddix / delta.js
Last active December 23, 2015 17:09
Delta Service
/*
* Checks two Date objects based on human date (mm/dd/yyyy) two test equality
*
* @param {Date} date1
* @param {Date} date2
* @return {Boolean}
*/
function sameHumanDate(date1, date2){
if (date1.getDate() === date2.getDate() &&
date1.getFullYear() === date2.getFullYear() &&
@tshaddix
tshaddix / geochart.js
Last active December 21, 2015 09:59
Using a geochart with OOcharts
oo.load(function(){
var regionQuery = new oo.Query('PROFILE ID', "30d");
//Add metrics, dimensions, and filter for region
regionQuery.addMetric('ga:visits');
regionQuery.addDimension('ga:metro');
regionQuery.setFilter('ga:region==California');
regionQuery.execute(function(data){
@tshaddix
tshaddix / angular.js
Last active December 21, 2015 00:58
Allowing CORS with ExpressJS and AngularJS
// Add COR ability
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
$httpProvider.defaults.withCredentials = true;