This file contains hidden or 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
def fib(n) | |
if n <= 1 | |
return n | |
else | |
return fib(n-1) + fib(n-2) | |
end | |
end | |
puts fib(30) |
This file contains hidden or 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(:block, | |
s(:gasgn, :$count, s(:lit, 0)), | |
s(:defn, | |
:valid?, | |
s(:scope, | |
s(:block, | |
s(:args, :state, :x, :y), | |
s(:iter, | |
s(:call, s(:lit, 0), :upto, s(:array, s(:lit, 8))), | |
s(:dasgn_curr, :i), |
This file contains hidden or 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 'benchmark' | |
def where(app) | |
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| | |
return File.join(path, app) if File.exist?(File.join(path, app)) && File.executable?(File.join(path, app)) | |
end | |
end | |
n = 1_000 |
This file contains hidden or 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
# Couldn't this | |
ENV["RC_ARCHS"] = `uname -m`.chomp if `uname -sr` =~ /^Darwin/ | |
# better be expressed like this? | |
ENV["RC_ARCHS"] = `uname -m`.chomp if RUBY_PLATFORM =~ /darwin/ |
This file contains hidden or 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
=== modified file 'win32/shlib/Makefile' | |
--- old/win32/shlib/Makefile 2008-01-16 06:24:21 +0000 | |
+++ new/win32/shlib/Makefile 2008-01-16 06:54:25 +0000 | |
@@ -55,6 +55,7 @@ | |
IMPORT_FLAG = -machine:x86 | |
IMPORT_OFLAG = -out: | |
IMPORT_DFLAG = -def: | |
+MT_DLL=if exist [email protected] mt.exe -nologo -outputresource:$@;2 -manifest [email protected] $(ADDITIONAL_MANIFESTS) | |
!endif | |
This file contains hidden or 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
module FileUtils | |
def which(file) | |
extensions = ENV['PATHEXT'].split(File::PATH_SEPARATOR) rescue [] | |
pattern = "#{file}{#{extensions.join(',').downcase}}" | |
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| | |
candidate = Dir.glob(File.join(File.expand_path(path), pattern)).first | |
return candidate if candidate && File.executable?(candidate) | |
end | |
end | |
end |
This file contains hidden or 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
package 'openssl', :type => :make do | |
default 'source' | |
version 'source' do | |
download 'http://...' | |
# hooks | |
before :download { } | |
after :download { } | |
after :extract { } |
This file contains hidden or 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
Feature: Compile C code into Ruby extensions. | |
In order to automate compilation process. | |
As a Gem developer. | |
I want rake tasks compile source code for me. | |
Scenario: Compile single extension | |
Given a safe project directory | |
And scaffold code for extension 'extension_one' | |
And 'tmp' folder is deleted |
This file contains hidden or 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 'win32console' | |
require 'snarl' | |
Autotest.add_hook :initialize do |at| | |
%w{.svn .hg .git .bzr}.each { |exception| at.add_exception(exception) } | |
end | |
module Autotest::Snarl | |
def self.icon |
This file contains hidden or 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
Feature: Cross-compile C extensions | |
In order to avoid bitching from Windows users | |
As a Ruby developer on Linux | |
I want some rake tasks that take away the pain of compilation | |
Scenario: compile single extension | |
Given that all my source files are in place | |
And I'm running a POSIX operating system | |
And I've installed cross compile toolchain |
OlderNewer