Skip to content

Instantly share code, notes, and snippets.

@l0rzl
l0rzl / !xpass.sh
Last active April 24, 2022 21:19
DS-Lite tunnel setup for Xpass
#!/bin/sh
srcaddr=$(ifconfig hn0 | grep -o '2001:f[67][0-9a-f:]*')
dstaddr=$(drill dgw.xpass.jp aaaa | grep -o '2001:f[67][0-9a-f:]*')
ifconfig gif0 create
ifconfig gif0 inet6 -accept_rtadv -auto_linklocal tunnel $srcaddr $dstaddr
ifconfig gif0 up mtu 1500
route -4 delete default
route -4 add default -interface gif0 -mtu 1240
sysctl net.inet.ip.forwarding=1
ifconfig gif0
@l0rzl
l0rzl / !AtCoder_2022.md
Last active May 29, 2022 10:38
競プロ日記
@l0rzl
l0rzl / !binaryheap.rb
Last active February 21, 2022 08:21
Ruby implementation of binary-heap and heapsort. (short code style)
def up(a,x,i=j=a.size) a[i]=a[i=j] while 0<=j=(i-1)>>1 and a[j]<x; a[i]=x end
def down(a,x=a.pop,i=0,n=a.size-1)
while n >= i+=1+j=i
y=a[i]; n>i&& y<a[i+1]&& y=a[i+=1]; x<y ? a[j]=y: break end; a[0]&& a[j]=x
end
def heapify(a,n=a.size); i=0; up(a,a[i],i) while n > i+=1 end
def sort(a,n=a.size)
heapify(a,n); (x,a[n] = a[n],a[i=j=0]; down(a,x,0,n-1)) while 0 < n-=1; a
end