Skip to content

Instantly share code, notes, and snippets.

$ ping github.com
PING github.com (192.30.252.131): 56 data bytes
64 bytes from 192.30.252.131: icmp_seq=0 ttl=248 time=88.360 ms
Request timeout for icmp_seq 1
64 bytes from 192.30.252.131: icmp_seq=2 ttl=248 time=91.491 ms
64 bytes from 192.30.252.131: icmp_seq=3 ttl=248 time=91.730 ms
64 bytes from 192.30.252.131: icmp_seq=4 ttl=248 time=86.243 ms
64 bytes from 192.30.252.131: icmp_seq=5 ttl=248 time=89.297 ms
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7
@mje113
mje113 / gist:9190455
Last active August 29, 2015 13:56
Ruby 2.1 method injection POC
module Instrumenter
def instrument(method)
alias_method "_#{method}", method
define_method method do
start = Time.now
result = send("_#{method}")
puts "Elapsed: #{Time.now - start}"
result
end
11:17:23,416 INFO [org.quartz.core.QuartzScheduler] (MSC service thread 1-11) JobFactory set to: org.torquebox.jobs.JobScheduler@6165e04b
11:17:23,416 INFO [org.quartz.core.QuartzScheduler] (MSC service thread 1-9) JobFactory set to: org.torquebox.jobs.JobScheduler@13ae3d1
11:17:23,417 INFO [org.quartz.core.QuartzScheduler] (MSC service thread 1-11) Scheduler jboss.deployment.unit."gateway-knob.yml".job_scheduler_$_NON_CLUSTERED started.
11:17:23,417 INFO [org.quartz.core.QuartzScheduler] (MSC service thread 1-9) Scheduler jboss.deployment.unit."partner_integration_layer-knob.yml".job_scheduler_$_NON_CLUSTERED started.
11:17:23,908 INFO [org.torquebox.core.runtime] (pool-1-thread-1) Setting up Bundler
11:17:23,915 INFO [org.torquebox.core.runtime] (pool-1-thread-5) Setting up Bundler
11:17:25,198 INFO [stdout] (pool-1-thread-5) Could not find activesupport-4.0.2 in any of the sources
11:17:25,199 INFO [stdout] (pool-1-thread-5) Run `bundle install` to install missing gems.
11:17:25,199 ERROR [org.torq
[1] pry(main)> require 'torquebox-cache'
=> false
[2] pry(main)> cache = TorqueBox::Infinispan::Cache.new( :name => 'treasure' )
=> #<TorqueBox::Infinispan::Cache:0x622b87e8
@cache=#<Object:0x17e7c2b2>,
@codec=TorqueBox::Codecs::MarshalSmart,
@options={:name=>"treasure"}>
[3] pry(main)> cache.put('abcd', 'asdfafdasdf')
=> nil
[4] pry(main)> cache.get('abcd')
@mje113
mje113 / gist:9829932
Created March 28, 2014 10:43
manticore redirect test
require 'manticore'
require 'webrick'
class Redirector < WEBrick::HTTPServlet::AbstractServlet
PORT = 9123
def do_GET(request, response)
case request.path
when '/'
response.status = 200
{
"title": "Services",
"style": "dark",
"editable": true,
"failover": false,
"panel_hints": true,
"refresh": true,
"index": {
"default": "NO_TIME_FILTER_OR_INDEX_PATTERN_NOT_MATCHED",
"pattern": "[logstash-]YYYY.MM.DD",
{
"title": "Services",
"style": "dark",
"editable": true,
"failover": false,
"panel_hints": true,
"refresh": true,
"index": {
"default": "NO_TIME_FILTER_OR_INDEX_PATTERN_NOT_MATCHED",
"pattern": "[logstash-]YYYY.MM.DD",
require 'java'
require 'jbundler'
require 'manticore'
class HisterixCommand < com.netflix.hystrix.HystrixCommand
java_import com.netflix.hystrix.HystrixCommand::Setter
java_import com.netflix.hystrix.HystrixCommandKey
java_import com.netflix.hystrix.HystrixCommandGroupKey
java_import com.netflix.hystrix.HystrixCommandProperties
require 'rack/test'
require 'swagger/docs'
Minitest.after_run {
puts Swagger.to_doc
}
module Swagger
@apis = []
func foobar() {
for i in 1...100 {
switch (i % 3, i % 5) {
case (0, 0): println("foobar")
case (0, _): println("foo")
case (_, 0): println("bar")
default: println("\(i)")
}
}
}