Skip to content

Instantly share code, notes, and snippets.

@kml
kml / Gemfile
Created March 6, 2012 09:32
Torquebox problem
source :rubygems
gem 'rack'
gem 'json'
gem 'torquebox-rake-support'
gem 'rdiscount'
# ...
options = {properties: {}}
options[:properties]['_HQ_SCHED_DELIVERY'] = Time.now.to_i * 1000 + 30.seconds * 1000 # milis
download_queue.publish({message: {photo_id: photo.id}}, options)
=begin
$ uname -a
Linux jboss-updater2 3.2.21-nkt #1 SMP Wed Aug 1 20:23:57 CEST 2012 x86_64 GNU/Linux
$ java -version
java version "1.7.0_03"
OpenJDK Runtime Environment (IcedTea7 2.1.1pre) (7~u3-2.1.1~pre1-2)
OpenJDK 64-Bit Server VM (build 22.0-b10, mixed mode)
$ jruby --version
# encoding: utf-8
class StringUtilsMock
def self.underscore(name); name.underscore; end
end
JavaUtilities.class_eval do
class << self
alias_method :get_proxy_or_package_under_package_original, :get_proxy_or_package_under_package
def get_proxy_or_package_under_package(obj, sym)
require 'torquebox/messaging'
require 'torquebox/messaging/connection_factory'
require 'torquebox/messaging/destination'
module TorqueBox
module Messaging
class Destination
def publish_each(messages, options = {})
wait_for_destination(options[:startup_timeout]) do
with_session(options) do |session|
@kml
kml / .gitignore
Last active August 29, 2015 14:02
activemq-stats-ruby
.bundle
bundle
@kml
kml / regexp_breaking_ruby.rb
Last active December 15, 2022 19:44
Regexp breaking Ruby
# encoding: utf-8
require 'minitest'
require 'minitest/autorun'
describe "regexp" do
let(:regexp) { /(\s*(<p>\s*<\/p>)\s*)+\Z/mi }
it "cleans up trailing empty tag from simple string" do
"X <p> </p> ".gsub(regexp, "").must_equal "X"
@kml
kml / gist:d7a0f27fe0c7c477f2f6
Last active December 13, 2016 20:34
ActiveModel::Model - show nested errors
class PersonData
include ActiveModel::Model
include Virtus.model
attribute :pesel, String
attribute :id_type, String
validates :pesel, presence: true
validates :id_type, presence: true
end
@kml
kml / rake_disable_db_tasks.rb
Created May 22, 2015 09:06
Rakefile - disable db: tasks in production
# Idea from: http://www.developingandstuff.com/2014/06/disable-dangerous-rake-tasks-in.html
if Rails.env.production?
Rake::Task.tasks.each do |task|
next unless task.name.start_with?("db:")
Rake::Task[task].enhance do
abort "This task is disabled in production."
end
end
jruby 1.7.20 (1.9.3p551) 2015-05-04 3086e6a on Java HotSpot(TM) 64-Bit Server VM 1.7.0_79-b15 +jit [darwin-x86_64]
>> $LOAD_PATH << File.expand_path('../vendor', __FILE__)
>> require "frak-0.1.7-SNAPSHOT-standalone.jar"
=> true
>> Java::clojure.lang.RT
=> Java::ClojureLang::RT
>> require "jrclj"
=> true