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
mrkn-mbp15-late2016:homebrew-red-data-tools mrkn$ brew install apache-arrow-glib.rb | |
==> Downloading https://www.apache.org/dyn/closer.cgi?path=arrow/arrow-0.7.0/apache-arrow-0.7.0.tar.gz | |
Already downloaded: /Users/mrkn/Library/Caches/Homebrew/apache-arrow-glib-0.7.0.tar.gz | |
"/opt/brew/lib/pkgconfig:/opt/brew/opt/jemalloc/lib/pkgconfig:/opt/brew/opt/apache-arrow/lib/pkgconfig:/opt/brew/opt/glib/lib/pkgconfig:/opt/brew/opt/gobject-introspection/lib/pkgconfig" | |
==> ./configure --prefix=/opt/brew/Cellar/apache-arrow-glib/0.7.0 CC=clang | |
Last 15 lines from /Users/mrkn/Library/Logs/Homebrew/apache-arrow-glib/01.configure: | |
checking for ld used by clang++... /Applications/Xcode_8.3.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld | |
checking if the linker (/Applications/Xcode_8.3.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no | |
checking whether the clang++ linker (/Applications/Xcode_8.3.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) 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
require 'pycall' | |
SSD_KERAS_DIR = File.expand_path('../../ssd_keras', __FILE__) | |
PyCall.import_module('sys').path.append(SSD_KERAS_DIR) | |
PICS_DIR = File.join(SSD_KERAS_DIR, 'pics') | |
np = PyCall.import_module('numpy') | |
imagenet_utils = PyCall.import_module('keras.applications.imagenet_utils') | |
image = PyCall.import_module('keras.preprocessing.image') |
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
[2] pry(main)> Pandas = PyCall.import_module('pandas') | |
/Users/mrkn/src/github.com/mrkn/pycall-next/lib/pycall/init.rb:20: warning: instance variable @handle not initialized | |
/Users/mrkn/src/github.com/mrkn/pycall-next/lib/pycall/init.rb:26: warning: loading in progress, circular require considered harmful - /Users/mrkn/src/github.com/mrkn/pycall-next/lib/pycall.bundle | |
from bin/console:10:in `<main>' | |
from /Users/mrkn/.rbenv/versions/2.4.1-o0/lib/ruby/gems/2.4.0/gems/pry-byebug-3.4.2/lib/pry-byebug/pry_ext.rb:11:in `start_with_pry_byebug' | |
from /Users/mrkn/.rbenv/versions/2.4.1-o0/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/pry_class.rb:169:in `start' | |
from /Users/mrkn/.rbenv/versions/2.4.1-o0/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/repl.rb:15:in `start' | |
from /Users/mrkn/.rbenv/versions/2.4.1-o0/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/repl.rb:38:in `start' | |
from /Users/mrkn/.rbenv/versions/2.4.1-o0/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/input_lock.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
require 'daru' | |
require 'tempfile' | |
require 'open-uri' | |
def read_as_dataframe(url) | |
Tempfile.open('hash_bench') do |tmpfile| | |
tmpfile.puts "category\tx\ty" | |
open(url) do |io| | |
io.each_line do |line| | |
next unless line =~ /^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 'pycall/import' | |
include PyCall::Import | |
pyimport 'matplotlib.pyplot', as: 'plt' | |
plt[:plot].([1, 2, 3, 4, 5], 5.times.map { rand }) | |
plt[:show].() |
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 Vocabulary | |
def initialize | |
@words = [] | |
@index = {} | |
end | |
def <<(word) | |
unless @index[word] | |
@index[word] = @words.length | |
@words << word |
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/ips' | |
Benchmark.ips do |x| | |
rat = 123456789123456789/987654321r | |
flt = 123456789.123456789 | |
fix = 1234567890 | |
big = 12345678901234567890 | |
x.report('rat + fix') { rat + fix } | |
x.report('rat + big') { rat + big } |
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
m = 0 | |
n = 5 | |
10_000_000.times do | |
xs = Array.new(n) { 1.0 + 1e-6 * (0.5 - rand) } | |
sq_mean = xs.map {|x| x**2 }.sum / n | |
mean_sq = (xs.sum / n)**2 | |
var = sq_mean - mean_sq | |
p [m += 1, var] if var.negative? | |
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
$ ./ruby -v -rbenchmark -e 'Benchmark.bmbm() {|x| x.report("even?") { 100_000_000.times { 1.even? } } } | |
' | |
ruby 2.4.0dev (2016-03-18 trunk 54163) [x86_64-darwin15] | |
Rehearsal ----------------------------------------- | |
even? 5.470000 0.020000 5.490000 ( 5.525505) | |
-------------------------------- total: 5.490000sec | |
user system total real | |
even? 5.590000 0.020000 5.610000 ( 5.668936) |
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
z='ズン';d='ドコ';loop.lazy.map{[z,d].sample.tap{|x|$><<x}}.each_cons(5){|x|break if x.join==z*4+d};puts'キ・ヨ・シ!' |