2024-02-01から1ヶ月間の記事一覧

ClusterRoleとRoleBindingの組み合わせ

Namespaced Resource Role Rolebinding Cluster Resource ClusterRole ClusterRolebinding Role系のリソースとBinding系のリソースの組み合わせ 以下は直感的に理解できる。 RoleとRoleBindingの組み合わせ(青線) ClusterRoleとClusterRoleBindingの組み合…

しゃくとり法(two pointer approach)

どういう場合で使えるか こちらの記事を引用させていただくと、以下のような問題を解くのに使える。 長さのn数列 a1, a2, a3, ... , anにおいて - 「条件」を満たす区間 (連続する部分列) のうち、最小の長さを求めよ - 「条件」を満たす区間 (連続する部分…

getopt, getopt_longについて

getopt #include <unistd.h> int getopt(int argc, char * const argv[], const char *optstring); extern char *optarg; extern int optind, opterr, optopt; optstringにはオプションで指定できる文字のリストになっていて、引数を取る場合にはその文字の直後に:を付</unistd.h>…

可変長引数のマクロ

__VA_ARGS__で可変長引数のマクロを実現できる。 example #include <stdio.h> #define DEBUG_PRINT(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__) #define DEBUG_PRINT2(...) fprintf(__VA_ARGS__, 22) int main(int argc, char **argv) { char *name = "Taro"; int i</stdio.h>…

可変長引数の関数

va_listという型があり、これを使って可変長引数リストを操作できる。 va_listは、SYSTEM_DATA_TYPES(7)に説明がある。 example #include <stdio.h> static void myprintf(char *first_arg, ...) { va_list ap; va_start(ap, first_arg); printf("%s\n", va_arg(ap, c</stdio.h>…

GolangのGenericsについてざっくり

any型 any型はinterface{}型のエイリアス 既存コードはgofmtで置換可能。 gofmt -w -r 'interface{} -> any' . comparable型 ==や!=で比較できるもの。 関数定義と一緒に型パラメータを定義 関数定義 func SumIntsOrFloats[K comparable, V int64 | float64]…

ubuntu22のkernel sourceコードの取得

ubuntu22のkernelソースコードの取得 git clone --depth=1 git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/jammy wiki.ubuntu.com