Raspberry-Pi์—์„œ lua ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ์„ค์น˜

Install luarocks ๋ฅผ ์ด์šฉํ•˜์ง€ ์•Š๊ณ  ํ•„์š”ํ•œ ๋ชจ๋“ˆ๋งŒ ์„ค์น˜ํ•ด์„œ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•  ๋•Œ $ sudo apt update && sudo apt upgrade $ apt install git build-essensial #git, gcc, make ํ™˜๊ฒฝ ํ•„์š” $ apt install lua5.1.0 liblua5.1.0 #lua module ์ปดํŒŒ์ผ์‹œ liblua ํ•„์š” $ git clone https://github.com/lunarmodules/luafilesystem.git #luafilesystem ์†Œ์Šค ๋ณต์‚ฌ $ cd luafilesystem $ make # gcc, make, liblua5.1.x ํ•„์š” ์กฐ๊ฑด $ cp src/lfs.so your_devel_directory/ $ cd your_devel_directory/ $ vim myprogram.lua require'lfs' ... LuaStatic ์„ค์น˜ ๋ฐฉ๋ฒ•1: luastatic.lua ์ž์‹ ์„ ์ปดํŒŒ์ผํ•ด์„œ ๋ฐ”์ด๋„ˆ๋ฆฌ๋กœ ์‚ฌ์šฉ $ git clone https://github.com/ers35/luastatic.git $ cd luastatic/ $ uastatic.lua luastatic.lua /usr/lib/arm-linux-gnueabihf/liblua5.1.a -I/usr/include/lua5.1/ $ ./luastatic # ๋ฐ”์ด๋„ˆ๋ฆฌ ์‹คํ–‰ ๋ฐ ๋ฒ„์ „ ํ™•์ธ ๋ฐฉ๋ฒ•2: luastatic.lua๋ฅผ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉ $ git clone https://github.com/ers35/luastatic.git $ cd luastatic/ $ ./luastatic.lua # ์Šคํฌ๋ฆฝํŠธ ์‹คํ–‰ ๋ฐ ๋ฒ„์ „ ํ™•์ธ ๋ชจ๋“ˆ๊ณผ ํ•ฉ์ณ์„œ ๋ฐ”์ด๋„ˆ๋ฆฌ๋กœ ์ปดํŒŒ์ผ ํ•˜๊ธฐ luastatic.lua ์ž์‹ ์€ ์˜์กด์„ฑ์ด ์—†์œผ๋ฏ€๋กœ ~/bin ๋“ฑ์— ์˜ฎ๊ธด ํ›„ ์‚ฌ์šฉํ•ด๋„ ๋œ๋‹ค. myprogram.lua๊ฐ€ ๊ฐ™์€ ํด๋”์— ์žˆ๋Š” ๋ชจ๋“ˆ์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ์ž๋™์œผ๋กœ ํฌํ•จํ•ด์„œ ์ปดํŒŒ์ผ๋œ๋‹ค. $ cp luastatic.lua ~/bin $ luastatic.lua myprogram.lua /usr/lib/arm-linux-gnueabihf/liblua5.1.a -I/usr/include/lua5.1/ ๊ณ ๋ ค ์‚ฌํ•ญ ์œ„์˜ ์˜ˆ์ œ์ฒ˜๋Ÿผ ์ปดํŒŒ์ผ ํ™˜๊ฒฝ์„ ๋งŒ๋“ค๊ณ  ๋ชจ๋“ˆ์„ ๋งŒ๋“ค์–ด requireํ•ด์„œ ์‚ฌ์šฉ. ์—ฌ๋Ÿฌ ๋ชจ๋“ˆ๊ณผ main.lua๊ฐ€ ์žˆ์„ ๊ฒฝ์šฐ ์ด๋ฅผ ํ•˜๋‚˜๋กœ ํ•ฉ์ณ ๋ฐ”์ด๋„ˆ๋ฆฌ๋กœ ๋งŒ๋“ ๋‹ค. ๋˜๋Š” ํŒŒ์ผ์„ ์„ค์น˜ํ•˜๊ณ  ์‹คํ–‰ํ™˜๊ฒฝ์„ ๋งŒ๋“ค์–ด ์ค€๋‹ค. ์ด์— ๋Œ€ํ•ด์„œ๋Š” ๋‚˜์ค‘์— ์ถ”๊ฐ€ํ•  ์˜ˆ์ •.

