Skip to content

Instantly share code, notes, and snippets.

Akira Hayakawa akiradeveloper

Block or report user

Report or block akiradeveloper

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 gist:b7c7b0dbce7734d9a17e82a8729298e4
public editDistance(that: Table): number {
let dist = 0;
// swap distance
let xs = this.asColorSeq();
let ys = that.asColorSeq();
let n = xs.length;
for (let i=0; i<n; i++) {
if (xs[i] != ys[i]) {
dist += 0.5;
View dfs in ford-fulkerson
fn dfs(&mut self, v: usize, t: usize, f: u32) -> u32 {
if v == t { return f; }
self.used[v] = true;
for e in &mut self.g[v] {
if !self.used[] && e.cap > 0 {
let d = self.dfs(, t, std::cmp::min(f, e.cap)); // cannot borrow `*self` as mutable more than once at a time
if d > 0 {
e.cap -= d;
self.g[][e.rev].cap += d; // cannot borrow `self.g` as mutable more than once at a time
return d;
View gist:7b5b28d252acfc4ef571ac79e65d02cc
cl_crosshairalpha 255; cl_crosshaircolor 2; cl_crosshairdot 0; cl_crosshairgap -2; cl_crosshairsize 3; cl_crosshairstyle 4; cl_crosshairusealpha 1; cl_crosshairthickness 1; cl_crosshair_drawoutline 0; cl_crosshair_sniper_width 1;
View gist:03b4355ef13d7cdc8605af270c2c5ac8
// misc
cl_autohelp "0"
cl_autowepswitch "0"
cl_dm_buyrandomweapons "0"
cl_forcepreload "1"
cl_showhelp "0"
cl_showpos "1"\
cl_teamid_overhead_always "2" // w/ equipment
cl_teammate_colors_show "1" // show teammates in rader with color
closeonbuy "0"
View gist:81b7fa34fb887d8e2dcf1ae1e8f5451d
linux-3.10: OK
linux-3.14: OK
linux-3.16: OK
linux-3.18.75: OK
linux-4.12.14: OK
linux-4.13.6: OK
linux-4.1.44: OK
linux-4.4.92: OK
linux-4.6: OK
linux-4.8: OK
View gist:f096e764be07794f157bd11f0da8fb76
udevadm monitor --kernel で待機させてそいつに観測させた
KERNEL[4202.177671] remove /devices/virtual/block/dm-0 (block)
KERNEL[4202.205822] remove /kernel/slab/dmwb_buf_8 (slab)
KERNEL[4202.206786] remove /kernel/slab/bio-3 (slab)
KERNEL[4202.250279] remove /devices/virtual/bdi/251:0 (bdi)
KERNEL[4202.250776] remove /devices/virtual/block/dm-0 (block)
View gist:96fa561e77377d8b038c08a0adf8ac51
sz=`sudo blockdev --getsz ${BACKING}`
echo $sz
sudo dd if=/dev/zero of=$CACHE oflag=direct bs=512 count=1
sudo dmsetup create wbdev --table "0 $sz writeboost $BACKING $CACHE 2 writeback_threshold 70"
sudo dmsetup status wbdev | wbstatus
sudo dd if=/dev/mapper/wbdev of=/tmp/o iflag=direct bs=4k count=1
akiradeveloper / gist:283d0e6d093d7437248de1bfdc110474
Created Oct 12, 2017
View gist:283d0e6d093d7437248de1bfdc110474
// デバイスを作る
$ sudo sh
[sudo] password for akira:
1+0 records in
1+0 records out
512 bytes copied, 0.00111281 s, 460 kB/s
View gist:890ca641eb52db71641fa5244568c30d
Error detected while processing function vimfiler#mappings#do_switch_action..vimfiler#mappings#do_action..vimfiler#mappings#do_files_action..unite#mappings#do_action..unite#action#do:
line 58:
E716: Key not present in Dictionary: file_quit && &buftype =~# 'nofile'
E15: Invalid expression: unite.context.file_quit && &buftype =~# 'nofile'
akiradeveloper /
Created Aug 4, 2016
writeboost read-caching

I am writing this blog as a documentation draft and the aim is to make all users feel easy to use read-caching in their production.

writeboost is a log-structured writeback-caching software so it sounds bit strange that it can supports read-caching. The idea is implement read-caching as lightweight write-caching. The basic idea is:

  1. Only caches 4KB (full-sized) read requests
  2. Captivate read data into the read-cache cells, in the endio callback. (read_cache_cell_copy_data) There are 2048 cells preallocated. reserve_read_cache_cell is called when the read request results in cache miss (then read from the backing device) and the function reserves one of the cells. In endio, the read data payload is copied to the cell reserved.
  3. Once all cells are occupied writeboost "injects" the read data captivated in the cells into the write-caching path. (inject_read_cache) This is something like read-requests turns into writers. But the code path is simpler than the actual write path because the data is assure
You can’t perform that action at this time.