Skip to content

Instantly share code, notes, and snippets.

View qb20nh's full-sized avatar
๐Ÿ’ญ
I may be slow to respond.

Yoo Taejong qb20nh

๐Ÿ’ญ
I may be slow to respond.
  • 16:14 (UTC +09:00)
View GitHub Profile
// ==UserScript==
// @name SO copy code snippet
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Adds copy button to code snippets
// @author me
// @match https://stackoverflow.com/questions/*
// @icon https://www.google.com/s2/favicons?domain=stackoverflow.com&sz=64
// @grant none
// @require https://cdnjs.cloudflare.com/ajax/libs/cash/8.1.1/cash.min.js
@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": ["รƒ", "รฅ", "ฤ‚", "ฤ…", "ฦ›", "วŸ", "ษ‘", "ฮ”", "ฮ›", "ฮฌ", "ฮฑ", "ฮป", "ะ”", "ะฐ", "ิน", "เธ„", "แƒ›", "แˆ", "แŽฏ", "แ—", "แ•ฑ", "แ—…", "แ—ฉ", "แด€", "แดฌ", "แตƒ", "โ‚", "โ‚ณ", "โบ", "โ“", "ๅ‚", "๊ฒ", "๊‹ซ", "๊‹ฌ", "๊", "๊ช–", "๏ฝ", "๏พ‘", "๐š", "๐‘Ž", "๐’‚", "๐’ถ", "๐“ช", "๐”ž", "๐•’", "๐–†", "๐–บ", "๐—ฎ", "๐˜ข", "๐™–", "๐šŠ", "๐›‚", "๐›ผ", "๐œถ", "๐ฐ", "๐žช", "๐Ÿ„ฐ", "๐Ÿ…", "๐Ÿ…ฐ", "๐Ÿ‡ฆ\u200c",],
"b": ["รŸ", "ฦ", "ฦ„", "ษ“", "ษฎ", "ส™", "ฮฒ", "ฯ", "ฯฆ", "ะ‘", "ะฌ", "ะฑ", "ะฒ", "า", "ี…", "เธฟ", "เน’", "เน–", "แ‚ฆ", "แƒฉ", "แƒช", "แŒŒ", "แ", "แฐ", "แ‘ฒ", "แ–ฏ", "แ—ท", "แ™˜", "แฅ‡", "แดฎ", "แต‡", "โ“‘", "โ™ญ", "ไนƒ", "๊ƒƒ", "๊ƒฒ", "๊ƒณ", "๊‹ฐ", "๊Œƒ", "๊—", "๊ช‰", "๏ฝ‚", "๐’ˆ", "๐›", "๐‘", "๐’ƒ", "๐’ท", "๐“ซ", "๐”Ÿ", "๐•“", "๐–‡", "๐–ป", "๐—ฏ", "๐˜ฃ", "๐™—", "๐š‹", "๐Ÿ„ฑ", "๐Ÿ…‘", "๐Ÿ…ฑ", "๐Ÿ‡ง\u200c",],
"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)