2022-09-13 ยท 181 words

Lua Quick Guide - tutorialspoint

Basic Tokens in Lua io.write("Hello world, from ",_VERSION,"!\n") Comments -- simple comment --[[ block comments --]] identifiers - ๋ณ€์ˆ˜๋ช…, ํ•จ์ˆ˜๋ช… ๋“ฑ ๊ทœ์น™ mohd zera abc move_name a_123 myname50 _temp a23b9 retVal Keywords - ์˜ˆ์•ฝ์–ด and break do else elseif end false for function if in local nil not or repeat return then true until while Lua - Variables Global variables, Local bariables, Table fields Variable Example -- Variable definition: local a, b --local g,l = 20,30 --global -- Initialization a = 10 b = 30 print("value of a:", a) print("value of b:", b) -- Swapping of variables b, a = a, b print("value of a:", a) print("value of b:", b) f = 70.0/3.0 print("value of f", f) Data Types nil - no data boolean - ture, false number - read numbers string - array of characters function - method that is written in C or Lua userdata - C data thread - independent threads of execution table - arrays, symbol tables, sets, records, graphs, trees, etc ...

2022-09-09 ยท 2184 words

Rust Install and Setup

INSTALL install - ์„ค์น˜ ํ›„ ~/.bashrc์— ~/.cargo ์ž๋™ ํ™˜๊ฒฝ ์„ค์ • $ curl https://sh.rustup.rs -sSf | sh -- --help rustup ์—…๋ฐ์ดํŠธ/ ์ œ๊ฑฐ $ rustup update $ rustup self uninstall rustc ์ปดํŒŒ์ผ๋Ÿฌ ๋ฒ„์ „ํ™•์ธ $ rustc --version Hello World $ vim hello_world.rs fn main() { #println!๋Š” ํ•จ์ˆ˜๊ฐ€ ์•„๋‹Œ ๋งคํฌ๋กœ println!("Hello, world!"); } $ rustc hello_world.rs Cargo๋ฅผ ํ†ตํ•œ ๊ฐœ๋ฐœ $ cargo new hello_cargo --bin $ cd hello_cargo $ vim src/main.rs fn main() { println!("Hello, world!"); } ./target/debug/hello_cargo ๋กœ ๋ฐ”์ด๋„ˆ๋ฆฌ ์ƒ์„ฑ $ cargo run # compile and run $ cargo run # run only: source is not changed $ cargo check # compile only no exe file create (rapid compile and test) $ cargo clean # cleanup all object and binary files $ cargo run -- --help #์‹คํ–‰ํŒŒ์ผ ์ธ์ž๋ฅผ ๋ฐ›์•„์„œ ์‹คํ–‰ํ•  ๋•Œ $ cargo build $ cargo build --release (optimize for release) ๋ชจ๋“ˆ์„ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ $ cargo add ansi_term #์ž๋™์œผ๋กœ Cargo.toml์— ๋ชจ๋“ˆ์ด๋ฆ„๊ณผ ๋ฒ„์ „์ด ๋“ฑ๋ก๋œ๋‹ค. $ vim src/main.rs #use ansi_term::xxxx ์„ ๋„ฃ๊ณ  ์ฝ”๋”ฉ $ cargo run Build From Git $ git clone someurl.com/someproject $ cd someproject $ cargo build reference ์ œ์ผ ๊ถ๊ธˆํ•œ ๊ฒƒ์€ ์ „์ฒด์ ์ธ ๊ฐœ๋ฐœ ๋ฐ ๋ฐฐํฌ ๊ณผ์ •์ธ๋ฐ ์•„๋ž˜๊ฐ€ ์•„์ฃผ ์ข‹์Œ https://free-strings.blogspot.com/2017/03/cargo-cargo.html https://rust-cli.github.io/book/tutorial/packaging.html ์•„์ฃผ ํ›Œ๋ฅญํ•œ ์ฟก๋ถ์ด๋‹ค. ๋จผ์ € ๊ธฐ๋ณธ ์˜จ๋ผ์ธ๋ถ์„ ๋ณด๊ณ ์„œ ์ด๊ฒƒ์„ ๊ณต๋ถ€ํ•˜์ž. https://rust-lang-nursery.github.io/rust-cookbook/

