This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#"" An FFI example on Mac 10.5.8 | |
# | |
# % gcc --version | |
# i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465) | |
# | |
# Setup a source file | |
# | |
require 'fileutils' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1) Install JRuby | |
# http://jruby.org/ | |
# 2) Download CLIPSJNI 6.30 | |
# http://sourceforge.net/projects/clipsrules/files/CLIPS/ | |
# 3) Put this file in the CLIPSJNI folder, then: | |
# | |
# % cd [CLIPSJNI folder] | |
# % jruby clips.rb | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h2. Use an older version of Tap (or any gem) | |
Rubygems makes it very easy to use an older version of tap: | |
<notextile><pre><code>% tap _version_ ...</pre></code></notextile> | |
As you can see, all you have to do is specify the version in the first argument. This trick can also be useful for fixing the version of tap used if it gets called from another process. | |
<notextile><pre><code>% tap _0.10.3_ | |
usage: tap <command> {options} [args] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################# | |
# Dependencies in this Gemfile are managed through the gemspec. Add/remove | |
# depenencies there, rather than editing this file ex: | |
# | |
# Gem::Specification.new do |s| | |
# ... | |
# s.add_dependency("sinatra") | |
# s.add_development_dependency("rack-test") | |
# end | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
get '/' do | |
erb :form, :locals => {:file => nil} | |
end | |
post '/' do | |
erb :form, :locals => {:file => request['file']} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# String escapes: | |
# | |
# \a Bell/alert (0x07) | |
# \b Backspace (0x08) | |
# \e Escape (0x1b) | |
# \f Formfeed (0x0c) | |
# \n Newline (0x0a) | |
# \r Return (0x0d) | |
# \s Space (0x20) | |
# \t Tab (0x09) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rack' | |
require 'mongrel' | |
app = lambda do |env| | |
[200, {}, "#{env['middleware.message']} world"] | |
end | |
class Middleware | |
attr_reader :app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s="s=%p;puts s%%s";puts s%s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<!-- Test how supportive a browser is of several rendering techniques. --> | |
<p id="text"> | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut | |
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco | |
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in | |
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'String' | |
describe '.split' | |
it 'should split by separator' | |
'a,b c, d'.split(',').should.eql ['a', 'b c', ' d'] | |
end | |
it 'should split characters if separator is empty' | |
'abc'.split('').should.eql ['a', 'b', 'c'] | |
end | |
end |