Skip to content

Instantly share code, notes, and snippets.

@Rob-ot
Rob-ot / gist:4464726
Created January 6, 2013 01:45
Override part of nib (http://visionmedia.github.com/nib/) that sets outline:0 in the reset.
// override the default reset-box-model because it sets outline: 0 which is naughty
reset-box-model() {
margin: 0
padding: 0
border: 0
}
global-reset()
reset-html5()
@Rob-ot
Rob-ot / jquery.offsets.coffee
Last active October 13, 2015 09:48
jquery.offsets.coffee
# jquery.offsets.coffee
# Rob Middleton - MIT License
define (require) ->
$ = require 'jquery'
cssObjectAdd = (object, left, top) ->
object.left += left
@Rob-ot
Rob-ot / unused.coffee
Created November 30, 2012 02:19
require js unused require finder
#!/usr/bin/env coffee
# A quick and dirty script to find non-required files when using requirejs
# r.js outputs the required file names so we just parse that and diff it with the files on disk
# npm install -g coffee-script
# npm install file path underscore
# then
# run this like this: ./unused.coffee grunt --no-color requirejs:prod
@Rob-ot
Rob-ot / fast_switch.py
Created September 12, 2012 16:19
Sublime plugin for fast file switching
# Quickly switch between files with the same name but a different extension
# add a shortcut to your user keymap file
# { "keys": ["super+alt+enter"], "command": "fast_switch" }
import sublime, sublime_plugin, os.path
def findfolder (file, folders):
for folder in folders:
if file.find(folder) == 0:
return folder
@Rob-ot
Rob-ot / prefixedCalc.js
Created August 20, 2012 01:23
Detect which prefixed css calc to use via javascript
// public domain, use it for whatever
// returns "calc", "-moz-calc", etc
// (no -ms because they already support it non-prefixed)
function prefixedCalc () {
var prefixes = ["","-webkit-","-moz-","-o-"], el
for (var i = 0; i < prefixes.length; i++) {
el = document.createElement('div')
el.style.cssText = "width:" + prefixes[i] + "calc(9px)"
if (el.style.length) return prefixes[i] + "calc"
;(function () {
var Modernizr
// run cb when the next animation is complate (or right away if there is no animation support)
var cssTransitionEnd = function (cb) {
var $self = $(this)
var transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd',
'MozTransition' : 'transitionend',
@Rob-ot
Rob-ot / TemplateView.js
Created March 29, 2012 01:35
Template View for Backbone + AMD
// use this as a starting point when adding a view
define([
'text!views/-------.html',
'views/View'
],
function (
template,
View
@Rob-ot
Rob-ot / gist:1782910
Created February 9, 2012 20:38
Firefox inspector trial run thoughts (FF 12.0a2 (2012-02-09))
There is no way to have the html editor open and not be inspecting. - because of this It is very hard to use, in order to see the whole page with no dimming I have to completely close the inspector
Bug: 2 tabs next to each other both with html inspector open, one tab without to the right, using keyboard shortcut (cmd-shift-[) quickly switch 2 tabs over.
Can't hover over htmelements in inspector to highlight it in the dom, have to click.
CSS changes don't update until you click off, would prefer on keyup.
no css attribute autocomplete
@Rob-ot
Rob-ot / Draggable.js
Created December 16, 2011 23:46
Draggable and dropable views for backbone, uses html5 drag and drop api, requires jquery and underscore, not tested in IE yet
return View.extend({
initialize: function () {
this.el.attr("draggable", "true")
this.el.bind("dragstart", _.bind(this._dragStartEvent, this))
},
_dragStartEvent: function (e) {
var data
if (e.originalEvent) e = e.originalEvent
e.dataTransfer.effectAllowed = "copy" // default to copy
@Rob-ot
Rob-ot / jquery.cssTransitionEnd.js
Created December 14, 2011 17:49
jQuery plugin that uses modernizr to detect css3 transition support and listens for transitionEnd or calls back right away if transitions are not supported
// jQuery plugin that uses modernizr to detect css3 transition support and listens for transitionEnd or calls back right away if transitions are not supported
// basically send this a cb and it will be run on transitionEnd or right away if transitionEnd is not supported
jQuery.fn.cssTransitionEnd = function (cb) {
// lifted from http://www.modernizr.com/docs/
var transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd',
'MozTransition' : 'transitionend',
'OTransition' : 'oTransitionEnd',