Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍
Dance

elzup elzup

🐍
Dance
View GitHub Profile
@elzup
elzup / n-node-install.sh
Last active Jul 26, 2021
node setup by n
View n-node-install.sh
# install n
sudo apt install -y nodejs npm
sudo npm install n -g
# install node by n
sudo n stable
sudo apt purge -y nodejs npm
# reload
exec $SHELL -l
@elzup
elzup / words.txt
Created Jul 22, 2021
Aligned words (nice length pair words)
View words.txt
## good
```
```
## sad
```
@elzup
elzup / is-my-network.ts
Created Jul 8, 2021
Check is home Network
View is-my-network.ts
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)
@elzup
elzup / useFitty.ts
Created Jun 14, 2021
fitty for react
View useFitty.ts
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) => {
View perrin-prime-check.ts
// 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]
View make_badge.sh
#!/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")
View package.json
{
"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",
@elzup
elzup / make_badge.sh
Last active Mar 9, 2020
create atcoder badge. (ex. `./make_badge.sh anozon`
View make_badge.sh
#!/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")
@elzup
elzup / 0->100 arrow functions
Last active Nov 28, 2020
Goal: 100 Arrow functions, Anonymous function, lambda, closure example.
View 0->100 arrow functions
...
checks
// no args
// block
// implicit parameter
// assign
@elzup
elzup / day-changed.js
Created Feb 25, 2020
Run setTimeout at become tomorrow
View day-changed.js
const nextDay = () => new Date().setHours(0, 0, 0, 0) + 24 * 60 * 60 * 1000
const tommorowFromNow = () => nextDay() - new Date()
setTimeout(() => {
// code
}, tommorowFromNow())