<?xml version="1.0" encoding="UTF-8" ?>
<rss version="0.91">
  <channel>
    <title>XOR</title>
    <description>天邪鬼のそこはかとない日記</description>
    <link>http://xor.zoku-sei.com/</link>
    <language>ja</language>
    <copyright>Copyright (C) NINJATOOLS ALL RIGHTS RESERVED.</copyright>

    <item>
      <title>XORとは</title>
      <description>えっ、そこ？みたいな観点でつづっていきたいと思わなくもないこともない&lt;br /&gt;
nwpfhがお送りするブログです。&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://xor.zoku-sei.com/Entry/4/&quot; target=&quot;_blank&quot;&gt;ちなみにXORで検索に引っかかってしまうので説明を軽く&lt;/a&gt;</description> 
      <link>http://xor.zoku-sei.com/Entry/4/</link> 
    </item>
    <item>
      <title>fluxboxからlabwcへの切り替え時にfluxboxでgnome-terminalから入力できなくなる</title>
      <description>fluxboxからlabwcに切り替えてみた下記インストールする必要があり
&lt;pre&gt; 
  sudo add-apt-repository ppa:samoilov-lex/labwc
  sudo apt-get install labwc
  sudo apt-get install waybar
  sudo apt-get install swaylock
  sudo apt-get install fonts-font-awesome
  sudo apt-get install fonts-fork-awesome
  sudo apt-get install fcitx5
  sudo apt-get install wl-clipboard
  sudo apt install fcitx5-mozc
  sudo apt-get isntall dmenu
&lt;/pre&gt;
&lt;br /&gt;
labwcに切り替えたが、fluxboxからgnome-terminalから入力できなくなる。。。&lt;br /&gt;
原因はwaylandが含まれるbus情報があるとx11で行っていた入力ができなくなるらしい・・・
&lt;pre&gt;(例)
~/.config/ibus/bus/49ba92f181ac4a7caf727f7c56429585-unix-wayland-0 
&lt;/pre&gt;</description> 
      <link>http://xor.zoku-sei.com/Entry/87/</link> 
    </item>
    <item>
      <title>[Solved] OEM unlock greyed out</title>
      <description>I installed lineageOS for pixel 6a. But I couldn't unlock my phone. &quot;fastboot flashing unlock&quot; didn't work. Because get_unlock_ability is 0. I looked up for &lt;a href=&quot;https://source.android.com/docs/core/architecture/bootloader/locking_unlocking&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;this page&lt;/a&gt;. I couldn't become root, So I clouldn't change ro.oem_unlock_supported option. So I turn on development mode, And displayed developer options. I understood oem lock is disabled. so I search oem unlock, But oem unlock greyed out. I finally found out. I did checkin on &lt;a href=&quot;https://source.android.com/docs/setup/build/flash#preparing-your-device&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;this page&lt;/a&gt;. All worked.</description> 
      <link>http://xor.zoku-sei.com/Entry/86/</link> 
    </item>
    <item>
      <title>PythonでExcelをTSVに変換してみた</title>
      <description>pythonでExcelからTSVに変換してみた。&lt;br /&gt;
DataFrameでもできるのだけども、ストリーム系でないとメモリをめっちゃ食ってしまう。&lt;br /&gt;
&lt;a href=&quot;https://gist.github.com/doshiraki/3f23cf44d41d50b2b60d9b966244360e&quot;&gt;ソース&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
37万件のデータで実施した場合、&lt;br /&gt;
■今回のソースの場合&lt;br /&gt;

&lt;pre&gt;$ time python excel2tsv_e.py KEN_ALL.xlsx &amp;gt; ken_all2.txt 

real    0m38.720s
user    0m38.614s
sys     0m0.105s
&lt;/pre&gt;
&lt;br /&gt;
■DataFrameを使った場合&lt;br /&gt;

&lt;pre&gt;$ time python excel2tsv_p.py KEN_ALL.xlsx

real    0m47.467s
user    0m47.094s
sys     0m1.139s
&lt;/pre&gt;
&lt;br /&gt;
lxml速い。&lt;br /&gt;
startイベントでendイベントの関数を生成するの結構良いかも。&lt;br /&gt;
あと、4階層以下は都度都度メモリ解放しなくしてるのもうまく働いている。&lt;br /&gt;
DataFrameだと最大800Mまでメモリを使用するが、今回のだと50Mくらい。
&lt;pre&gt;            for event, elem in parser.read_events():
                if event == &quot;end&quot;:
                    yield event, elem, stack
                    stack.pop()
                    if 1 &amp;lt;= len(stack) &amp;lt;= 2:
                        stack[-1].remove(elem)
                    level -= 1
                else:
                    level += 1
                    stack.append(elem)
                    yield event, elem, stack
&lt;/pre&gt;</description> 
      <link>http://xor.zoku-sei.com/Entry/85/</link> 
    </item>
    <item>
      <title>mkfifoを使わずに、プログラムの循環パイプ(yourPG | interpreter | yourPG)サンドウィッチ</title>
      <description>mkfifoを使うと、重複して使えないので、名前なしパイプに名前を付けてみた。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://gist.github.com/doshiraki/779dd679c9d05f3119250655bda70a7f&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;ソース&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
■使い方 &lt;a href=&quot;https://xor.zoku-sei.com/Entry/82/&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;fifoの使い道&lt;/a&gt;と同じことがパイプファイルなしにできる。&lt;br /&gt;

&lt;pre&gt;$ ./a.out
$ $PIPEIN | bash | tee /dev/stderr | python ./test.py | tee /dev/stderr | $PIPEOUT
&lt;/pre&gt;
&lt;br /&gt;
プロセス内で作成したパイプ処理を環境変数に閉じ込めて、bash呼び出しは重複して呼び出せるので良いかも。</description> 
      <link>http://xor.zoku-sei.com/Entry/84/</link> 
    </item>
    <item>
      <title>MovableType To Yaml のsedスクリプト作ってみた。</title>
      <description>引越し検討がてら、MovableType To Yaml のsedスクリプト作ってみた。&lt;br /&gt;
&lt;a href=&quot;https://www.movabletype.jp/documentation/mt7/appendices/export-import-format/&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;MovableTypeフォーマット&lt;/a&gt;&lt;br /&gt;
このフォーマットsedで置換できますか？&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://gist.github.com/doshiraki/c28d1d349341b4d205f4324140c24f17&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;ソース&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
いい感じにyamlになって使い勝手が良いかも？&lt;br /&gt;
&lt;a href=&quot;//xor.zoku-sei.com/File/unknown.png&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;//xor.zoku-sei.com/File/unknown.png&quot; width=&quot;100%&quot; alt=&quot;&quot; /&gt; &lt;br /&gt;
&lt;/a&gt; &lt;br /&gt;
&lt;a href=&quot;//xor.zoku-sei.com/File/b312ae2e.png&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;//xor.zoku-sei.com/File/b312ae2e.png&quot; width=&quot;100%&quot; alt=&quot;&quot; /&gt; &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Qiitaはエクスポート標準で対応してないし、インポートもできないのか。。。&lt;br /&gt;
引越し辞めるかw</description> 
      <link>http://xor.zoku-sei.com/Entry/83/</link> 
    </item>
    <item>
      <title>mkfifoの使い道</title>
      <description>mkfifoを使うと標準出力と標準入力を用いてインタプリタのプログラムを組むことが容易になる。&lt;br /&gt;
&lt;br /&gt;
pythonプログラム(subprocessを用いていない)&lt;br /&gt;

&lt;pre&gt;import re
def send(s):
    RET = &quot;@@RETURN VALUE@@&quot;
    print(s+&quot;;echo {} $?&quot;.format(RET))
    outputs = []
    while True:
        output = input()
        if re.search(&quot;^{} &quot;.format(RET), output):
            m = re.match(&quot;^{} (.*)&quot;.format(RET), output)
            return (int(m.groups()[0]), outputs)
        outputs.append(output)

import sys
print(send(&quot;ping www.google.co.jp -c 4&quot;), file=sys.stderr)
print(send(&quot;ls ----&quot;), file=sys.stderr)
&lt;/pre&gt;
subprocessなしでシェルをキック&lt;br /&gt;

