Hugo - Youttube URL

์†Œ๊ฐœ hugo์—์„œ ์ง€์›๋˜๋Š” youtube ์˜์ƒ ํฌํ•จ ๋ฌธ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. ๋ฌธ์ œ๋Š” ๋ธŒ๋ผ์šฐ์ €์—์„œ ๋™์˜์ƒ URL์„ ๋ณต์‚ฌํ•˜๋ฉด Youtube-ID๋งŒ ์ถ”์ถœํ•˜์—ฌ ๋„ฃ์–ด ์ฃผ๋Š” ๊ฒƒ์ด ๋ฌด์ฒ™ ๋ฒˆ๊ฑฐ๋กญ๋‹ค. ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋‹ค์Œ์˜ ์„ธ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์ด ์žˆ๋‹ค. ๋ธŒ๋ผ์šฐ์ € ์ฃผ์†Œ์ฐฝ์—์„œ ์ง์ ‘ ID๋ถ€๋ถ„๋งŒ ์˜์—ญ ๋ณต์‚ฌํ•˜๊ธฐ ๋ธŒ๋ผ์šฐ์ €์˜ ๋ถ๋งˆํด๋ฆฟ(Bookmarklet)์„ javascript๋กœ ๋งŒ๋“ค์–ด ID ๋ณต์‚ฌํ•˜๊ธฐ ๋ณต์‚ฌํ•œ URL์„ ์ž…๋ ฅํ•˜๋ฉด ์ž๋™ ์ถ”์ถœํ•ด์ฃผ๋Š” ํ”„๋กœ๊ทธ๋žจ ๋งŒ๋“ค๊ธฐ Brave(๋˜๋Š” Chrome)์—์„œ ๋ถ๋งˆํด๋ฆฟ์„ ์ด์šฉํ•œ ์œ ํŠœ๋ธŒ URL ID๋ณต์‚ฌ Brave ๋ธŒ๋ผ์šฐ์ €์—์„œ ๋ถ๋งˆํฌ ์ถ”๊ฐ€ Name: Youtube-ID-Copy URL: ๋‹ค์Œ ์ฝ”๋“œ ์ž…๋ ฅ ํ›„ ์ €์žฅ javascript:(function(){ const url = window.location.href; const match = url.match(/(?:v=|youtu\.be\/)([A-Za-z0-9_\-]{11})/); if(match){ const id = match[1]; navigator.clipboard.writeText(id); alert("์˜์ƒ ID ๋ณต์‚ฌ๋จ: " + id); } else { alert("์˜์ƒ ID๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."); } })(); Nvim์—์„œ ๋ณต์‚ฌํ•œ URL์—์„œ ID ์ถ”์ถœ ์•„๋ž˜ ์˜ˆ์ œ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์‹คํ–‰ ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด๋„ ์ข‹๋‹ค. :let url = input("YouTube URL: ") :let id = matchstr(url, '\v(v=|youtu\.be/)([A-Za-z0-9_-]{11})') :execute "normal i "

2025-07-27 ยท 124 words

Hugo Include - ํŒŒ์ผ์„ ํฌํ•จ์‹œํ‚ค๊ธฐ

