Skip to content

Instantly share code, notes, and snippets.

View nobucshirai's full-sized avatar

Nobu C. Shirai nobucshirai

View GitHub Profile
@nobucshirai
nobucshirai / chatgpt_json2md.py
Last active May 18, 2023 00:30
This Python script parses a JSON file, converts its content into Markdown format, and prints the result to the console. Use -h option for help.
#!/usr/bin/env python3
import json
import argparse
import datetime
def json_to_markdown(json_data):
markdown = ""
for document in json_data:
markdown += f"# {document['title']}\n\n"
@nobucshirai
nobucshirai / 3d_line_intersection.py
Last active July 3, 2020 05:10
CALCULATE THE LENGTH OR SHORTEST LINE BETWEEN TWO LINES IN 3D
#!/usr/bin/env python3
#
# CALCULATE THE LENGTH OR SHORTEST LINE BETWEEN TWO LINES IN 3D
#
# See "The shortest line between two lines in 3D" of
# http://paulbourke.net/geometry/pointlineplane/ written by Paul Bourke
from optparse import OptionParser
import sys
import numpy as np
@nobucshirai
nobucshirai / ipm.py
Created October 19, 2018 08:15 — forked from mkakh/ipm.py
#!/usr/bin/env python
import sys
import json
from optparse import OptionParser
# loadJson :: String -> Dict
def loadJson(filePath):
with open(filePath, 'r') as f:
jsonDict = json.load(f)
return jsonDict
# users generic .zshrc file for zsh(1)
# LANG
#
export LANG=ja_JP.UTF-8
case ${UID} in
0)
LANG=C
;;
esac
# コマンドキーを Ctrl+T にする
escape ^Tt
# 起動時のライセンス画面を表示しない
startup_message off
# スクロールバックできる行数を2000行にする
defscrollback 2000
# ステータス行に表示するメッセージを10秒間表示する
"------------------------------------------------
"表示関係
"------------------------------------------------
syntax on
"カラースキーマ
colorscheme desert
highlight fortranTab ctermfg=0
highlight fortranOperator ctermfg=5
highlight Number ctermfg=white
highlight LineNr ctermfg=white
#!/bin/bash
DIR="JOB_OUTPUT"
main(){
ifdne_mkdir
for file in `ls`; do
err_count=`echo $file | grep -c "sh\.e"`
out_count=`echo $file | grep -c "sh\.o"`
if [[ $err_count > 0 || $out_count > 0 ]]; then
mv $file $DIR
fi
@nobucshirai
nobucshirai / project_namer.sh
Created April 4, 2014 12:34
sed-wrapper script for cafemol input and job files.
#!/bin/bash
N_TSTEP=1000000 # 1 day
JOB_PATH="${PWD%/*}"
main(){
os_check
check_options $@
file_name_def $@
dir_check
#!/bin/bash
file="$1"
name="${1%.pdb}"
Bfile="${name}-bb.pdb"
Mfile="m_$Bfile"
Mname="${Mfile%.pdb}"
bbq="java apps.BBQ"
scwrl="Scwrl4"
#!/bin/bash
#$Id: rewrite.sh,v 1.10 2014-01-08 14:09:47+09 shirai Exp $
rewrite(){
all=()
check_options $@
file="${all[$((${#all[@]}-1))]}"
file_check $file
tmp="TEMP_${file##*/}"
${all[@]} > $tmp