Skip to content

Instantly share code, notes, and snippets.

View jamespantalones's full-sized avatar

James Singleton jamespantalones

View GitHub Profile
//get previous position, so hand doesn't jump on route changes
var xPos = 0;
var yPos = 0;
var storePos = function(x,y){
xPos = x;
yPos = y;
};
var getPos = function(){
@jamespantalones
jamespantalones / gist:e403ffa368b17bef326d
Created January 21, 2015 13:22
jchambers micro media query
// ---------------------------------
// Media query breakpoints & mixin
//
// Usage:
//
// @include mq("BREAKPOINT_NAME") { //styles }
$breakpoints: (
"extra-small" 500px,
@jamespantalones
jamespantalones / index.html
Last active August 29, 2015 14:18
Vanilla JS Video Setup
<!-- Basic setup. Preload none will load vids faster. I've left the src blank so we can dynamically swap videos if needed, but if
you want just one video, just add the src here -->
<video id="player" autoplay loop preload="none">
<source id="videomp4" src="" type="video/mp4">
<source id="videowebm" src="" type="video/webm">
</video>
@jamespantalones
jamespantalones / gulpfile.js
Last active September 20, 2015 09:30 — forked from mlouro/gulpfile.js
gulpfile.js with browserify, jshint, libsass, browserSync for livereload, image optimization and system notifications on errors
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var del = require('del');
var uglify = require('gulp-uglify');
var gulpif = require('gulp-if');
var exec = require('child_process').exec;
var notify = require('gulp-notify');
angular.module('progApp').factory('canvasState', function (drawService, Shapes) {
var clickzone = document.getElementById('clickzone');
var controls = document.getElementById('controls');
function CanvasState(canvas) {
this.canvas = canvas;
this.width = canvas.width;
this.height = canvas.height;
this.ctx = canvas.getContext('2d');
@jamespantalones
jamespantalones / draw-service.js
Created October 21, 2015 10:00
Canvas Draw Service
'use strict';
/* global async: false */
/**
* @ngdoc service
* @name progApp.drawService
* @description
* # drawService
* Factory in the progApp.
@jamespantalones
jamespantalones / overlay-service.js
Created October 21, 2015 10:01
Canvas Overlays
'use strict';
/**
* @ngdoc service
* @name progApp.overlayService
* @description
* # overlayService
* Factory in the progApp.
*/
angular.module('progApp').factory('Overlays', function () {
@jamespantalones
jamespantalones / routing.js
Created January 3, 2016 15:12
React universal routing demo
// client
import router from 'path/to/isomorphic/router';
import createLocation from 'history/lib/createLocation';
import createBrowserHistory from 'history/lib/createBrowserHistory';
const location = createLocation(document.location.pathname, document.location.search);
const history = createBrowserHistory();
router(location, history)
.then((reactEl) => {
const prefix = require('vendor-prefix')
import Tweezer from 'tweezer.js'
var transformPrefix = prefix('transform')
var linear = function (t, b, c, d) {
return c*t/d + b;
}
module.exports = function (el) {
@jamespantalones
jamespantalones / inflation.js
Created December 16, 2016 17:15
Calculate Annual Inflation
//--------------------------------------------
// Inflation
//
export const calculateInflation = ( priceArray ) => {
/*
--let's assume the price rises from 100 to 150 over a span of 42 days.
--that's obviously a 50% increase
--then look at days in full year: 365/42 = 8.690476
--for the annualization calculation, the 50% is expressed mathematically as 1.50, like this:
1.50^8.690476 (that is, taking that number and raising it to 8.69th power)