Skip to content

Instantly share code, notes, and snippets.

@alecperkins
alecperkins / gist:2322939
Created April 6, 2012 21:06
+postclear Compass mixin
// Adds a pseudo element :after that clears floats, preventing them from riding
// up into the element, while still allowing the element to wrap around floats
// before it. This is useful for ensuring floating elements remain in place,
// vertically, when the non-floating elements are too short to push them down.
=postclear($side: both)
&:after
content: " "
display: block
clear: $side
@alecperkins
alecperkins / gist:2400075
Created April 16, 2012 17:20
The Fold bookmarklet: adds a cyan box showing 1024x768
javascript:function%20l()%7Bvar%20d=document,o=d.createElement('div'),o2=d.createElement('div');b=d.body;if(!b)throw(0);var s='z-index:2147483647;position:fixed;top:0;width:1024px;height:768px;left:50%;margin-left:-512px;pointer-events:none;border:1px%20solid%20cyan;';o.setAttribute('style',%20s+'height:768px;opacity:0.4');o2.setAttribute('style',s+'height:628px;opacity:0.8');b.appendChild(o);b.appendChild(o2)%7Dl();void(0)
$('h1').click ->
$(this).toggleClass('on')

Condimentum Amet

Dolor Pellentesque Inceptos

Vestibulum id ligula porta felis euismod semper. Donec sed odio dui. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vestibulum id ligula porta felis euismod semper. Nulla vitae elit libero, a pharetra augue. Vestibulum id ligula porta felis euismod semper.

Elit Mollis Egestas

Nulla vitae elit libero, a pharetra augue. Nulla vitae elit libero, a pharetra augue. Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod. Maecenas sed diam eget risus varius blandit sit amet non magna. Aenean lacinia bibendum nulla sed consectetur. Curabitur blandit tempus porttitor.

@alecperkins
alecperkins / namedview.coffee
Created August 8, 2012 21:12
NamedView: Backbone View with automatic className
# Public: A Backbone View that automagically adds CSS classes based on its
# CoffeeScript class names, going right up the inheritence chain. This
# is cool because it's less crap to write, and plays well with CSS.
#
# Given:
#
# class Person extends NamedView
# class Wizard extends Person
# harry = new Wizard()
#
@alecperkins
alecperkins / TodoMVC.TodoApp.coffee
Created August 15, 2012 19:57
TodoMVC tutorial in coffeescript
TodoMVC.module 'TodoApp', (App, TodoMVC, Backbone, Marionette, $, _) ->
log arguments
class App.TodoForm extends Marionette.ItemView
events:
'keypress #new-todo' : 'createOnEnter'
'click .mark-all-done' : 'toggleAllClicked'
triggers:
'click .todo-clear a' : 'clear:completed'
@alecperkins
alecperkins / _export.coffee
Created August 15, 2012 20:16
CoffeeScript export helper
window._export = (module, to_export...) ->
for cls in to_export
module[cls.name] = cls
# Usage:
# Export globally:
_export window,
MyModel
MyItemView
@alecperkins
alecperkins / markup.haml
Created September 6, 2012 20:02
[pad] - Choose-your-own-adventure proto
#story
@alecperkins
alecperkins / gist:3889507
Created October 14, 2012 19:03
Detect any XMLHttpRequests
// From: http://stackoverflow.com/questions/3596583/javascript-detect-an-ajax-event
var s_ajaxListener = new Object();
s_ajaxListener.tempOpen = XMLHttpRequest.prototype.open;
s_ajaxListener.tempSend = XMLHttpRequest.prototype.send;
s_ajaxListener.callback = function () {
// this.method :the ajax method used
// this.url :the url of the requested script (including query string, if any) (urlencoded)
// this.data :the data sent, if any ex: foo=bar&a=b (urlencoded)
console.log(this.method);
@alecperkins
alecperkins / interpolation.scss
Created October 15, 2012 15:08 — forked from idan/interpolation.scss
Kind of a hack
@function colorchoice($choice) {
@if $choice == "0" {
@return rgb(202,0,32);
}
@if $choice == "1" {
@return rgb(244,165,130);
}
@if $choice == "2" {
@return rgb(247,247,247);
}