Skip to content

Instantly share code, notes, and snippets.

View kazuma0129's full-sized avatar
♨️
ONSEN LOVER

Kazuma Ohashi kazuma0129

♨️
ONSEN LOVER
View GitHub Profile
@kazuma0129
kazuma0129 / autoStart.scpt
Last active January 19, 2023 08:05
Japanese version of a script that automatically launches the safari inspector of the iOS simulator
-- `menu_click`, by Jacob Rus, September 2006.
-- Ref: https://stackoverflow.com/questions/14669542/automatically-open-the-safari-debugger-when-the-iphone-simulator-is-launched
on find_by(arr, str)
repeat with elm in arr
if str contains elm then
return str
else
return null
end if
@kazuma0129
kazuma0129 / intersection.js
Last active October 14, 2022 09:54
Investigate whether there is a difference in calculation speed between "Array" and "Set" for array intersections in javascript
const intersectionSet = (a, b) => {
const setB = new Set(b);
return Array.from(new Set([...new Set(a)].filter((x) => setB.has(x))));
};
const intersectionArr = (a, b) => a.filter((x) => b.includes(x));
const genTestArr = () =>
[...Array(1000000)].map(() => Math.floor(Math.random() * 1000));
// [...Array(1000000)].map(() => `${Math.floor(Math.random() * 1000)}`);
@kazuma0129
kazuma0129 / collectExactMatchFiles.ts
Last active July 29, 2022 16:41
Collect files exact match using Map in Deno
const collectExactMatchFiles = async (p: string, cache: Map<string, string[]>) => {
const collect = async (key: string) => {
const c = await Deno.readTextFile(key);
if (!cache.has(c)) {
cache.set(c, [key]);
return;
}
const e = cache.get(c);
e && cache.set(c, [...e, key]);
};
@kazuma0129
kazuma0129 / hex2hsl.js
Last active May 4, 2020 05:27 — forked from xenozauros/hex2hsl.js
Javascript: HEX to RGB to HSL
fucntion hexToHSL(hex) {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
const r = parseInt(result[1], 16) / 255
const g = parseInt(result[2], 16) / 255
const b = parseInt(result[3], 16) / 255
const max = Math.max(r, g, b)
const min = Math.min(r, g, b)
let h = 0
let s = 0
const l = (max + min) / 2