Skip to content

Instantly share code, notes, and snippets.

View chrismo's full-sized avatar

chrismo chrismo

View GitHub Profile
@chrismo
chrismo / output.txt
Created November 27, 2012 22:25
all(?) things at_exit and otherwise
18930: Parent
18933: Child A
18934: Child B
18933: END in child if only exit called
18933: at_exit in child if only exit called
18933: parent END (only one)
18933: parent at_exit (2 times)
18933: parent at_exit (2 times)
18930: parent: child died
18930: parent trap(0)
@chrismo
chrismo / child_at_exit.rb
Created November 7, 2012 15:44
Using at_exit with fork
child = fork do
at_exit { $stderr.puts "Child one is done." }
exit # superfluous
end
Process.wait
$stderr.puts "Parent is done waiting for child one #{child}."
child = fork do
at_exit { $stderr.puts "This won't get hit." }
exit!
@chrismo
chrismo / howto.txt
Created November 1, 2012 17:09
How to spelunk code in RubyMine with git
Open git history for the file.
In annotate view, find the line of code and the sha.
Select history view and start typing the sha until it's selected.
Type 'esc', then down arrow.
Right-click and select "Annotate" - this will open the prior rev in the editor in annotate view.
Find that line of code and repeat.
@chrismo
chrismo / [outputs]
Created October 15, 2012 21:15
Dump date/time formats with examples of a locale in Rails
$ bin/rake i18n:show_sample_dates_and_times['en-MY']
time:
date : %m/%d/%Y : 2012-10-15
date_day : %d : 15
date_hour : %l:%M %p : 4:13 pm
date_month : %B : October
date_month_name : %B %e, %Y : 15 October 2012
date_month_year : %B %Y : October 2012
date_short_month_year : %e %b %Y : 15 Oct 2012
date_short_year : %m/%d/%y : 15-10-12
@chrismo
chrismo / gist:3800936
Created September 28, 2012 16:55
Non-merging copying over of changes from branch to branch
If file exists in both places:
git diff target_branch source_branch relative_path_to_file | git apply
If file is new on other branch:
git checkout source_branch relative_path_to_file
The checkout will work even if the file exists, and will stomp it,
@chrismo
chrismo / method_logger_test.rb
Created September 13, 2012 15:33 — forked from nhance/method_logger.rb
Rails compatible method logging. Use this to log all calls to instance methods of a class to the log.
# converted to stand-alone script
require 'minitest/autorun'
require 'minitest/unit'
require 'stringio'
# fake out the logger
class Rails
@@logger = StringIO.new