Skip to content

Instantly share code, notes, and snippets.

View luislavena's full-sized avatar

Luis Lavena luislavena

View GitHub Profile
def fib(n)
if n <= 1
return n
else
return fib(n-1) + fib(n-2)
end
end
puts fib(30)
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),
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
# 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/
=== 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 $@.manifest mt.exe -nologo -outputresource:$@;2 -manifest $@.manifest $(ADDITIONAL_MANIFESTS)
!endif
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
package 'openssl', :type => :make do
default 'source'
version 'source' do
download 'http://...'
# hooks
before :download { }
after :download { }
after :extract { }
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
@luislavena
luislavena / gist:23338
Created November 9, 2008 20:33
~/.autotest
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
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