This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# This script performs an OAuth authorized POST with multipart encoding to | |
# http://twitter.com/account/update_profile_image.json | |
# | |
# This code is primarily taken from my Grackle library's implementation at | |
# http://github.com/hayesdavis/grackle | |
# | |
# RUNNING THIS WILL CHANGE AN ACCOUNT'S PROFILE IMAGE. BE CAREFUL. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from: http://kfahlgren.com/blog/2006/11/01/multipart-post-in-ruby-2/ | |
# edited by makevoid, http://makevoid.com | |
URL = "http://localhost:3000/your_url" | |
TIMEOUT_SECONDS = 10 | |
params = {} | |
file = File.open(filename, "rb") | |
params["file[replay]"] = file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* XmlHttpRequest's getAllResponseHeaders() method returns a string of response | |
* headers according to the format described here: | |
* http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders-method | |
* This method parses that string into a user-friendly key/value pair object. | |
*/ | |
function parseResponseHeaders(headerStr) { | |
var headers = {}; | |
if (!headerStr) { | |
return headers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(($) -> | |
class Plugin | |
constructor: (@element, @settings) -> | |
console.log @element | |
@element.bind | |
'click' : @started | |
'blur' : @stopped | |
started: (e) => @settings.start.call @element, e | |
stopped: (e) => @settings.stop.call @element, e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// includes bindings for fetching/fetched | |
var PaginatedCollection = Backbone.Collection.extend({ | |
initialize: function() { | |
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage'); | |
typeof(options) != 'undefined' || (options = {}); | |
this.page = 1; | |
typeof(this.perPage) != 'undefined' || (this.perPage = 10); | |
}, | |
fetch: function(options) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this is a generic function which should be moved to a Baseclass of Backbone or a Backbone extension | |
autoBind = | |
{ | |
autoBind: function () { | |
var self = this; | |
var funcs = _.functions(this.constructor.prototype); | |
var protoFuncs = ['autoBind', 'constructor'].concat( | |
_.functions(Backbone.Collection.prototype), | |
_.functions(Backbone.Model.prototype), | |
_.functions(Backbone.View.prototype)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# db/migrate/20110714024435_split_author.rb | |
class SplitAuthor < ActiveRecord::Migration | |
def self.up | |
Post.where(:author=>nil).each do |p| | |
author = Author.create!(:name => p.author_name, | |
:account_id => p.account_id) | |
p.author = author | |
p.save! | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin border-radius($radius, $prefixes: -moz -webkit -o) { | |
@each $prefix in $prefixes { | |
#{$prefix}-border-radius:$radius; | |
} | |
border-radius:$radius; | |
} | |
#id { | |
@include border-radius(5px, -moz -webkit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for more info: https://gist.github.com/1120938 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# works exactly like `.bind()`, with the difference that it gets executed with a delay. | |
# Each time the event gets triggered again, the delay gets reset. | |
# | |
# based on: http://benalman.com/projects/jquery-throttle-debounce-plugin/ | |
# | |
# example: | |
# | |
# car = new Backbone.Model | |
# bind_triggered = debounce_triggered = 0 | |
# |
OlderNewer