Skip to content

Instantly share code, notes, and snippets.

View ytaki0801's full-sized avatar

TAKIZAWA Yozo ytaki0801

  • National Insitute of Technology (KOSEN), Ibaraki College
  • Hitachinaka, Ibaraki, JAPAN
  • 07:53 (UTC +09:00)
  • X @ytaki0801
View GitHub Profile
npub1jf3y3cdz3jffczmrlu8qxwxgmvr5r3w85t3rynp4nddqrsxsq4gqq8nmn0
@ytaki0801
ytaki0801 / Nostr-verify.py
Created August 8, 2026 15:37
Simple Nostr-event authentication: 'event.json' is needed to run
import json
import hashlib
from coincurve import PublicKeyXOnly
with open('event.json', encoding='utf-8') as f:
e = json.load(f)
d = [ 0, e['pubkey'], e['created_at'], e['kind'], e['tags'], e['content'] ]
j = json.dumps(d, ensure_ascii=False, separators=(',', ':'))
h = hashlib.sha256(j.encode('utf-8')).hexdigest()
@ytaki0801
ytaki0801 / CGoL_tput.py
Created February 4, 2023 05:03
Conway's Game of Life in Python with tput
from random import randint
from copy import deepcopy
from os import system
a, b = 80, 24; x, y, n = range(a), range(b), [-1,0,1]
c = [[randint(0,1) for _ in x] for _ in y]; g = deepcopy(c)
while True:
t = ''.join([''.join(['*' if c[j][i] else ' ' for i in x])+'\n' for j in y])
system('tput cup 18 0'); print(t, end='')
@ytaki0801
ytaki0801 / CGoL.scm
Last active February 2, 2023 17:20
Conway's Game of Life in Scheme
;; Using srfi.1 srfi.18 srfi.27
;;
;; gosh -u srfi.1 -u srfi.18 -u srfi.27 CGoL.scm
;; chibi-scheme -m srfi.1 -m srfi.18 -m srfi.27 CGoL.scm
(define xs 80) (define ys 38)
(random-source-randomize! default-random-source)
(define (randbinlist n)
(list-tabulate n (lambda (n) (random-integer 2))))
@ytaki0801
ytaki0801 / CGoL.sh
Last active February 16, 2023 19:22
Conway's Game of Life in POSIX Shell
#!/bin/sh
xs=80 ys=24
ORIGIN=$(clear) LF='
'
if [ ! ${RANDOM} ]; then
set -- $(head -c $((xs * ys)) /dev/random | od -An -vtu1)
fi
@ytaki0801
ytaki0801 / CGoL.py
Created February 1, 2023 12:17
Conway's Game of Life in Python
from random import randint
from os import system
from time import sleep
from copy import deepcopy
xs, ys = 210, 100
c = [[randint(0,1) for _ in range(ys)] for _ in range(xs)]
cn = [[0 for _ in range(ys)] for _ in range(xs)]
while True:
@ytaki0801
ytaki0801 / eca.c
Created January 31, 2023 12:08
Elementary Cellular Automata in C
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define CN 180
#define ST 80
int main(void)
{
char r[8], c[CN], cn[CN], b, x, y, z;
@ytaki0801
ytaki0801 / eca.scm
Last active January 31, 2023 11:51
Elementary Cellular Automata in Scheme
(define (d2b n x)
(let loop ((d n) (r '()))
(if (= d 0) (let ((b (if (null? r) '(0) r)))
(append (make-list (- x (length b)) 0) b))
(loop (quotient d 2) (cons (modulo d 2) r)))))
(define (cinit cnum)
(let ((ci (make-list (+ (quotient cnum 2) (modulo cnum 2)) 0)))
(append ci '(1) (make-list (- (quotient cnum 2) 1) 0))))
@ytaki0801
ytaki0801 / eca.sh
Last active February 1, 2023 03:29
Elementary Cellular Automata in POSIX Shell, Rules from 0 to 255
#!/bin/sh
cnum=180; step=80;
rule=0
while [ $rule != 256 ]; do
b=$rule; for x in 0 1 2 3 4 5 6 7; do export r$x=$((b%2)) b=$((b/2)); done
i=0; while [ $i != $cnum ]; do export c$i=0 i=$((i+1)); done
export c$((cnum/2))=1