2022-08-31 ยท 197 words

Rust Compile์‹œ ์šฉ๋Ÿ‰ ์ค„์ด๊ธฐ

Intro debug > release ์ˆœ์œผ๋กœ ์—„์ฒญ๋‚œ ๋ฐ”์ด๋„ˆ๋ฆฌ ์‚ฌ์ด์ฆˆ๋ฅผ ์ž๋ž‘ํ•œ๋‹ค. ์šฐ์„  ๊ฐœ๋ฐœ๊ณผ ๋””๋ฒ„๊น…์„ ๋ณ‘ํ–‰ํ•œ ํ›„์— ์ตœ์ข… ๋ฆด๋ฆฌ์ฆˆ์‹œ์— ์ ์šฉํ•œ๋‹ค. ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. Howto Cargo.toml์— ๋‹ค์Œ์„ ์ถ”๊ฐ€ํ•œ๋‹ค. [profile.release] lto = true codegen-units = 1 opt-level = "z" panic = 'abort' build cargo build --release reference https://www.collabora.com/news-and-blog/blog/2020/04/28/reducing-size-rust-gstreamer-plugin/ https://github.com/johnthagen/min-sized-rust

2022-08-31 ยท 44 words

LuaJit - Lua Just in Time Compiler

last updated: {{ โ€œ1736305941โ€ | date: โ€œ%Y-%m-%d %H:%Mโ€ }} Intro ํ•จ์ˆ˜๋“ค์ด ์ฒ˜์Œ ์‹คํ–‰ ๋  ๋•Œ ํ•„์š”์— ์˜ํ•ด ์ปดํŒŒ์ผ๋œ๋‹ค. ์ด๊ฒƒ์€ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ๋น ๋ฅด๊ฒŒ ์‹œ์ž‘๋˜๋Š” ๊ฒƒ๊ณผ ๋ถˆํ•„์š”ํ•œ ์ž‘์—…์„ ๋ฐœ์ƒ์‹œํ‚ค์ง€ ์•Š๋Š” ๊ฒƒ์„ ๋ณด์žฅํ•ด ์ค€๋‹ค. LuaJit์€ neovim์— ๊ธฐ๋ณธ ํƒ‘์žฌ๋˜์–ด ์žˆ๋‹ค. python, ruby ๋“ฑ์˜ Jit๋ณด๋‹ค ์šฐ์ˆ˜ํ•œ ์„ฑ๋Šฅ์„ ๋ณด์—ฌ์ค€๋‹ค. LuaJit์˜ FFI(Foreign Function Interface)๋Š” Low-Level C์–ธ์–ด ํ•จ์ˆ˜๋“ค์„ ๋ณ„๋‹ค๋ฅธ ์ž‘์—… ์—†์ด ์ง์ ‘์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ๋„ค์ดํ‹ฐ๋ธŒ์— ๊ฒฌ์ค„๋งŒํผ ์†๋„๊ฐ€ ๋น ๋ฅด๊ณ , ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰์ด ๋งค์šฐ ์ ๋‹ค. nginx์— LuaJIT์„ ํฌํ•จ์‹œ์ผœ์„œ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•์„ ํ•œ OpenResty ์›น ์„œ๋ฒ„๋„ ์žˆ๋‹ค. ...

2022-08-30 ยท 446 words