Skip to content

Instantly share code, notes, and snippets.

View shyouhei's full-sized avatar

卜部昌平 shyouhei

View GitHub Profile
#! /your/favourite/path/to/ruby
# -*- coding: utf-8 -*-
# Copyright (c) 2013 Urabe, Shyouhei
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@shyouhei
shyouhei / result
Last active December 16, 2015 21:29
これだからPerlは…
zsh % carton exec perl tmp.pl
$VAR1 = {
'1.79769313486232e+308' => '1.79769313486232e+308'
};
$VAR2 = {
'1.79769313486232e+308' => 'inf'
};
zsh % bundle exec ruby tmp.rb
{1.7976931348623157e+308=>1.7976931348623157e+308}
{"1.7976931348623157e+308"=>1.7976931348623157e+308}
# -*- coding: utf-8 -*- # Unicode UTF-8エンコーディングを指定する
# マルチバイトの乗算記号を含む文字列リテラル
s = "2×2=4"
# 文字列には5文字をエンコードする6バイトが含まれている
s.bytesize # => 6
s.bytesize.times {|i| print s.getbyte(i), " "} # "50 195 151 50 61 52"と表示
s.length # => 5
s.length.times {|i| print s[i], " "} # "2 × 2 = 4"と表示
zsh % rbenv install 2.0.0-dev
/home/shyouhei/.rbenv/plugins/ruby-build/bin/rbenv-install: line 66: rbenv-hooks: command not found
Downloading http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz...
Installing yaml-0.1.4...
Installed yaml-0.1.4 to /home/shyouhei/.rbenv/versions/2.0.0-dev
Cloning https://github.com/ruby/ruby.git...
Installing ruby-2.0.0-dev...
BUILD FAILED

本年もRubyConfに行っていただきたく思います。

趣意

まあ前回と同じなのですけれども、それだけだとアレなので、繰り返させていただきますが、基本となるのはやはりRubyConfというカンファレンスがとてもよいカンファレンスだということです。RubyConfは「驚くほど同じだし、驚くほど違います」。同じ部分に関して言えば、RubyConfは海外のカンファレンスがどうとか以前の問題として、Rubyのカンファレンスなのです。ようするにおまえらは多少住む大陸が違った程度ではやっぱりおまえらということです。しかし違うところは違う。その違いを、ここで言葉で説明するのはたやすいが、私としてはぜひ皆さん自身の体験としてそれを得てほしいと思っているのです。なぜなら、体験することではじめて得られる部分があるからです。発表スライドや発表動画なら、こんにちインターネット経由でいくらでも入手可能です。それらは、無論、とても良いものですが、かといってそれだけではカンファレンスとして成立しないのも、お分かりかと思います。ぜひ、本物のRubyConfを体験してほしいし、RubyConfにはそれだけの価値はある、と信じています。

お金のこと

今年も卜部が全額負担する予定です。

diff --git a/tengine_resource/tengine_resource.gemspec b/tengine_resource/tengine_resource.gemspec
index 7730e17..fb205d1 100644
--- a/tengine_resource/tengine_resource.gemspec
+++ b/tengine_resource/tengine_resource.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["taigou", "totty", "g-morita", "shyouhei", "akm", "hiroshinakao"]
- s.date = "2012-05-02"
+ s.date = "2012-05-23"
require 'benchmark'
a = Array.new(4096) { [rand(1 << 64), rand(1 << 64)] }
n = 1 << 32
Benchmark.bmbm do |x|
x.report do
a.collect do |b|
a.select do |c|
n >= Math.sqrt(
(b[0] - c[0]) ** 2 + (b[1] - c[1]) ** 2
)
#! /bin/ruby1.8.7 -Ku
require 'socket'
require 'open-uri'
require 'time'
require 'json'
require 'base64'
def cut str, len=100
a = str.scan /./u
@shyouhei
shyouhei / gist:1445972
Created December 8, 2011 03:25
Coverage kills encodings
zsh % ruby -ve '
require "fileutils"
require "coverage"
FileUtils.mkdir_p "ディレクトリ"
FileUtils.touch "ディレクトリ/ファイル.rb"
$LOAD_PATH << "ディレクトリ"
Coverage.start
require "ファイル"