🚙

💨 💨 💨

×

  • Categories

  • Archives

  • Tags

  • About

C++与Lua本质原始交互API

Posted on 11-11-2015 | In Misc

我们用一个例子来说明.

. . .

Lua中ipairs和pairs的区别与使用

Posted on 11-11-2015 | In Misc

关于ipairs()和pairs(),Lua官方手册是这样说明的:

pairs (t)

If t has a metamethod __pairs, calls it with t as argument and returns the first three results from the call.

Otherwise, returns three values: the next function, the table t, and nil, so that the construction

` for k,v in pairs(t) do body end`

will iterate over all key–value pairs of table t.

See function next for the caveats of modifying the table during its traversal.

ipairs (t)

If t has a metamethod __ipairs, calls it with t as argument and returns the first three results from the call.

Otherwise, returns three values: an iterator function, the table t, and 0, so that the construction

` for i,v in ipairs(t) do body end`

will iterate over the pairs (1,t[1]), (2,t[2]), …, up to the first integer key absent from the table.

根据官方手册的描述,pairs会遍历表中所有的key-value值,而pairs会根据key的数值从1开始加1递增遍历对应的table[i]值,直到出现第一个不是按1递增的数值时候退出。

. . .

tolua++安装

Posted on 11-11-2015 | In Misc

我们用一个例子来说明.

本文环境为 :

  • ubuntu1404
  • g++ 4.8.4
  • python
  • git
  • lua5.1( 因为tolua++只支持到5.1, 安装5.1教程看 Lua的win和linux环境简单安装 )

. . .

Lua的win和linux环境搭建

Posted on 11-08-2015 | In Misc

ubuntu环境

. . .

Linux常用命令笔记整理之tcpdump

Posted on 11-03-2015 | In Linux

强大的抓包工具, 博大精深内容太多, 所以这篇博客整理得只说常用, 具体的参考tcpdump用户手册,
tcpdump需要root权限, 所以记得加上sudo

常用参数

  • -nn选项:
    意思是说当tcpdump遇到协议号或端口号时,不要将这些号码转换成对应的协议名称或端口名称。比如,大家都知道80是http端口,tcpdump就不会将它显示成http了

  • -c选项:
    是Count的含义,这设置了我们希望tcpdump帮我们抓几个包。

  • -i : 指定哪一张网卡

  • -l : 使得输出变为行缓冲

  • -t : 输出时不打印时间戳

  • -v : 输出更详细的信息

  • -F : 指定过滤表达式所在的文件, 可以建立了一个filter.txt文本文件来存储过滤表达式,然后通过-F来指定filter.txt

  • -w : 将流量保存到文件中

  • -r : 读取raw packets文件

. . .

linux常用文本处理命令笔记整理之sed

Posted on 10-23-2015 | In Linux

sed是一种流编辑器,它是文本处理中非常中的工具,能够完美的配合正则表达式使用,功能不同凡响。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾。文件内容并没有 改变,除非你使用重定向存储输出。Sed主要用来自动编辑一个或多个文件;简化对文件的反复操作;编写转换程序等。

. . .

linux常用文本处理命令笔记整理之grep和awk

Posted on 10-21-2015 | In Linux

linux常用文本处理的命令的使用率很高, 所以整理了一些之前的笔记,用markdown来记录备忘。
首先抛出问题, 带着问题来学记忆知识更有动力:

  • 如何通过一条命令取得eth0的IP4地址 :

    ifconfig eth0 | grep -w 'inet' | awk '{print $2}' | awk -F: '{print $2}'
  • 如何通过一条命令替换当前路径下所有文件中的所有“xxx”为“yyy“ :

    ls -alF | grep '^-' | awk '{print $NF}' |  xargs sed -i 's/xxx/yyy/g'
  • 如何通过一条命令杀掉占用端口34600的进程 :

    sudo lsof -i:34600 | grep -v 'PID' | awk '{print $2}' | xargs kill -9

这些命令它们分别具体是什么意思呢?为何能达到上述效果?

. . .

Unity中C#调用C++写的DLL之Swig篇

Posted on 09-13-2015 | In Misc

近来要用Unity打包到安卓上玩, Unity那边需要用到服务器中用C++写的库,
对比了 P/Invoke 和 C++/CLI 两种方式, 都不够省心省力, 决定使用 Swig来撸.

教程基本上按照这篇文章就可以, 文章写得非常详尽,

但文中关于设置 swiglib.i 自定义生成工具的命令行的时候,

他文中的下面一段要注意 :

在常规中选择命令行并且写入:

echo on
$(SolutionDir)/../../thirdpart/swigwin-3.0.12/swig.exe -c++ -csharp -outdir “$(SolutionDir)/../../../UnityProj/UnityCppLearn/Assets/SwigTools/Interface” “%(FullPath)”
echo off

应改成 :

我们在自己填的时候要记得改成自己项目中的路径, 以及把上面这段命令中的中文引号改成英文引号.

1…19202122232425262728293031323334353637
Mike

Mike

🚙 🚗 💨 💨 If you want to create a blog like this, just follow my open-source project, "hexo-theme-neo", click the GitHub button below and check it out ^_^ . It is recommended to use Chrome, Safari, or Edge to read this blog since this blog was developed on Edge (Chromium kernel version) and tested on Safari.

11 categories
296 posts
111 tags
about
GitHub Spotify
© 2013 - 2025 Mike