Skip to content

Instantly share code, notes, and snippets.

@yujinakayama
yujinakayama / gist:4608863
Created January 23, 2013 16:14
Patch for GNU Screen HEAD on OS X, which disables the error message "/var/run/utmp: No such file or directory" on launch. This is based on http://www.opensource.apple.com/source/screen/screen-16/patches/config.h.in.diff
diff --git a/src/acconfig.h b/src/acconfig.h
index 2e46985..c797e5c 100644
--- a/src/acconfig.h
+++ b/src/acconfig.h
@@ -191,14 +191,14 @@
* If screen is installed with permissions to update /etc/utmp (such
* as if it is installed set-uid root), define UTMPOK.
*/
-#define UTMPOK
+#undef UTMPOK
@yujinakayama
yujinakayama / gitlab-sidekiq.service
Last active December 11, 2015 17:39
GitLab 5.0 systemd unit files for Arch Linux
[Unit]
Description=GitLab Sidekiq
Wants=redis.service
After=redis.service
[Service]
Type=forking
SyslogIdentifier=gl-sidekiq
User=git
PIDFile=/home/git/gitlab/tmp/pids/sidekiq.pid
@yujinakayama
yujinakayama / git-ls-files-which-should-be-ignored-but-tracked.sh
Last active December 15, 2015 07:19
List files which should be ignored but already tracked by Git
git ls-files --ignored --exclude-standard
describe 'File.stub(:open).and_call_original' do
context 'with Rubinius 2.0.0.rc1 (1.9.3 a46dcf9b) and RSpec 2.13.1' do
it 'raises SystemStackError' do
File.write('file.txt', 'foo')
File.stub(:open).and_call_original
File.open('file.txt') { |file| p file.read }
end
end
end
@yujinakayama
yujinakayama / rubinius_and_rspec_system_stack_error_stacktrace.log
Last active December 18, 2015 14:29
Stacktrace of File.stub(:open).and_call_original with Rubinius 2.0.0.rc1 (1.9.3 a46dcf9b) and RSpec 2.13.1
# Installed Rubinius with `rbenv install rbx-2.0.0-dev`
$ rbx -v
rubinius 2.0.0.rc1 (1.9.3 a46dcf9b yyyy-mm-dd JI) [x86_64-apple-darwin12.4.0]
$ uname -a
Darwin macbookpro.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May 1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64
$ rbenv -v
rbenv 0.4.0-48-g5130b41
$ echo $RBXOPT
-X19
$ rspec -v
$ cat test.rb
def some_method
foo = 1
puts foo
1.times do |i; foo|
foo = 2
puts foo
end
puts foo
end
describe 'the issue with `expect(subject).to receive(:some_method).with do ... end`' do
subject { double('subject') }
context 'with #should_receive' do
it 'receives #some_method with 1' do
subject.should_receive(:some_method).with do |arg|
arg == 1
end
subject.some_method(1)
@yujinakayama
yujinakayama / guard-ignore-issue.log
Created October 9, 2013 17:57
`ignore` DSL issue with Guard 2.0
$ bundle exec guard --debug
02:54:49 - DEBUG - Command execution: which notify-send
02:54:49 - DEBUG - Command execution: emacsclient --eval '1' 2> /dev/null || echo 'N/A'
02:54:49 - INFO - Guard is using NotifySend to send notifications.
02:54:49 - INFO - Guard is using TerminalTitle to send notifications.
02:54:49 - DEBUG - Command execution: hash stty
02:54:49 - DEBUG - Guard starts all plugins
02:54:49 - DEBUG - Hook :start_begin executed for #<Guard::RSpec @name=rspec @group=#<Guard::Group @name=default @options={}> @watchers=[#<Guard::Watcher:0x007fdda35c1830 @action=nil, @pattern=/^spec\/.+_spec\.rb$/>] @callbacks=[] @options={:focus_on_failed=>false, :all_after_pass=>false, :all_on_start=>false, :keep_failed=>false, :spec_paths=>["spec"], :run_all=>{}, :group=>:default, :callbacks=>[]}>
02:54:49 - INFO - Guard::RSpec is running
02:54:49 - DEBUG - Hook :start_end executed for #<Guard::RSpec @name=rspec @group=#<Guard::Group @name=default @options={}> @watchers=[#<Guard::Watcher:0x007fdda35c1830 @action
@yujinakayama
yujinakayama / and_return_without_args_spec.rb
Last active August 29, 2015 13:56
The problematic behavior of `and_return` without arguments
describe '`and_return` without arguments' do
let(:obj) { double('obj') }
context 'with `stub`' do
context 'and `{ }` block' do
it 'works properly' do
obj.stub(:foo).and_return {
'a return value'
}
# coding: utf-8
require 'tmpdir'
require 'parser/current'
def in_tmpdir
Dir.mktmpdir do |tmpdir|
Dir.chdir(tmpdir) do
yield
end