Skip to content

Instantly share code, notes, and snippets.

View trpfrog's full-sized avatar
🏠
Working from home

TrpFrog trpfrog

🏠
Working from home
View GitHub Profile
@trpfrog
trpfrog / prompt.txt
Last active March 14, 2024 15:38
英文を早く読みたいつまみさんのためのシステムプロンプト
You must complete the following tasks
# Task 1
- **Itemize** the user input in English.
- Don't omit contents
- You can use indent
- Output the formulas in LaTeX format.
- Note that formulas in LaTeX format must be enclosed in $ $.
- Important parts should be bolded.
@trpfrog
trpfrog / satori-google-fonts.jsx
Created October 3, 2023 13:32
Satori で Google Fonts を使う
import satori from 'satori'
import fs from 'fs'
// fetch font information
const endpoint = new URL('https://www.googleapis.com/webfonts/v1/webfonts');
endpoint.searchParams.set('family', 'M PLUS Rounded 1c');
endpoint.searchParams.set('key', process.env.GOOGLE_FONTS_API_KEY);
const fontInfo = await fetch(endpoint).then(res => res.json());
// fetch font
@trpfrog
trpfrog / quicksort.ts
Last active July 21, 2023 09:45
型で1桁の数を quicksort する
type SingleDigitNumber = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
type Succ<N extends SingleDigitNumber> = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0][N]
type EQ<N1, N2> =
[N1 extends N2 ? true : false, N2 extends N1 ? true : false] extends [true, true] ? true : false
// N1 < N2
type LT<N1 extends SingleDigitNumber, N2 extends SingleDigitNumber> =
Succ<N1> extends 0
@trpfrog
trpfrog / toggle_comma_period.sh
Created February 1, 2023 05:47
Mac で句読点とカンマピリオドを切り替えるやつ
x=$(defaults read com.apple.inputmethod.Kotoeri JIMPrefPunctuationTypeKey)
if [[ $x == 0 ]] then
defaults write com.apple.inputmethod.Kotoeri JIMPrefPunctuationTypeKey -int 3
echo "カンマ・ピリオド に切り替えました"
else
defaults write com.apple.inputmethod.Kotoeri JIMPrefPunctuationTypeKey -int 0
echo "句点・読点 に切り替えました"
fi
killall -HUP JapaneseIM-RomajiTyping
@trpfrog
trpfrog / better-uec-portal.css
Last active June 7, 2023 08:08
UEC学生ポータル (portalweb.uec.ac.jp) につけると嬉しくなるCSS
/* 掲示板の投稿一覧を見やすくするCSS */
.def_tree_div {
/* ツリーを最上部に固定 */
position: sticky;
top: 10px;
}
div.def_block {
/* sticky の有効化に必要 */
@trpfrog
trpfrog / convertall.py
Created November 21, 2021 20:24
Macでカレントディレクトリの画像を一括変換
import os, sys, subprocess
extfrom: str
extto: str
def sips_convert(filename: str):
outputname = filename.replace(extfrom, extto)
subprocess.call([
'sips', '-s', 'format', extto,
filename, '-o', outputname
@trpfrog
trpfrog / google-centering.css
Created July 4, 2021 11:18
Googleの検索結果を中央寄せするやつ
:root {
--google-margin-left: calc((100vw - 600px) / 2);
}
@media (min-width:1600px) {
.A8SBwf {
margin-left: calc(var(--google-margin-left) - 37px);
}
.MUFPAc {
@trpfrog
trpfrog / NearestPointOnHalfLine.pde
Created May 9, 2021 18:38
最も近い半直線上の点の座標を計算するやつ
PVector A, B;
void halfStraightLine(float x1, float y1, float x2, float y2) {
final int INF = 10000;
line(x1, y1, x1 + (x2 - x1) * INF, y1 + (y2 - y1) * INF);
}
PVector calcQ(float x, float y) {
float theta = atan2(B.y - A.y, B.x - A.x);
float d = dist(A.x, A.y, B.x, B.y);
@trpfrog
trpfrog / LaTeXTableMaker.java
Last active November 18, 2019 18:22
表計算ソフトからコピーした表データをLaTeX形式に変換し、クリップボードにコピーします。指数表記(E-01,E+00など)もLaTeXの数式に変換されます。
package net.trpfrog.latex_table_generator;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.util.Scanner;
public class LaTeXTableMaker {
public static final String INDENT = " ";
@trpfrog
trpfrog / trpfrog_builder.rb
Last active November 14, 2019 18:53
つまみアイコンを出力します。
WIDTH = 500
HEIGHT = 500
Pixel = Struct.new(:r,:g,:b)
$img = Array.new(HEIGHT) do
Array.new(WIDTH) do Pixel.new(255,255,255) end
end
def clear
$img = Array.new(HEIGHT) do