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 'pdf-reader' | |
require 'csv' | |
pdf_reader = PDF::Reader.new("input.pdf") | |
csv = CSV.open("output.tsv","wb", {:col_sep => "\t"}) | |
area = "" | |
pdf_reader.pages[42..69].each do |page| | |
page.text.each_line do |line| | |
if /^[a-z|\s]*$/i=~line |
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
number.chars.map(&:to_i).each_cons(5).map{|a| a.inject(&:*)}.max |
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
class Array | |
def count_by function | |
map = Hash.new(0) | |
self.each { |e| map[e.send(function)] += 1 } | |
map | |
end | |
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
module Enumerable | |
def count_by (&block) | |
Hash[ self.group_by { |e| yield e }.map { |key, list| [key, list.length] } ] | |
end | |
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
a = ["test", "tull", "t\U+FFC3\U+FFB8ys"] | |
=> ["test", "tull", "tys"] |
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
$ rvm get latest | |
$ rvm pkg install readline --verify-downloads 1 | |
$ rvm reinstall all --force --verify-downloads 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
a = ["test", "tull", "tøys"] | |
=> ["test", "tull", "tøys"] |
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
begin | |
require 'gnuplot' | |
rescue LoadError | |
puts "No usable Gnuplot..." | |
end | |
class Point | |
def initialize(coords) | |
@coords = coords | |
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 'csv' | |
require 'pp' | |
require './names.rb' | |
require './countries.rb' | |
number_of_runs = 10000 | |
number_of_groups = 4 | |
participants_file = "participants.txt" | |
col_sep = "\t" | |
encoding = "UTF-8" |
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 'benchmark' | |
require 'benchmark/ips' | |
array = [] | |
1000.times { array << rand(1000) } | |
N = 10000 | |
module Enumerable | |
def count_by_function function | |
map = Hash.new(0) |
OlderNewer