gcc code block evaluation c extension {...}的使用
重写UI的getter方法,把初始化方法放在getter中,可以有效的较少viewDidLoad的负荷,也能使整个页面变得清晰。同时,可以利用GCC Code Block Evaluation C Extension ({…})的语法,结构化局部变量的初始化和逻辑处理,增加了代码的可读性。
例子:
12345678910111213- (UIView *)demoView{ if (!_demoView) { _demoView = ({ UIView *demoView = [[UIView alloc] initWithFrame:({ CGRect rect = CGRectMake(SCREEN_WIDTH/2-50, SCREEN_HEIGHT/ 2-100,100 ,100 ); rect; })]; demoView.backgroundColor = [UICo ...
stm32f4-discovery开发板运行elua
Content
vs2012 编译luasocket
Content
lua-resty-mysql事务封装
lua-resty-mysql没有提供事务封装,下面提供一个事务的封装例子的主要代码部分。事务是基于session,主要将事务相关语句在同一个session上执行。123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139local mysql = require "resty.mysql"local config = require "config"local log = require "ut ...
evaluación de interfaces
Plannificación de una evaluación
Procedimientos de evaluacion analítica
Procedimientos de evaluación empírica
IntroducciónLas interfaces de usuario se deben evaluar como cualquier software para verificar la usabilidad y mejorar y corregir los fallos.
Evaluamos la interface de usuario y su utilización, tareas realistas y entorno realista.
Revisaremos requerimientos de usabilidad
Cualitativos: fácil de aprender, tolerante a errores, etc.
Cuantitativos: Tiempo, números de clic, etc.
Priorizar r ...
Hello Lua
在游戏开发中,Lua是一种比较热门的轻量级脚本语言。由C实现的Lua可以很好得和C/C++进行交互,同时它可以很方便地和和各种语言结合进行跨平台开发。 特别是在当前最流行的游戏Unity中,为了实现C#脚本热更新,Lua几乎是唯一的解决方案,各种基于Lua的库层出不穷。一直在写C#脚本,还是有必要学习Lua。
###Lua初见
一开始就直接打开Lua官方的Reference Manual Lua Reference Manual
接下来下载好Lua的binary版本,开始学习基本的语法 Lua 基础教程
总体感觉Lua非常的轻巧 基础的数据类型也只有nil boolean number string function userdata thread table (整形和浮点都是number 想起了SQLite) 动态类型语言和Javascript一样 结尾不需要;和Python一样 函数可以是多返回值 没有自带的++ +=等运算符,写的时候特别难受...T_T
但是有metatable可以进行任意的扩展,这个metatable给我的感觉就像是JS中的prototype
### ...
lua instruction
<h2 id="introduction">1. Introduction</h2>
本文讲解lua 5.3.1虚拟机命令。lua的命令具有固定的大小,缺省使用一个32bit无符号整型数据类型。当前lua 5.3.1使用4个命令类型和47个操作码(编号从0到46)。命令类型枚举为:iABC, iABx, iAsBx, iAx。每个操作码占用最初的6bits。命令可以有以下的域:
'A' : 8 bits
'B' : 9 bits
'C' : 9 bits
'Ax': 26 bits ('A', 'B', and 'C' together)
'Bx': 18 bits ('B' and 'C' together)
'sBx': signed Bx
字段 A、B 和 C 通常引用寄存器编码(我将使用术语“寄存器”,因为它与处理器的寄存器相似)。虽然算术操作中字段A是目标操作数,但这个规则并非也适用于其他命令。寄存器通常是指向当前栈帧中的索引,0号寄存器是栈底位置。与 Lua C API 不同的是负索引(从栈顶开始计数)是不支持的。某些命令需要 ...
lua中执行shell
文章目录
</div>
<h3 id="直接执行Shell"><a href="#直接执行Shell" class="headerlink" title="直接执行Shell"></a>直接执行Shell</h3><p>直接执行xxx指令</p>
os.execute('xxx')
以指定用户执行Shellpi用户执行ls
os.execute('su -s /bin/bash -c "ls" pi')
屏幕亮
os.execute('su -s /bin/bash -c "xset dpms force on" pi')
屏幕灭
os.execute('su -s /bin/bash -c "xset dpms force off" pi')
获取执行结果获取ls执行结果
local t = io ...
lua打印表格
Lua打印表格function print_table(t) local cache = {} local function print_table_sub (t, indent) if (cache[tostring(t)]) then print(indent .. "*" .. tostring(t)) else cache[tostring(t)] = true if (type(t) == "table") then for pos, val in pairs(t) do if (type(val) == "table") then print(indent .. "[" .. pos .. "] => " .. tostring(t) .. ...
evaluate division
思路巧妙的方法,化为双向图,例如等式a / b = 2.0,可以转化为两条边:,,其长度分别为2.0,0.5。对queries的每一项,先判断2个点是否都出现,然后判断是不是自己到自己,最后用dfs进行搜索,然后用递归进行每条边权重的相乘,如果最后找不到路径,则返回-1.0。12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849class {public: double dfs(string from, string to, map<string, map<string, double>> &mp, set<string> & visited, double val){ if (mp[from].count(to)) { return mp[from][to] * val; } for (pair<string, double>p : mp[from]) { ...


