Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / jquery.draghover.js
Created September 27, 2012 13:52
jquery.draghover.js
/*
jquery.draghover.js
Emulates draghover event by tracking
dragenter / dragleave events of element + children.
https://gist.github.com/gists/3794126
http://stackoverflow.com/a/10310815/4196
@meleyal
meleyal / setup-sync-sublime-over-dropbox.sh
Created December 6, 2012 22:25
Set-up Sublime settings + packages sync over Dropbox
#!/bin/sh
#
# Set-up Sublime settings + packages sync over Dropbox
#
# Will sync settings + Installed plug-ins
#
# Tested on OSX - should support Linux too as long as
# you set-up correct SOURCE folder
#
# Copyright 2012 Mikko Ohtamaa http://opensourcehacker.com
@meleyal
meleyal / plugin-gc-test.coffee
Created March 15, 2013 15:32
Test jQuery plugins for memory leaks
window.installTest = ->
for i in [0...500]
els = $('[data-behavior~=plugin]')
els.each (idx, el) -> $(el).plugin().data('plugin').uninstall()
console.log i
@meleyal
meleyal / view-gc-test.coffee
Last active December 16, 2015 02:48
Test Backbone views for memory leaks
window.installTest = ->
views = []
viewClass = app.NotificationsView
options = { collection: new Backbone.Collection }
views.push(new viewClass(options)) for i in [0...500]
view.remove() for view in views
views = []
console.log "#{viewClass.name} installed and removed x #{i}"