Skip to content

Instantly share code, notes, and snippets.

View munierujp's full-sized avatar
👨‍💻
Contribute to the world

Munieru / MUROOKA Naoki munierujp

👨‍💻
Contribute to the world
View GitHub Profile
@munierujp
munierujp / apple_compare_highlight.js
Last active September 26, 2025 08:19
This script highlights differences on the device comparison page on Apple's website. Paste it into the developer tools console and run it. This script was generated by ChatGPT.
(() => {
// --- Custom Styles ---
const STYLE_ID = 'compare-diff-style-2';
if (!document.getElementById(STYLE_ID)) {
const style = document.createElement('style');
style.id = STYLE_ID;
style.textContent = `
.diff-yellow {
background: rgba(255, 255, 150, 0.8) !important;
}
const array1: number[] = [1, 2, 3]
const array2: boolean[] = [false, true]
const array3 = array1.flatMap(a => array2.map(b => [a, b] as const))
/*
type: (readonly [number, boolean])[]
value:
[
[ 1, false ],
[ 1, true ],
[ 2, false ],
export class SensitiveParameter<T> {
private readonly value: T
private readonly masked: string
constructor (value: T, masked: string = '***') {
this.value = value
this.masked = masked
}
/**
const waitDOMContentLoaded = async () => {
await new Promise((resolve) => {
window.addEventListener('DOMContentLoaded', () => {
resolve()
})
})
}
const waitLoaded = async () => {
await new Promise((resolve) => {
window.addEventListener('load', () => {
resolve()
})
})
}
const sleep = async (ms) => {
return await new Promise(resolve => setTimeout(resolve, ms))
}
import { useMemo } from 'react'
import { useLocation } from 'react-router-dom'
/**
* @see https://v5.reactrouter.com/web/example/query-parameters
*/
export const useQueryParams = (): URLSearchParams => {
const { search } = useLocation()
return useMemo(() => new URLSearchParams(search), [search])
}
((function () {
const backup = localStorage.getItem('backup')
const { data } = JSON.parse(backup)
const searchParams = new URLSearchParams(data)
const params = Object.fromEntries(searchParams)
console.log(params)
})()
@munierujp
munierujp / sleep.ts
Last active September 25, 2022 14:04
const sleep = async (ms: number): Promise<void> => {
return await new Promise(resolve => setTimeout(resolve, ms))
}
function getRandomNumber (
min: number,
max: number
): number {
min = Math.ceil(min)
max = Math.floor(max)
return Math.floor(Math.random() * (max - min)) + min
}