OpenResty China简报
OpenRestyChina简报—20160401
1.(文章) :开源经济和OpenResty
OpenResty北京面基大会后,池老师发表了一篇文章,很有料。
2.(问答):error loading module 'cjson' from file
因为conf的文件设置不正确, 造成了OpenResty将.so文件,做为.lua为文件进行 了require读取。
3.(问答):resty 的md5和string的问题
part_end 导致的计算错误。
4.(图书):高可用架构·硅谷篇(第4期)
人邮异步社区,出版新的免费电子书,高可用架构·硅谷篇(第4期)
5.(软件):Orange - 基于OpenResty的API Gateway
饭总发布了他的, API Gateway, 可以说是Kong的mini版本吗?
Sublime的LUA和Openresty插件。
作者:糖果
下面是两个补全插件,在Sublime中可以很好的补全LUA代码和OpenResty的API。
Lua插件
installation
Openresty的补全
Lapis的数据库查询分页功能
作者:leafo
翻译:糖果
Pagination分页
Using the paginated method on models we can easily paginate through a query that might otherwise return many results. The arguments are the same as the select method but instead of the result it returns a specialPaginator object.
使用paginated方法,我们可以很轻松的实现多检索结果的分页效果。select方法的参数都是一样的,但是返回的查询结果是特定的Paginator对象。
For example, say we have the following table and model: (See Database Schemas for more information on creating tables.)
例如,下面的数据表定义:(Database Schemas那章有更多关于表创建的细 ...
vim 可视化模式(visual模式)
为了便于选取文本,VIM 引入了可视(Visual)模式。 要选取一段文本,首先将光标移到段首,在普通模式下按 v 进入可视模式,然后把光标移到段末。 需要注意,光标所在字符是包含在选区中的 。
v 进入字符可视化模式
V 进入行可视化模式
Ctrl+v 进入块可视化模式
块选择 Ctrl+v
在表格中删除指定列非常有用
用 v 命令进入的字符可视化模式(Characterwise visual mode)。文本选择是以字符为单位的。
用 V 命令进入的行可视化模式(Linewise visual mode)。文本选择是以行为单位的。
用 ctrl-V 进入的块可视化模式(Blockwise visual mode)。可以选择一个矩形内的文本。
选择:
选中{}中间的内容,不包括{}
va{ 选中{}中间内容,包括{}
选中()中间内容
vi< 选中<>中间内容
vi[ 选中[]中间内容
vit 选中中间的内容
vi” 选中”"中间内容
vi’ 选中”中间的内容、
vis 选中一个句子
vib 选中一个block
viw 选中一个单词
vip 选中一个段落
...
在Heroku云上部署Lua应用
在Heroku云上部署Lua应用
Running Lua on Heroku
Posted February 05, 2012 by leafo (@moonscript)
Since the release of Heroku’s Cedar platform they've opened up the opportunity for users to run web applications on any stack. Using something called a buildpack we can describe a template for deploying any kind of application. I saw this as a great opportunity to try using Lua on a cloud hosting platform (for free).
因为Heroku发布的Cedar平台,开放了为用户运行任意web应用的栈技术支持,buildpack使我们可以用模板来描述任意类型的应用部署,关键的是这东西,在云上运行lua还免费。
I ...
Luabit的位运算简介
作者:糖果
Luabit的位运算
Lua提供了bit库,可以对变量数据进行位运算,在某些应有场景,我们得确需要在lua中对数据进行位移,或是进行“与,或,非”,进制转换等操作。
例如有这么一种较典型的情况,我们用一个32位的整数表示RGB颜色,32位整数,被分为4个部分,每个部分8bit, 8bit可表示的10进制数的范围是0~255。
我们现在有一组RGB的颜色值: Alpha通道=8, R=4, G=2, B=1
下面是,二进制表示:
Alpha Red Green Blue
00001000 00000100 00000010 00000001
第四组 第三组 第二组 第一组
下面是,十六进制表示:
Alpha Red Green Blue
0x08 0x04 0x02 0x01
第四组 第三组 第二组 第一组
下面是,十进制表示:
134480385
我们现在要作的是把整数"134480385"的“4组”“8bit”数据截取出来。
思路和C语言二进制运算是一样,首先是“4 ...
动态修改OpenResty的Conf配置文件(nginx-upsync-module)
翻译:糖果
nginx-upsync-module - Nginx C module, sync upstreams from consul or others, dynamiclly modify backend-servers attribute(weight, max_fails,...), needn't reload nginx.
nginx-upsync-module Nginx C模块,通过consul组件对upstream进行同步,动态的修改后端服务器的属性。(权重,最大失败数,…)并且不需要reload重新加载nginx.
It may not always be convenient to modify configuration files and restart NGINX. For example, if you are experiencing large amounts of traffic and high load, restarting NGINX and reloading the configuration at that point furt ...
Writing a DSL in Lua
作者:leafo
DSLs, or domain specific languages, are programming languages that are designed to implement a set of features specific to a particular problem or field. An example could be Make, the build tool, which is a specially designed language for combining commands and files while managing dependencies.
DSLs,“领域特定语言”:是为了特定领域的问题,设计实现了某些功能的编程语言。
* Dropping the parenthesis
* Chaining
* Using function environments
* Implementing the HTML builder
* Closing
A lot of modern programming languages hav ...
如何在Lapis中响应POST,GET方法
by 糖果
How do I respond to GET, POST, DELETE or other HTTP verbs?
如何响应GET,, POST, DELETE等动作。
The respond_to action decorator function gives a basic framework for running different code depending on the HTTP method.
在同一个路由中响应类似get,post这种用户请求,关键是要使用respond_to这个装饰器。
try_to_login is a hypothetical functions, and not regularly globally available
try_to_login,只是一个假的,用说明可能会调用的驱动函数。
local lapis = require("lapis")
local app = lapis.Application()
local respond_to = require(" ...
Lua web framework Lapis(日文版)
Lua web framework Lapis
前记:
这篇的原文,原文是一篇很老的文章,一直以来也没有翻译。原文其实是有配置的,下面只是其中的一小段。
正文:
Lua web framework Lapis
LuaのWeb Frameworkの需要はほとんどないと思いますが、LapisというFrameworkを見かけたので触ってみました。
LuaのWeb Frameworkといえば、OrbitやTirがありますが、いずれも開発は止まっていて寂しい限りでした。そこへ最近になって現れたのがLapisです。
Lapisのホームページの頭には、MoonScriptとOpenRestyのWeb Frameworkと書かれています。
MoonScriptはCoffeeScriptにインスパイアされて作られた言語で、CoffeeScriptがJavaScriptに変換されるように、Luaに変換することができます。
また、OpenRestyはNginxに拡張モジュールを入れたもので、コアはNginxそのものです。
インストール moonscriptとlapisはluarocksでインストールできます ...


