- Tatsuhiro Ujihisa
- http://ujihisa.blogspot.com/
- 非同期とは?
- スレッド、プロセス
- プロセス生成
| require 'jruby/profiler' | |
| profile_data = JRuby::Profiler.profile do | |
| # code to be profiled.... | |
| end | |
| my_output_stream = java.io.ByteArrayOutputStream.new | |
| print_stream = java.io.PrintStream.new(my_output_stream) | |
| profile_printer = JRuby::Profiler::GraphProfilePrinter.new(profile_data) |
| t = Time.now.utc | |
| t.sec.seconds.ago(((t.min).minutes.ago(t))) | |
| # Aditya Raj: http://whizcreed.com | |
| =begin | |
| >> t = Time.now.utc | |
| => Thu Jul 28 12:13:26 UTC 2011 | |
| >> t.sec.seconds.ago(((t.min).minutes.ago(t))) |
| # A chainable Either monad for Ruby | |
| # | |
| # Examples | |
| # | |
| # Either.right('s') >> proc { |s| Either.right(s + '-1') } >> proc { |s| Either.right(s + '-2') } | |
| # #=> #<Either @left=nil, @right="s-1-2"> | |
| # | |
| # Either.right('s') >> proc { |s| Either.left('error!') } >> proc { |s| Either.right(s + '-2') } | |
| # #=> #<Either @left='error!', @right=nil> | |
| # |
| module NameSpaceMethods | |
| def define_class name, superclass=Object, &block | |
| Class.allocate.tap do |klass| | |
| const_set name, klass | |
| klass.send :initialize, superclass, &block | |
| module_or_class_defined klass | |
| class_defined klass | |
| end | |
| end |
| module ThreadSafe | |
| class NonConcurrentCacheBackend | |
| def self.method(key, value) | |
| end | |
| end | |
| class MriCacheBackend < NonConcurrentCacheBackend | |
| WRITE_LOCK = Mutex.new | |
| def self.method(key, value) |
| #!/bin/bash | |
| startDir=$1 | |
| wordToFind=$2 | |
| for dir in $(find $startDir -type d) ; do | |
| echo -n "$dir:" | |
| for file in $(find $dir --depth 1 -name "*.rb") ; do | |
| if grep $wordToFind $file >/dev/null ; then | |
| echo -n "X" |