Skip to content

Instantly share code, notes, and snippets.

View qb20nh's full-sized avatar

Yoo Taejong qb20nh

  • 21:48 (UTC +09:00)
View GitHub Profile
@qb20nh
qb20nh / keyboardsubmit.user.js
Created November 7, 2023 10:08
Keyboard submit on programmers.co.kr
// ==UserScript==
// @name Ctrl+Enter executes for programmers.co.kr
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://school.programmers.co.kr/learn/courses/*/lessons/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=programmers.co.kr
// @grant none
// ==/UserScript==
@qb20nh
qb20nh / deepEqual.js
Created September 27, 2023 17:03
deepEqual.js
function deepEqual(a, b) {
// Handle edge cases and primitives using Object.is
if (Object.is(a, b)) return true;
// Handle arrays
const isArray = Array.isArray(a) && Array.isArray(b);
const isTypedArray = ArrayBuffer.isView(a) && ArrayBuffer.isView(b);
if (isArray || isTypedArray) {
if (isTypedArray) {
// Check if both are of the same type
@qb20nh
qb20nh / migrate-docker-volume.sh
Created May 4, 2023 09:49 — forked from funkyfisch/migrate-docker-volume.sh
Migrate a docker volume from one host to another
#!/bin/bash
# Environment check
# If migrating from localhost, set this to localhost
if [[ ! $SOURCE_HOST_ADDRESS ]]
then
echo "Please set the current host address in SOURCE_HOST_ADDRESS"
exit 1
fi
@qb20nh
qb20nh / canon_map.py
Last active September 4, 2023 23:39
Unicode alphanumeric lookalikes
canon_map = {
"a": ["Ã", "å", "Ă", "ą", "ƛ", "ǟ", "ɑ", "Δ", "Λ", "ά", "α", "λ", "Д", "а", "Թ", "ค", "მ", "ል", "Ꭿ", "Ꮧ", "ᕱ", "ᗅ", "ᗩ", "ᴀ", "ᴬ", "ᵃ", "ₐ", "₳", "⍺", "ⓐ", "卂", "ꁲ", "ꋫ", "ꋬ", "ꍏ", "ꪖ", "a", "ム", "𝐚", "𝑎", "𝒂", "𝒶", "𝓪", "𝔞", "𝕒", "𝖆", "𝖺", "𝗮", "𝘢", "𝙖", "𝚊", "𝛂", "𝛼", "𝜶", "𝝰", "𝞪", "🄰", "🅐", "🅰", "🇦\u200c",],
"b": ["ß", "Ɓ", "Ƅ", "ɓ", "ɮ", "ʙ", "β", "ϐ", "Ϧ", "Б", "Ь", "б", "в", "ҍ", "Յ", "฿", "๒", "๖", "Ⴆ", "ჩ", "ც", "ጌ", "Ꮟ", "Ᏸ", "ᑲ", "ᖯ", "ᗷ", "ᙘ", "᥇", "ᴮ", "ᵇ", "ⓑ", "♭", "乃", "ꃃ", "ꃲ", "ꃳ", "ꋰ", "ꌃ", "ꍗ", "ꪉ", "b", "𐒈", "𝐛", "𝑏", "𝒃", "𝒷", "𝓫", "𝔟", "𝕓", "𝖇", "𝖻", "𝗯", "𝘣", "𝙗", "𝚋", "🄱", "🅑", "🅱", "🇧\u200c",],
"c": ["¢", "ç", "Ć", "Č", "Ƈ", "ƈ", "ȼ", "ς", "ϲ", "с", "Շ", "८", "૮", "ე", "ᄃ", "ር", "ፈ", "Ꮯ", "Ꮳ", "ᑕ", "ᑢ", "ᑤ", "ᝯ", "ᥴ", "ᨶ", "ᴄ", "ᶜ", "₡", "₵", "ℂ", "ⅽ", "ⓒ", "☾", "ⲥ", "ㄈ", "匚", "ꀯ", "ꇃ", "ꉓ", "ꉔ", "ꏳ", "ꏸ", "꒝", "ꮯ", "c", "𐐽", "𐒨", "𝐜", "𝑐", "𝒄", "𝒸", "𝓬", "𝔠", "𝕔", "𝖈", "𝖼", "𝗰", "𝘤", "𝙘", "𝚌", "🄲", "🅒", "🅲", "🇨\u200c",],
"d": ["Ð", "Ď", "ď", "Đ", "Ɗ", "
from time import sleep, time
import os
def binary_search(condition, low, high):
if callable(condition) and high > low:
mid = int((high + low) / 2)
res = condition(mid)
@qb20nh
qb20nh / HttpRedirectionInterceptor.java
Last active January 14, 2022 09:29
Intercept Redirect
package kr.co.benew.iddle_admin.servlet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.UnaryOperator;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
@qb20nh
qb20nh / json_format.js
Last active December 17, 2021 06:35
Simple json formatter
const json_format = (jsons, level = 2) => {
let i = 0
return JSON.stringify(JSON.parse(jsons)).replace(/\[\]|\{\}|[{[,\]}]/g,
c => ['[]', '{}'].includes(c) ? c : '{[,'.includes(c) ? c + '\n' + (','.includes(c) ? ' '.repeat(i * level) : ' '.repeat(++i * level)) : '\n' + ' '.repeat(--i * level) + c)
.replace(/"(?:[^"]|\\")+"(:)/g, '$& ')
}
@qb20nh
qb20nh / template.js
Last active December 17, 2021 06:38
Populate jstl-el-like expressions with JS
const iterateNode = (rootNode, [attrVisitor, textVisitor]) => {
if (rootNode instanceof Node) {
for(const node of rootNode.childNodes) {
if (node instanceof Element) {
for (const attr of node.attributes) {
attrVisitor.call(null, attr)
}
iterateNode(node, [attrVisitor, textVisitor])
} else if (node instanceof Text) {
textVisitor.call(null, node)
@qb20nh
qb20nh / intercept-function.js
Last active December 11, 2021 12:39 — forked from tilmanschweitzer/intercept-function.js
Function to intercept functions calls even to nativ functions.
const interceptFunction = (object, fnName, options) => {
const noop = () => {}
const fnToWrap = object[fnName]
const before = options.before || noop
const after = options.after || noop
object[fnName] = function (...args) {
before.apply(this, args)
const result = fnToWrap.apply(this, args)
after.apply(this, args, result)
@qb20nh
qb20nh / rps.js
Created December 7, 2021 13:19
RPS.js
let com = Math.random()*3 | 0
let usr
const rps = 'rock paper scissors'.split(' ')
const score = 'draw win lose'.split(' ')
let usrNum
while ((usrNum = rps.indexOf(usr = prompt('choose your move'))) === -1) {
alert('invalid move')