View irb_benchmark.rb
require 'benchmark'
module IRB
def self.before_eval
end
def self.after_eval
end
def self.around_eval(&block)
@timing = Benchmark.measure do
block.call
end
View README.txt
= irb_callbacks
* http://rubysideshow.rubyforge.org/irb_callbacks
== DESCRIPTION:
This gem adds callbacks to irb, intended for you to
override at your discretion.
== FEATURES:
View flash-swfobject.html
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="420">
<param name="movie" value="https://impdesk-cdn.s3.amazonaws.com/c5/63/01fa951290d8ccab15bae443cfcc.swf?1385464753" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="https://impdesk-cdn.s3.amazonaws.com/c5/63/01fa951290d8ccab15bae443cfcc.swf?1385464753" width="780" height="420">
<!--<![endif]-->
<a target="_blank" href="http://example.com">
<img
width="607"
height="367"
border="0"
View ack-gems
#! /usr/bin/env ruby
require 'bundler'
paths = Bundler.load.specs.map(&:full_gem_path)
system("ack '#{ARGV[0]}' #{paths.join(' ')}")
View lua-self-memory-usage.lua
local pid = io.open('/proc/self/stat'):read('*all'):gmatch('%d+')()
print(io.popen('ps -p ' .. pid .. ' -o cmd,vsz,rss'):read('*all'))
View i18n_raise_exception_handler.rb
module I18n
class JustRaiseExceptionHandler < ExceptionHandler
def call(exception, locale, key, options)
if exception.is_a?(MissingTranslation)
raise exception.to_exception
else
super
end
end
end
View chrome-cookies.sh
# Not needs as there is 'Copy as Curl' in Chrome now
sqlite3 -separator ' ' ~/.config/google-chrome/Default/Cookies 'select host_key, "TRUE", path, "FALSE", expires_utc, name, value from cookies'
View gotcha.rb
irb(main):009:0> 1/BigDecimal.new('0')
=> #<BigDecimal:b36d598,'Infinity',9(36)>
irb(main):010:0> 1/0
ZeroDivisionError: divided by 0
View irssi_trigger_echo_last_messages.sh
$ mkdir -p ~/.irssi/scripts/autorun/
$ cd ~/.irssi/scripts/autorun/
$ wget http://wouter.coekaerts.be/irssi/scripts/trigger.pl
$ irssi
/server add -auto -network Freenode irc.freenode.net 6667
/channel add -auto ##channel Freenode
/SET autolog ON
/trigger add -joins -command 'exec -o tail -10 ~/irclogs/Freenode/\#\#channel.log'
View hows.rb
require 'stamp'
require 'text-table'
def how(ts)
hour = (ts.to_f / 3600).floor
hour % 24 + ((hour / 24 + 4).floor % 7) * 24
end
from = Time.utc(2013, 4, 7)
to = Time.utc(2013, 4, 7 + 7)