Skip to content

Instantly share code, notes, and snippets.

looking for new opportunities - let's have them!

Karol Bucek kares

looking for new opportunities - let's have them!
Block or report user

Report or block kares

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
kares / gist:161328
Created Aug 4, 2009
globalize2 bug tracking
View gist:161328
#test "makes sure interpolation does not break even with False as string" do
# assert_equal "translation missing: en, support, array, skip_last_comma", I18n.translate(:"support.array.skip_last_comma")
test "returns missing translation string for missing key" do
assert_equal "translation missing: hu, foo, bar, huu", I18n.translate(:"", :locale => :hu)
test "returns false translation" do
kares / trim_blob_logging.rb
Created Aug 23, 2009
trim blobs from ActiveRecord's log
View trim_blob_logging.rb
ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
def log_with_blobs_trimmed(sql, name, &block)
sql = sql.gsub(/x'([^']+)'/) do |blob|
blob.size > 32 ? "x'#{$1[0,32]}... (#{blob.size} bytes)'" : $0
end if sql
log_without_blobs_trimmed(sql, name, &block)
alias_method_chain :log, :blobs_trimmed
kares / gist-embed_twilight.css
Created Aug 30, 2009
a twilight theme for gists
View gist-embed_twilight.css
.gist {
color: /* #000 */ #9B703F;
.gist div {
padding: 0;
margin: 0;
.gist .gist-file {
border: 1px solid #dedede; /* gray */
font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace;
kares / request_exception_fix.rb
Created Sep 6, 2009
action pack request exception patching for the pre 2.3 era
View request_exception_fix.rb
# Patch request to receive exceptions from body parsing (e.g. XML parsing)
ActionController::AbstractRequest.class_eval do
alias_method :parse_formatted_request_parameters_unsafely, :parse_formatted_request_parameters
def parse_formatted_request_parameters
parse_formatted_request_parameters_unsafely #super
rescue Exception => e # YAML, XML or Ruby code block errors
self.env['EXCEPTION'] = e # there will be a before filter to check for this and re-raise
kares / application_controller.rb
Created Sep 6, 2009
request_exception_handler plugin usage sample
View application_controller.rb
class ApplicationController < ActionController::Base
rescue_from 'REXML::ParseException' do |exception|
render :text => exception.to_s, :status => 422
kares / weblogic.xml
Created Oct 25, 2009
weblogic descriptor snippet
View weblogic.xml
<!-- @see docs -->
kares / assert_json_parse_exception.rb
Created Dec 28, 2009
assert an error is caused by JSON parsing for rails 2.x.x
View assert_json_parse_exception.rb
def assert_json_parse_exception(error)
if ActiveSupport::JSON.respond_to?(:parse_error) # 2.3.5
parse_error_class = ActiveSupport::JSON.parse_error
assert_instance_of parse_error_class, error
assert_instance_of ActiveSupport::JSON::ParseError, error
View web.xml
<web-app xmlns="" xmlns:xsi=""
<!-- ... rest omited ... -->
View pom.xml
<project xmlns="" xmlns:xsi=""
View overrides.groovy
def overrideResourcesDir =["override.resources.dir"]
if (new File( overrideResourcesDir ).exists()) {"cleaning contents of directory $overrideResourcesDir")
ant.delete { fileset(dir: overrideResourcesDir, includes: "**") }
else {
new File( overrideResourcesDir ).mkdirs() // webResource - should exist
if (SOME_PORT) { // if not set don't touch the web.xml
You can’t perform that action at this time.