Skip to content

Instantly share code, notes, and snippets.

Jacek Becela ncr

Block or report user

Report or block ncr

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
View choke.rb
class Choke
def initialize(interval)
@interval = interval
@mutex =
def perform
thread, result = nil, nil
@mutex.synchronize do
thread = { result = yield }
ncr / How I run this
Created Apr 2, 2011
The little stress test
View How I run this
~/dev/parslet$ rvm use 1.8.7-p302
Using /Users/ncr/.rvm/gems/ruby-1.8.7-p302
~/dev/parslet$ bundle exec rspec spec/parslet/mem_stress_spec.rb
23.030000 1.290000 24.320000 ( 24.331595)
Finished in 24.33 seconds
1 example, 0 failures
~/dev/parslet$ rvm use 1.9.2
Using /Users/ncr/.rvm/gems/ruby-1.9.2-p180
View fault.xml
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle=""
<faultfactor>doGetItemsInfo - Wrong session</faultfactor>
View anti_heap_fragmentation.rb
# put this in config/initializers
class NoopArray < Array
def <<(e)
def push(e)
View devise_and_basic_auth.txt
Started GET "/api/private/users/1" for at Wed Jul 07 15:43:09 +0200 2010
Processing by Api::Private::UsersController#show as HTML
Parameters: {"id"=>"1"}
Completed 401 Unauthorized in 1ms
NoMethodError (undefined method `new__session_path' for #<Devise::FailureApp:0x103260cd8>):
/Users/ncr/.bundle/ruby/1.8/gems/devise-1.1.rc2/lib/devise/failure_app.rb:50:in `send'
/Users/ncr/.bundle/ruby/1.8/gems/devise-1.1.rc2/lib/devise/failure_app.rb:50:in `redirect'
/Users/ncr/.bundle/ruby/1.8/gems/devise-1.1.rc2/lib/devise/failure_app.rb:30:in `respond'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.beta4/lib/abstract_controller/base.rb:145:in `send_action'
View modules_wtf.rb
irb(main):002:0> module A; def x; "x"; end end
=> nil
irb(main):003:0> module B; def x; "y"; end end
=> nil
irb(main):004:0> do include A;
=> "x"
irb(main):005:0> do include B;
=> "y"
irb(main):006:0> do include A; include B
=> "y"
View app_responder.rb
# Customizing your Responder to always redirect to the collection path (index action).
class AppResponder < ActionController::Responder
# Overwrite navigation_behavior to redirect to the collection_location.
def navigation_behavior(error)
if get?
raise error
elsif has_errors? && default_action
render :action => default_action
ncr / gist.html.erb
Created Jun 6, 2010
Blogist Templates
View gist.html.erb
<!DOCTYPE html>
<title>Nice templates Wanted ;)</title>
<h1>Are you a graphic designer?</h1>
<p>Fork this gist and contribute a better layout</p>
ncr / config.yml
Created Jun 5, 2010
Blogist Meta
View config.yml
title: Jacek Becela is Blogist
layout: 427820
- 426631
View Hello

I wrote my first program 25 years ago.

embed: hello.bas

You can’t perform that action at this time.