Skip to content

Instantly share code, notes, and snippets.

@meleyal
meleyal / backbone.bridge.coffee
Created June 18, 2012 10:45
Backbone Bridge v2
Backbone.View.bridge = (klass, namespace = window) ->
name = klass.charAt(0).toLowerCase() + klass.slice(1)
return unless namespace[klass]
console.log $.fn[name]
return $.fn[name] if $.fn[name]?
$.fn[name] = (options = {}) ->
$el = $(this)
opts = _.extend(options, { el: this })
ctor = new namespace[klass] opts
data = $el.data(name)
@meleyal
meleyal / html5-video-events.coffee
Created February 29, 2012 11:22
HTML5 video event listeners
# jquery on
next.on('canplay', ->
console.log('canplay')
# next.unbind('canplay')
)
next.on('canplaythrough', ->
console.log('canplaythrough')
# next.unbind('canplay')
@meleyal
meleyal / macvim-padding
Created February 24, 2012 18:42
Add padding to MacVim windows
defaults write org.vim.MacVim MMTextInsetTop '10'
defaults write org.vim.MacVim MMTextInsetLeft '10'
defaults write org.vim.MacVim MMTextInsetBottom '10'
defaults write org.vim.MacVim MMTextInsetRight '10'
@meleyal
meleyal / backbone-bridge.coffee
Created January 19, 2012 17:52
Backbone Bridge - jQuery syntax for creating Backbone views
# Backbone.View + jquery.widget.bridge
# https://gist.github.com/1641439
#
# Bridge Backbone views > jQuery.ui widget
# Allows instantiating BB views using jQuery
# e.g. $('.slideshow').slideshow()
#
# requires jquery.ui.widget
class window.Slideshow extends Backbone.View
@meleyal
meleyal / mp3_to_ogg.rb
Created December 7, 2011 09:20
Convert MP3s to OGG with ffmpeg
# INSTRUCTIONS
# - Put this file into a directory containing mp3s
# - Open in TextMate + run it (cmd+r)
dir = File.dirname(__FILE__)
mp3s = File.join(dir, "**", "*.mp3")
Dir.glob(mp3s) do |f|
@meleyal
meleyal / mp3_duration.rb
Created December 6, 2011 14:58
Get duration of all MP3s in a directory (recursively)
# INSTRUCTIONS
# - Puth this file into a directory containing mp3s
# - Open in TextMate + run it (cmd+r)
# - get_audio_length method via: http://bit.ly/sIKObq
dir = File.dirname(__FILE__)
mp3s = File.join(dir, "**", "*.mp3")
@meleyal
meleyal / simplegrid.scss
Created November 30, 2011 17:24
SimpleGrid
/*! -----------------------------------------------
* simplegrid.scss
* https://gist.github.com/gists/1409900/
* Custom version of 960.gs (http://960.gs/)
* Naming inspired by SimpleBits (http://simplebits.com/)
* Licensed under GPL and MIT
*
* Custom:
* - columns > 12
* - underscores > dashes
// Let's start with the basics
$base-color: #333;
$active-color: #ff8100;
$base-gradient: 'flat';
// Buttons
$button-gradient: 'bevel';
// Lists
$list-bg-color: #eee;
@meleyal
meleyal / optimize_images.rb
Created October 19, 2011 11:10
Simple png + jpg optimization script using optipng + jpegtran
#!/usr/bin/ruby
# Instructions
# - Install optipng + libjpeg (http://mxcl.github.com/homebrew/)
# - Put this file in a directory of images
# - Open in TextMate + run it (cmd+r)
# Config