Skip to content

Instantly share code, notes, and snippets.

@shirou
shirou / aix_on_qemu.sh
Created June 2, 2024 13:58
AIX on qemu
# AIX 7.2 PowerPC "POWER9"
# https://github.com/shirou/gopsutil/pull/1651#issuecomment-2123753059
sudo qemu-system-ppc64 -M pseries,ic-mode=xics -cpu POWER9 \
-smp 4,sockets=4,cores=2,threads=2,maxcpus=16 \
-m 4096 \
-name aix_7200-04-02-2027 \
-netdev bridge,id=net0,br=virbr0 \
-device spapr-vlan,netdev=net0,mac=52:54:00:49:53:14 \
-device virtio-scsi,id=scsi0 \
-drive file=/var/lib/libvirt/images/aix7.2-ppc64.qcow2,if=none,id=drive-scsi0-0-0-0,format=qcow2,cache=none \
@shirou
shirou / Dockerfile
Last active May 9, 2024 05:58
AWS Lambda bash CLI with own Docker container image
FROM debian:trixie-slim
ENV LAMBDA_TASK_ROOT=/var/task
ENV LAMBDA_RUNTIME_DIR=/var/runtime
RUN apt update && apt install -y curl unzip groff jq \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install AWS CLI
@shirou
shirou / sample.go
Created September 8, 2023 03:02
dynamodb batch get items sample code
const maxRetryCount = 3
func (s *Server) getAlbums(ctx context.Context, albumIDs []uuid.UUID) ([]Album, error) {
ctx, span := tracer.Start(ctx, "getAlbums")
defer span.End()
keysToGet := make([]map[string]types.AttributeValue, len(albumIDs))
for i, albumID := range albumIDs {
idv, err := attributevalue.Marshal(albumID.String())
if err != nil {
#cloud-config
repo_update: true
repo_upgrade: all
packages:
- socat
write_files:
- content: |
[Unit]
Description=Socat Port forward
Wants=network-online.target
@shirou
shirou / .wezterm.lua
Created January 5, 2023 04:27
wezterm setting on Windows
local wezterm = require 'wezterm'
local default_prog
local set_environment_variables = {}
if wezterm.target_triple == 'x86_64-pc-windows-msvc' then
-- And inject clink into the command prompt
default_prog =
{ 'powershell.exe', '-NoLogo' }
end
@shirou
shirou / query.py
Last active August 17, 2022 03:59
AWS Timestream
import boto3
DBName = 'shiroutest'
client = boto3.client('timestream-query')
SQL = "SELECT * FROM shiroutest.USDJPY WHERE time between '2022-08-15' and '2022-08-16' "
paginator = client.get_paginator('query')
pageIterator = paginator.paginate(
QueryString=SQL,
diff --git a/disk/iostat_darwin.c b/disk/iostat_darwin.c
index 9619c6f..04d9984 100644
--- a/disk/iostat_darwin.c
+++ b/disk/iostat_darwin.c
@@ -25,7 +25,7 @@ readdrivestat(DriveStats a[], int n)
kern_return_t status;
int na, rv;
- IOMasterPort(bootstrap_port, &port);
+ IOMainPort(bootstrap_port, &port);
#!/usr/bin/env python3
import sys
import os
import json
result = {"themes": []}
skip_themes = [
"autorch-sphinx-theme", # no theme named 'pytorch_sphinx_theme' found (missing theme.conf?)
@shirou
shirou / main.py
Last active November 10, 2020 06:16
Write file with timebased rotate and compression.
import file_logging
import time
file_logger = file_logging.setup("/tmp/foo/bar/example.log")
for i in range(0, 1000):
file_logger.info(f"msg: {i}")
time.sleep(0.3)