Skip to content

Instantly share code, notes, and snippets.

View maxidr's full-sized avatar

Maxi Dello Russo maxidr

  • mxHero
  • Buenos Aires, Argentina
  • X @maxidr
View GitHub Profile
@zerowidth
zerowidth / paginated_collection.js
Created November 18, 2010 22:04
first whack at pagination with backbone.js
// includes bindings for fetching/fetched
PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
this.page = 1;
},
fetch: function(options) {
options || (options = {});
this.trigger("fetching");
@mbleigh
mbleigh / Gemfile
Created March 21, 2012 03:14
Non-Rails Rackup with Sprockets, Compass, Handlebars, Coffeescript, and Twitter Bootstrap
source "https://rubygems.org"
gem 'sprockets'
gem 'sprockets-sass'
gem 'sass'
gem 'compass'
gem 'bootstrap-sass'
gem 'handlebars_assets'
gem 'coffee-script'
@ryandotsmith
ryandotsmith / instruments.rb
Created April 6, 2012 07:09
Sequel & Sinatra Instrumentation
module Instruments
def self.set_logger(l, m)
@logger = l
@method = m
end
def self.logger
@logger
end
@collinpeters
collinpeters / tomcat.sh
Created April 19, 2012 20:09
Tomcat 7 Debian LSB Script
#!/bin/sh
#
# /etc/init.d/tomcat -- startup script for the Tomcat 7 servlet engine
#
# Modified init-Script from Ubuntu Tomcat init-script
#
# 2010 - Sebastian Mogilowski - http://www.mogilowski.net/2010/12/11/install-tomcat-7-on-debian-lenny-with-virtual-hosts-and-apache2-integration/
# 2012 - Collin Peters - Added debug option
#
### BEGIN INIT INFO
@maccman
maccman / juggernaut.rb
Created June 26, 2012 02:49
Sinatra Server Side Event streaming.
# Usage: redis-cli publish message hello
require 'sinatra'
require 'redis'
conns = []
get '/' do
erb :index
end
@maccman
maccman / juggernaut_channels.rb
Created June 26, 2012 04:56
Sinatra Server Side Event streaming with private channels.
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = Hash.new {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do
@jordelver
jordelver / gist:3230399
Created August 1, 2012 20:25
Ruby simple delegator
# Example from http://mikepackdev.com/blog_posts/31-exhibit-vs-presenter
class Decorator < SimpleDelegator
end
class Car
def price
1_000_000
end
end
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@matflores
matflores / gist:3692524
Created September 10, 2012 17:53
Fixing conflicts between Ghostscript & gs

Fixing conflicts between Ghostscript & gs

If you are using gs for managing your gem sets and you are also using any tool that relies on Ghostscript for converting PDF files to other formats (e.g. GraphicsMagick, docsplit, etc.), you may find that one of the two will fail due to a conflict between the two gs commands.

There are two possible solutions to this problem:

  • rename the gs command to something else (e.g. gset, gs_, etc), and leave Ghostscript's gs as the only gs command in your system.
  • edit GraphicMagick's delegates file and specify the full path to the gs command. This file is located in the lib/GraphicsMagick/config directory of your GraphicsMagick's installation. If GraphicsMagick was installed via homebrew, you can find the full path to this file by running brew list graphicsmagick | grep delegates.
@maxidr
maxidr / env.yml
Created October 11, 2012 13:28
Allows you to set environment variables in a YAML file at config/env.yml (from http://railswizard.org of intridea)
# in config/env.yml
defaults: &defaults
ENV_YAML: true
development:
<<: *defaults
test:
<<: *defaults