Skip to content

Instantly share code, notes, and snippets.

View hkoba's full-sized avatar

Kobayasi, Hiroaki hkoba

View GitHub Profile
@hkoba
hkoba / gist:a16a29afb9a810649800f95b990f6271
Created May 7, 2020 06:33
Memory fragmentation on one site.
# cat /proc/buddyinfo
Node 0, zone Normal 2285 415 2237 3582 0 1 0 0 0 0 0
Node 1, zone DMA 0 0 1 0 2 1 1 0 1 1 3
Node 1, zone DMA32 301 59 2024 2403 0 0 0 0 0 0 0
Node 1, zone Normal 258 1480 3060 980 1 0 0 0 0 0 0
# uptime
15:31:03 up 308 days, 57 min, 30 users, load average: 0.25, 0.70, 0.82
#
@hkoba
hkoba / instance_configs.cfg.template
Created January 25, 2020 09:42
Minimum config file to use zsh in oslogin account on GCP
# Put this file under /etc/default
[Accounts]
useradd_cmd = useradd -m -s /bin/zsh -p * {user}
@hkoba
hkoba / docker-selinux-kernel.log
Created December 22, 2019 03:24
Possible dockerd related SELinux bug. Triggered by mount --rbind /sys /mnt/disk/sys + mount --make-rslave /mnt/disk/sys . This causes massive setroubleshootd + locate load
-- Logs begin at Mon 2019-11-11 11:08:24 JST, end at Sun 2019-12-22 12:19:02 JST. --
Dec 22 12:01:06 chtholly.localdomain kernel: SELinux: Converting 2611 SID table entries...
Dec 22 12:01:06 chtholly.localdomain kernel: SELinux: Context system_u:object_r:container_var_lib_t:s0 became invalid (unmapped).
Dec 22 12:01:06 chtholly.localdomain kernel: SELinux: Context system_u:object_r:container_unit_file_t:s0 became invalid (unmapped).
Dec 22 12:01:06 chtholly.localdomain kernel: SELinux: Context system_u:object_r:container_runtime_exec_t:s0 became invalid (unmapped).
Dec 22 12:01:06 chtholly.localdomain kernel: SELinux: Context system_u:system_r:container_runtime_t:s0 became invalid (unmapped).
Dec 22 12:01:06 chtholly.localdomain kernel: SELinux: Context system_u:object_r:container_var_run_t:s0 became invalid (unmapped).
Dec 22 12:01:06 chtholly.localdomain kernel: SELinux: Context system_u:object_r:container_plugin_var_run_t:s0 became invalid (unmapped).
Dec 22 12:01:06 chtholly.localdomain kernel: SE
@hkoba
hkoba / main.rs
Created September 22, 2019 13:01
A rust example to read perl's build configuration
use std::process::Command;
use std::collections::HashMap;
use std::result::Result;
use regex::Regex;
fn perl_config(configs: Vec<&str>) -> Result<String, String> {
let mut cmd = Command::new("perl");
cmd.arg("-wle");
cmd.arg(r#"
use strict;
@hkoba
hkoba / gist:00393c5ff10fa9d35b3a6e5ab6813fbf
Created September 17, 2019 06:06
dnfdragora-updater repeatedly dies with this
#2 0x00007f18ca30e769 in __assert_fail_base (fmt=0x7f18c55ca6eb <error: Cannot access memory at address 0x7f18c55ca6eb>,
assertion=0x7f18c8eaf800 "!xcb_xlib_threads_sequence_lost", file=0x7f18c8eaf673 "xcb_io.c", line=263, function=<optimized out>) at assert.c:92
#3 0x00007f18ca31c566 in __GI___assert_fail (assertion=assertion@entry=0x7f18c8eaf800 "!xcb_xlib_threads_sequence_lost", file=file@entry=0x7f18c8eaf673 "xcb_io.c",
line=line@entry=263, function=function@entry=0x7f18c8eafab0 <__PRETTY_FUNCTION__.14998> "poll_for_event") at assert.c:101
#4 0x00007f18c8e3c8db in poll_for_event (dpy=dpy@entry=0x55f92b80f4c0, queued_only=queued_only@entry=0) at xcb_io.c:260
#5 0x00007f18c8e3c980 in poll_for_response (dpy=dpy@entry=0x55f92b80f4c0) at xcb_io.c:303
#6 0x00007f18c8e3cc85 in _XEventsQueued (dpy=dpy@entry=0x55f92b80f4c0, mode=mode@entry=2) at xcb_io.c:363
#7 0x00007f18c8e2e727 in XPending (dpy=0x55f92b80f4c0) at Pending.c:55
#8 0x00007f18bfed5103 in gdk_check_xpending (display=<optimized out>)
@hkoba
hkoba / .gitignore
Last active August 28, 2019 03:19
perf result of ko1's nop test
a.out
nop.rb
t.c
@hkoba
hkoba / main.rs
Created August 7, 2019 10:57
An example of rust ffi to call perl_parse()
// cargo run -- -le 'use strict; $x'
use std::ptr;
use std::ffi::CString; // C に渡す文字列
// use std::ffi::CStr; // for C から返された文字列
use std::os::raw::{c_char, c_int /*, c_void*/, c_schar};
enum PerlInterpreter {}
@hkoba
hkoba / json_of_restricted_hash.pl
Created July 2, 2019 03:16
JSON::XS refuses to encode a restricted hash to json (while Cpanel::JSON::XS is not).
#!/usr/bin/env perl
use strict;
use warnings;
{
my ($use_cpanel) = @ARGV;
my $class = do {
if ($use_cpanel) {
@hkoba
hkoba / extract-meta-scope-list-from-tmlanguage-json.zsh
Last active June 16, 2019 04:13
Extracted list of meta scopes found in VSCode distribution
#!/bin/zsh
emulate -L zsh
perl -nle 'print $& for /meta(\.[-\w]+)*/g' **/*.tmLanguage.json|sort|uniq|
perl -MList::Util=uniq -nle '
(undef, my ($key, @rest)) = split /\./;
pop @rest;
push @{$meta{$key}}, join(".", @rest);
END {
print join "\t", "scope-prefix", "subscopes:";
@hkoba
hkoba / 00readme.md
Last active March 23, 2019 12:24
Experimental snippet to parse LSP's specification.md and extract interface specs as machine readable form

Here is how to use YATT::Lite::LanguageServer::SpecParser from CLI. Zsh is assumed. (Not sure for other shells).

% specFn=specification.md
% parser=Lite/LanguageServer/SpecParser.pm

% $parser --flatten parse_statement_list "$(
     $parser tokenize_statement_list "$(
 $parser --flatten extract_statement_list "$(