Skip to content

Instantly share code, notes, and snippets.

View cr0sh's full-sized avatar
๐Ÿฆ€

Junghyun Nam cr0sh

๐Ÿฆ€
View GitHub Profile
@cr0sh
cr0sh / lazy_lock.rs
Created January 24, 2025 11:33
Rust std LazyLock ported to parking-lot
mod lazy_lock {
use parking_lot::{Once, OnceState};
use std::{cell::UnsafeCell, default::Default, mem::ManuallyDrop, ops::Deref};
union Data<T, F> {
value: ManuallyDrop<T>,
f: ManuallyDrop<F>,
}
pub struct LazyLock<T, F = fn() -> T> {
once: Once,
@cr0sh
cr0sh / keywords.md
Last active October 7, 2023 10:39
The Khala Language Specification v0.3.1
ํ‚ค์›Œ๋“œ ์šฉ๋„
fn (parenless) ํ•จ์ˆ˜/ํด๋กœ์ € ์„ ์–ธ
if ๋ถ„๊ธฐ๋ฌธ
for ๋ฐ˜๋ณต๋ฌธ
else ๋ถ„๊ธฐ๋ฌธ์˜ ๋ณ„๋„ ์กฐ๊ฑด ํ˜น์€ for์˜ ์ •์ƒ ์ข…๋ฃŒ ๊ตฌ๋ฌธ
break ๋ฐ˜๋ณต๋ฌธ ํƒˆ์ถœ
return ์กฐ๊ธฐ ๋ฐ˜ํ™˜
@cr0sh
cr0sh / extract.go
Created January 19, 2017 01:45
spinel_extract
package main
import (
"log"
"flag"
"fmt"
"strconv"
"sync"
package main
import (
"fmt"
"io/ioutil"
"math/big"
"os"
"strconv"
"time"
)
package main
import (
"fmt"
"io/ioutil"
"math/big"
"os"
"strconv"
"time"
)
@cr0sh
cr0sh / .vimrc
Last active March 26, 2016 02:53
set nocompatible
filetype off
set hlsearch
set scrolloff=3
set nobackup
set noswapfile
set bs=eol,start,indent
set autoread
set smarttab
" set smartindent
@cr0sh
cr0sh / synopsis-draft-2.md
Last active March 6, 2016 12:46
Synopsis Language draft #2(Korean)

Synopsis language

๋ชฉ์ : ๋ฉ”๋ชจ๋ฆฌ ์˜ค๋ฅ˜๋ฅผ ๋ฐฉ์ง€ํ•˜๋Š” ๋™์‹œ์„ฑ ํ”„๋กœ๊ทธ๋ž˜๋ฐ

์‚ฌ์ „ ๊ณ ์ฐฐ

๋™์‹œ์„ฑ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์—์„œ์˜ ์œ„ํ—˜ ์š”์†Œ: Race condition ๋ฐ Deadlock

Rust ์–ธ์–ด์˜ ํ•ด๊ฒฐ ๋ฐฉ์•ˆ: move-by-default, ownership, lifetime

  • = ์—ฐ์‚ฐ์ž๋Š” ๋ณ€์ˆ˜์˜ ownership(์†Œ์œ ๊ถŒ)์„ ์ด๋™์‹œํ‚ด
@cr0sh
cr0sh / synopsis-draft.md
Last active March 6, 2016 12:53
Synopsis Language draft(Korean)

Synopsis language

๋ชฉ์ : ๋ฉ”๋ชจ๋ฆฌ ์˜ค๋ฅ˜๋ฅผ ๋ฐฉ์ง€ํ•˜๋Š” ๋™์‹œ์„ฑ ํ”„๋กœ๊ทธ๋ž˜๋ฐ

์‚ฌ์ „ ๊ณ ์ฐฐ

๋™์‹œ์„ฑ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์—์„œ์˜ ์œ„ํ—˜ ์š”์†Œ: Race condition ๋ฐ Deadlock

Rust ์–ธ์–ด์˜ ํ•ด๊ฒฐ ๋ฐฉ์•ˆ: move-by-default, ownership, lifetime

  • = ์—ฐ์‚ฐ์ž๋Š” ๋ณ€์ˆ˜์˜ ownership(์†Œ์œ ๊ถŒ)์„ ์ด๋™์‹œํ‚ด
#!/bin/bash
echo ์ด ์‰˜ ์Šคํฌ๋ฆฝํŠธ๋Š” ๋ฆฌ๋ˆ…์Šค์—์„œ MiNET์„ ์‰ฝ๊ฒŒ ์„ค์น˜ํ•ด์ค๋‹ˆ๋‹ค
echo ์‰˜ ์Šคํฌ๋ฆฝํŠธ ์ œ์ž‘์ž: ํ‘ธ๋ฅธ๊ณก๊ดญ์ด, MiNET ์ œ์ž‘์ž: NiclasOlofsson๋‹˜
echo ์ •๋ง ๊ฐ„๋‹จํ•˜๊ฒŒ ๋งŒ๋“ค์–ด์ง„ ์‰˜ ์Šคํฌ๋ฆฝํŠธ์ž…๋‹ˆ๋‹ค ์ •๋ง๋กœ ํ•˜๋ฃจ๋งŒ์— ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค
echo $(date) ์„ค์น˜๋ฅผ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค...
echo Git๊ฐ€ ์„ค์น˜๋˜์–ด์žˆ๋‚˜์š”? \(๋„ค/์•„๋‹ˆ์š”\)
read gitanswer
if [ $gitanswer -eq ๋„ค ]
then
#!/bin/bash
#Needed to use aliases
shopt -s expand_aliases
type wget > /dev/null 2>&1
if [ $? -eq 0 ]; then
if [ "$IGNORE_CERT" == "yes" ]; then
alias download_file="wget --no-check-certificate -q -O -"
else
alias download_file="wget -q -O -"