Skip to content

Instantly share code, notes, and snippets.

View koba-yu's full-sized avatar

Koba-yu koba-yu

View GitHub Profile
@koba-yu
koba-yu / From_ShiftJIS_To_UTF8.cs
Last active May 2, 2020 06:17
C#で指定フォルダのファイルを全てShift-JISからUTF-8に変換する
void Main()
{
foreach (var file in Directory.EnumerateFiles(@"ここにフォルダを指定"))
{
var content = File.ReadAllText(file, Encoding.GetEncoding("Shift_JIS"));
if(content.Length == 0)
continue;
File.WriteAllText(file, content, Encoding.GetEncoding("UTF-8"));
}
}
@koba-yu
koba-yu / copy-red-file.red
Created April 25, 2020 11:36
A script to get red's file! from script argument.
Red [
Title: "copy-red-file"
Needs: View
]
unless empty? system/script/args [
path: to-red-file system/script/args
write-clipboard mold either attempt [read path][path][dirize path]
]
@koba-yu
koba-yu / pipeline-operator.red
Last active March 16, 2018 13:19
Redでパイプライン演算子的なものを作ってみる
Red []
; パイプ演算子の実体となる関数
pipe: function [x 'y] [value: get y value x]
; 「|>」にpipe関数を演算子としてセット
|>: make op! :pipe
; 使い方はこんな感じになる。残念ながら呼び出される側の関数には「'」を付けないと呼べない・・・
[1 2 3] |> 'rejoin
; returns "123"
@koba-yu
koba-yu / object-comparison.red
Last active September 18, 2016 05:34
Redのobject!のインスタンスの比較の挙動
Red[]
; object!の比較ではフィールドの値が比較される模様。aとbを比較するとtrue。aとcだとfalse
a: make object! [name: "Alice" surname: "Gold"]
b: make object! [name: "Alice" surname: "Gold"]
c: make object! [name: "Bob" surname: "Gold"]
a = b
; returns true
a = c