-
極端に長い行の貼り付け・編集などのパフォーマンスが悪い
- 長い行数を貼り付けるよりも利用頻度高そう。jsonを貼り付けるとか。どこがボトルネックか測る
-
Unicode
- split_by_widthはheightを返す必要もないし配列の偶数番めにnilを含める必要もない
- get_prev_mbchar とか、unicode.rbでやるべきことか怪しいような
- get_nth_prev_mbchar とかにしないとvi_argが大きい場合のパフォーマンスが悪い
- get_mbchar_widthの高速化をどこまでやるか(あと2段階くらい変身を残してる)効果がどれくらいあるか測る
-
GeneralIO
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
return if ENV['WITHOUT_IRBRC'] | |
{ IRB: 'irb', Reline: 'reline', ReplTypeCompletor: 'repl_type_completor' }.each do |const_name, lib| | |
require lib | |
const = Object.const_get(const_name) | |
version = const::VERSION | |
dir = File.expand_path File.join(File.dirname(const.const_source_location(:VERSION).first), '../../') | |
if File.exist?(File.join(dir, '.git')) | |
Dir.chdir dir do | |
branch = `git branch`[/^\* .+/][2..] |
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
files_rbreadline = Dir.glob('rb-readline/lib/**/*.rb') | |
files_reline = Dir.glob('reline/lib/**/*.rb') | |
K = 123456789 | |
P = (1 << 81) | 17 | |
def hashes(text, n) | |
output = {} | |
hash = 0 | |
hash2 = 0 |
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 'open3' | |
# Usage: cat code.rb | ruby ansi_pbcopy.rb --size 64 --font monospace | |
FONT = ARGV[ARGV.index('--font') + 1] rescue 'courier' | |
SIZE = ARGV[ARGV.index('--size') + 1] rescue 16 | |
COLORS = ARGV[ARGV.index('--color') + 1].split rescue %w[#000000 #A00000 #008000 #606000 #0000C0 #800080 #008080 #808080] | |
initial = { bg: 9, fg: 9, bold: false, italic: false, underline: false } | |
style = initial.dup |
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
%w@state=32;(st@=>s;at_exit{eval( | |
c=s*'')};s+=%w@ate..).each{|s|a=64.ch | |
r;t=((-11..11).map{|iy|((-22..22).map{|ix | |
|x,y=((ix+iy*2i)*(1i**(s/16r))).rect;[x.abs+( | |
y-5).abs,y+10].max<23.4??X:32.chr}*'').rstrip |
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 'matrix' | |
module RegEqSolver | |
class RHS | |
alias ~ binding | |
public :~ | |
end | |
[Integer, Float, Rational, Complex].each do |klass| | |
refine klass do | |
def ~ | |
$rhs = self |
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
# https://github.com/ruby/reline/pull/632 | |
sizes=[] | |
CHUNK_LAST.zip(CHUNK_WIDTH).each{sizes << _2 while sizes.size <= [_1, 0x10ffff].min }; | |
BITCHUNKS = sizes.each_slice(2048).map do |seg| | |
next seg.first if seg.uniq.size == 1 | |
seg.each_slice(64).map do |sub| | |
next sub.first if sub.uniq.size == 1 | |
s = sub.map { _1 == -1 ? 3 : _1 }.reverse.join | |
num = s.to_i(4) |
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
def series(l, r) | |
if r - l <= 1 | |
p = (2 * r - 1) * (6 * r - 5) * (6 * r - 1) | |
q = r * r * r * 10939058860032000 | |
a = (r % 2 == 0 ? 1 : -1) * (13591409 + 545140134 * r) | |
[p, q, a * p] | |
else | |
m = (l + r) / 2 | |
p0, q0, t0 = series(l, m) |
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
MAYBE_TIOCGETC = [ | |
0x40067412, # M2 Mac | |
2, # docker rubyfarm? something is wrong | |
# unknown, found in github search | |
('T'.ord << 8) | 2, | |
('t'.ord << 8) | 18 | |
] | |
cchars = "\0" * 256 | |
STDIN.ioctl(TIOCGETC, cchars) |
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
def fibo_c(n) | |
return 1 if n == 0 | |
a=fibo_c(n/2)*b=1i**n[0] | |
b.*a.abs2+(a.*2+1i).real*a.imag.i | |
end | |
10.times.map{fibo_c(_1).real} | |
# => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] |
NewerOlder