Skip to content

Instantly share code, notes, and snippets.

@45deg
45deg / tsp.py
Last active April 20, 2024 15:58
Traveling Salesman Problem (TSP) using the 2-opt algorithm (Japan's prefectoral capital) 都道府県庁所在地の巡回セールスマン
import random
import matplotlib.animation as animation
import matplotlib.pyplot as plt
capitals = {
'Hokkaido': (43.0646, 141.3468),
'Aomori': (40.8246, 140.7406),
'Iwate': (39.7036, 141.1527),
'Miyagi': (38.2688, 140.8721),
@45deg
45deg / delete_all_tweets.js
Created April 9, 2023 10:49
Farewell to Elon
const Twit = require('twit');
const fs = require('fs');
const { promisify } = require('util');
const ProgressBar = require('progress');
const asyncPool = require('tiny-async-pool');
const T = new Twit({
consumer_key: 'HERE',
consumer_secret: 'HERE',
access_token: 'HERE',
@45deg
45deg / tsp.gif
Last active April 4, 2023 20:01
2-opt tsp
tsp.gif
@45deg
45deg / Cargo.toml
Created March 23, 2023 18:15
Wordle for Rust by GPT-4
[package]
name = "wordle"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rand = "0.8"

https://github.com/kohya-ss/sd-scripts/blob/main/train_network_README-ja.md これが正しい

  • 正則化画像はいらん
  • バッチサイズは2でいい
  • 巷の文章では学習用プロンプトの拡張子がtxtだが公式ではcaptionなので注意
  • dimは https://rentry.org/lora_train には 128 と書いてあるけど 4~16 ぐらいが無難 → dimの大きさによって重みを 1/n 倍する必要あり? → アップデートで直った
  • 最初は1epochでもうまく学習できてればそこそこ良い画像が生成される。うまく学習できてないといくら学習しても無が生成されることになる。
  • Additional Networks で 生成するときの weight は 0.1 付近じゃないとガビガビになる → アップデートで直った

@45deg
45deg / _raytracing_on_bigquery.png
Last active April 29, 2021 02:47
Ray Tracing on BigQuery (for free of charge)
_raytracing_on_bigquery.png
@45deg
45deg / iq1.md
Last active December 16, 2019 13:59

この記事はなんとかアドベントカレンダーの何日目かの記事です。

なんかエイリアスってあるじゃないですか。ll = ls -lah みたいな。

頻繁に使うコマンドを短く書けるのはいいんですけど、いちいち書くのダルくないですすか?

vim ~/.zshrc[Enter]Goalias ll='ls -lah'[ESC]:wq[ENTER]source ~/.zshrc[ENTER] ってやるんですよね。

あっこれエイリアス作りたいな~と思っても、IQが1なのでたぶんvim ~/.zshrc[Enter]Goって打った時点で「あれ、何のエイリアス作りたいんだっけ……」と忘れてしまいそうじゃないですか?

import os
from multiprocessing import Pipe
class Continuation:
def __init__(self, cont):
self._cont = cont
def __call__(self, arg):
self._cont.send(arg)
exit(0)
import sys
import os
import pathlib
import shutil
import exiftool
target_dir = sys.argv[1]
os.chdir(target_dir)
var Twitter = require('twitter');
function sleep(ms){
return new Promise(function(res){
setTimeout(() => res(), ms);
});
}
(async () => {
try {