Skip to content

Instantly share code, notes, and snippets.

tomoya ishida tompng

Block or report user

Report or block tompng

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View asciiart_noblink.rb
View integerdigits.rb
class Integer
alias_method :original_digits, :digits
def digits(base)
bits = bit_length
base_bits = base.bit_length
return original_digits base if bits < base_bits * 64 # return [self] if self < base
if base == 1 << (base_bits - 1)
n = base_bits - 1
# return Array.new((bits + n - 1) / n) { self[n * _1, n] } # but it's slow
return Array.new((bits + n - 1) / n) { |i| k = 0; j = 0; while j < n; k |= self[n * i + j] << j; j += 1; end; k }
@tompng
tompng / tompng_oedo08_codes.md
Last active Feb 12, 2020
大江戸Ruby会議の資料に使ったコード集
View tompng_oedo08_codes.md
View hashtag_generator.rb
c=%w()*'';eval(c)
code=<<CODE
n=0;
c='c=%w('+c.sub(/[0-9]/,((n+1)%7).to_s).split(f=?#+?;)[0]+f+c.delete('()');
d=(0..19).map{|y|
(0..27).map{|x|
(32.chr+?#)[
'1zafcwugrqlbgca9ooyr858xb34mju9nuvjlz7a61qkek0xi'.to_i(36)[
35*n+y/4*7+x/4
]
View seasons.rb
n=1;eval(x=%[$a='';def$a.+n;$a<<n.to_s;$a;end;->s{$a=s[0..1180];$x=$a.chars.map{
|a|(a.to_i-1).to_s}.join.to_i(9).digits(128).map(&:chr).join;eval($x)}]).call$a+
8327942+
6394+ 56937423834+
888599538188885813761+
1374578327473944888222+
397452662851954429537478+ 7314653+
722676446448949364443325+ 9386372913528+
View unary_clock.rb
eval($a="def$_.+*;eval$c.join.to_i(2).digits(128).map(&:chr)*''end;$_")+
----~~~~-~-~~~--~-~~~~~--~~~~~~--~-~-~--~~-~~-~~~~----~~--~~-~~---~-~---
~--~-~----~~~-~~~~--~---~-~~~--~-~~-~-~---~--~-~----~~~~-~-~-~~~--~--~--
-~-~--~-~-~~-~-~-~~~--~-~~-~~~---~-~~~~-~~~~---~-~-~~--~-~~~-~~-~~~-~--~
~-~~~-~--~~~-~~~~~~-~~~~~-~~~~~-~~~----~-~~~-~~~~---~-~~~-~~~-~----~-~~~
~~~-~~~-~-~~~-~--~~~~-~--~-~---~~--~--~~--~-~-~-----~~--~~~-~-~-~-~~--~-
-~~-~~-~-~----~-~-~-~~-~~~-~~~~---~-~~~-~~~-~-+++~-~~-~~~--~-~~-~~~-~~~~
~~-~-~--~~~--~~~-~--~~-~~-~--~-~-~~~~-~-~---~~+++--~--~~-~~-~~~-~~--~~--
-~-~~--++++++++++++++++++++~~~-~---~-~~~~--~-~+++~~-~~-~~~-~--~~~~--~~~~
~-~~~~-++++++++++++++++++++-~~~~+++++++++++++++++++++++++++++++~~--~~~~-
View gorogoro.rb
;eval((c=%{E=Math::E;P=Math::PI;m=96;n=48.0;
w=32.chr;c=(w*26+';eval((c=%{'+c+"}).split*'')")
.split$/;gr=->r,t{r<1&&(r>1-(t%u=P*2/3)**2/6||(r*E
**((t-u/ 2)%u-u/2).i-0. 6).abs
<0.4)?2:0};gt=->x,y{y-=0.2;i=n+x*168;j=24+y*84;next(x*(-y)
**0.5*16%1<0.5?1:2)if(y<-0.4&&y>-0.9-x**6&&y>-0.4/x**2);next(
x.abs*2.6%1>0.6||y>-0.35||x.abs<0.1?2:0)if(y>=-0.4&&y<-0.32-x**4
/10);next( 2)if(0< =j&&j<n&&0<i&& (c[j][i] ||w)!=w);nex
t(1)if(2*x**4+y**4<0.01);x=(x.abs-0.5).abs;y<-0.4||y>0.55||x >0.2?0:x>
0.12||y>0.47||(y-0.2)%0.5<0.1?y>0.45&&x>0.12?2:1:2*x*x+y*y<0.0 1+y%0.05/
@tompng
tompng / quine575.rb
Last active Dec 18, 2019
57577 quine
View quine575.rb
##5## ###7### ##5## ###7### ###7###
!eval s="$><< '!%sl s=%%p'% :eva%s"
code = File.read(__FILE__).lines[1].strip
File.write 'tmp.rb', code
out = `ruby tmp.rb`
counts = code.split.map(&:size)
puts
p out == code
p counts
View hockey.rb
require'zlib';_=->_{eval(C=Zlib.inflate(_.unpack('m')[0]))};_[%(
eJyVV213m0YW/j6/gpKNBAgQM5YcR9bYx3Xc1tscp8f2ac4upj68OUJCgmWwBBX6
770zIAnFTjeVDYLnPnPnvs3cEZrRk5!!!!!PhYPhueEwGw8HJyft3x+/fEUIsC2X
h/56jLOxGSd9PFiyJw+4OY4k/C/!' "P9+5Qliy5a0QGMm9DhsYWC0KfG2
Ww9M4PoS5QzhWgT1Zy76bpyK9d' !YbTYoXHCK5q5dM3T9yeMqyieP
0SIIC5M9z9fVUo8qZdVbqpoYrG :kRDJpjaqE54Te4MpgRpTG/z9k
XuohixCYptS3d8vD2Y8FHRxywL :GzxG94i9bvVfNeQJSCrEdQDv/
p8k9iC9vrwDthN2hjStqIe2NhZ; .G719bV529omPwz11uauNhdyvvU
FtE7co/n740PkdKl4O3XrF/5byrx,. .,;W/hGvLa9hB3Clv69SOgNuK8daUL
XCYDWvPfeVrn4C95d9N3WXpdeouQPXTC2a7cv6Bzu801HpVy9/b+e2YQiayRZCJJ
@tompng
tompng / rotate.html
Created Dec 2, 2019
Mac Chrome 外付マウスをつけた時だけ表示が荒ぶる
View rotate.html
<style>
body { margin:0; }
canvas { box-shadow:0 0 4px inset; width:100%; }
div { position:fixed; left: 50%; animation: rotate 1s linear infinite; }
@keyframes rotate { 100% { transform:rotate(360deg); } }
</style>
<div>a</div>
<canvas>
<script>
const canvas = document.querySelector('canvas')
You can’t perform that action at this time.