์†Œ๊ฐœ Hugo๋กœ ํ™ˆํŽ˜์ด์ง€๋ฅผ ์ œ์ž‘ํ•  ๋•Œ ์ฃผ๋กœ ๋งˆํฌ๋‹ค์šด(markdown)์œผ๋กœ ์ž‘์—…์„ ํ•œ๋‹ค. ์ฝ”๋“œ๋ธ”๋Ÿญ์„ ์‚ฌ์šฉํ•  ๋•Œ ์›๋ž˜ ์†Œ์ŠคํŒŒ์ผ์ด ๋ณ€๊ฒฝ๋˜๋ฉด ๋‹ค์‹œ ๋งˆํฌ๋‹ค์šด ๋ฌธ์„œ๋„ ์ˆ˜์ •์„ ํ•ด์•ผํ•œ๋‹ค. ์ด ๋•Œ ์ง์ ‘ ์†Œ์Šค ํŒŒ์ผ์„ ์ฝ์–ด์„œ ํŽ˜์ด์ง€๋ฅผ ๋งŒ๋“ ๋‹ค๋ฉด ํ•ด๋‹น ์†Œ์ŠคํŒŒ์ผ๋งŒ ๊ด€๋ฆฌํ•˜๋ฉด ๋ฌธ์„œ์— ์ผ๊ด€์„ฑ์ด ์ƒ๊ธฐ๊ณ  ๋ณ€๊ฒฝํ•˜๋”๋ผ๋„ ์ฆ‰์‹œ ๋ฐ˜์˜๋œ๋‹ค. Hugo์—์„œ๋Š” shortcode๋ผ๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•˜์—ฌ ์‚ฌ์šฉ์ž๋งŒ์˜ shortcode๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค. Shortcode Include - ๋งˆํฌ๋‹ค์šด ํŒŒ์ผ ํฌํ•จํ•˜๊ธฐ Hugo Project ๋‚ด์— ๋‹ค์Œ ํŒŒ์ผ์„ ์ž‘์„ฑ: layouts/shortcodes/include.html {{- $relPath := .Get 0 -}} {{- $baseDir := .Page.File.Dir -}} {{- $fullPath := path.Join $baseDir $relPath -}} {{- readFile $fullPath | markdownify -}} ์ž‘์„ฑ๋œ shortcode ์‚ฌ์šฉํ•˜๊ธฐ: content/posts/mypost.md์— foo.md๋ฅผ ํฌํ•จํ•˜๊ธฐ {{< include "foo.md" >}} Shortcode Code - ์ฝ”๋“œ ํŒŒ์ผ ํฌํ•จํ•˜๊ธฐ Hugo Project ๋‚ด์— ๋‹ค์Œ ํŒŒ์ผ์„ ์ž‘์„ฑ: layouts/shortcodes/code.html {{ $language := .Get "language" }} {{ $source := .Get "source" }} {{ $options := .Get "options" }} {{ with $source | readFile }} {{ highlight (trim . "\n\r") $language $options }} {{ end }} ์ž‘์„ฑ๋œ shortcode ์‚ฌ์šฉํ•˜๊ธฐ: content/posts/mypost.md์— foo.c๋ฅผ ํฌํ•จํ•˜๊ธฐ ์ฝ”๋“œ๋ธ”๋Ÿญ ๋‚ด์— ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ๋„ฃ์œผ๋ฉด foo.c๋ฅผ ์ฑ„์›Œ ๋„ฃ๊ณ  language์˜ต์…˜์— ๋”ฐ๋ผ ์ปฌ๋Ÿฌ๊ฐ€ ์ง€์›๋œ๋‹ค. {{< code source="example/foo.c" >}} REFERENCE How to include code examples from file with hugo: https://marcusolsson.dev/how-to-include-code-examples-from-file-with-hugo/ ...

2025-07-09 ยท 182 words

Openresty - Scalable Web Platform NGINX with Lua

