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/bash | |
echo $(id -nu) $(date -R) $$ "$@" | tee -a /tmp/test.log | |
exit 0 |
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 Callback | |
def initialize(sleep_time=5) | |
@sleep = sleep_time | |
end | |
def start | |
sleep(@sleep) | |
@on_finish.call if defined?(@on_finish) | |
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 Kernel | |
class << self | |
def retry_on_exception(exception, retry_count=1, throw=true, &block) | |
raise ArgumentError, 'no block given' unless block_given? | |
retry_attempt = 0 | |
begin | |
block.call | |
rescue exception => e |
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
# | |
# dump.rb | |
# | |
# Copyright 2011 Puppet Labs Inc. | |
# Copyright 2011 Krzysztof Wilczynski | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# |
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):008:0> kwilczynski@desktop:~$ irb | |
irb(main):001:0> value = %w(this is a test) | |
=> ["this", "is", "a", "test"] | |
irb(main):002:0> [*value].join ',' | |
=> "this,is,a,test" | |
irb(main):003:0> value = 'this is a test' | |
=> "this is a test" | |
irb(main):004:0> [*value].join ',' | |
=> "this is a test" | |
irb(main):005:0> [*value] |
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 Hash | |
def deep_merge!(other) | |
other.each_pair do |k,v| | |
if self[k].is_a?(Hash) and other[k].is_a?(Hash) | |
self[k].deep_merge!(other[k]) | |
else | |
self[k] = other[k] | |
end | |
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
require 'rubygems' | |
require 'eventmachine' | |
children = [] | |
Signal.trap('SIGINT') do | |
EventMachine.next_tick { EventMachine.stop_event_loop } | |
end | |
Signal.trap('EXIT') do |
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
require 'rubygems' | |
require 'eventmachine' | |
require 'socket' | |
SOCKET = '/tmp/test.socket' | |
module Connection | |
def receive_data(data) | |
puts "\t#{data}" |
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 EventMachine | |
def self.threadqueue | |
@threadqueue | |
end | |
def self.resultqueue | |
@resultqueue | |
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
require 'rubygems' | |
require 'eventmachine' | |
children = [] | |
Signal.trap('SIGINT') do | |
EventMachine.next_tick { EventMachine.stop_event_loop } | |
end | |
Signal.trap('EXIT') do |