Skip to content

Instantly share code, notes, and snippets.

View jiro4989's full-sized avatar
🏠
Working from home

jiro jiro4989

🏠
Working from home
View GitHub Profile
@jiro4989
jiro4989 / joyn.clj
Created July 23, 2020 08:19
引数に応じて関数を切り替えるだけ
;; https://github.com/jiro4989/joyn の処理をClojureで書こうとして途中で飽きた
(ns joyn-clj.core
(:require [clojure.string :as str])
(:require [clojure.edn :as edn]))
(defn char-to-fields
"1-15とかを1,2,3...15にする"
[ch]
(->> (str/split ch #",")
@jiro4989
jiro4989 / README.md
Created April 4, 2020 02:56
Nim 1.2.0のベンチマーク

Nim 1.2.0 と他の言語の文字列結合ベンチマーク

  • Nim 1.2.0 がリリースされた
  • 高速化されたらしいので何かベンチマークしてみたい
  • ついでに他の言語でもやってみる

計測方法

「100万回文字列結合して結果をファイル出力する」処理を100回計測して、その結果の平均値をだす。

@jiro4989
jiro4989 / jester1.nim
Last active July 16, 2021 16:22
Nimでマルチスレッドで起動してスレッド間で変数を共有する
import asyncdispatch, json
import jester
var
v = "sushi"
router myrouter:
get "/":
{.gcsafe.}:
var upstream_Game_Party_gainItem = Game_Party.prototype.gainItem;
Game_Party.prototype.gainItem = function (item, amount, includeEquip) {
upstream_Game_Party_gainItem.apply(this, arguments);
if (amount > 0) {
TextLastGet.item = item;
$gameVariables.setValue(1, item.id); // 追加した処理。変数99にアイテムのIDを格納したいのであれば1を99に変更する
}
};
@jiro4989
jiro4989 / db1.nim
Created December 26, 2019 18:53
import test
const
loaded* = true
proc exec*(query: string) =
echo "db1:" & query
@jiro4989
jiro4989 / ttytest.nim
Last active November 4, 2019 06:15
Stop output stream to pipe
import os
var tty = open("/dev/tty", fmReadWrite)
var oldStdin = stdin
var oldStdout = stdout
var oldStderr = stderr
stdin = tty
stdout = tty
stderr = tty
echo "こっちはnlされない"
@jiro4989
jiro4989 / ansible_cowsay
Last active August 27, 2019 12:19
Ansibleがメッセージを出力する時に使用するcowsayを置き換えるスクリプト
#!/bin/bash
# 使い方:
#
# このコマンドを /bin/cowsay
# あるいは/usr/local/bin/cowsayとかに配置して実行権限をつける
shift 3
cmd="$(shuf -en1 "unko.shout" "muscular shout" "edf.say")"
@jiro4989
jiro4989 / gitctl
Created July 13, 2019 03:04
gitの自分がよく使うコマンドをpecoでわかりやすく操作できるようにした
#!/bin/bash
set -eu
# pecoコマンドが存在しないとこのコマンドは使えないのでチェック
type peco >/dev/null 2>&1
ret=$?
if [ "$ret" -ne 0 ]; then
echo "Need 'peco' command in PATH." 1>&2
exit 1
@jiro4989
jiro4989 / vp
Created July 5, 2019 15:58
VimPluginリポジトリの雛形を生成するシェルスクリプト
#!/bin/bash
set -eu
readonly SCRIPT_NAME=$(basename $0)
main() {
local args=()
while ((0 < $#)); do
local opt=$1
@jiro4989
jiro4989 / gameoflife.v
Last active July 3, 2019 14:33
V言語でライフゲームしてみた (v0.1.11)
import time
const (
dead = 0
live = 1
)
fn get_neighbour_cells(board [][]int, x, y int) []int {
mut result := []int
for y2 := y-1; y2 <= y+1; y2++ {