Skip to content

Instantly share code, notes, and snippets.

View hkoba's full-sized avatar

Kobayasi, Hiroaki hkoba

View GitHub Profile
@hkoba
hkoba / generator-test.ts
Last active July 24, 2021 08:16
To pass JS Generator between functions like stream, you should not use `for (const v of gen)`
console.log('\nNG')
ng();
console.log('\nOK')
ok();
function ng() {
let lex = gen(0, 10);
for (const i of lex) {
console.log(`top: ${i}`)
if (i === 3) {
@hkoba
hkoba / my-tide-init.el
Last active June 30, 2021 10:32
Run static checkings on typescript for every saving action in Emacs tide mode.
;; (add-hook 'after-save-hook #'my-tide-do-lint nil t)
(defun my-tide-do-lint ()
(interactive)
(tide-command:geterr
(lambda (response)
(when (tide-command-unknown-p response)
(tide-tsserver-version-not-supported))
(if (tide-response-success-p response)
;; (message "%s" response)
@hkoba
hkoba / 10-synaptics.zsh
Created November 18, 2020 04:25
xinput sample
#!/bin/zsh
thisDir=$(cd $0:h && print $PWD)
source $thisDir/config.env
set -e
zparseopts -D -K n=o_dryrun
# dev='SynPS/2 Synaptics TouchPad'
@hkoba
hkoba / gist:7156c84f058769bc3abf52f95dd9537e
Created October 31, 2020 05:29
This is why Module::Build::Pluggable do not work well with subclassing. `use MyBuiilder` just destroys `_build`.
DB<2> T
@ = DB::DB called from file '/usr/share/perl5/vendor_perl/File/Path.pm' line 271
. = File::Path::rmtree('_build', 0, 0) called from file '/usr/share/perl5/vendor_perl/Module/Build/Base.pm' line 5283
. = Module::Build::Base::delete_filetree('Module::Build', '_build') called from file '/usr/share/perl5/vendor_perl/Module/Build/Base.pm' line 1064
$ = Module::Build::Base::subclass('Module::Build', 'code', '^J use Module::Build::Pluggable;^J sub resume {^J my $class = shift;^J my $self = $class->SUPER::resume(@_);^J Module::Build::Pluggable->call_triggers_all(\'build\', $self, [[\'Module::Build::Pluggable::CPANfile\',undef]]);^J $self;^J }^J ') called from file '/usr/local/share/perl5/5.30/Module/Build/Pluggable.pm' line 30
. = Module::Build::Pluggable::import(undef, 'CPANfile') called from file '/home/hkoba/db/work/2020/App-oo_modulino_zsh_completion_helper/misc/cpan/MyBuilder.pm' line 8
. = MyBuilder::BEGIN() called from file '/home/hk
@hkoba
hkoba / LICENSE
Last active September 11, 2020 23:09
A tiny cookie based session example in raw PSGI. Ported from pp62-65 of 徳丸本 ISBN: 978-4797393163
This software is copyright (c) 2020 by Kobayasi, Hiroaki <[email protected]>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
Terms of the Perl programming language system itself
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
@hkoba
hkoba / ng.poll.strace
Created May 30, 2020 11:55
google chrome のマスタープロセスが cpu100% になった時の strace の撮り比べ、 poll だけに注目すると起きる頻度が違うなと。fd=12 起きすぎ?
14:35:16.290028 poll([{fd=11, events=POLLIN}, {fd=12, events=POLLIN}, {fd=24, events=POLLIN}, {fd=32, events=POLLIN}], 4, 0) = 0 (Timeout) <0.000007>
14:35:16.290184 poll([{fd=11, events=POLLIN}, {fd=12, events=POLLIN}, {fd=24, events=POLLIN}, {fd=32, events=POLLIN}], 4, 12405) = 1 ([{fd=12, revents=POLLIN}]) <0.000941>
14:35:16.291406 poll([{fd=11, events=POLLIN}, {fd=12, events=POLLIN}, {fd=24, events=POLLIN}, {fd=32, events=POLLIN}], 4, 0) = 0 (Timeout) <0.000005>
14:35:16.291616 poll([{fd=11, events=POLLIN}, {fd=12, events=POLLIN}, {fd=24, events=POLLIN}, {fd=32, events=POLLIN}], 4, 12404) = 1 ([{fd=12, revents=POLLIN}]) <0.000006>
14:35:16.291842 poll([{fd=11, events=POLLIN}, {fd=12, events=POLLIN}, {fd=24, events=POLLIN}, {fd=32, events=POLLIN}], 4, 0) = 0 (Timeout) <0.000006>
14:35:16.292009 poll([{fd=11, events=POLLIN}, {fd=12, events=POLLIN}, {fd=24, events=POLLIN}, {fd=32, events=POLLIN}], 4, 12404) = 1 ([{fd=12, revents=POLLIN}]) <0.000539>
14:35:16.292740 poll([{fd=11, events=POLLIN}, {fd=12, even
@hkoba
hkoba / gdb-session.log
Created May 29, 2020 04:25
最近の linux 版 google-chrome の master プロセスが recvmsg を無駄に呼び出して cpu100% 食う現象の記録、その2. fd24 と 32、どちらも XPending の呼び出しらしい
Continuing.
Thread 1 "chrome" hit Breakpoint 1, __libc_recvmsg (fd=32, msg=msg@entry=0x7fff42e0c580, flags=flags@entry=0) at ../sysdeps/unix/sysv/linux/recvmsg.c:26
26 {
(gdb) bt
#0 __libc_recvmsg (fd=32, msg=msg@entry=0x7fff42e0c580, flags=flags@entry=0) at ../sysdeps/unix/sysv/linux/recvmsg.c:26
#1 0x00007f974f06bc39 in _xcb_in_read (c=c@entry=0x2ee86a5ac000) at xcb_in.c:1000
#2 0x00007f974f06c728 in poll_for_next_event (c=0x2ee86a5ac000, queued=queued@entry=0) at xcb_in.c:352
#3 0x00007f974f06c791 in poll_for_next_event (queued=0, c=<optimized out>) at xcb_in.c:722
#4 xcb_poll_for_event (c=<optimized out>) at xcb_in.c:722
@hkoba
hkoba / google-chrome-heavyload-strace.log
Created May 22, 2020 12:54
My google-chrome-stable-83.0.4103.61-1.x86_64 eats CPU100%. This occurs very frequently. google-chrome-stable-83.0.4103.61-1.x86_64 on Fedora32
1590141400.309540 recvmsg(31, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
1590141400.309564 recvmsg(32, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
1590141400.309587 recvmsg(32, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
1590141400.309611 poll([{fd=11, events=POLLIN}, {fd=12, events=POLLIN}, {fd=31, events=POLLIN}, {fd=32, events=POLLIN}], 4, 187) = 1 ([{fd=12, revents=POLLIN}])
1590141400.309847 recvmsg(31, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
1590141400.309875 recvmsg(31, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
1590141400.309902 read(12, "!", 2) = 1
1590141400.309944 write(29, "\0", 1) = 1
1590141400.309974 recvmsg(31, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
1590141400.309998 recvmsg(31, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
@hkoba
hkoba / AppX.tcl
Created May 17, 2020 03:23
A demo for Tcl/Tk's `[send]` command. (Requires Tk8.6 on Unix with Xwindow support).
#!/usr/bin/wish
# -*- mode: tcl; coding: utf-8 -*-
tk appname AppX
set X 0
pack [button .b -text "Increment var in AppY" -command {
send AppY [list incr Y]
}] -fill both -expand yes
@hkoba
hkoba / sysconfig-docker.patch
Created May 12, 2020 09:45
Workaround to revert devicemapper thinpooldev in Fedora32
# [graphdriver] WARNING: the devicemapper storage-driver is deprecated, and will be removed in a future release
diff --git a/sysconfig/docker b/sysconfig/docker
index 6ba9fd7..370f2bf 100644
--- a/sysconfig/docker
+++ b/sysconfig/docker
@@ -7,4 +7,7 @@ OPTIONS="--selinux-enabled \
--default-ulimit nofile=1024:1024 \
--init-path /usr/libexec/docker/docker-init \
--userland-proxy-path /usr/libexec/docker/docker-proxy \