Skip to content

Instantly share code, notes, and snippets.

View shimarin's full-sized avatar

Tomoatsu Shimada shimarin

View GitHub Profile
diff --git a/components/tcp_transport/transport_tcp.c b/components/tcp_transport/transport_tcp.c
index 5bfb99dd..cdae5bf0 100644
--- a/components/tcp_transport/transport_tcp.c
+++ b/components/tcp_transport/transport_tcp.c
@@ -32,60 +32,51 @@ typedef struct {
int sock;
} transport_tcp_t;
-static int resolve_dns(const char *host, struct sockaddr_in *ip) {
-
@shimarin
shimarin / trade.html
Last active February 26, 2022 07:58
<html>
<head>
<title>信用取引計算くん</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
</head>
<body>
<div id="page-content" class="card">
<h1 class="card-header"><i class="bi bi-calculator"></i>信用取引計算くん</h1>
@shimarin
shimarin / Makefile.vscode
Last active February 22, 2021 21:34
VS Codeで、複数のC++ソースファイルが置いてあるフォルダで編集中ファイルの実行をできるようにするための tasks.jsonと外部 Makefile
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
OBJS=$(subst .cpp,.o,$(call rwildcard,,*.cpp))
BINS=$(subst .cpp,,$(call rwildcard,,*.cpp))
HEADERS=$(call rwildcard,,*.h)
CXXFLAGS ?= -std=c++2a
all: $(BINS)
libproj.a: $(OBJS)
@shimarin
shimarin / dupremover.py
Last active February 21, 2021 05:40
重複ファイル削除ツール
#!/usr/bin/python3
import os,argparse,glob
import xxhash
def calc_hash_from_file_handle(f):
h = xxhash.xxh64()
bufsize = h.block_size * 0x800
data = f.read(bufsize)
while data:
h.update(data)
/**
* ICMPv6 echo request (ping6) test
*/
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/icmp6.h>
@shimarin
shimarin / build-wg-gateway.py
Last active April 9, 2025 05:34
Python script to build VPN config files for wireguard gateay server
#!/usr/bin/python
import argparse,ipaddress,subprocess,re
import qrcode
def generate_privkey():
return subprocess.check_output(["wg","genkey"]).decode("UTF-8").strip()
def get_pubkey(privkey):
return subprocess.check_output(["wg","pubkey"], input=privkey.encode("UTF-8")).decode("UTF-8").strip()
#include <errno.h>
#include <poll.h>
#include <unistd.h>
#include <pty.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
#include <stdexcept>
#include <iostream>
@shimarin
shimarin / vtermtest.cpp
Last active May 9, 2025 06:49
SDL2 terminal emulator using libvterm
/*
MIT License
Copyright (c) Tomoatsu Shimada 2024
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 2020-07-23 13:58:14.392337637 +0900
+++ a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 2020-08-02 12:26:10.677578297 +0900
@@ -775,14 +775,15 @@
tmp_str++;
while (isspace(*++tmp_str));
- while (tmp_str[0]) {
- sub_str = strsep(&tmp_str, delimiter);
+ while (tmp_str[0] && (sub_str = strsep(&tmp_str, delimiter)) != NULL) {
ret = kstrtol(sub_str, 0, &parameter[parameter_size]);
@shimarin
shimarin / age
Created June 16, 2020 23:44
script to get file age(seconds from mtime)
#!/bin/sh
if [ "$#" -eq 0 ] ; then
echo "Usage: $0 file" 1>&2
exit 1
fi
if [ ! -e $1 ];then
echo 9223372036854775807
exit 1
fi