Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kalley's full-sized avatar

Kalley Powell kalley

  • OneSignal
  • Houston, TX
View GitHub Profile
@kalley
kalley / canvas.js
Created February 7, 2014 18:06
Simple wrapper around canvas
var Canvas = (function() {
var Canvas = function(id, width, height) {
this.el = id.nodeName ? id : document.getElementById(id);
this.context = this.el.getContext('2d');
this._events = {};
if ( width || height ) this.size(width, height);
},
proto = Canvas.prototype,
started = false,
extendProto = function(p, obj) {
@kalley
kalley / styled-components.js.flow
Last active September 27, 2017 21:43
styled-components libdef that actually checks props and defaultProps
// @flow
type $npm$styledComponents$ComponentWithDefaultProps<
DefaultProps: {},
Props: {}
> = React$ComponentType<Props> & { defaultProps: DefaultProps }
type $npm$styledComponents$Interpolation =
| (<C: {}>(executionContext: C) => $npm$styledComponents$Interpolation)
| string

Keybase proof

I hereby claim:

  • I am kalley on github.
  • I am kalley (https://keybase.io/kalley) on keybase.
  • I have a public key ASAaiqievDn32ALvFULMGmDK18blZEjaN0dedGNRDvPX_Ao

To claim this, I am signing this object:

@kalley
kalley / Garmin.php
Created September 24, 2014 21:10
Garmin server for use with https://github.com/thephpleague/oauth1-client. Garmin doesn't have any public endpoints outside of authorization, so this takes that into account.
<?php
use League\OAuth1\Client\Server\Server;
use League\OAuth1\Client\Credentials\CredentialsInterface;
use League\OAuth1\Client\Credentials\TokenCredentials;
use League\OAuth1\Client\Credentials\TemporaryCredentials;
use League\OAuth1\Client\Credentials\CredentialsException;
use League\OAuth1\Client\Server\User;
use Guzzle\Http\Exception\BadResponseException;
(function($) {
var head = $('head');
$.cssCapture = function(selectors, manipulate) {
var stylesheets = document.styleSheets,
selectors = selectors.split(/\s*,\s*/),m
promises = [],
matched = [],
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Marionette Render Process</title>
<style>
body, select {
font-family: sans-serif;
}
ul {
Modernizr.testStyles('#modernizr { height: 50px; width: 50px; margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: 0; display: table; }', function(elem, rule) {
Modernizr.addTest('shaw', Math.round(window.innerHeight / 2 - 25) === elem.offsetTop);
});
@kalley
kalley / color.js
Last active December 20, 2015 10:39
Small class to create colors, output different formats (hex, rgb(a), hsl(a)), or interpolate between colors, for animation or just to mix them.
/*
* How to use
*
* var red = new Color('#f00');
* var green = new Color(0, 255, 0);
* var blue = new Color('rgb(0,0,255)');
* var yellow = new Color('hsla(60,100%,50%,.5)');
* var purple = new Color();
* purple.extend(Color.parse('800080'));
*
(function($, name) {
var $clone = $.fn.clone;
$.fn[name] = function() {
return this.map(function() {
var $this = $(this),
clone = $this.data('clone');
if ( ! clone ) {
// Setting data('clone') on clone so it can't be cloned
clone = $clone.call($this).data('clone', true);
$this.data('clone', clone);
// Using lodash so we can use isPlainObject
var
_ = require('lodash'),
Marionette = require('backbone.marionette');
var _constructor = Marionette.View.prototype.constructor;
Marionette.View = Marionette.View.extend({
constructor: function (attributes, options) {
var self = this;