View okinawa.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
code=%(h=60;w=140;s | |
=32.chr;q=s+'rq_xkyzsugt[w | |
vc'.bytes.map{(_1+9509).chr'u | |
tf-8'}*'';l=(s*22+'code=%('+code | |
+");eval(code.scan(/[!-~]/)*'');") ▄▄ | |
.tr(q,s).split($/);v=40.times.map{[ ▟███▄ | |
2*rand-1,rand,0.2+rand,1+_1*0.05]};(0 ▐██████▄ | |
..).each{|t|cv=(1..h).map{[0]*w};v.eac ▐████████▖ | |
h{->cx,cy,r{((2*cx-2*r).ceil..2*cx+2*r ▝█████████▖ | |
).map{|x|((cy-r).ceil..cy+r).map{|y|(2* ▝█████████▖ |
View matrix_mult_concat.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
# https://twitter.com/potetoichiro/status/1538130783785095173 を見て遊んでみた | |
hoge=(11..99).select{_1%10!=0}.to_h do |num| | |
a, b = num.divmod 10 | |
nums = (1..9).to_a | |
combinations = nums.repeated_permutation(4).select do |a2, a3, b2, b3| | |
num == a * b + a2 * b2 + a3 * b3 | |
end | |
[num, combinations.map{|a2,a3,b2,b3|[[a,a2,a3],[b,b2,b3]]}] | |
end |
View TupleMap.ts
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 TupleMap<Key extends readonly any[], Value> { | |
identifierMap = new Map<any, [number, number]>() | |
internalEntries = new Map<string, readonly [Readonly<Key>, Value]>() | |
lastId = 0 | |
addKey(key: Readonly<Key>) { | |
const { identifierMap } = this | |
return key.map(item => { | |
let entry = identifierMap.get(item) | |
if (!entry) identifierMap.set(item, entry = [this.lastId++, 0]) | |
entry[1]++ |
View fact.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
def fact_i(n) = n == 0 ? 1 : (1..n).inject(:*) | |
def fact_s(x) | |
x+=1 | |
Math.sqrt(2*Math::PI/x)*(x/Math::E)**x*Math.exp( | |
1/12.0/x-1/360.0/x**3+1/1260.0/x**5-1/1680.0/x**7+1/1188.0/x**9 | |
) | |
end | |
def fact_i2(x) |
View .gitignore
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-records.conf | |
custom_servers.json |
View 20220220.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
eval(%w(->{ev al($s=_1.sp lit*'')})*'') ["h=29;$*.map | |
{h=[25,( _1.to_f*2 ).roun d].max };e='';q =32.chr+ 'rq_xkyz sugt[wvc | |
'.byte s.map{ (_1+95 09).c hr'utf -8'}*' ';s=[' 2022', | |
'2/20' ].map {|s|( 1..h) .map{ |y|y=1-(2*y- 1.0)/ | |
h;(1.. 6*h).m ap{|x| j,x=x .divm | |
od(1. 5*h); x=(x-0 .75*h) /h;a=( | |
0.5-y) **2;[ (x*x/0 .49-1+ c=y.a | |
bs*y*y )*(c* 41+26* b=(30* x/11)* | |
*2-1), (y-2* x).abs *6-1,2 *y>1?( | |
x*x/1 .96+y *y-y)* (b+9*a ):[(6* |
View dot_irbrc_completion_color.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
# .irbrc | |
Reline.core.add_dialog_proc( | |
:autocomplete, | |
->{ | |
instance_exec(&Reline::DEFAULT_DIALOG_PROC_AUTOCOMPLETE).tap { | |
_1&.bg_color = rand(40..47) | |
} | |
}, | |
Reline::DEFAULT_DIALOG_CONTEXT | |
) |
View strict_colorizer.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
class Colorizer | |
attr_reader :code, :ast, :lines, :line_indices | |
def initialize(code) | |
@code = code | |
@ast = RubyVM::AbstractSyntaxTree.parse code | |
@lines = code.lines | |
@line_indices = [0] | |
@lines.each { @line_indices << @line_indices.last + _1.size } | |
end |
View gongo.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
# https://gist.github.com/gongo/c404167ae49165acd4df63c27ae1a54c | |
# iseqの中から [:putobject, object], :RUBY_EVENT_RETURN や [:putstring, "string"], ?, :RUBY_EVENT_RETURN を雑に探す作戦 | |
def nanika_no_method(code) | |
flat_iseq = RubyVM::InstructionSequence.new(code).to_a.flatten | |
flat_iseq.select.with_index do |s, idx| | |
flat_iseq[idx + 1, 2].include?(:RUBY_EVENT_RETURN) && %i[putobject putstring].include?(flat_iseq[idx - 1]) | |
end.uniq | |
end |
View wordle.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
allwords = File.read('./words.txt').split($/) | |
def select_words(words, query, result) | |
r = result.chars.map(&:to_i) | |
words.select do |w| | |
5.times.all? do |i| | |
c = query[i] | |
r[i] == (w[i] == c ? 2 : w[c] ? 1 : 0) | |
end | |
end |
NewerOlder