Skip to content

Instantly share code, notes, and snippets.

View shimarin's full-sized avatar

Tomoatsu Shimada shimarin

View GitHub Profile
@shimarin
shimarin / shift_key.py
Created September 8, 2024 22:08
コンソールでシフトキーが押されているかどうかを判定する関数
def is_shift_key_being_pressed():
TIOCLINUX = 0x541C # TIOCLINUXの値はLinuxのカーネルヘッダファイルから取得
shift_state = 6 # 変数の初期値
# 変数をバイトオブジェクトに変換
shift_state_buf = struct.pack('B', shift_state)
try:
# ioctlシステムコールを使用してシフト状態を取得
shift_state_buf = fcntl.ioctl(sys.stdin.fileno(), TIOCLINUX, shift_state_buf)
# 取得した結果をアンパックして表示
@shimarin
shimarin / event.php
Last active August 16, 2024 12:49
JavaScriptのEventSource APIにサーバー側でのファイル更新イベントを通知するためのエンドポイント
<?php
/**
* event.php
* JavaScriptのEventSource APIにサーバー側でのファイル更新イベントを通知するためのエンドポイント
*
* PHPにinotifyエクステンションが必要 https://github.com/arnaud-lb/php-inotify
*
* 2024 Tomoatsu Shimada
*/
@shimarin
shimarin / check-openssh-version.py
Created July 1, 2024 16:03
指定ホストの22/tcpに接続し、SSHサーバのバージョン情報を表示するスクリプト
#!/usr/bin/python
import socket
import argparse
def get_ssh_version_string(host, port=22, timeout=5):
try:
# ソケットアドレス情報を取得
addr_info = socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_STREAM)
for res in addr_info:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
def image_loaded(driver, element):
try:
# 画像が完全にロードされているかどうかを確認するJavaScript
return driver.execute_script("return arguments[0].complete && typeof arguments[0].naturalWidth != 'undefined' && arguments[0].naturalWidth > 0", element)
#!/usr/bin/python
import MySQLdb
import ssl
import socket
from datetime import datetime
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
# MySQLデータベース接続設定
#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);
ffmpeg -ss 00:00:44 -i testa.mkv -to 00:01:30 -vf "scale=1920:-2" -vcodec libx264 testa.mp4
#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"
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"
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) {
-