Skip to content

Instantly share code, notes, and snippets.

View so298's full-sized avatar

Sosuke Hosokawa so298

View GitHub Profile
@so298
so298 / watch.py
Last active May 31, 2024 23:12
Simple command line tool to run a command and send a message to a Slack webhook if the command fails. (No external library dependencies!!)
#!/usr/bin/env python3
'''
Command line tool to run a command and send a message to a Slack webhook if the command fails.
'''
import subprocess
import urllib
import urllib.request
import urllib.parse
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@so298
so298 / cilksort.c
Last active April 24, 2024 13:24
OpenMP cilksort (efficient parallel sort for fork-join model)
/*
* Run `cc -Wall -Wextra -fopenmp -O3 cilksort.c -o cilksort` to compile.
* Recommend to use clang over gcc for performance.
*/
/*
* Original code from the Cilk project
*
* Copyright (c) 2000 Massachusetts Institute of Technology
* Copyright (c) 2000 Matteo Frigo
@so298
so298 / lualatx-font-setup.md
Created April 2, 2024 13:14
(lua)LaTeXでフォントを設定する方法について

$\text{(Lua)}\LaTeX$ でフォントを設定する方法

$\LaTeX$を使っていて、たまにフォントを指定して組版したいときに毎回調べていて大変なので、備忘録として書いておきます

同じ方法が$\text{Xe}\LaTeX$では利用可能だと思いますが、他の実装($\text{p}\LaTeX$など)では多分使えないです

TL;DR

LuaLaTeXなどではfontspecパッケージを利用して利用するフォントをかんたんに指定することができる

@so298
so298 / mirror-gitlab-to-github.md
Created March 3, 2024 18:19
Fine-grained access tokenを利用してGitLabからGitHubへのミラーを設定する

Fine-grained access tokenを利用してGitLabからGitHubへのミラーを設定する方法

GitHubのfine-grained access tokenとGitLabのミラー機能を利用して、GitLabからGitHubのリポジトリへとミラーを行う方法についての説明

1. GitLab側にミラー元となるリポジトリを用意する

特にすることは無いので省略

2. GitHub側にミラー先となる空リポジトリを用意する

@so298
so298 / compare_tensors.py
Created February 21, 2024 17:18
Comparing two `.safetensors` files
import argparse
from safetensors import safe_open
import torch
parser = argparse.ArgumentParser(description='Compare two safetensors')
parser.add_argument('tensor1', type=str, help='First tensor to compare')
parser.add_argument('tensor2', type=str, help='Second tensor to compare')
args = parser.parse_args()
@so298
so298 / how-to-build.md
Last active December 13, 2023 19:54
Build Boost-C++ library with Fujitsu compiler

Build Boost-C++ library with Fujitsu compiler (FCC/FCCpx)

FCCpx is a cross compiler for login node. So if you build boost on computation nodes, you should replace FCCpx command with FCC.

1. Get source code

VARIANT="1_83_0"; \
  wget "https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_${VARIANT}.tar.gz" && \
  tar xvf "boost_${VARIANT}.tar.gz" && \
@so298
so298 / retryFetch.ts
Last active November 17, 2023 08:30
API呼び出しに失敗したりタイムアウトしたときに複数回APIをコールするためのラッパー関数
/**
*
* @param targetFunc fetch function
* @param opt retry options
* @returns
*/
export const retryFetch = <T>(
targetFunc: () => Promise<T>,
opt?: {
retryCount?: number;
@so298
so298 / code-tunnel.md
Last active November 13, 2023 15:49
VSCode CLIを利用したVSCode Tunnelのセットアップ

VSCode CLIを利用したVSCode Tunnelのセットアップ

概要

VSCode CLIをサーバーにインストールすることで、SSHを経由することなくVSCodeやvscode.dev上からサーバーにアクセスすることができる様になる

できること&できないこと (2023/11/13時点)

できること

@so298
so298 / deno_proxy.ts
Last active October 28, 2023 06:14
deno proxy
// main.ts
import { serve } from "https://deno.land/std/http/server.ts";
const target = "https://example.com"; // destination URL
const port = 8000;
async function handleRequest(req: Request): Promise<Response> {
const url = new URL(req.url);
const targetUrl = `${target}${url.pathname}${url.search}`;