&lt;pre&gt;$ mkfifo net
$ bash &amp;lt; net 2&amp;gt;&amp;amp;1 | tee /dev/stderr | python ls.py | tee net
ping www.google.co.jp -c 4;echo @@RETURN VALUE@@ $?
PING www.google.co.jp (142.250.206.195) 56(84) bytes of data.
64 bytes from kix07s07-in-f3.1e100.net (142.250.206.195): icmp_seq=1 ttl=56 time=14.8 ms
64 bytes from kix07s07-in-f3.1e100.net (142.250.206.195): icmp_seq=2 ttl=56 time=16.6 ms
64 bytes from kix07s07-in-f3.1e100.net (142.250.206.195): icmp_seq=3 ttl=56 time=15.8 ms
64 bytes from kix07s07-in-f3.1e100.net (142.250.206.195): icmp_seq=4 ttl=56 time=15.4 ms

--- www.google.co.jp ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 14.760/15.666/16.645/0.681 ms
@@RETURN VALUE@@ 0
(0, ['PING www.google.co.jp (142.250.206.195) 56(84) bytes of data.', '64 bytes from kix07s07-in-f3.1e100.net (142.250.206.195): icmp_seq=1 ttl=56 time=14.8 ms', '64 bytes from kix07s07-in-f3.1e100.net (142.250.206.195): icmp_seq=2 ttl=56 time=16.6 ms', '64 bytes from kix07s07-in-f3.1e100.net (142.250.206.195): icmp_seq=3 ttl=56 time=15.8 ms', '64 bytes from kix07s07-in-f3.1e100.net (142.250.206.195): icmp_seq=4 ttl=56 time=15.4 ms', '', '--- www.google.co.jp ping statistics ---', '4 packets transmitted, 4 received, 0% packet loss, time 3005ms', 'rtt min/avg/max/mdev = 14.760/15.666/16.645/0.681 ms'])
ls ----;echo @@RETURN VALUE@@ $?
ls: unrecognized option '----'
Try 'ls --help' for more information.
@@RETURN VALUE@@ 2
(2, [&quot;ls: unrecognized option '----'&quot;, &quot;Try 'ls --help' for more information.&quot;])
&lt;/pre&gt;
&lt;br /&gt;
ほかにも、通信系のインタプリタをライブラリなしで実行することができる。&lt;br /&gt;
便利なり。&lt;br /&gt;
その代わり、標準出力は使えないが(笑)簡易RPA的なコンソールプログラムはすぐに作れる。</description> 
      <link>http://xor.zoku-sei.com/Entry/82/</link> 
    </item>
    <item>
      <title>Ubuntuの復旧 Ubuntu18.04→Ubuntu20.04へのアップデート</title>
      <description>・Ubuntuが起動できなくなったので、インストールCDでリカバリした。&lt;br /&gt;
&lt;a href=&quot;https://www.linuxfromscratch.org/lfs/view/stable/chapter07/kernfs.html&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;マウント&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.linuxfromscratch.org/lfs/view/stable/chapter07/chroot.html&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;chroot&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
デバイスドライバまわりのメモ&lt;br /&gt;
・r8168ネットワークドライバが認識しない。&lt;br /&gt;
　&lt;a href=&quot;https://tarufu.info/r8168-ubuntu/&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;RTL8111/8168/8411 のインストールに苦悩した話&lt;/a&gt;&lt;br /&gt;
・i915ビデオドライバがflickerする。&lt;br /&gt;
　&lt;a href=&quot;https://l-w-i.net/t/ubuntu/pci_bus_error_100.txt&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;「PCIe Bus Error: severity=Corrected, type=Data Link Layer」を回避する方法&lt;/a&gt;</description> 
      <link>http://xor.zoku-sei.com/Entry/81/</link> 
    </item>
    <item>
      <title>AGC039 Graph partitionを解いてみた</title>
      <description>AGC039に参加して&lt;a href=&quot;https://atcoder.jp/contests/agc039/tasks/agc039_b&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;問題B&lt;/a&gt;が解けなかったのだけども、解き方が分かったので解説&lt;br /&gt;
