Skip to content

Instantly share code, notes, and snippets.

View glebm's full-sized avatar

Gleb Mazovetskiy glebm

View GitHub Profile
#!/usr/bin/env ruby
# coding: utf-8
require 'net/http'
require 'json'
# a simple wrapper to do an HTTPS GET
def fetch_uri(url)
STDERR.puts "GET #{url}" if ENV['VERBOSE']
uri = URI(url)
@glebm
glebm / gist:4430698
Created January 1, 2013 22:50
Yet another stack dump
This file has been truncated, but you can view the full file.
Deadlock Detection:
No deadlocks found.
Thread 22209: (state = BLOCKED)
- sun.misc.Unsafe.park(boolean, long) @bci=0 (Compiled frame; information may be imprecise)
- java.util.concurrent.locks.LockSupport.parkNanos(java.lang.Object, long) @bci=20, line=226 (Interpreted frame)
- java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(java.util.concurrent.SynchronousQueue$TransferStack$SNode, boolean, long) @bci=174, line=460 (Compiled frame)
- java.util.concurrent.SynchronousQueue$TransferStack.transfer(java.lang.Object, boolean, long) @bci=102, line=359 (Interpreted frame)
- java.util.concurrent.SynchronousQueue.poll(long, java.util.concurrent.TimeUnit) @bci=11, line=942 (Interpreted frame)
Full thread dump Java HotSpot(TM) 64-Bit Server VM (23.5-b02 mixed mode):
"JRubyWorker-3" daemon prio=10 tid=0x00007f36dc028000 nid=0x432e waiting on condition [0x00007f3720f41000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000006eaaf1970> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1085)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:807)
@glebm
glebm / gist:4254783
Created December 11, 2012 00:55
Error: bad file descriptor
ActionView::Template::Error (Bad file descriptor - Bad file descriptor):
5: else
6: url = create_item_path
7: text = I18n.t("common.post_free_ad")
8: end
9: %a.post-free-ad{href: url}
10: %span.icons.icon-myposts
11: %span.icon-text= text
/usr/justlanded/apps/deploy/releases/20121211003656/app/views/classifieds/shared/_post_free_ad_button.html.haml:8:in `_app_views_classifieds_shared__post_free_ad_button_html_haml___675504869_21714'
@glebm
glebm / gist:4240962
Created December 8, 2012 16:45
Puma error
2012-12-08 17:41:03 +0100: Rack app error: #<NoMethodError: undefined method `>' for nil:NilClass>2012-12-08 17:41:03 +0100: Rack app error: #<NoMethodError: undefined method `>' for nil:NilClass>
/Users/glebm/.rvm/gems/jruby-head@jl/gems/rack-cache-1.2/lib/rack/cache/context.rb:251:in `fetch'
/Users/glebm/.rvm/gems/jruby-head@jl/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
/Users/glebm/.rvm/gems/jruby-head@jl/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
/Users/glebm/.rvm/gems/jruby-head@jl/gems/rack-cache-1.2/lib/rack/cache/context.rb:49:in `call'
/Users/glebm/.rvm/gems/jruby-head@jl/gems/railties-3.2.9/lib/rails/engine.rb:479:in `call'
/Users/glebm/.rvm/gems/jruby-head@jl/gems/railties-3.2.9/lib/rails/application.rb:223:in `call'
org/jruby/RubyBasicObject.java:1665:in `__send__'
org/jruby/RubyKernel.java:2090:in `send'
@glebm
glebm / gist:4240917
Created December 8, 2012 16:37
ActionView::Template::Error (not opened for writing)
125642:ActionView::Template::Error (not opened for writing):
125643- 3: .sign_inner.location-selector
125644- 4: .selects
125645- 5: - selected = localiser.application_location.world? ? nil : localiser.application_location
125646- 6: - cache "#{localiser.locale.cache_key}/#{selected.try(:cache_key) || "w"}/main_loc_selector", expires_in: 24.hours do
125647- 7: = country_select selected: selected.try(:country).try(:id), class: 'combobox'
125648- 8: - if selected.try(:country).try(:has_children?)
125649- 9: = region_and_city_select selected, :class => "combobox"
125650- org/jruby/ext/stringio/RubyStringIO.java:992:in `write'
125651- org/jruby/RubyIO.java:2376:in `write'
@glebm
glebm / gist:4235007
Created December 7, 2012 17:44
puma + jruby journey error
NoMethodError (undefined method `names' for nil:NilClass):
/Users/glebm/.rvm/gems/jruby-head@jl/gems/journey-1.0.4/lib/journey/router.rb:137:in `find_routes'
org/jruby/RubyArray.java:2360:in `map'
/Users/glebm/.rvm/gems/jruby-head@jl/gems/journey-1.0.4/lib/journey/router.rb:132:in `find_routes'
/Users/glebm/.rvm/gems/jruby-head@jl/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/Users/glebm/.rvm/gems/jruby-head@jl/gems/actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:601:in `call'
/Users/glebm/justlanded/lib/rack/ec2_uploader/lib/ec2_uploader/rack_app.rb:25:in `call'
/Users/glebm/.rvm/gems/jruby-head@jl/gems/newrelic_rpm-3.5.3.25/lib/new_relic/rack/error_collector.rb:8:in `call'
/Users/glebm/.rvm/gems/jruby-head@jl/gems/newrelic_rpm-3.5.3.25/lib/new_relic/rack/browser_monitoring.rb:12:in `call'
/Users/glebm/.rvm/gems/jruby-head@jl/gems/newrelic_rpm-3.5.3.25/lib/new_relic/rack/developer_mode.rb:24:in `call'
@glebm
glebm / gist:4215614
Created December 5, 2012 13:45
puma error backtrace
ActionView::Template::Error (closed stream):
5: else
6: url = create_item_path
7: text = I18n.t("common.post_free_ad")
8: end
9: %a.post-free-ad{href: url}
10: %span.icons.icon-myposts
11: %span.icon-text= text
java/lang/Thread.java:1567:in `getStackTrace'
org/jruby/runtime/backtrace/TraceType.java:171:in `getBacktraceData'
@glebm
glebm / cache_if.rb
Created November 20, 2012 01:24
Conditional fragment caching
require 'haml/helpers/action_view_mods' # if you use haml, you have to require its mods first
require 'action_view/helpers/cache_helper'
module ActionView
module Helpers
module CacheHelper
def cache_if(condition, *args, &block)
if @dont_cache || !condition
# Disable cache usage for all `cache` calls within a false condition cache_if block
disable_caching { yield }
else
@glebm
glebm / gist:4102735
Created November 18, 2012 01:51
top redis
17917 redis 20 0 2310m 1.6g 424 D 5 41.3 0:00.61 /usr/bin/redis-server /etc/redis/redis.conf
11790 redis 20 0 2310m 1.5g 928 S 0 39.7 0:10.39 /usr/bin/redis-server /etc/redis/redis.conf