Skip to content

Instantly share code, notes, and snippets.

View kat0h's full-sized avatar
:octocat:

Kota Kato kat0h

:octocat:
  • Japan
View GitHub Profile
@kat0h
kat0h / quine_clock.rb
Created May 9, 2021 00:51
[Quine] Clock.rb
eval$s=%w' t="e val$
s=% w"<< 39<< ($s*
3);s =?0 ;b=[ ""]*
7;Ti me .now .str
ftim e( "%H: %M")
.spl it(" ").e
ach{ |n|c =[12
6,48 ,109 ,121
,51,9 1,95 ,112
,127, 123] [n.to_ i];h= ->(i ){n=
@kat0h
kat0h / loop
Last active May 14, 2021 14:00
eval$s=%w'loop{a=Array;s=34;b=a.new(s){a.new(s,0)};(0...s).each{|x|(0...s).each{|y|xx=x-s/2.1;yy=y-s/2.1;i=xx**2+yy**2;b[y][x]=(s/2.8)**2<i&&i<(s/2)**2?1:((i<(s/20)**2)?1:0)}};l=Math;t=Time.new;h,m,v=(t.hour%12+t.min*0.00872664625)*0.5235,t.min*0.1047,t.sec*0.1047;c=->(p,z,u,d,e){g=d-z;i=(g>=0)?1:-1;o=e-u;j=(o>=0)?1:-1;g=g.abs*2;o=o.abs*2;p[u][z]=1;x=z;y=u;if(g>o);f=o-g/2;until(x==d);k=f>=0;y+=(k)?j:0;f-=(k)?g:0;x+=i;f+=o;p[y][x]=1;end;else;f=g-o/2;until(y==e);if(f>=0);x+=i;f-=o;end;y+=j;f+=g;p[y][x]=1;end;end;};b[(-l.cos(v)*(s/3)+s/2).to_i][(l.sin(v)*(s/3)+s/2).to_i]=1;c.call(b,s/2,s/2,(l.sin(m)*(s/2.6)+s/2).to_i,(-l.cos(m)*(s/2.5)+s/2).to_i);c.call(b,s/2,s/2,(l.sin(h)*(s/5)+s/2).to_i,(-l.cos(h)*(s/4)+s/2).to_i);e=0;q="";b.each{|y|y.each{|x|q+=(x==1)?("eval$s=%w"<<39<<$s*3)[e..e+1]:32.chr*2;e+=(x==1)?2:0;};q<<10};q[-33,6]=""<<39<<".join#";e=27.chr;puts("##{e}[1;1H#{e}[H#{e}[2J"+10.chr+q);sleep(1)}#'.join#
@kat0h
kat0h / md-preview.ts
Created September 24, 2021 11:31
Markdownをリアルタイムにプレビューするやーつ(denops.vim :MDP)
import { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import { execute } from "https://deno.land/x/[email protected]/helper/mod.ts";
import * as op from "https://deno.land/x/[email protected]/option/mod.ts";
import MarkdownIt from "https://esm.sh/markdown-it";
import { listenAndServe } from "https://deno.land/[email protected]/http/server_legacy.ts";
import {
acceptWebSocket,
WebSocket,
} from "https://deno.land/[email protected]/ws/mod.ts";
import { open } from "https://deno.land/x/[email protected]/index.ts";
@kat0h
kat0h / c.rb
Created November 6, 2021 14:11
eval$s=%w'a=Array;s=
34;b=a.new(s){a.new(s,0)};(0..
.s).each{|x|(0...s).each{|y|xx=x-s/2.1
;yy=y-s/2.1;i=xx**2+yy**2;b[y][x]=(s/2.8)*
*2<i&&i<(s/2)**2?1:((i<(s/20)**2)?1:0)}};l=Math;
t=Time.new;h,m=( t.hour%12+t.min*
0.00872664625) *0.5235,t.min*
0.1047;c=->(p, z,u,d,e){g=d
-z;i=(g>=0)? 1:-1;o=e-u;j
=(o>=0)?1:-1 ;g=g.abs*2;o
#反転
eval(s="a='eval(s='+s.inspect+')';puts a.reverse")
#色付き
eval(s='a="\\e[31meval(s="+s.inspect+")\\e[m";puts a')
@kat0h
kat0h / has_wsl.patch
Last active May 22, 2022 09:13
has('wsl') porting for vim (供養)
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 72e2cf13f..833a39a11 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -10445,6 +10445,7 @@ xpm Compiled with pixmap support.
xpm_w32 Compiled with pixmap support for Win32. (Only for
backward compatibility. Use "xpm" instead.)
xsmp Compiled with X session management support.
+wsl Vim is running on WSL (Windows Subsystem for Linux).
xsmp_interact Compiled with interactive X session management support.
@kat0h
kat0h / VimBug?.md
Created July 31, 2022 14:47
Vimのバグ!
let Ref = function({val -> execute("echo val")})
call Ref("hoge") " => hoge
vim9script
var Ref = function((val) => execute("echo val"))
Ref("hoge") # =&gt; E121: Undefined variable: val
@kat0h
kat0h / zundoko.md
Last active August 3, 2022 13:00
ズンドコキヨシ
const Z = (f=> (x=>f(y=>x(x)(y))) (x=>f(y=>x(x)(y))) )

console.log(
  Z(
    (x) => (
      (n) => (
        (n==0) ? 1 : n * x(n-1)
      )
    )
@kat0h
kat0h / counter.vim
Last active August 29, 2022 11:47
Vimのバッファでカウンターを実装するサンプル
function! s:State(bufid) abort
let l:counter = 0
let l:bufid = a:bufid
function! Inc() closure
let l:counter += 1
call Flash()
endfunction
function! Dec() closure
@kat0h
kat0h / AnalogClockQuine.rb
Last active September 4, 2022 05:44
プログラム
# アナログ時計の形に整形された 自分自身と等しいプログラムを出力するプログラム
eval$s=%w'a=Array;s=
34;b=a.new(s){a.new(s,0)};(0..
.s).each{|x|(0...s).each{|y|xx=x-s/2.1
;yy=y-s/2.1;i=xx**2+yy**2;b[y][x]=(s/2.8)*
*2<i&&i<(s/2)**2?1:((i<(s/20)**2)?1:0)}};l=Math;
t=Time.new;h,m=( t.hour%12+t.min*
0.00872664625) *0.5235,t.min*
0.1047;c=->(p, z,u,d,e){g=d
-z;i=(g>=0)? 1:-1;o=e-u;j