This file contains hidden or 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
| require 'rubygems' | |
| require 'spec' | |
| module Transformable | |
| private | |
| def transform(&block) | |
| copy = self.clone | |
| copy.instance_eval(&block) |
This file contains hidden or 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
| gem list '\A(?:(?:d[mo])[_-]|data_?(?:mapper|objects)|extlib)' --no-versions \ | |
| | xargs gem uninstall -aIx |
This file contains hidden or 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
| require 'rubygems' | |
| require 'eventmachine' | |
| require 'em-websocket' | |
| require 'json' | |
| class Connection | |
| attr_accessor :socket, :user_id | |
| def initialize(socket, user_id) | |
| @socket = socket |
This file contains hidden or 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
| # workaround from | |
| # http://stackoverflow.com/questions/1987386/foreign-key-name-in-datamapper-associations | |
| field_naming_convention = lambda do |v| | |
| if v.name.to_s[0..0] == v.name.to_s[0..0].upcase | |
| v.name.to_s | |
| else | |
| DataMapper::NamingConventions::Field::Underscored.call(v) | |
| end | |
| end |
This file contains hidden or 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
| # Sample configuration file for Unicorn (not Rack) | |
| worker_processes 1 | |
| # listen on the sinatra port | |
| listen 4567 | |
| # feel free to point this anywhere accessible on the filesystem | |
| pid PIDFILE = "#{ENV['XDG_CACHE_HOME']}/unicorn.pid" | |
| stdout_path "#{ENV['XDG_CACHE_HOME']}/unicorn.log" |
This file contains hidden or 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
| require 'sinatra/base' | |
| module M1 | |
| def self.apps | |
| @apps ||= {} | |
| end | |
| class A < Sinatra::Base |
This file contains hidden or 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
| require 'openid' | |
| require 'openid/consumer' | |
| require "openid/store/filesystem" | |
| require 'openid/extensions/sreg' | |
| class LoginController < ApplicationController | |
| def create | |
| response = openid_consumer.begin(params[:openid_url]) | |
| sregreq = ::OpenID::SReg::Request.new | |
| sregreq.request_fields(["email"], true) |
This file contains hidden or 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/ruby | |
| # Copyright (c) 2010 Jonathan Stott, unless otherwise noted | |
| # | |
| # Permission is hereby granted, free of charge, to any person ob- | |
| # taining a copy of this software and associated documentation | |
| # files (the "Software"), to deal in the Software without restric- | |
| # tion, including without limitation the rights to use, copy, modi- | |
| # fy, merge, publish, distribute, sublicense, and/or sell copies of | |
| # the Software, and to permit persons to whom the Software is fur- | |
| # nished to do so, subject to the following conditions: |
This file contains hidden or 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
| require 'action_view' | |
| require 'active_support' | |
| require 'mustache' | |
| class Mustache | |
| # TODO - Think about allowing to overwrite layout methods in subclassing views | |
| # | |
| # http://github.com/defunkt/mustache/blob/master/lib/mustache/sinatra.rb#L79-82 | |
| # http://github.com/defunkt/mustache/blob/master/lib/mustache/sinatra.rb#L96-102 |
This file contains hidden or 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 ApplicationController < ActionController::Base | |
| before_filter :compound_date_values | |
| protected | |
| def compound_date_values(h=params,prefix=[]) | |
| to_fix = {} | |
| h.each do |k, v| | |
| if v.is_a? Hash |