Skip to content

Instantly share code, notes, and snippets.

View netalkGB's full-sized avatar

GB netalkGB

  • Japan
  • 15:12 (UTC +09:00)
View GitHub Profile
@netalkGB
netalkGB / main.cpp
Last active August 27, 2024 16:08
光学ドライブのドライブレターの一覧を取得 (ドライブにディスクがない場合は除外)
#include <windows.h>
#include <iostream>
#include <string>
int main() {
for (int i = 0; i < 26; ++i) {
TCHAR szDrive[] = { (TCHAR)('A' + i), L':', L'\\', L'\0' };
if (!GetVolumeInformation(szDrive, NULL, NULL, NULL, NULL, NULL, NULL, 0)) continue; // 真が返れば、ディスクはあるようだ
if (GetDriveType(szDrive) != DRIVE_CDROM) continue;
@netalkGB
netalkGB / main.cpp
Last active July 13, 2024 12:31
MCIでCDを再生
#include <windows.h>
#include <iostream>
#include <string>
#define DRIVE_LETTER L"D:"
#pragma comment(lib, "winmm.lib")
DWORD OpenCd(MCI_OPEN_PARMS *pMciOpenParms) {
@netalkGB
netalkGB / audacity.py
Last active February 26, 2023 11:11
先頭末尾無音除去
import sys
import os
class Audacity:
def __init__(self):
if sys.platform == 'win32':
TONAME = '\\\\.\\pipe\\ToSrvPipe'
FROMNAME = '\\\\.\\pipe\\FromSrvPipe'
self._EOL = '\r\n\0'
else:
@netalkGB
netalkGB / titles.py
Created February 22, 2023 17:36
Windowsの開いてるウインドウたちのタイトルを取得する
import ctypes
user32 = ctypes.windll.user32
def get_titles():
titles = []
def foreach_window(hwnd, lparam):
length = user32.GetWindowTextLengthW(hwnd)
buf = ctypes.create_unicode_buffer(length + 1)
user32.GetWindowTextW(hwnd, buf, length + 1)
@netalkGB
netalkGB / main.py
Last active December 6, 2021 14:28
[WIP] Twitter API v2でFiltered Stream
import sys
import os
import base64
import json
import urllib.request
import urllib.parse
api_key = os.environ['TWITTER_API_KEY']
api_key_secret = os.environ['TWITTER_API_KEY_SECRET']
bearer_token = os.environ['TWITTER_BEARER_TOKEN']
@netalkGB
netalkGB / main.py
Last active December 1, 2021 16:47
Twitter API v2で sample stream
import sys
import os
import base64
import json
import urllib.request
import urllib.parse
api_key = os.environ['TWITTER_API_KEY']
api_key_secret = os.environ['TWITTER_API_KEY_SECRET']
@netalkGB
netalkGB / calculateChecksum.js
Last active December 1, 2021 16:02
GS音源のSysExのチェックサム計算するやつ
function calculateChecksum(d) {
const a = d[5]
const b = d[6]
const c = d[7]
const data = d[8]
const result = 0x80 - (a + b + c + data) % 0x80
return result
}
@netalkGB
netalkGB / main.py
Created July 9, 2021 09:30
再生時間しらべる
import pretty_midi
import math
midi_data = pretty_midi.PrettyMIDI('TEST.RCP.MID')
duration_seconds = midi_data.get_end_time()
print(math.ceil(duration_seconds))
@netalkGB
netalkGB / settings.json
Created May 30, 2020 12:42
Windows Terminalの設定
// This file was initially generated by Windows Terminal 1.0.1401.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@netalkGB
netalkGB / 10-custom-kernel-bbr.conf
Created May 6, 2020 11:32
/etc/sysctl.d/10-custom-kernel-bbr.conf
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr