# instead of LOAD_PATH
require_relative 'lib/ServerlessOptions'
# file
DIR_HOME = File.expand_path File.dirname __FILE__
DIR_LIB = File.join(DIR_HOME, 'lib')
$LOAD_PATH.unshift DIR_LIB unless $LOAD_PATH.include? DIR_LIB
# print backtraces
begin
Whatever.you.want
rescue => e
puts e.message
puts
# filter gems and fix path
puts e.backtrace.grep_v(/\/gems\//).map { |l|
l.gsub(`pwd`.strip + '/', '')
}
raise # always reraise
end
# open file
open("testfile") do |f|
print f.gets
end
# pipe
cmd = open("|date")
print cmd.gets
cmd.close
# unbuffed output
$stdout.sync = true
$stderr.sync = true
# comment at top
encoding: utf-8
ENV_JAVA['file.encoding']
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
JAVA_OPTS=-Dfile.encoding=UTF-8
# look these up
:startdoc:
:stopdoc:
:nodoc:
# profiling
prof = []
prof << Time.now
prof << Time.now
prof << Time.now
prof[0..-2].zip(prof[1..-1]).each.with_index do |i,n|
Rails.logger.info "%4d: %.6f" % [n, i[1] - i[0]]
end
#remove color escapes
cat or echo x |ruby -ne 'print $_.gsub(/\e\[[\d\;]*m/,"");'
puts URI.unescape get_user_policy( user_name:'jenkins.lambdas', policy_name:'jenkins-lambdas').policy_document
# plumb a view
rr g controller hello_angular index
# Random string
require 'securerandom'
SecureRandom.hex(32)