Skip to content

Instantly share code, notes, and snippets.

View andyl's full-sized avatar
🎯
Focusing

andyl

🎯
Focusing
View GitHub Profile
def run_in_background(&block)
Process.fork do
Process.fork do
puts "Launching Background Process"
Daemons.call &block
puts "Background Process has been Launched"
end
exit
end
end
# test2_spec.rb - call using 'rspec test2_spec.rb'
require 'rspec'
require 'mocha'
RSpec::configure do |config|
config.mock_with :mocha
end
class Test2
# test2_spec.rb - call using 'rspec test2_spec.rb'
require 'rspec'
class Test2
attr_accessor :msg
def initialize
@msg = sayhi
end
def sayhi
c
d
e
You can become a registered Vim user by sending at least 10 euro. This works
similar to sponsoring Vim, see |sponsor| above. Registration was made
possible for the situation where your boss or bookkeeper may be willing to
register software, but does not like the terms "sponsoring" and "donation".
@andyl
andyl / test1_spec.rb
Created March 21, 2011 01:28
Rspec Stub Test
# test1_spec.rb - run this using "rspec test1_spec.rb"
require 'rspec'
class Test1
def initialize
sayhi
end
def sayhi
puts "HI"
end
@andyl
andyl / simple_parse.rb
Created March 7, 2011 05:17
simple parsing test
#!/usr/bin/env ruby
require 'rubygems'; require 'parslet'
class Xp < Parslet::Parser
rule(:b) { str("\n").absnt? }
root(:b)
end
# this generates an error - I think it should just return "a"...
@andyl
andyl / parslet.rb
Created March 7, 2011 04:44
parslet line parsing
#!/usr/bin/env ruby
require 'rubygems'
require 'parslet'
class LineParser < Parslet::Parser
rule(:eol) { match['\n\r'] }
rule(:eol?) { eol.maybe }
rule(:line) { (any.repeat).as(:line) }
rule(:line_eol) { line >> eol? }
@andyl
andyl / ctags_vim_paths_gemfile.rb
Created February 18, 2011 19:08
Generates Ctags and Vim Paths from Gemfile.lock
#!/usr/bin/ruby
require 'rubygems'
require 'bundler'
=begin
This script was written to incorporate Bundler and Gemfile.lock into
Vim's tag and file-finding tools.
=end
# This code generates ctags. If a Gemfile.lock is found
@andyl
andyl / gist:818821
Created February 9, 2011 17:06
Rspec / SinatraExtension: Solution Suggested by namelessjon
require 'spec_helper'
=begin
Example One - this is working
In this example, the constant (ZZZ) is set in the
Spec, and detected in the target code.
=end
module TestModule
class TestClass