Skip to content

Instantly share code, notes, and snippets.

@zakuroishikuro
zakuroishikuro / evernote_to_kindle.js
Last active February 26, 2024 09:56
MacでEvernoteの選択されたノートをKindleにメール送信 (JXA) ref: http://qiita.com/zakuroishikuro/items/7d47f9180f82ab9293c9
// 自分のKindleのメールアドレス (必ず変更すること)
KINDLE_MAIL_ADDRESS = "your_kindle_address@きんどる.com"
// Kindleへの送信を許可しているメールアドレス
KINDLE_PERMITTED_ADDRESS = "your_name <your_address@gmail.com>"
TEMP_DIR = "evernote_to_kindle"
ZIP_NAME = "evernote_to_kindle.zip"
app = Application.currentApplication()
@zakuroishikuro
zakuroishikuro / stop_lenovo_vantage_cleaning_mode.ps1
Last active January 5, 2024 14:57
kill lenovo vantage cleaning mode
$filePath = "C:\ProgramData\Lenovo\Vantage\Addins\ThinkKBDAddin\*\LenovoVantage.CleanYourDevice.exe"
$acl = Get-Acl $filePath
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone", "Execute", "Deny")
$acl.SetAccessRule($rule)
Set-Acl -Path $filePath -AclObject $acl
@zakuroishikuro
zakuroishikuro / try_split_address.rb
Last active October 24, 2023 06:12
住所を分ける正規表現をチェックするやつ
require 'csv'
require 'optparse'
#
# なるべく短い正規表現で住所を「都道府県/市区町村/それ以降」に分けるエクストリームスポーツ
# http://qiita.com/zakuroishikuro/items/066421bce820e3c73ce9
#
# 正規表現で住所の「都道府県/市区町村/それ以降」をキャプチャできるか試すスクリプト
# 使い方はとりあえず実行すれば分かると思います
#
@zakuroishikuro
zakuroishikuro / generate_rex.rb
Created January 24, 2016 00:10
住所を都道府県 / 市区町村 / 町域名に分ける正規表現
require 'csv'
# 郵便局のサイトから郵便番号データをダウンロードしておく
# 同じフォルダ内のKEN_ALL.csvを読み込む
csv_path = File.expand_path("../KEN_ALL.CSV", __FILE__)
# 市区町村を取得
cities = CSV.read(csv_path, encoding:"Shift_JIS:UTF-8").transpose[7].uniq
# 最後の文字以外に「市・区・町・村」があれば、その文字までの最長の文字列を取得
@zakuroishikuro
zakuroishikuro / create_logseq_page.js
Last active October 18, 2023 17:54
logseq bookmarklet
javascript: (()=>{
const {hostname, pathname} = location;
let page = hostname + pathname;
let content = "";
const now = new Date();
const date = now.toLocaleDateString().replace(/\//g, "-");
const time = now.toLocaleTimeString();
content = `source:: [${document.title}](${location.href})\ncreated:: [[${date}]] ${time}`;
@zakuroishikuro
zakuroishikuro / tiktoken_search_long_word.py
Last active May 2, 2023 14:18
1トークンで長い単語を探す
import tiktoken
import heapq
import re
ONLY_JAPANESE = True
CONTAINS_NON_SYMBOL = True
MODEL = "gpt-3.5-turbo"
#MODEL = "gpt-4"
enc = tiktoken.encoding_for_model(model)
const defaultDict = <T>(defaultValue: T, object = {}): { [key: string]: T } => {
return new Proxy(object, {
get(obj, prop) {
return prop in obj ? obj[prop] : defaultValue;
},
});
};
const dict = defaultDict(100);
declare global {interface Object { log<T>(this: T, msg?): T }} // prettier-ignore
export function main(input: string): number | string {
const [A, B] = input.split(/\s/).map(Number);
return input;
}
// === ここから読む必要なし ===
const DEBUG = process.env.NODE_ENV === "test";
Object.assign(Object.prototype,{log<T>(this:T,msg="log"){if(DEBUG)console.log(`[${msg}] ${this}`);return this}}) // prettier-ignore
Object.defineProperty(Object.prototype, "out", {
value() {
console.log(this.toString());
return this;
},
});
interface Object {
out<T>(this: T): T;
}
@zakuroishikuro
zakuroishikuro / getout.ts
Created November 13, 2022 00:04
console.logするだけのgetter生やしたい
Object.defineProperty(Object.prototype, "out", {
get() {
console.log(this.toString());
return this;
},
});
interface Object {
get out(): any; // ここをanyじゃなくoutを呼んでいるインスタンスの型にしたい
}