Skip to content

Instantly share code, notes, and snippets.

View zbabtkis's full-sized avatar

Zachary Babtkis zbabtkis

View GitHub Profile
var AngleControlView = Backbone.View.extend({
tagName: 'canvas',
className: 'angle-control',
initialize: function() {
_.bindAll(this);
this.el.height = 200;
this.el.width = 200;
// Defaults for drawing background circle.
@zbabtkis
zbabtkis / gist:5613384
Created May 20, 2013 16:24
Better jQuery ToolTip -- Simple and works in Firefox!
$.fn.betterTip = function() {
var that = this;
function getTip() {
var tip = $('<div />', {'class': 'tooltip'});
tip.html($(this).attr('title'));
tip.css({
'position': 'absolute',
@zbabtkis
zbabtkis / gist:5639191
Last active December 17, 2015 16:29
Simple module function.
function module(require, func) {
for(var i = 0; i < require.length; i++) {
require[i] = window[require[i]];
}
exports[func].apply(this, require);
}
@zbabtkis
zbabtkis / gist:6009675
Created July 16, 2013 15:17
Your extremely controlling mother in code.
var Bani = (function() {
var types = {
'View': {
cool: 'hi',
age: new Date()
}
};
function extend(name, type, obj) {
var extension = function() {};
@zbabtkis
zbabtkis / Backbone LazyModel
Created August 29, 2013 23:55
Lazily load associated models and collections from a model easily.
(function(Factory) {
if(typeof define !== 'undefined') {
define(['backbone', 'underscore'], Factory);
} else if(typeof Backbone !== 'undefined'
&& typeof _ !== 'undefined'
&& typeof jQuery !== 'undefined') {
@zbabtkis
zbabtkis / SimpleNodeRouter.js
Last active December 23, 2015 09:19
Super simple router for node js applications. Can handle file requests as well as clean url paths. Instantiate the Router object by passing the following in as a single object argument. ``` { basePath: '../public/', routes: { '/': function(req, res) { req.url = 'index.html'; this.route(req, res); } } ``` You can define more routes later using th…
var fs = require('fs')
, Router;
/**
* Router Constructor
*
* Sets default router values and provides file serving functionality.
*
* @param {Object} options Used to set basePath and default GET routes for Router.
*/
@zbabtkis
zbabtkis / StyleCopier.js
Last active December 30, 2015 07:39
Utility function to copy rules from all stylesheets to another document
/**
* Utility function to copy rules from all stylesheets to another document
*
* @author Zachary Babtkis <zackbabtkis@gmail.com>
* @date December 4th 2013
* @License WTFPL
*/
/**
* copy styles
@zbabtkis
zbabtkis / LinkedList.js
Last active December 31, 2015 02:19
Arrayish Linked List in JavaScript
var LinkedList = function () {
"use strict";
var _this = this
, first
, last;
/**
* These hold data and link to the next node.
*
@zbabtkis
zbabtkis / ObjectObserver.js
Last active December 31, 2015 07:29
An Object.observe shim (use Object.observe = new ObjectObserver;)
ObjectObserver = function() {
var objects = []
, cache = []
, callbacks = [];
var compare = function(obj, old, change) {
var newObj = {};
for(var i in obj) {
if(obj.hasOwnProperty(i)) {
@zbabtkis
zbabtkis / CDB.js
Created December 17, 2013 16:47
Composition based database tool.
var DB = {};
DB.collections = {};
var Collection = function(Constructor, IndexInterface) {
var d = []
, i = new IndexInterface;
return {