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 / password.rb
Created Jan 12, 2016 — forked from steakknife/password.rb
get password - Ruby - any platform - no gems needed
View password.rb
# Copyright 2012-2013 Barry Allard <>
# All rights reserved.
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
kares / current_thread_aware_formatter.rb
Created Oct 19, 2015
Logger::Formatter aware of Thread.current for JRuby
View current_thread_aware_formatter.rb
require 'jruby'
class CurrentThreadAwareFormatter < Logger::Formatter
FORMAT = "%s [%5s] {%s} -- %s\n".freeze
def call(severity, time, progname, msg)
thread = Thread.current
thread_id = JRuby.reference(thread).getNativeThread.to_s
thread_id << ' ' << ( thread[:name] || thread.to_s )
FORMAT % [format_datetime(time), severity, thread_id, msg2str(msg)]
kares / pool.rb
Last active Oct 14, 2015
AR 3.2 pool patch for less contention on release_connection
View pool.rb
::ActiveRecord::ConnectionAdapters::ConnectionPool.class_eval do
def release_connection(with_id = current_connection_id)
#synchronize do
conn = @reserved_connections.delete(with_id)
checkin conn, true if conn
def checkin(conn, on_release = nil)
kares / celluloid.rb
Last active Aug 29, 2015
celluloid InternalPool backport from master (due inproper synchronization)
View celluloid.rb
require 'celluloid/internal_pool'
# NOTE: this also avoids JRuby bug with ThreadGroup#list !
# require 'celluloid' likely happened already :
if Celluloid.internal_pool
Celluloid.internal_pool = nil
View 0_logging_unnecesary_synchronize.rb
require 'logging'
module Logging
# require 'logging/repository'
# class Repository
# # include Singleton
# def initialize; require 'thread_safe'
# # @h = {:root =>}
# @h =
kares / celluloid_stack_dump.rb
Created Dec 22, 2014
Celluloid.stack_dump tunings on JRuby
View celluloid_stack_dump.rb
require 'celluloid/stack_dump'
module Celluloid
class StackDump
class ActorState
attr_accessor :thread_name, :thread_id
def dump
kares / benchmark_java_lang_System_getProperty.rb
Created Dec 3, 2014
JRuby 1.7.16 benchmark for java.lang.System.getProperty
View benchmark_java_lang_System_getProperty.rb
require 'benchmark'
TIMES = 10_000
Benchmark.bmbm do |x|"java.lang.System.get_property [#{TIMES}x]") do
TIMES.times do
java.lang.System.get_property('jars.skip') == 'true'
kares /
Last active Aug 29, 2015
JRuby - (mostly) some of the concurrency related - changes since 1.7.4
View no-conn-pool.rb
# Monkeypatch to disable connection pooling in ActiveRecord
module ActiveRecord
module ConnectionAdapters
class ConnectionPool
def checkout
c = ActiveRecord::Base.send(spec.adapter_method, spec.config.dup)
kares / response_process.rb
Last active Aug 29, 2015
ActionController::Live::Response partial <code>process</code> that happens on every "live" request
View response_process.rb
error = nil
# This processes the action in a child thread. It lets us return the
# response code and headers back up the rack stack, and still process
# the body in parallel with sending data to the client {
rescue => e
if @_response.committed?
You can’t perform that action at this time.