Skip to content

Instantly share code, notes, and snippets.

View Fivell's full-sized avatar
🏠
Working from home

Igor Fedoronchuk Fivell

🏠
Working from home
View GitHub Profile
# In config/initializers/local_override.rb:
require 'devise/strategies/authenticatable'
module Devise
module Strategies
class LocalOverride < Authenticatable
def valid?
true
end
require 'rubygems'
require 'socket'
include Socket::Constants
class ChatServer
def initialize
@reading = Array.new
@writing = Array.new
@clients = Hash.new
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) }
# 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
@Fivell
Fivell / c301.rb
Created September 12, 2013 10:47 — forked from Dan-Q/c301.rb
#!/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.
require 'torquebox-stomp'
class DemoStomplet
def initialize()
super
@subscribers = []
# passthrough for local messages to skip auth
@passthrough_code = "e32f53ac7569ae3a1f692177"
end
require 'torquebox-stomp'
class SomeStomplet
def initialize()
@pending_subscribers = {}
@subscribers = {}
end
require 'torquebox-stomp'
class SomeStomplet
def initialize()
@pending_subscribers = {}
@subscribers = {}
end
@Fivell
Fivell / dbclock.rb
Created October 20, 2013 18:55 — forked from ianneub/dbclock.rb
# version 1
require 'clockwork'
require './config/boot'
require './config/environment'
module DBBackedClockwork
extend Clockwork
# add a periodic job to update @@events
@Fivell
Fivell / gist:7570698
Created November 20, 2013 20:46 — forked from dwg/gist:7372744
# Base class
class DynamicHostMailer < ActionMailer::Base
def initialize method_name=nil, host, *args
@host = host
super method_name, *args
end
def url_options
# Host should be checked against a relevant whitelist, this is only an example
{ host: @host }