Skip to content

Instantly share code, notes, and snippets.

@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)
use std::io::{self};
fn main() -> io::Result<()> {
println!("<!--");
let mut paragraph: [String; 30] = Default::default();
let mut count = 0;
loop {
let mut buffer = String::new();
match io::stdin().read_line(&mut buffer) {
@shirou
shirou / open_in_tmux.sh
Created June 4, 2020 00:13
Open file from other window
alias coder="VSCODE_IPC_HOOK_CLI=`ls --sort=time /tmp/vscode-ipc-* | head -n 1` `ls ~/.vscode-server/bin/*/bin/code | head -1`"