Skip to content

Instantly share code, notes, and snippets.

@Rob-ot
Rob-ot / gist:877963
Created March 20, 2011 00:55
CSS only tabs
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Nav thing</title>
<style type='text/css'>
input {
display: none;
}
#link1:checked ~ #content1,
var updateAvgFps = (function (fpsElm) {
var fpsMap = [0,0,0,0,0,0,0,0,0,0],
avgFps = 0,
lastTime = new Date().getTime(),
drawCount = 0;
if (! fpsElm) {
fpsElm = document.createElement("div");
fpsElm.style.position = "absolute";
fpsElm.style.right = "5px";
@Rob-ot
Rob-ot / test.html
Created March 29, 2011 05:03
A nice little wrapper for web workers, I will be hacking on this more because I plan on using it for a game. Live version (for now) http://middlerob.com/tasky/ dont forget to open console
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tasky</title>
<style>
</style>
</head>
@Rob-ot
Rob-ot / gist:1027804
Created June 15, 2011 18:53
javascript tilde operator with indexOf
> var a = ["a", "b"]
> a.indexOf("a")
0
> a.indexOf("b")
1
> a.indexOf("c")
-1
> ~a.indexOf("a")
-1
> ~a.indexOf("c")
@Rob-ot
Rob-ot / gist:1094018
Created July 19, 2011 23:43
Empty image src checker
// put in head right after jquery
(function () {
function check ($e) {
if ($e.attr("src") == "") {
console.log($e)
}
}
$(window).bind("DOMNodeInserted", function (e) {
@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',
@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 / 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 / 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
;(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',