Skip to content

Instantly share code, notes, and snippets.

View jumski's full-sized avatar
🐴
For the lack of a nail, throw new HorseshoeNailNotFoundException("no nails!");

Wojtek Majewski jumski

🐴
For the lack of a nail, throw new HorseshoeNailNotFoundException("no nails!");
View GitHub Profile
around do |example|
old_base = ActionView::Base
ActionView::Base = old_base.dup
ActionView::Base.send :include, Rails.application.routes.url_helpers
ActionView::Base.send :include, ApplicationHelper
example.run
ActionView::Base = old_base
# vim: set ft=puppet:
input {
file {
path => [ "/var/log/rails.log" ]
type => rails
format => plain
start_position => beginning
}
}
filter {
multiline {
type => simulator
patterns_dir => "/home/jumski/work/logstash-shell/patterns"
pattern => "%{SIMULATOR_PASSENGER_LOG}"
negate => true
what => next
}
@jumski
jumski / custom-exception-logger.rb
Created July 26, 2013 12:04
custom exception logger
require './application.rb'
class CustomExceptionLogger
def initialize(app)
@app = app
end
def call(env)
@app.call(env)
rescue Exception => e
@jumski
jumski / gist:6077839
Created July 25, 2013 08:26
stacktrace
/home/jumski/.rvm/gems/ruby-1.9.3-p327-falcon/gems/virtus-0.5.4/lib/virtus/class_methods.rb:67:in `const_missing': uninitialized constant BillHistory::BillDetail (NameError)
from /home/jumski/work/mywind_simulatore/models/bill_history.rb:10:in `<class:BillHistory>'
from /home/jumski/work/mywind_simulatore/models/bill_history.rb:3:in `<top (required)>'
from /home/jumski/.rvm/gems/ruby-1.9.3-p327-falcon/gems/backports-2.6.7/lib/backports/tools.rb:314:in `require'
from /home/jumski/.rvm/gems/ruby-1.9.3-p327-falcon/gems/backports-2.6.7/lib/backports/tools.rb:314:in `require_with_backports'
from /home/jumski/work/mywind_simulatore/application.rb:77:in `block in <top (required)>'
from /home/jumski/work/mywind_simulatore/application.rb:77:in `each'
from /home/jumski/work/mywind_simulatore/application.rb:77:in `<top (required)>'
from /home/jumski/work/mywind_simulatore/config.ru:1:in `require'
from /home/jumski/work/mywind_simulatore/config.ru:1:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos-56-32-3"
config.vm.box_url = 'http://dl.dropbox.com/u/9227672/centos-5.6-x86_64-netinstall-4.1.6.box'
# config.vm.box_url = "https://s3.amazonaws.com/itmat-public/centos-6.3-chef-10.14.2.box"
config.vbguest.auto_update = true
config.vm.provider :virtualbox do |vb|
@jumski
jumski / 1-formatted-request.xml
Last active December 19, 2015 07:19
Allegro WebAPI - doNewAuctionExt bug
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:typens="urn:AllegroWebApi" xmlns:ins0="urn:AllegroWebApi">
<env:Body>
<typens:doNewAuctionExt>
<session-handle>94072a84bebc737c198f00bd8e015032c71277bd155a173301_1</session-handle>
<fields>
<fields>
<fid>5</fid>
<fvalue-string />
<fvalue-int>1</fvalue-int>
@jumski
jumski / projections.json
Created June 11, 2013 13:21
rails.vim projections
{
"vendor/alle_api/lib/alle_api/job/*.rb": {
"command": "job",
"template": "module AlleApi\n module Job\n class %S < Base\n def perform\n end\n end\n end\nend",
"test": "spec/alle_api/job/%s_spec.rb"
},
"vendor/alle_api/lib/alle_api/wrapper/*.rb": {
"command": "wrapper",
"template": "module AlleApi\n module Wrapper\n class %S < Base\n def wrap_multiple\n end\n end\n end\nend",
"test": "spec/alle_api/wrapper/%s_spec.rb"
@jumski
jumski / tire_helpers.rb
Created May 22, 2013 09:56
tire helpers
module TireHelpers
extend ActiveSupport::Concern
module ClassMethods
def drop_index
tire.index.delete
end
def create_index
tire.index.create mappings: tire.mapping_to_hash,
@jumski
jumski / elasticsearch_ngram.rb
Created May 22, 2013 09:51
elasticsearch ngram config
class Author < ActiveRecord::Base
include Tire::Model::Search
include Tire::Model::Callbacks
include TireHelpers
has_many :books
validates :name, presence: true
normalize_attributes :name