Skip to content

Instantly share code, notes, and snippets.

@pgtwitter
pgtwitter / a.sh
Last active September 23, 2024 04:01
"%b %d, %Y" to "%Y-%m-%d" using awk
#! /bin/sh
# reference: https://stackoverflow.com/questions/38262829/awk-command-to-convert-date-format-in-a-file#answer-38271260
/usr/bin/awk -F'\t' '{
split($1,a," ");
printf "%04d-%02d-%02d", a[3], (match("JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC",toupper(a[1]))+2)/3, a[2];
for(i=2;i<=NF;i++)printf("\t%s",$i);
printf("\n")
}' << EOF
Sep 9, 2024 142.1234 143.1234 142.1234 142.1234 142.1234
Aug 8, 2024 146.1234 147.1234 145.1234 146.1234 146.1234
@pgtwitter
pgtwitter / a.ipynb
Created August 25, 2024 11:44
円周率1万桁の中に1から数えていって入っていない最初数は何か?
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgtwitter
pgtwitter / a.sh
Last active August 24, 2024 14:23
360mp4: Blender, Camera/Panoramic/Equirectangular, Stereoscopy/Multi-View. Views Format/Indivisual
#! /bin/sh -x
DIR=`pwd`
FPS=24
S_NUMBER=83
LOOP=10
STEREO="left-right" #"top-bottom"
DIST_PREFIX="dist"
SRC_DIR="360"
DIST_DIR=${DIR}
@pgtwitter
pgtwitter / a.ipynb
Created August 7, 2024 14:11
rendering network with networkx (extends Maze)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgtwitter
pgtwitter / a.ipynb
Created August 7, 2024 01:48
rendering network with networkx
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgtwitter
pgtwitter / a.ipynb
Last active July 21, 2024 06:39
半径0.5の外接円を持つ正n角形の周の長さ
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgtwitter
pgtwitter / py.ipynb
Created July 20, 2024 06:45
Monte Carlo method
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# %%
import stanza
import graphviz as gv
# %%
# https://qiita.com/ytaki0801/items/b8d7d4c778fe98966ce5
def p_lex(p):
for s in '()[]{}",':
@pgtwitter
pgtwitter / py.ipynb
Last active June 10, 2024 02:24
モンテカルロ法的な積分 ( 参考 https://x.com/nichimath/status/1799033564094230546 )
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgtwitter
pgtwitter / .py
Created June 5, 2024 09:12
Convex hull division using Fiedler vectors
# %%
import bpy
import networkx as nx # /path/to/blender's/python -m pip install scipy networkx
import numpy as np
from scipy.spatial import ConvexHull
def obj2GraphAndXyzAndNormFiedler(obj):
edges = [(e.vertices[0], e.vertices[1]) for e in obj.data.edges]
G = nx.Graph(edges)