Skip to content

Instantly share code, notes, and snippets.

View xnuk's full-sized avatar
🏳️‍🌈
pride

즈눅 xnuk

🏳️‍🌈
pride
View GitHub Profile
@xnuk
xnuk / parser.kt
Last active February 1, 2024 23:47
Java Serialized HashMap<String, String | Boolean> --> JSON
// $ kotlinc-jvm -include-runtime -d parser.jar parser.kt
// $ java -jar parser.jar
import java.io.Serializable
import java.io.ObjectInputStream
import java.io.FileInputStream
import java.util.HashMap
// simple, and wrong escaping for JSON
fun escapeStr(s: String): String =
(() => {
const isObject = t => {
const z = typeof t
return t != null && (z === 'object' || z === 'function')
}
const traceProxy = (target, name = 'object', recursive = false) => new Proxy(target, {
get: (target, prop, receiver) => {
const res = Reflect.get(target, prop, receiver)
console.log('get prop:', name, prop, '==', res)
@xnuk
xnuk / min.js
Last active May 13, 2023 06:24
Colemak-DH + 3-P2
(r=>{const x=t=>(t=typeof t=="number"?t:t.charCodeAt(0),4352<=t&&t<=4607||12592<=t&&t<=12687||44032<=t&&t<=55215),d=(t,f)=>{const a=Math.min(t.length,f.length),e=33,l=Array.from({length:126-e+1},(s,o)=>[o+e,0]);for(let s=0;s<a;++s){const o=f[s],n=t[s].charCodeAt(0);if(x(o)){const[u,i,c]=[...o.normalize("NFKD")].map(_=>_.charCodeAt(0));c!=null&&u===4363?(l[n-e]=[c,0],l[r.shift_table[n-e]-e]=[i,c]):i!=null?l[n-e]=[u,i]:l[n-e]=[u,0]}else o.charCodeAt(0)===n?l[n-e]=[n,0]:l[n-e]=[o.codePointAt(0),0]}return l};r.is_left_key=t=>{if(t<33||t>126)return!1;const a=r.find_current_layout_info().layout[t-33]?.[0];return a==null?!1:a>4447};const y={KE:"Ko",type_name:"Sin3-P2-Xnuk",full_name:"\uB51C\uB3C4 P2",layout:d([..."qwfpbjluy;",..."arstgmneio-",..."zxcdvkh,./"],[..."\uC5AB\uC584\uC571\uC5CD\uC604\u3139\u3137\u3141\uCD94\u314D",..."\uC735\uC60C\uC78F\uC55E\uC743\u3134\u3147\u3131\u3148\u3142\u314C",..."\uC768\uC6A8\uC5D1\uC63A\uC6C7\u3145\u314E,.\uCF54"])};r.eval("window.additional_layouts.push("+JSON.stringify(y)+")")
// ==UserScript==
// @name jQuery ajax force async
// @version 1
// @grant none
// @run-at document-end
// @match https://stdict.korean.go.kr/search/*
// ==/UserScript==
const a = () => {
const ajax = window.$.ajax.bind(window.$)
copy(
(() => {
const a = {}
for (
const el
of document.querySelectorAll('#problem-body .sampledata[id^=sample-]')
) {
const m = el.id.match(/^sample-(input|output)-([0-9]+)$/)
if (m == null) continue
const o = (a[m[2]] ??= {})
@xnuk
xnuk / dick.cr
Last active September 6, 2022 13:14
GeoGebra Geometry .ggb file Generator
# vim: ts=4
require "./geo.cr"
PI = '\u03C0'
Geo.render(Path["./foo.ggb"]) do
d "poly = 2 * pi / 7" { hidden }
d "r = 10" { hidden }
angle_hidden = false
{"filters":{"completion":"uncaught","patch":[6,5,5.1,5.2,5.3,5.4,5.5,4,4.1,4.2,4.3,4.4,4.5,3,3.1,3.2,3.3,3.4,3.5,2,2.1,2.2,2.3,2.4,2.5],"extra":"all","hideAlwaysAvailable":true},"upcomingWindowFormat":"fromPrevClose","sortingType":"windowPeriods","theme":"dark","completed":[10123,24210,7693,24209,8757,24882,24214,20034,8761,8762,8763,27467,8755,27432,27481,7703,24886,17584,14215,17588,15635,28067,12774,30433,8775,7682,8756,27494,24213,7947,17586,27456,13730,8772,33322,4913,7686,7678,7709,4999,7923,7917,7679,7938,8754,27492,12723,7714,22397,23055,24204,23056,21177,24203,20021,24216,20124,20122,23068,20027,24891,24995,24887,24994,33319,20114,24888,28065,24889,23067,20051,24885,20030,12821,8758,28928,16742,24890,28070,30438,8768,7931,28069,32052,22392,24205,7708,17581,13727,12815,7701,12833,12827,4905,7713,12812,27508,7698,7692,7689,17589,12816,16753,12751,8774,32050,14213,16750,4924,20100,7685,5022,30432,8765,7905,12803,7915,16744,7951,8759,13728,7944,24884,16743,7950,33240,5007,8753,30437,28925,12767,13731,156
@-moz-document domain("www.acmicpc.net") {
span[class^="solvedac-tier-name-"]:not(.solvedac-tier-name-0):not(.solvedac-tier-name--1):after {
color: currentcolor;
font-size: .9em
}
/* cheese bar: https://codepen.io/xnuk/pen/LYQRZJa */
span[class^="solvedac-tier-name-"]:not(.solvedac-tier-name-0):not(.solvedac-tier-name--1):before {
background-image: linear-gradient(to right
, #ad5600 calc(100% * (0 / 6))
const arr = [8, 9, 1, 2, 3]
const limit = 6
const akamigSum = (arr: readonly number[], x: number) =>
arr
.map(item => item + x)
.filter(item => item > 0)
.reduce((a, b) => a + b)
const fib = (arr: readonly number[], limit: number) => {
@xnuk
xnuk / baekjoon_uploader.user.js
Last active April 15, 2022 18:33
이제 제출할 파일을 무료로 에디터에 끌어다 놓으세요 확장자에 따른 언어 감지도 해준다 백준저지 API 만들어주세요
// ==UserScript==
// @name Baekjoon Drag-n-Drop Uploader
// @version 1
// @grant none
// @run-at document-end
// @match https://acmicpc.net/submit/*
// @match https://www.acmicpc.net/submit/*
// ==/UserScript==
;(() => {