[ { "name": "iterate_table", "label": "Iterate Table", "code": "-- Iterate over a table\nfor key, value in pairs(my_table) do\n print(string.format(\"%s = %s\", tostring(key), tostring(value)))\nend" }, { "name": "string_manipulation", "label": "String Manipulation", "code": "-- String manipulation helpers\nlocal str = \"Hello, MetaBuilder!\"\nlocal upper = str:upper()\nlocal sub = str:sub(1, 5)\nlocal replaced = str:gsub(\"MetaBuilder\", \"World\")\nlocal formatted = string.format(\"Result: %s (len=%d)\", replaced, #replaced)" }, { "name": "kv_operations", "label": "KV Store Operations", "code": "-- Key-value store operations\nlocal kv = require(\"metabuilder.kv\")\n\nkv.set(\"session:\" .. user_id, json.encode(session_data), { ttl = 3600 })\nlocal cached = kv.get(\"session:\" .. user_id)\nif cached then\n local session = json.decode(cached)\nend\nkv.delete(\"session:\" .. user_id)" }, { "name": "http_request", "label": "HTTP Request", "code": "-- HTTP request via built-in client\nlocal http = require(\"metabuilder.http\")\n\nlocal response = http.request({\n method = \"POST\",\n url = \"https://api.example.com/webhook\",\n headers = {\n [\"Content-Type\"] = \"application/json\",\n [\"Authorization\"] = \"Bearer \" .. token\n },\n body = json.encode({ event = \"user.created\", data = payload }),\n timeout = 5000\n})\n\nif response.status == 200 then\n local result = json.decode(response.body)\nend" } ]