This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const apiKey = Deno.env.get("CHATGPT_API_KEY"); | |
const url = "https://api.openai.com/v1/chat/completions"; | |
const content = await fetch(url, { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json", | |
"Authorization": `Bearer ${apiKey}`, | |
}, | |
body: JSON.stringify({ | |
model: "gpt-3.5-turbo", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# ChatGPT client by ShellScript | |
# $ curlgpt "hello world!" | |
# or | |
# $ echo "hello world!" | curlgpt | |
# | |
# MIT License | |
# | |
# Copyright (c) 2023 u1and0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" docxファイルの文字列置換を行うモジュール | |
usage: | |
$ python replacex.py OLDWORD NEWWORD [FILENAMES...] | |
""" | |
import sys | |
from docx import Document | |
# from docx.shared import Pt | |
from docx.shared import RGBColor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Convert Markdown file to HTML file every 3sec using pandoc | |
# 引数に渡したmarkdownファイルを3秒ごとにpandocを通してhtml化する | |
# Requirement | |
# * docker | |
# * pandoc/core (docker container) | |
# Usage | |
# $ ~/sh/autopandoc.sh ./hoge.md | |
# then extract hoge.html | |
# Recommendation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[【 awk 】コマンド(応用編その6)――テキストの加工とパターン処理、複数ファイルの処理](https://www.atmarkit.co.jp/ait/articles/1806/01/news041.html#sample1) | |
```特定行 | |
$ awk '{if (FNR==500){print FILENAME, $1, $3}}' 20200508_06*.txt | sed -e 's/.txt//g' | |
``` | |
上記コマンドで 20200508_06(2020年5月8日 6時台)にマッチするファイルの500行目だけに対して | |
ファイル名(拡張子なし) | 1列目(行数) | 3列目(AVER) | |
を抜き出せます。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ランダムに300件のファイルをコピーする | |
``` | |
$ shuf <(\ls 2020*) | grep -v 202004 | head -300 | xargs -I {} cp {} ../mlwork/data/ | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Requied vagrant plugin | |
# $ vagrant plugin install [NAME] | |
# sahara (0.0.17, global) | |
# - Version Constraint: > 0 | |
# vagrant-cachier (1.2.1, global) | |
# - Version Constraint: > 0 | |
# vagrant-disksize (0.1.3, global) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`sys.argv`がリストで返るので、`fileinput.input()`の結果もリスト形式で返るようにして使いました。 | |
if Path(sys.argv[1]).exists(): # 第一引数がファイルだったら | |
# ファイルの内容を一行ずつOrder Search | |
ARGV = [ # 改行削除 | |
line.replace('\n', '') for line in fileinput.input() | |
if line != '\n' | |
] | |
else: # 第一引数がファイルではなかったら |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### rgのpreオプションを使ってdocに対してripgrep | |
`rg 検索語 --pre catdoc --pre-glob "*.doc"` | |
### rgのpreオプションを使ってxlsに対してripgrep | |
` rg 検索語 --pre xls2csv --pre-glob "*.xls" *.xls` | |
### rgのpreオプションを使ってxlsxに対してripgrep | |
` rg 検索語 --pre xlsx2csv --pre-glob "*.xlsx" *.xlsx` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## nkf on msys2 install | |
```sh | |
$ mkdir -p ~/abs/nkf # absにパッケージtar.gzを入れる | |
# https://wiki.archlinux.jp/index.php/%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8%E3%81%AE%E4%BD%9C%E6%88%90 | |
$ cd ~/abs/nkf | |
$ curl -fsSL https://ja.osdn.net/projects/nkf/downloads/70406/nkf-2.1.5.tar.gz/ | |
$ tar -xvf nkf-2.1.5.tar.gz | |
$ cd nkf-2.1.5 | |
$ make |
NewerOlder