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
t = {"apple", "orange"} | |
setmetatable(t, { | |
__index = function (t, i) | |
t[i] = "absent" | |
return t[i] | |
end | |
}) | |
print(t[3]) -- => "absent" |
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
Set = {} | |
Set.mt = {} | |
function Set.new(t) | |
local set = {} | |
setmetatable(set, Set.mt) | |
for i,v in ipairs(t) do set[i] = v end | |
return set | |
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 'prawn' | |
require 'prawn/layout' | |
Prawn::Document.generate("table-test.pdf") do | |
headers = ["Course", "Grade", "Comments"] | |
data = [["Home Room", "A+", "Great work!"], | |
["Home Room", "A+", "Great work!"], | |
["Home Room", "A+", "Great work!"], | |
["Home Room", "A+", "Great work!"], | |
["Home Room", "A+", "Great work!"]] |
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 'prawn' | |
require 'prawn/layout' | |
Prawn::Document.generate("table-test2.pdf") do | |
headers = ["Course", "Grade", "Comments"] | |
data = [] | |
10.times { |i| data << ["Home Room", "A+", "Great work!"]} | |
def make_table(headers, data) | |
table( |
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 'prawn' | |
Prawn::Document.generate('crop-marks.pdf') do | |
spacing = 12 | |
margin = 100 | |
canvas do | |
# topleft corner | |
stroke_line [bounds.left + spacing, bounds.top - margin], | |
[bounds.left + margin - spacing, bounds.top - margin] |
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 'prawn' | |
require 'prawn/layout' | |
Prawn::Document.generate("prawn-table-height.pdf") do | |
data = [["This is a line"]] * 10 | |
row_height = font.ascender - font.descender + font.line_gap | |
10.times do |i| | |
stroke_rectangle([0, bounds.top - (i * row_height)], 100, row_height) |
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
print("You have no mail"); | |
running <- T; | |
while(running) { | |
c <- scan(n=1, what="character", quiet=T) | |
if(c=="uname") { | |
print("RUnix 1.1") | |
} else if(c=="halt") { | |
running <- F |
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
data <- read.csv("birth-data.csv") | |
data.sorted <- data[do.call(order, data[c("Pair.ID", "Birth.Order")]), ] | |
tapply(data.sorted$IQ,data.sorted$Pair.ID,function(x){x[2]-x[1]}) |
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
$ ruby -v | |
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-darwin10.2.0] | |
$ rails server | |
/Users/bryce/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:167:in `require': /Users/bryce/.rvm/gems/ruby-1.9.1-p378/bundler/gems/right-rails-31e116387439ab0e3214eef55f316e6da35920f3-master/lib/right_rails/helpers/forms.rb:122: invalid multibyte char (US-ASCII) (SyntaxError) | |
/Users/bryce/.rvm/gems/ruby-1.9.1-p378/bundler/gems/right-rails-31e116387439ab0e3214eef55f316e6da35920f3-master/lib/right_rails/helpers/forms.rb:122: invalid multibyte char (US-ASCII) | |
/Users/bryce/.rvm/gems/ruby-1.9.1-p378/bundler/gems/right-rails-31e116387439ab0e3214eef55f316e6da35920f3-master/lib/right_rails/helpers/forms.rb:122: syntax error, unexpected $end, expecting '}' | |
content_tag :div, '★', :class => i < value ? 'ri... | |
^ | |
from /Users/bryce/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:167:in `block in require' |
OlderNewer