Skip to content

Instantly share code, notes, and snippets.

View foxyblocks's full-sized avatar

Chris Schlensker foxyblocks

View GitHub Profile
@foxyblocks
foxyblocks / classic.js
Created January 25, 2015 07:02
Elevator Saga (classic elevator strategy)
{
init: function(elevators, floors) {
var floorsWaiting = {
up: [],
down: []
};
var self = this;
var distance = function(num1, num2) {
@foxyblocks
foxyblocks / train.js
Created January 25, 2015 07:02
Elevator Saga (Train strategy)
{
init: function(elevators, floors) {
var floorsWaiting = {
up: [],
down: []
};
var self = this;
var distance = function(num1, num2) {
@foxyblocks
foxyblocks / clock.module.js
Last active April 21, 2016 14:30
Angular JS Analog Clock directive
// Clock Directive
// Demo at http://embed.plnkr.co/W36A8G1dJfmbnXSnbl98/preview
// Uses SVG to render an analog clock
// Requires moment.js and also moment-timezone if you set the `zone` optional attribute.
// Usage
// <clock radius='40'></clock>
// You can also set the timezone
// <clock radius='40' zone='America/New_York'></clock>
module AnimalKingdom
def type
'Animal'
end
end
module PlantKingdom
def type
'Plant'
end
// This is a plugin for ImpactJS that Google Chrome
// rendering for the Macbook Pro with Retina display.
// Based on the solution offered on http://www.html5rocks.com/en/tutorials/canvas/hidpi/
// It probably have a negative impact on performance.
// Use wisely.
//
//
// Place this in lib/plugins/smart-resize.js
@foxyblocks
foxyblocks / gist:5871998
Last active December 19, 2015 00:58
Jquery Key Event mapping
KeyCodes =
K_CANCEL: 3
K_HELP: 6
K_BACK_SPACE: 8
K_TAB: 9
K_CLEAR: 12
K_RETURN: 13
K_ENTER: 14
K_SHIFT: 16
K_CONTROL: 17
// EMBLEM OUTPUT
window.require.register("templates/application", function(exports, require, module) {
module.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
this.compiledVersion = '1.0.rc.2';
helpers = helpers || Handlebars.helpers; data = data || {};
var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
buffer += "<div class=\"container-fluid\"><div class=\"navbar\"><div class=\"navbar-inner\"><a class=\"brand\">Hampsters</a><ul class=\"nav\"><li class=\"active\"><a>Home</a></li><li></li><li><a>Link</a></li></ul></div></div><p>Find me in <code>app/templates/application.emblem</code>";
@foxyblocks
foxyblocks / .ackrc
Created August 9, 2012 18:09
Ackrc
--type-set=mustache=.mustache
--type-set=css=.css,.scss,.less
--type-set=html=.html,.haml,.hamlc
--type-set=js=.js,.coffee
@foxyblocks
foxyblocks / env.rb
Created August 8, 2012 04:54
Conditional spork with cucumber
ENV["RAILS_ENV"] ||= 'test'
require 'pry'
# Conditional Spork.prefork (this comment is needed to fool Spork's `bootstrapped?` check)
if /spork/i =~ $0
require File.expand_path("../env_spork", __FILE__)
else
require File.expand_path("../env_base", __FILE__)
end
@foxyblocks
foxyblocks / gist:2314735
Created April 5, 2012 22:38
easy vim hash=>rocket and php $object->thingy
"Paste into your .vimrc
" for insert mode remap <c-l> to:
" Insert a hash rocket for ruby
" Insert a -> for php
function! SmartHash()
let ruby = match(expand("%"), '\(.rb\|.haml\)$') != -1
let php = match(expand("%"), '.php') != -1
if php