Skip to content

Instantly share code, notes, and snippets.

View mununki's full-sized avatar
๐Ÿ‘จโ€๐Ÿ’ป
Reasoning

woonki mununki

๐Ÿ‘จโ€๐Ÿ’ป
Reasoning
View GitHub Profile
@mununki
mununki / datamodel.prisma
Created April 5, 2019 17:26
prisma introspect - v1.3.0
// This is generated by v1.3.0
type AccountRatereader @pgTable(name: "account_ratereader") {
id: Int! @unique
readerId: AccountMyuser @pgColumn(name: "reader_id")
relationshipDate: DateTime! @pgColumn(name: "relationship_date")
showerId: AccountMyuser @pgColumn(name: "shower_id")
}
// This is generated by v1.2.x and modified manually to deploy
// eg. generated `@relation(name: "account_ratereaders_readers")` -> modify `@relation(name: "AccountRatereaderReaders")
@mununki
mununki / user_password_django_pbkdf2_sha256.go
Last active July 21, 2024 19:28
[Go] Implementation Django default password hashing PBKDF2_SHA256 with Go
import (
"crypto/rand"
"crypto/sha256"
"crypto/subtle"
"encoding/base64"
"strconv"
"strings"
"time"
"golang.org/x/crypto/pbkdf2"
@mununki
mununki / doom.txt
Created April 17, 2021 05:41 — forked from hjertnes/doom.txt
Doom Emacs Cheatsheet
SPC
SPC: find file
, switch buffer
. browse files
: MX
; EX
< switch buffer
` eval
u universal arg
x pop up scratch
@mununki
mununki / y2021d1.ml
Created December 1, 2021 16:34
Advent of Code 2021, Day 1
let input = Util.read_file "../input/y2021d1" |> List.map int_of_string
(* let%test _ = input = ["1"] *)
(* let%expect_test _ =
input |> List.iter (fun s -> print_endline s);
[%expect ""] *)
let prevs xs = xs |> List.rev |> List.tl |> List.rev
@mununki
mununki / gIndex.res
Last active April 18, 2022 18:11
ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”ํ…Œ - ๋…ผ๋ฌธ g-index
open Belt
let solution = xs => {
// ์ธ์šฉ ํšŸ์ˆ˜๋ฅผ ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค. [3, 2, 1, ...]
// g-index๊ฐ€ ์ œ์ผ ๋†’์€ ๊ฒฝ์šฐ, ๋…ผ๋ฌธ N๊ฐœ
// ์ธ์šฉ ํšŸ์ˆ˜ ๋ฐฐ์—ด์˜ ๋งจ ๋’ค๋ถ€ํ„ฐ ํ•˜๋‚˜์”ฉ sum์„ ๋น„๊ตํ•˜์—ฌ, sum >= gIndex^2 ์ธ gIndex๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค.
// ์—ญ์œผ๋กœ ์ฐพ๋Š” ์ด์œ ๋Š” ์•ž์—์„œ๋ถ€ํ„ฐ ์ฐพ๋Š” ๊ฒฝ์šฐ ์ค‘๊ฐ„ ์ดํ›„ ๋‹ค์‹œ ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜๊ฒŒ ๋˜๋Š” ๊ฒฝ์šฐ๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.
// [3, 2, 1, ...]
let sorted = xs->List.fromArray->List.sort((a, b) => b - a)->List.toArray
@mununki
mununki / addBigInt.res
Last active April 18, 2022 18:11
ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”ํ…Œ - ๋ฌธ์ž์—ด ์ •์ˆ˜ ๋”ํ•˜๊ธฐ
open Belt
// ๊ฐ ๋ฌธ์ž์—ด์˜ ๊ฐ€์žฅ ๋’ท ๊ธ€์ž๋ผ๋ฆฌ ์ •์ˆ˜๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ๋”ํ•œ๋‹ค.(a)
// ์ด์ „ ์—ฐ์‚ฐ์˜ ๊ฒฐ๊ณผ๋กœ ๋„˜์–ด์˜จ ๊ฐ’ 1 or 0 (b)
// ๊ฒฐ๊ณผ (c)
// (a + b)๊ฐ€ 10 ๋ฏธ๋งŒ์ธ ๊ฒฝ์šฐ c ์— prepend ํ•˜๊ณ , ๋‹ค์Œ ์—ฐ์‚ฐ(next)์— 0์„ ๋„˜๊ฒจ์ค€๋‹ค.
// (a + b)๊ฐ€ 10 ์ด์ƒ์ธ ๊ฒฝ์šฐ 10์„ ๋บ€ ๊ฐ’์„ c์— prepend ํ•˜๊ณ , ๋‹ค์Œ ์—ฐ์‚ฐ(next)์— 1์„ ๋„˜๊ฒจ์ค€๋‹ค.
let toArray = s => s->Js.String2.split("")
@mununki
mununki / chess.res
Last active April 18, 2022 18:11
ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”ํ…Œ - ์ฒด์Šค
open Belt
module rec Board: {
type rec t
and coord = (row, col)
and size = int
and col
and row
let init: size => t
@mununki
mununki / quadTree.res
Last active April 20, 2022 16:32
ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”ํ…Œ - ์ฟผ๋“œํŠธ๋ฆฌ
open Belt
module QuadTree = {
exception Invalid_Operation(string)
// P(ne, nw, sw, se)
type rec t = P(t, t, t, t) | White | Black | Empty
let empty = () => Empty
let fromString = s =>
@mununki
mununki / subString.res
Created April 19, 2022 14:59
ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค 5 - ์ข‹์€ ๋ถ€๋ถ„ ๋ฌธ์ž์—ด
// ์ข‹์€ ๋ถ€๋ถ„ ๋ฌธ์ž์—ด
// ์ข‹์€ ๋ถ€๋ถ„ ๋ฌธ์ž์—ด์ด๋ž€ ์–ด๋–ค ๋ฌธ์ž์—ด s์˜ ๋ถ€๋ถ„ ๋ฌธ์ž์—ด์ด๋ฉด์„œ ๊ฐ™์€ ์•ŒํŒŒ๋ฒณ์ด ๋‘ ๋ฒˆ ์ด์ƒ ๋‚˜ํƒ€๋‚˜์ง€ ์•Š๋Š” ๋ฌธ์ž์—ด์„ ๋งํ•ฉ๋‹ˆ๋‹ค.
// ์˜ˆ๋ฅผ๋“ค์–ด ์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด์ด "abac" ์ผ ๋•Œ, ๋ถ€๋ถ„ ๋ฌธ์ž์—ด "a", "ab", "bac"๋“ฑ์€ ์›๋ž˜ ๋ฌธ์ž์—ด "abac" ์˜ ๋ถ€๋ถ„ ๋ฌธ์ž์—ด์ด๋ฉด์„œ
// ๋ฌธ์ž์—ด ๋‚ด์— ๊ฐ™์€ ์•ŒํŒŒ๋ฒณ์ด ๋‘ ๋ฒˆ ์ด์ƒ ๋‚˜ํƒ€๋‚˜์ง€ ์•Š์œผ๋ฏ€๋กœ ์ข‹์€ ๋ถ€๋ถ„ ๋ฌธ์ž์—ด์ž…๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ "aba", "abac"๋Š” ๋ฌธ์ž์—ด ๋‚ด์—
// ๊ฐ™์€ ์•ŒํŒŒ๋ฒณ 'a'๊ฐ€ ๋‘ ๋ฒˆ ์ด์ƒ ๋‚˜ํƒ€๋‚˜๋ฏ€๋กœ ์ข‹์€ ๋ถ€๋ถ„ ๋ฌธ์ž์—ด์ด ์•„๋‹™๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด s๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ ์ข‹์€ ๋ถ€๋ถ„ ๋ฌธ์ž์—ด์˜ ๊ฐœ์ˆ˜๋ฅผ
// return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”.
// "abac" => "a", "b", "c", "ab", "ba", "ac", "bac"
// "abcd" => "a", "b", "c", "d", "ab", "bc", "cd", "abc", "bcd", "abcd"
@mununki
mununki / ReFormFieldArrayPOC.res
Created December 2, 2022 06:32
ReForm field array validation example
module ProfileFormFields = %lenses(
type t = {
nickname: string,
age: int,
}
)
module FormFields = %lenses(
type state = {
name: string,