upamune
https://scrapbox.io/files/63a44b434c5cb8001e70c908.png
upamuneは「うぱみゅん」と読む
/pduck/punch.icon 読んで /pduck/punch.icon
SaaSを開発しているソフトウェアエンジニア
現在の所属: https://ogp-image.deno.dev/svg?url=https://link.serizawa.me/join-layerx#.png https://link.serizawa.me/join-layerx
各種リンク
旧日記
Ghost解約した瞬間に見ることができなくなったw
/icons/-.icon
文字カウント
code:script.js
import '/api/code/shokai/文字カウント/page.js'
import '/api/code/shokai/文字カウント/popup.js'
アイコン強調記法
upamune.icon
upamune.icon
code:style.css
/* 強調記法 hoge.icon のアイコンのとき、サイズをもっと大きくする */
.line img.strong-icon { max-height: 7em; height: auto }
/pduck/punch.icon
日記フォーマット
code:script.js
tweet menu
code:script.js
scrapbox.PageMenu.addItem({
title: 'Tweet',
onClick: () => window.open(https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(window.scrapbox.Page.title)})
})
テンプレート
code:style.css
a#Templates.tool-btn:hover { text-decoration: none }
a#Templates.tool-btn::before { position: absolute; content: '\f067'; font: 900 21px/46px 'Font Awesome 5 Free' }
a#Templates.tool-btn img { opacity: 0 }
code:script.js
addTemplateItemsToPageMenu()
function addTemplateItemsToPageMenu() {
// テンプレートメニューの定義ここから ---------- 下の解説を見てね!! ----------
const __templates = [
{ title: '📄 日記', template: '/api/code/upamune/upamune/日記.js' },
{ title: '✍️ 週振り返り', template: '/api/code/upamune/upamune/週振り返り.js' },
{ title: '🎯 週目標', template: '/api/code/upamune/upamune/週目標.js' }
]
// テンプレートメニューの定義ここまで ----------
const __templMenuTitle = 'Templates'
__templates.forEach((i) => {
scrapbox.PageMenu(__templMenuTitle).addItem({
title: i.title,
onClick: () => { __loadTemplate(i.template) }})
})
var __loadTemplate = function (templateUrl) {
if (scrapbox.Page.lines && scrapbox.Page.lines.length == 1) {
// タイトル行をクリックしたことにする
const line = document.getElementById('L' + scrapbox.Page.lines0.id) const lastChar = line.querySelector('span.char-index:last-of-type')
const textarea = document.getElementById('text-input')
lastChar.dispatchEvent(new MouseEvent('click', {bubbles: true, cancelable: true}))
textarea.dispatchEvent(new KeyboardEvent('keydown', {bubbles: true, cancelable: true, keyCode: 35}))
// テンプレートを読み込む
$('#text-input').load(templateUrl, function (response, status, xhr) {
if (status == "success") {
try {
// 読み込んだテンプレートをテキストエリアにセットしまして
textarea.value = /\.js$/.test(templateUrl) ? eval(response) : response
// テキストエリアのinputイベントを出しまして
textarea.dispatchEvent(new InputEvent('input', {bubbles: true, cancelable: true}))
} catch (ex) {
console.log("だめでした>< \n" + ex)
}
} else {
console.log("だめでした>< \n" + status)
}
})
}
}
}
テンプレート:日記
code:日記.js
(function() {
Date.prototype.setWeek = function(year, week, day) {
var week1 = new Date(year, 0, 1)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.setISOWeek = function(year, week, day) {
var week1 = new Date(year, 0, 4)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.format = function(format) {
// yyyy, MM, dd, ddd だけ
.replace('yyyy', this.getFullYear())
.replace('MM', ('0' + (this.getMonth() + 1)).slice(-2))
.replace('dd', ('0' + this.getDate()).slice(-2))
}
// Returns the ISO week of the date.
Date.prototype.getWeek = function() {
var date = new Date(this.getTime());
date.setHours(0, 0, 0, 0);
// Thursday in current week decides the year.
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
// January 4 is always in week 1.
var week1 = new Date(date.getFullYear(), 0, 4);
// Adjust to Thursday in week 1 and count number of weeks from date to week1.
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000
- 3 + (week1.getDay() + 6) % 7) / 7);
}
// Returns the four-digit year corresponding to the ISO week of the date.
Date.prototype.getWeekYear = function() {
var date = new Date(this.getTime());
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
return date.getFullYear();
}
// 処理ここから
const d = new Date()
const yesterday = new Date(d.getFullYear(), d.getMonth(), d.getDate() - 1)
const tomorrow = new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1)
const dateFormat = "yyyy-MM-dd"
const dayFormat = "ddd"
// ここで返してるものがページのタイトルと本文になるよ! 1週間分の日付と曜日を並べていきます
return `${d.format(dateFormat)} ${d.format(dayFormat)} : (WIP)
/icons/-.icon
生活
見たやつ・読んだやつ
`
})()
code:週振り返り.js
(function() {
Date.prototype.setWeek = function(year, week, day) {
var week1 = new Date(year, 0, 1)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.setISOWeek = function(year, week, day) {
var week1 = new Date(year, 0, 4)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.format = function(format) {
// yyyy, MM, dd, ddd だけ
.replace('yyyy', this.getFullYear())
.replace('MM', ('0' + (this.getMonth() + 1)).slice(-2))
.replace('dd', ('0' + this.getDate()).slice(-2))
}
// Returns the ISO week of the date.
Date.prototype.getWeek = function() {
var date = new Date(this.getTime());
date.setHours(0, 0, 0, 0);
// Thursday in current week decides the year.
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
// January 4 is always in week 1.
var week1 = new Date(date.getFullYear(), 0, 4);
// Adjust to Thursday in week 1 and count number of weeks from date to week1.
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000
- 3 + (week1.getDay() + 6) % 7) / 7);
}
// Returns the four-digit year corresponding to the ISO week of the date.
Date.prototype.getWeekYear = function() {
var date = new Date(this.getTime());
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
return date.getFullYear();
}
// 処理ここから
const d = new Date()
const yesterday = new Date(d.getFullYear(), d.getMonth(), d.getDate() - 1)
const tomorrow = new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1)
const dateFormat = "yyyy-MM-dd"
const dayFormat = "ddd"
// ここで返してるものがページのタイトルと本文になるよ! 1週間分の日付と曜日を並べていきます
return `${d.getWeekYear()}年WN${d.getWeek()}の目標振り返り
/icons/-.icon
Objective1: リズムに乗る
Objective2: 技術でリードできる土台を作る
それ以外
振り返り
`
})()
code:script.js
function insertText({text}) {
const cursor = document.getElementById('text-input');
cursor.focus();
cursor.value = text;
const uiEvent = document.createEvent('UIEvent');
uiEvent.initEvent('input', true, false);
cursor.dispatchEvent(uiEvent);
}
function convertWholeText(text) {
const urls = text.match(/https?:\/\/\S+/g) ?? [];
if (urls.length === 0) return undefined;
const links = urls.map((url) => convert(url));
let map = {};
for (let i = 0; i < urls.length; i++) {
}
console.log(map);
const result = text.replace(
/https?:\/\/\S+/g,
(match) => mapmatch?.text ?? match, );
debugger;
console.log(result);
return result;
}
function convert(url) {
return { text: [[https://ogp-image.deno.dev/svg?url=${url}#.png ${url}]]};
}
scrapbox.PopupMenu.addButton({
title: (text) => (/https?:\/\/\S+/.test(text) ? "OGP" : "."), // URLがなければボタンを押しにくくする
onClick: (text) => {
if (!/https?:\/\/\S+/.test(text)) return; // URLがなければ何もしない
const converted = convertWholeText(text);
console.log(text, converted);
insertText({ text: converted });
},
});
code:週目標.js
(function() {
Date.prototype.setWeek = function(year, week, day) {
var week1 = new Date(year, 0, 1)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.setISOWeek = function(year, week, day) {
var week1 = new Date(year, 0, 4)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.format = function(format) {
// yyyy, MM, dd, ddd だけ
.replace('yyyy', this.getFullYear())
.replace('MM', ('0' + (this.getMonth() + 1)).slice(-2))
.replace('dd', ('0' + this.getDate()).slice(-2))
}
// Returns the ISO week of the date.
Date.prototype.getWeek = function() {
var date = new Date(this.getTime());
date.setHours(0, 0, 0, 0);
// Thursday in current week decides the year.
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
// January 4 is always in week 1.
var week1 = new Date(date.getFullYear(), 0, 4);
// Adjust to Thursday in week 1 and count number of weeks from date to week1.
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000
- 3 + (week1.getDay() + 6) % 7) / 7);
}
// Returns the four-digit year corresponding to the ISO week of the date.
Date.prototype.getWeekYear = function() {
var date = new Date(this.getTime());
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
return date.getFullYear();
}
// 処理ここから
const d = new Date()
const yesterday = new Date(d.getFullYear(), d.getMonth(), d.getDate() - 1)
const tomorrow = new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1)
const dateFormat = "yyyy-MM-dd"
const dayFormat = "ddd"
const nextWeek = d.getWeek() + 1
// ここで返してるものがページのタイトルと本文になるよ! 1週間分の日付と曜日を並べていきます
return `${d.getWeekYear()}年WN${nextWeek}の目標
/icons/-.icon
Objective1: リズムに乗る
1. インプットを継続できるような仕組みを構築して習慣化する
2. OKRの毎月・毎週の振り返りを継続する
Objective2: 技術でリードできる土台を作る
1. パフォーマンス周りのインプットをする
2. アーキテクチャ周りのインプットをする
それ以外
まとめ
`
})()