Skip to content

Instantly share code, notes, and snippets.

@azu
azu / github-proxy-client.js
Created March 13, 2022 13:02 — forked from DavidWells/github-proxy-client.js
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
@azu
azu / irdor-komesan.user.js
Last active January 24, 2022 14:53
Greamonkey Script: irodr integrate with komesan
// ==UserScript==
// @name irodr: komesan
// @namespace github.com/azu
// @match https://irodr.netlify.app/
// @grant none
// @version 1.0
// @author azu
// @description irodr integrate
// @run-at document-end
// ==/UserScript==
@azu
azu / commonjs-module.js
Last active January 12, 2022 11:30
webpack 5.66.0 add library type: commonjs-static
"use strict";
var __webpack_require__ = {
d: (_, e) => {
for (var r in e) __webpack_require__.o(e, r) && !__webpack_require__.o(_, r) && Object.defineProperty(_, r, {
enumerable: !0,
get: e[r]
})
}, o: (_, e) => Object.prototype.hasOwnProperty.call(_, e), r: _ => {
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(_, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(_, "__esModule", { value: !0 })
}
@azu
azu / useHistoryState.ts
Created September 29, 2021 06:52
Undo/Redo Manage implementation using React Hooks: https://twitter.com/azu_re/status/1443105296994340867
type HistoryState = unknown; /* state object */
const useHistoryState = (defaultState: HistoryState) => {
const STACK_SIZE_LIMIT = 20;
const [currentState, setCurrentState] = useState<HistoryState>(defaultState);
const [undoStack, setUndoStack] = useState<HistoryState[]>([]);
const [redoStack, setRedoStack] = useState<HistoryState[]>([]);
const canUndo = useMemo(() => undoStack.length > 0, [undoStack.length]);
const canRedo = useMemo(() => redoStack.length > 0, [redoStack.length]);
const pushState = useCallback((item: HistoryState) => {
setCurrentState(item);
@azu
azu / 0.memory-note.md
Last active September 27, 2021 21:39
Memory Noteの開発メモ

目的

  • いつでも入力
  • いつでも見れる
  • とにかく早い、ストレスフリー
  • 30分とか枠を用意してそこにメモを書くのが良さそう

なぜ

  • 人の脳の容量はでかいが、記憶のスタックが小さい(疑似)
@azu
azu / furusato-tax.jp: price * 0.2.user.js
Last active August 8, 2021 04:13
furusato-tax.jpの表示金額に2割の表示を追加するGreasemonkeyスクリプト
// ==UserScript==
// @name furusato-tax.jp: price * 0.2
// @namespace furusato-tax.jpの表示金額に2割の表示を追加する
// @match https://www.furusato-tax.jp/*
// @grant none
// @version 1.0
// @author -
// @description 2021/8/8 12:08:48
// @run-at document-end
// ==/UserScript==
@azu
azu / get-domain.js
Last active June 24, 2021 03:09
Get domain(site) from url using document.cookie hacking. without public suffix
const isSite = (domain) => {
console.log(domain)
const key = "WILL_BE_FIRED." + 'xxxx-xxxx-xxx-xxxx'.replace(/[x]/g, (c) => {
const r = Math.floor(Math.random() * 16);
return r.toString(16);
});
document.cookie = `${key}=1; domain=${domain}; samesite`;
// Test wrinting
console.log("document.cookie", document.cookie)
const canWrite = document.cookie.includes(`${key}=1`);
@azu
azu / 英語 文書 翻訳 読む ツール まとめ.md
Last active November 17, 2023 16:11
英語の文書を翻訳して読むときのツールのまとめ
@azu
azu / nenkin-clipboard.user.js
Created June 7, 2021 04:08
法人番号にクリップボードをペーストできないので、できるようにするGreasemonkey: https://www2.nenkin.go.jp/do/search_section
// ==UserScript==
// @name nenkin: クリップボードから法人番号
// @namespace Violentmonkey Scripts
// @match https://www2.nenkin.go.jp/do/search_section*
// @grant none
// @version 1.0
// @author azu
// @description クリップボードから法人番号を入れる
// ==/UserScript==
const button = document.createElement("button");
@azu
azu / README.md
Created June 6, 2021 07:13
Decrypt and restore iOS backup(`Manifest.db` is encrypted) for restoring my iOS photos.

Setup

Use https://github.com/jfarley248/iTunes_Backup_Reader

git clone https://github.com/jfarley248/iTunes_Backup_Reader
cd iTunes_Backup_Reader
# apply https://github.com/jfarley248/iTunes_Backup_Reader/pull/12
gh pr checkout https://github.com/jfarley248/iTunes_Backup_Reader/pull/12