Skip to content

Instantly share code, notes, and snippets.

api.mapkey('<Meta-Shift-Enter>', 'Open textwell', function() {
const text = '“' + window.getSelection().toString() + '”\n' + window.top.document.title + ' - ' + window.top.location.href;
location.href = `textwell:///add?text=${encodeURIComponent(text)}`
});
@htakeuchi
htakeuchi / amazon2textwell.js
Created November 1, 2023 08:02
Amazon商品の商品名と画像へのリンクをTextwellに追加するブックマークレット
javascript: (() => {
const dest_path = "notes"; //ファイルを格納するパス
const amazon_id = "namaraiicom-22"; // アフィリエイトID
let p = document.getElementById("productTitle") || document.getElementById("ebooksProductTitle"); //書籍のタイトルの処理
const title = p.innerText.trim();
const asinElement = document.getElementById('ASIN') || document.getElementsByName('ASIN.0')[0]; //ASIN番号の処理
const a = asinElement.value;
@htakeuchi
htakeuchi / book2textwell.js
Last active November 2, 2023 05:02
Amazonの書誌情報をTextwellの追記するブックマークレット
javascript: (() => {
const dest_path = 'notes'; //ファイルを格納するパス
const amazon_id = 'namaraiicom-22'; // アフィリエイトID
let p = document.getElementById("productTitle"); //書籍のタイトルの処理
p = p ? p : document.getElementById("ebooksProductTitle");
const title = p.innerText.trim();
let asin = document.getElementById('ASIN'); //ASIN番号の処理
@htakeuchi
htakeuchi / calculator.html
Last active August 30, 2023 04:17
ChatGPTが書いた電卓
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>電卓</title>
<style>
body {
font-family: Arial, sans-serif;
}
@htakeuchi
htakeuchi / kindle_books_mac.rb
Created January 7, 2022 04:54
Kindle for Macの情報からCSVで蔵書一覧を出力する
require 'rexml/document'
require 'date'
require 'csv'
# Kindle for Mac
KINDLE_XML = "#{ENV['HOME']}/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/Cache/KindleSyncMetadataCache.xml"
doc = REXML::Document.new(File.read(KINDLE_XML))
csv = CSV.generate(force_quotes: true) do |csv|
@htakeuchi
htakeuchi / quote.js
Created July 30, 2021 01:21
表示中のページのURL、タイトル、選択範囲をクロップボードへコピーするBookmarklet
(() => {
const main = () => {
const textAreaElement = document.createElement("textarea");
textAreaElement.textContent = getUrlInfo();
const bodyElement = document.getElementsByTagName("body")[0];
bodyElement.appendChild(textAreaElement);
textAreaElement.select();
const isSuccessCopy = document.execCommand('copy');
@htakeuchi
htakeuchi / bear_today.js
Last active June 26, 2021 22:20
Bearの今日の日付のメモに追記するTextwellアクション
function zp(n) {
return ( '0' + n ).slice(-2);
}
now = new Date();
year = now.getFullYear();
month = now.getMonth() + 1;
day = now.getDate();
d = year + '/' + zp(month) + '/' + zp(day)
@htakeuchi
htakeuchi / bear_new.js
Created June 23, 2021 21:32
Bearに新規メモを作成するTextwellアクション
T( 'urlScheme', {
url: 'bear://x-callback-url/create?title=' + encodeURIComponent( T.line(1) ) + '&text=' + encodeURIComponent( T.lines(2, null) )
} );
@htakeuchi
htakeuchi / wavmp3.rb
Last active March 19, 2021 13:47
mp3とwavを相互変換する
#!/usr/bin/env ruby
def usage
$stderr.puts "usage: wavmp3 file [file ...]"
exit 1
end
usage if ARGV.size < 1
ARGV.each do |f|
@htakeuchi
htakeuchi / exif.html
Created September 20, 2020 07:46
HugoでイメージのリサイズとExif情報を行うShortcode
{{ $originalImage := (.Page.Resources.ByType "image").GetMatch (printf "**%s**" (.Get "src")) }}
{{ $noExif := .Get "noExif" }}
{{ $resized := "" }}
{{ $orientation := $originalImage.Exif.Tags.Orientation }}
{{ if eq $orientation 6 }}
{{ $resized = $originalImage.Resize "x800 q92 r270" }}
{{ else if (eq $orientation 8) }}
{{ $resized = $originalImage.Resize "x800 q92 r90"}}
{{ else }}