Skip to content

Instantly share code, notes, and snippets.

View tamakiii's full-sized avatar

Daichi Tamaki tamakiii

  • undefined
  • Shibuya, Tokyo, Japan
  • X @tamakiii
View GitHub Profile
@tamakiii
tamakiii / README.md
Last active December 11, 2023 05:52
GNU Make: export AWS_PROFILE with `:=`, `=` and `?=`

With export AWS_PROFILE :=

$ cat Makefile
.PHONY: test

export AWS_PROFILE := acme
export AWS_REGION := us-west-2

test:
        @echo "AWS_PROFILE=$(AWS_PROFILE) (origin: $(origin AWS_PROFILE))"
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
@tamakiii
tamakiii / README.md
Created September 12, 2022 06:26
diff Shift-JIS CSV with jq (CSV to JSON conversion)

Usage

diff -u <(sjis_csv_to_json a.csv) <(sjis_csv_to_json b.csv) | vim -R -
sed -e 's/\([├|└]──\)/\t/g' -e 's/[│| ├──| └──]/\t/g' -e 's/ //g'
--- /tmp/a.txt 2021-05-11 11:35:31.000000000 +0900
+++ /tmp/b.txt 2021-05-11 12:04:02.000000000 +0900
@@ -1,16 +1,13 @@
bash-4.2# yum search php-
Loaded plugins: ovl, priorities
amzn2-core | 3.7 kB 00:00:00
-amzn2extra-php7.4 | 3.0 kB 00:00:00
+amzn2extra-php8.0 | 3.0 kB 00:00:00
(1/5): amzn2-core/2/x86_64/group_gz | 2.5 kB 00:00:00
-(2/5): amzn
@tamakiii
tamakiii / README.md
Last active May 5, 2021 11:19
Fill package gaps between amazonlinux2 AMI and Docker image

On EC2 instance

sudo sh -c 'AMI=2.0.20210427.0 && for architecture in x86_64 aarch64; do compgen -c | xargs which 2> /dev/null | xargs rpm -qf | sed -E "s/.$(uname -m)$/.${architecture}/" | sort | uniq > packages-${AMI}.${architecture}.txt; done'

In Dockerfile, like

COPY . /tmp/amazonlinux2
RUN yum update -y && yum install -y $(cat /tmp/amazonlinux2/packages-2.0.20210427.0.$(uname -m).txt | tr "\n" ' ') && rm -rf /tmp/amazonlinux2
@tamakiii
tamakiii / compgen-c.diff
Last active May 5, 2021 11:26
ami-0d14de74618b313e2...amazonlinux:2.0.20210126.0 (docker.io)
--- /dev/fd/11 2021-05-05 18:13:16.000000000 +0900
+++ /dev/fd/13 2021-05-05 18:13:16.000000000 +0900
@@ -3,267 +3,57 @@
:
[
[[
-[ec2-user@ip-10-0-0-0 ~]$ compgen -c
]]
-__expand_tilde_by_ref
-__get_cword_at_cursor_by_ref
<?php
class NumberFormatterTest
{
const STYLES = [
'NumberFormatter::PATTERN_DECIMAL' => NumberFormatter::PATTERN_DECIMAL,
//Decimal format defined by pattern
'NumberFormatter::DECIMAL' => NumberFormatter::DECIMAL,
// Decimal format
'NumberFormatter::CURRENCY' => NumberFormatter::CURRENCY,
cd /tmp
export COLORSCHEME=gruvbox
export PLUGNAME=morhetz/gruvbox
vim \
-c "call plug#begin('~/.vim/plugged')|Plug '$PLUGNAME'|call plug#end()|PlugInstall --sync|q" \
-c "colorscheme $COLORSCHEME" \
-c 'redir @x|silent highlight|redir END|put x' \
-c 'g/^$/d' \
-c 'g/links to/d' \
-c 'g/cleared$/d' \
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
import time
class S(BaseHTTPRequestHandler):
def _set_response(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()