&lt;br /&gt;
問題としては、同じVnに辺があってはいけないというもの。&lt;br /&gt;
&lt;a target=&quot;_blank&quot; href=&quot;http://file.xor.zoku-sei.com/AGC039B1.png&quot; title=&quot;&quot;&gt;&lt;img src=&quot;http://file.xor.zoku-sei.com/Img/1570360277/&quot; alt=&quot;&quot; width=&quot;80%&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
幅優先探索法で、既に探索済みのノードに出会った場合、次のレベルか前のレベルかしかないということに気づけば後はもっとも長いパスを見つければOK&lt;br /&gt;
&lt;a target=&quot;_blank&quot; href=&quot;http://file.xor.zoku-sei.com/AGC039B2.png&quot; title=&quot;&quot;&gt;&lt;img src=&quot;http://file.xor.zoku-sei.com/Img/1570360276/&quot; alt=&quot;&quot; width=&quot;80%&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
うーん、時間中には思いつかん。。。</description> 
      <link>http://xor.zoku-sei.com/Entry/79/</link> 
    </item>
    <item>
      <title>赤黒木をgoで実装してみた</title>
      <description>作ったのはこちら&lt;br /&gt;
&lt;a href=&quot;https://github.com/doshiraki/rbtree_bygo/blob/master/rbtree.go&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;https://github.com/doshiraki/rbtree_bygo/blob/master/rbtree.go&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://en.wikipedia.org/wiki/Red%E2%80%93black_tree&quot; title=&quot;&quot; target=&quot;_blank&quot;&gt;赤黒木&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
やっぱり削除は難しい。。。&lt;br /&gt;
ポイントは、delete case 3,4がまったく同じ結果というようにまとめられること。&lt;br /&gt;

&lt;pre&gt;	Node := delNode
	for {
		parent := Node.parent
		if parent == nil {
			&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;//case 1&lt;/span&gt;&lt;/strong&gt;
			break
		}

		dir := Node.dir()
		dirOther := dir ^ 1
		sibling := parent.children[dirOther]

		if sibling.isRed {
			&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;//case 2&lt;/span&gt;&lt;/strong&gt;
			parent.flip(dirOther)
			sibling.isRed = false
			parent.isRed = true
			sibling = parent.children[dirOther]
		}
		&lt;span style=&quot;text-decoration: underline;&quot;&gt;//sibling is Black&lt;/span&gt;

		nephew := sibling.children[dirOther]
		if nephew == nil || !nephew.isRed {
			&lt;span style=&quot;text-decoration: underline;&quot;&gt;//far nephew is Black&lt;/span&gt;
			nephew = sibling.children[dir]
			if nephew == nil || !nephew.isRed {
				&lt;span style=&quot;text-decoration: underline;&quot;&gt;//near nephew is Black&lt;/span&gt;
				sibling.isRed = true
				if parent.isRed {
					&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;//case 4&lt;/span&gt;&lt;/strong&gt;
					parent.isRed = false
					break
				} else {
					&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;//case 3&lt;/span&gt;&lt;/strong&gt;
					Node = parent
					continue
				}
			}
			&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;//case 5&lt;/span&gt;&lt;/strong&gt;
			&lt;span style=&quot;text-decoration: underline;&quot;&gt;//near nephew is Red and far nephew is Black&lt;/span&gt;
			sibling.flip(dir)
			sibling, nephew = nephew, sibling
			sibling.isRed = false
			nephew.isRed = true
		}
		&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;//case 6&lt;/span&gt;&lt;/strong&gt;
		&lt;span style=&quot;text-decoration: underline;&quot;&gt;//sibling is Black &amp;amp;&amp;amp; far nephew is Red&lt;/span&gt;

		saveColor := parent.isRed
		parent.flip(dirOther)
		sibling.isRed = saveColor
		parent.isRed = false
		nephew.isRed = false
		break

	}

&lt;/pre&gt;</description> 
      <link>http://xor.zoku-sei.com/Entry/78/</link> 
    </item>

  </channel>
</rss>