INTRO openresty๋Š” nginx์™€ lua ๊ธฐ๋ฐ˜์˜ ์›น๊ฐœ๋ฐœ ํ”Œ๋žซํผ์ด๋‹ค. lua๋Š” luajit ์„ ์‚ฌ์šฉํ•˜๊ณ  ์—”์ง„์ด ํฌํ•จ๋˜์–ด ์žˆ๋‹ค. ์„œ๋ฒ„์—์„œ ๋™์ž‘ํ•œ๋‹ค. ๋Œ€๋ถ€๋ถ„์˜ ๋ฆฌ๋ˆ…์Šค ๋ฐฐํฌํŒ์€ ํŒจํ‚ค์ง€๋ฅผ ์ง€์›ํ•œ๋‹ค. ์—ฌ๊ธฐ์—์„œ๋Š” docker ์ด๋ฏธ์ง€๋กœ ์„ค์น˜ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ •๋ฆฌํ•œ๋‹ค. System Info: RaspberryPi 3 Model B Rev 1.2 OS: Raspbian (Debian 11, Bullseye) Docker: version 24.0.5 Getting Started Hello World # Install Docker and Relogin after exit curl -sSL https://get.docker.com | sh sudo usermod -aG docker $usermod exit ... docker run hello-world # Docker Image get docker pull openresty/openresty:alpine # Setup mkdir ~/www cd ~/www mkdir conf html vi conf/nginx.conf ... worker_processes 1; error_log error.log; events { worker_connections 1024; } http { server { listen 8000; location / { default_type text/html; content_by_lua ' ngx.say("<p>hello world!</p>") '; } } } ... # Run openresty docker image docker run --name mresty --rm --volume `pwd`/conf/:/usr/local/openresty/nginx/conf/ \ -p 127.0.0.1:8000:8000 openresty/openresty:alpine # docker process check docker ps # openresty web server test curl localhost:8000 <p>hello world!</p> Openresty Comandline Utility # version check resty -v # Hello World resty -e 'print("Hello World")' echo 'print("Hello World")' > hello.lua resty hello.lua # resty ngx module test time resty -e 'gnx.sleep(1) ngx.say("done")' resty -e 'local sock = ngx.socket.tcp() print(socke:connect("openresty.com",443))' resty -e 'ngx.thread.wait(ngx.thread.spawn(function () print("in thread!") end))' mkdir lua/ vim lua/test.lua ... local _M = {} function _M.hello() print("Hello") end return _M ... resty -e 'require "test".hello()' # Error resty -I lua/ -e 'require "test".hello()' # Hello resty -e 'local ok, stdout = require "resty.shell".run([[echo ok]]) print(stdout)' # ok resty --shdict 'dogs 10m' -e 'print(ngx.shared.dogs:set("age",11))' # truenilfalse resty --shdict 'dogs 7m' --shdict 'cats 5m' -e 'print(ngx.shared.dogs, " ", ngx.shared.cats)' resty --http-conf 'lua_regex_match_limit 102400;' -e 'print "ok"' # Bench Test echo 'local a = 0 for 1, 1e8 do a = a+1 end print(a)' > bench.lua time resty -joff bench.lua # without Jit Compiler time resty bench.lua # with Jit Compiler (Fast) resty -jv bench.lua resty -jdump bench.lua | less # Help resty -h | less # See Help restydoc resty-cli # See Document Structure and Lua Module Create Project Folder and Modules mkdir test-module cd test-module mkdir logs conf lua vim lua/hello.lua ... local _M = {} function _M.greet(name) ngx.say("Greetings from ", name) end return _M ... Setup nginx.conf vim conf/nginx.conf ... worker_processes 1; events { worker_connections 1024; } http { # Lua module Preload for performance and Cache init_by_lua_block { require "hello" } # add module path to lua package path: $prefix means nginx -p option value lua_package_path "$prefix/lua/?.lua;;" # Server Setup: port, lua block... server { listen 8080 reuseport; location / { content_by_lua_block { local hello = require "hello" hello.greet("a Lua module") } } } } ... Server start and Test # server configuration test nginx -p $PWD/ -t # server start nginx -p $PWD/ # Chech Error Log tail logs/error.log # client request test : Browser also available curl 'http://127.0.0.1:8080' Greetins from a Lua module Server Admin # check server process ps aux | grep nginx | grep -v /tmp/ pgrep -l nginx # Edit nginx.conf vim conf/nginx.conf # Server Restart (After editting of nginx.conf) kill -HUP `cat logs/nginx.pid` # client request again curl 'http://127.0.0.1:8080' Build Develop Environment Makefile์„ ๋งŒ๋“ค๊ณ  ๋„์ปค์ด๋ฏธ์ง€๋ฅผ ์ œ์–ดํ•˜๊ณ  ๋กœ๊ทธ ๋“ฑ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ํ™˜๊ฒฝ์„ ๋งŒ๋“ ๋‹ค. Makefile conf/nginx.conf Test REFERENCE awesome-resty - https://github.com/bungle/awesome-resty ...

2023-09-16 ยท (updated 2023-09-27) ยท 566 words

Edge - ์œˆ๋„์šฐ์ฆˆ ๋ธŒ๋ผ์šฐ์ €

์ด๊ฒƒ์„ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ ๋Š” ์–ด์ฉ” ์ˆ˜ ์—†์ด ๊ด€๊ณต์„œ๋‚˜ ๊ธˆ์œต๊ถŒ ๋•Œ๋ฌธ์ด๋‹ค. ํ•œ๊ตญ์˜ ํ›„์ง„์ ์ธ ๊ณต์ธ์ธ์ฆ์„œ์ œ๋„์™€ ์œˆ๋„์šฐ์ฆˆ ์ค‘์‹ฌ ์‚ฌ์šฉ์œผ๋กœ ์ธํ•œ ํํ•ด๊ฐ€ ์•„๋‹๊นŒ ํ•œ๋‹ค. ๋‹คํฌ๋ชจ๋“œ Dark mode ๋ณ€๊ฒฝ ๋ชจ์–‘๋ณ€๊ฒฝ: ์„ค์ • > ๋ธŒ๋ผ์šฐ์ € ๋””์Šคํ”Œ๋ ˆ์ด> ๋ชจ์–‘ ์‚ฌ์šฉ์ž ์ง€์ • > ์–ด๋‘ก๊ฒŒ ์›นํŽ˜์ด์ง€๋ณ€๊ฒฝ: ๋ธŒ๋ผ์šฐ์ € ์ฐฝ์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ž…๋ ฅ ํ›„ ์žฌ์‹คํ–‰ edge://flags/#enable-force-dark

