This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { readdir } = require('fs').promises | |
const readdirRecursiveEnt = async (dir, ent) => { | |
const path = `${dir}/${ent.name}` | |
if (ent.isFile()) return path | |
if (ent.isDirectory()) { | |
return await readdirRecursive(path) | |
} | |
console.log(`${ent.name} is not a file or directory`) | |
return null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs' | |
import { promisify } from 'util' | |
import network from 'network' | |
const getActiveInterface = promisify(network.get_active_interface) | |
const getCurrent = async () => (await getActiveInterface())?.mac_address | |
const SAVE_FILE = 'home.mac.txt' | |
const saveHomeNetwork = (id: string) => fs.writeFileSync('home.mac.txt', id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef } from 'react' | |
import fitty from 'fitty' | |
export function useFitty() { | |
const ref = useRef<HTMLDivElement>(null) | |
useEffect(() => { | |
if (!ref.current) return | |
fitty(ref.current) | |
ref.current.addEventListener('fit', (e) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// perrin(n) / n === 0 | |
// = | |
// isPrime(n) | |
const perrinMemo: [bigint, bigint, bigint] = [0n, 2n, 3n] | |
const primeMemo: number[] = [2, 3] | |
function perrinNext(): bigint { | |
const next = perrinMemo[0] + perrinMemo[1] | |
perrinMemo[0] = perrinMemo[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# this script dependence "pup", "jq" | |
USERNAME=$1 | |
SELECTOR='tr:nth-child(2) span:nth-child(1) json{}' | |
USERDATA=$(curl -s https://atcoder.jp/users/$USERNAME |pup $SELECTOR) | |
COLOR=$(echo $USERDATA |jq --raw-output ".[0].class" |sed 's/user-//') | |
RATE=$(echo $USERDATA |jq --raw-output ".[0].text") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# this script dependence "pup", "jq" | |
USERNAME=$1 | |
SELECTOR='tr:nth-child(2) span:nth-child(1) json{}' | |
USERDATA=$(curl -s https://atcoder.jp/users/$USERNAME |pup $SELECTOR) | |
COLOR=$(echo $USERDATA |jq --raw-output ".[0].class" |sed 's/user-//') | |
RATE=$(echo $USERDATA |jq --raw-output ".[0].text") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "competitive-pg-wrokspace", | |
"version": "1.0.0", | |
"main": "index.js", | |
"author": "elzup <guild0105@gmail.com>", | |
"license": "MIT", | |
"devDependencies": { | |
"@types/node": "^13.5.3", | |
"atcoder-cli": "^2.0.4", | |
"eslint": "^6.8.0", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nextDay = () => new Date().setHours(0, 0, 0, 0) + 24 * 60 * 60 * 1000 | |
const tommorowFromNow = () => nextDay() - new Date() | |
setTimeout(() => { | |
// code | |
}, tommorowFromNow()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cat ~/.chpwd-recent-dirs \ | |
| sed -e 's/^..\(.*\)./\1/g' \ | |
| while read line | |
do | |
if [ -d "$line" ]; then | |
echo "\$'$line'" | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as functions from 'firebase-functions' | |
import * as admin from 'firebase-admin' | |
admin.initializeApp({ | |
credential: admin.credential.applicationDefault(), | |
// databaseURL: 'https://hoge.firebaseio.com/', | |
}) | |
export const api = functions.https.onRequest(async (req, res) => { | |
const message = { |