Skip to content

Instantly share code, notes, and snippets.

@1j01
1j01 / undo-redo-history.js
Last active October 14, 2024 01:43
Undo/redo history pattern example in JavaScript
// first setup our stacks of history states
// (const refers to the reference to the arrays, but they arrays themselves are mutable)
const undos = [];
const redos = [];
// undo and redo are symmetrical operations, so they *could* be factored to use an "undoOrRedo" / "stepHistory" function that takes two stacks as arguments, but it might be clearer as two functions
const undo = () => {
if (undos.length < 1) { return false; }
@sadnessOjisan
sadnessOjisan / index.md
Last active February 27, 2025 16:12
それっぽいランダムな値が欲しい時にやってること

ランダムな文字列をワンライナーで出す

まえがき

それっぽいランダムな値が欲しい時がありますよね。例えば、モックアプリで使うIDや、開発環境のダミーユーザーのパスワードなど、そんなに安全じゃなくていいから手軽に作れるランダムな文字列が欲しいという場面があります。パスワード生成アプリなどもありますが、アプリのインストールや起動がめんどくさく、一回だけ欲しいみたいなときになんか簡単かつ汎用的な方法はないものかと探していました。そこで、様々な環境から一行で作れる方法を紹介します。手軽さが優先されているので、安全性が多少は下がる面もあります。本番環境でのパスワードなどには使わない方が良いでしょう。

JavaScriptを利用する

Math経由

JavaScriptは汎用的です。ブラウザのインスペクタから実行できますし、Node.jsがあればターミナル上でREPLを実行できます。このワンライナーはどうでしょうか。

@ymmt2005
ymmt2005 / howto-tech-docs.md
Last active March 17, 2026 03:41
技術文書の書き方

技術文書の書き方

このメモは、私(@ymmt2005)が長年にわたってソフトウェアプロダクト開発に関わってきて 2022年現在こうしたほうが良いと考えているベストプラクティスです。

科学的な分析等に基づくわけではない経験則であるため、今後も随時見直すことがありますし、 ここに書いてあることが常に正しいわけでもあらゆるソフトウェア開発に適するわけでもありません。

しかしながら、実務経験が豊富で、モダンな技術スタックに明るいエンジニアの経験則は一定の 役に立つのではないかと考えて記します。

// This code is Public domain (Creative Commons Zero CC0-1.0)
// https://creativecommons.org/publicdomain/zero/1.0/deed.ja
// from nostr-tools (Public domains)
export type NostrEvent = {
id?: string;
kind: number;
tags: string[][];
pubkey: string;
content: string;
@NicolasDorier
NicolasDorier / I-Dont-Know.md
Created March 25, 2024 04:16
I don't know

I don't know

Having been a prolific open-source developer in Bitcoin for nearly 10 years, time to time, I get asked my opinion on news about Bitcoin and Lightning Network.

It may surprise you, but most of the time you know more than I do, and you know more than what you think.

My priority is BTCPay Server, and I have a very narrow (myopic shall I say) focus on what I do every day. My focus is even too intense to keep track of all the developement happening on BTCPay Server alone. (When in doubt, ask @pavlenex)

My focus is more akin to a code gardener, where I focus on removing weeds, and making sure the ground is fertile so people can grow their fruits on the BTCPay Server garden.