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
# In config/initializers/local_override.rb: | |
require 'devise/strategies/authenticatable' | |
module Devise | |
module Strategies | |
class LocalOverride < Authenticatable | |
def valid? | |
true | |
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
require 'rubygems' | |
require 'socket' | |
include Socket::Constants | |
class ChatServer | |
def initialize | |
@reading = Array.new | |
@writing = Array.new | |
@clients = Hash.new |
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
ActiveRecord::Base.class_eval do | |
def self.find_by_anything(identifier) | |
matchable_columns = columns.reject { |column| [:binary, :boolean].include?(column.type) } | |
query_clauses = matchable_columns.collect do |column| | |
qualified_column_name = "#{table_name}.#{column.name}" | |
column_as_string = "CAST(#{qualified_column_name} AS CHAR)" | |
"#{column_as_string} = ?" | |
end | |
bindings = [identifier] * query_clauses.size |
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
def set_callback(name, *filter_list, &block) | |
mapped = nil | |
__update_callbacks(name, filter_list, block) do |target, chain, type, filters, options| | |
mapped ||= filters.map do |filter| | |
Callback.new(chain, filter, type, options.dup, self) | |
end | |
filters.each do |filter| | |
chain.delete_if {|c| c.matches?(type, filter) } |
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
# config/database.rb | |
config_file = Padrino.root("config", "mongoid.yml") | |
if File.exists?(config_file) | |
settings = YAML.load(ERB.new(File.read(config_file)).result)[Padrino.env.to_s] | |
::Mongoid.from_hash(settings) if settings.present? | |
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
#!/usr/bin/ruby | |
# | |
# Author: Dan Q ([email protected]) | |
# More information: http://www.scatmania.org/?p=4600 | |
# | |
# This program is free software. It comes without any warranty, to | |
# the extent permitted by applicable law. You can redistribute it | |
# and/or modify it under the terms of the Do What The Fuck You Want | |
# To Public License, Version 2, as published by Sam Hocevar. See | |
# http://sam.zoy.org/wtfpl/COPYING for more details. |
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 'torquebox-stomp' | |
class DemoStomplet | |
def initialize() | |
super | |
@subscribers = [] | |
# passthrough for local messages to skip auth | |
@passthrough_code = "e32f53ac7569ae3a1f692177" | |
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
require 'torquebox-stomp' | |
class SomeStomplet | |
def initialize() | |
@pending_subscribers = {} | |
@subscribers = {} | |
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
require 'torquebox-stomp' | |
class SomeStomplet | |
def initialize() | |
@pending_subscribers = {} | |
@subscribers = {} | |
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
# version 1 | |
require 'clockwork' | |
require './config/boot' | |
require './config/environment' | |
module DBBackedClockwork | |
extend Clockwork | |
# add a periodic job to update @@events |