Skip to content

Instantly share code, notes, and snippets.

Avatar

Tomoatsu Shimada shimarin

View GitHub Profile
View memfd_create.cpp
#include <sys/mman.h>
#include <unistd.h>
#include <iostream>
int main()
{
auto fd = memfd_create("mytmpfile", 0);
if (fd < 0) throw std::runtime_error("memfd_create");
std::string tmp_filename = "/proc/" + std::to_string(getpid()) + "/fd/" + std::to_string(fd);
View trim.sh
ffmpeg -ss 00:00:44 -i testa.mkv -to 00:01:30 -vf "scale=1920:-2" -vcodec libx264 testa.mp4
View mqtt-relay.cpp
#include <cstring>
#include <string>
#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "driver/gpio.h"
#include "esp_wifi.h"
#include "esp_log.h"
View lwip_support_ipv6_scopes.patch
diff --git a/src/core/ipv6/ip6_addr.c b/src/core/ipv6/ip6_addr.c
old mode 100644
new mode 100755
index 687c02f7..ad649761
--- a/src/core/ipv6/ip6_addr.c
+++ b/src/core/ipv6/ip6_addr.c
@@ -41,6 +41,7 @@
*/
#include "lwip/opt.h"
View esp8266-mqtt-ipv6.patch
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
View trade.html
<html>
<head>
<title>信用取引計算くん</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.0/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
View Makefile.vscode
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
重複ファイル削除ツール
View dupremover.py
#!/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)
View ping6test.cpp
/**
* 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 December 22, 2021 01:30
Python script to build VPN config files for wireguard gateay server
View build-wg-gateway.py
#!/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()