This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ObjectSpace.each_object(Class) { |o| o.send(:public, *o.instance_methods) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module PlacekittenHelper | |
| def placekitten(width, height, color = true) | |
| path = [width.to_s, height.to_s] | |
| path = %w(g) + path unless color | |
| image_tag "//placekitten.com/#{path.join('/')}" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _.each(['Start', 'Stop', 'Complete', 'Error', 'Success', 'Send'], function(s){ | |
| $(window)['ajax' + s](function(event, xhr, options) { | |
| // your instrumentation goes here | |
| console.log('ajax' + s); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ValueComparableIterator<T extends Comparable<T>> extends ForwardingIterator<T> implements PeekingIterator<T>, Comparable<T> { | |
| private final PeekingIterator<T> delegate; | |
| public ValueComparableIterator(PeekingIterator<T> delegate) { | |
| this.delegate = delegate; | |
| } | |
| @Override | |
| public T peek() { | |
| return delegate.peek(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| open "https://www.meldium.com" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ExpensiveJob | |
| include Resque::Plugins::Status | |
| def perform | |
| Service.find(options['id']).create_user | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Resque::Plugins::Status::Hash | |
| def self.generate_uuid | |
| require 'uuid' unless defined?(UUID) | |
| UUID.generate(:compact) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| irb(main):004:0> require 'uuid' | |
| => true | |
| irb(main):005:0> UUID.generate(:compact) | |
| => "855ff3305ce60130d84d12313d05011b" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| irb(main):010:0> pp Array.new(10) { sleep 1; UUID.generate(:compact) } | |
| ["331028305ce70130d84d12313d05011b", | |
| "33aa4b005ce70130d84d12313d05011b", | |
| "344475605ce70130d84d12313d05011b", | |
| "34de8ea05ce70130d84d12313d05011b", | |
| "357898605ce70130d84d12313d05011b", | |
| "3612ba505ce70130d84d12313d05011b", | |
| "36acdc305ce70130d84d12313d05011b", | |
| "374713605ce70130d84d12313d05011b", | |
| "37e118605ce70130d84d12313d05011b", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ExpensiveJob < Job | |
| def perform | |
| user = Service.find(options['id']).create_user | |
| write_result(user.account_id) | |
| end | |
| end | |
| # Usage | |
| job_id, cache_key = ExpensiveJob.create | |
| result = Rails.cache.read(cache_key) # Poll until non-nil |