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
# if you want to monkey patch every controller, put this in initializers/active_admin.rb
ActiveAdmin::ResourceController.class_eval do
include ActiveAdmin::CSVStream
end
require 'rubygems'
require 'rubygems/package'
require 'zlib'
require 'fileutils'
module Util
module Tar
# Creates a tar file in memory recursively
# from the given path.
#
module ActiveAdminHelper
def admin_arbre_context
@admin_arbre_context ||= Arbre::Context.new(assigns, self)
end
def default_renderer
case controller.send(:resource_class).name
when "ActiveAdmin::Page"
"page"
@Fivell
Fivell / have_xml.rb
Created December 18, 2013 17:00 — forked from faun/have_xml.rb
require 'nokogiri'
RSpec::Matchers.define :have_xml do |xpath, text|
match do |body|
doc = Nokogiri::XML::Document.parse(body)
nodes = doc.xpath(xpath)
nodes.empty?.should be_false
if text
nodes.each do |node|
node.content.should == text
end
@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 }
@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
require 'torquebox-stomp'
class SomeStomplet
def initialize()
@pending_subscribers = {}
@subscribers = {}
end
require 'torquebox-stomp'
class SomeStomplet
def initialize()
@pending_subscribers = {}
@subscribers = {}
end
require 'torquebox-stomp'
class DemoStomplet
def initialize()
super
@subscribers = []
# passthrough for local messages to skip auth
@passthrough_code = "e32f53ac7569ae3a1f692177"
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.