Skip to content

Instantly share code, notes, and snippets.

View sgotand's full-sized avatar

Shotaro Gotanda sgotand

View GitHub Profile
@sgotand
sgotand / stack_layers.py
Last active December 1, 2020 17:37
stack_layers.py
#!/usr/bin/env python3
import argparse
import sys
import json
import pathlib
import os
from os import path
import tarfile
import subprocess
@sgotand
sgotand / git-tree
Created August 20, 2020 11:53
gitのサブコマンド
#!/bin/bash
# 全ブランチのコミットログをいい感じにツリー表示してくれる
# パスに置けば git tree で実行できる
set -eu
git log --graph $(git branch -a |sed s/\*//g | sed -E 's/->.*//')
(gdb) bt
#0 __platform_readv (fd=<optimized out>, fd@entry=4, iov=iov@entry=0x7ffd340ad138, iovcnt=<optimized out>, iovcnt@entry=5) at readv.c:12
#1 0x00000000007e2d00 in fs_request (fs=..., iov=0x7ffd340ad128, cnt=6) at lib/rump-host.c:823
#2 0x00000000007e1212 in fs9p_enqueue (dev=<optimized out>, q=<optimized out>, req=0x7ffd340ad120) at lib/virtio_9pfs.c:36
#3 0x00000000007e1551 in virtio_process_one (dev=dev@entry=0x7f29c3b70118, qidx=qidx@entry=0) at lib/virtio.c:283
#4 0x00000000007e180c in virtio_process_queue (dev=0x7f29c3b70118, qidx=0) at lib/virtio.c:319
#5 0x00000000007e1967 in virtio_write (data=0x7f29c3b70118, offset=<optimized out>, res=<optimized out>, size=<optimized out>) at lib/virtio.c:478
#6 0x0000000000a21cfc in __raw_writel (value=<optimized out>, addr=0x1000050) at /home/travis/build/ukontainer/frankenlibc/linux/arch/lkl/include/asm/io.h:80
#7 writel (value=<optimized out>, addr=0x1000050) at /home/travis/build/ukontainer/frankenlibc/linux/include/asm-generic/io.h:232
#8 vm_n
@sgotand
sgotand / Vagrantfile
Created August 14, 2020 16:44
Vagrantfileのtemplate
# -*- mode: ruby -*-
# vi: set ft=ruby nowrap :
def os
@os ||= (host_os = RbConfig::CONFIG["host_os"]
case host_os
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
:windows
when /darwin|mac os/
:macosx
@sgotand
sgotand / bash_parse_args.sh
Created May 27, 2020 01:45
bashスクリプトの雛形
#!/usr/bin/env bash
set -eu
PROGNAME=$(basename $0)
VERSION="1.0"
usage() {
cat <<EOF
@sgotand
sgotand / upload_layer.py
Created May 21, 2020 07:06
ファイルをdockerレジストリにアップロードするpythonスクリプト
import requests
import logging
import subprocess
def calc_file(path):
proc = subprocess.run(["sha256sum", path],stdout = subprocess.PIPE, stderr = subprocess.PIPE)
digest=proc.stdout.decode().split()[0]
proc = subprocess.run(["wc","-c", path],stdout = subprocess.PIPE, stderr = subprocess.PIPE)
size=proc.stdout.decode().split()[0]
digest=f"sha256%3A{digest}"
return digest, size
#!/bin/bash
set -eu
pushd $(dirname $0)
sudo apt install -y python3 python3-pip
sudo -H python3 -m pip install --upgrade pip
sudo -H python3 -m pip install jupyter
sudo -H python3 -m pip install bash_kernel
@sgotand
sgotand / analyze_docker.go
Created May 20, 2020 15:47
詳しくわ覚えていないが goのソースコードのシンボル抽出をしていたはず。
package main
import (
"bytes"
"fmt"
"go/ast"
"go/format"
"go/parser"
"go/token"
"log"
@sgotand
sgotand / Vagrantfile
Created May 20, 2020 11:38
vagrantでdockerレジストリを試す環境
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
config.vm.box = "generic/ubuntu1804"

Ubuntu18.04上のlibvirtでnested KVMをためす方法

基本情報

  • ホスト: Ubuntu18.04
  • ゲスト(L1): Ubuntu18.04
  • ゲスト(L2): Fedora30

ホストへのlibvirtのインストール

sudo apt update