2023-09-08 ยท 42 words

Lynx - ํ„ฐ๋ฏธ๋„ ํ…์ŠคํŠธ ๋ธŒ๋ผ์šฐ์ €

INTRO ์˜ˆ์ „์— ํ„ฐ๋ฏธ๋„ ์ƒ์—์„œ ์›น๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ. ํ˜„์žฌ utf-8์ง€์› ๋ฐ ์ปฌ๋Ÿฌ ์ง€์›, vi key binding ์ง€์› ๋“ฑ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ ๋ณด์œ . ๊ด‘๊ณ ๋‚˜ ํ˜„๋ž€ํ•œ ๊ทธ๋ฆผ๋“ค, ๊ทธ๋ฆฌ๊ณ  ํ•˜์–€ ํ™”๋ฉด์œผ๋กœ๋ถ€ํ„ฐ ๋ˆˆ์„ ๋ณดํ˜ธํ•˜์ž. ๊ธฐ์ˆ ๋ฌธ์„œ๋‚˜ ์‹ ๋ฌธ๊ธฐ์‚ฌ ๋˜๋Š” ๋ฌธ์„œ ์œ„์ฃผ์˜ ์ž‘์—…์„ ์ฃผ๋กœ ํ•  ๋•Œ ๋น ๋ฅด๊ณ  ๊ฐ„๊ฒฐ. CPU์™€ MEMORY๋ฅผ ํƒ€ ๋ธŒ๋ผ์šฐ์ € ๋ณด๋‹ค ์ ๊ฒŒ ์‚ฌ์šฉํ•˜๋Š” ๊ทธ์•ผ๋ง๋กœ ์นœํ™˜๊ฒฝ ๋ธŒ๋ผ์šฐ์ €. tmux์—์„œ vim๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋ฉด ํ™˜์ƒ์˜ ๊ถํ•ฉ์ด๋ผ ๋งํ•  ์ˆ˜ ์žˆ๊ฒ ๋‹ค. INSTALL Debian, Ubuntu $ sudo apt install lynx $ lynx --version $ lynx duckduckgo.com Alpine $ doas apk add lynx SETUP Vi Key ์„ค์ • - ํ™”๋ฉด ์ด๋™์„ hjkl๋กœ ๋ณ€๊ฒฝ 1. ์‹คํ–‰ ํ›„ `o` ๋ช…๋ น์œผ๋กœ ์˜ต์…˜ ์„ค์ • 2. VI keys -> [ON] ์œผ๋กœ 3. Line edit style -> [Bash-like Bindings] ๋กœ ์„ค์ • 4. ํ™”๋ฉด ์ƒ๋‹จ์— Save options to disk: [x] ํ‘œ์‹œ 5. ํ™”๋ฉด ๊ฐ€์žฅ ์œ—์ค„์— Accept Changes ํด๋ฆญ Usage ํ™”์‚ดํ‚ค <- ์ด์ „ ์›นํŽ˜์ด์ง€๋กœ ์ด๋™ ํ™”์‚ดํ‚ค -> ์ดํ›„ ์›นํŽ˜์ด์ง€๋กœ ์ด๋™ ํ™”์‚ดํ‚ค up ํŽ˜์ด์ง€ ์ƒ๋‹จ์œผ๋กœ ์ด๋™ ํ™”์‚ดํ‚ค down ํŽ˜์ด์ง€ ํ•˜๋‹จ์œผ๋กœ ์ด๋™ h ๋„์›€๋ง o ์˜ต์…˜ p ํ”„๋ฆฐํŠธ g ์ž…๋ ฅํ•œ ์‚ฌ์ดํŠธ๋กœ ์ด๋™ m ๋ฉ”์ธ์œผ๋กœ q ์ข…๋ฃŒ /= ๊ฒ€์ƒ‰ delete= ํžˆ์Šคํ† ๋ฆฌ ๋ฆฌ์ŠคํŠธ Links tmux home: https://lynx.browser.org

2022-12-18 ยท 170 words