Skip to content

Instantly share code, notes, and snippets.

View Vesnica's full-sized avatar

Vesnica Vesnica

View GitHub Profile
@Vesnica
Vesnica / PskParser.as3
Created September 1, 2012 07:14
Parse Unreal .psk file to Stage3d VertexBuffer3D and IndexBuffer3D. Currently only read position and uv data.
package
{
import flash.display3D.Context3D;
import flash.display3D.IndexBuffer3D;
import flash.display3D.VertexBuffer3D;
import flash.utils.ByteArray;
import flash.utils.Endian;
/**
* ...
* @author Wisher
@Vesnica
Vesnica / gist:3671956
Created September 8, 2012 04:58
Hints for embed lua in vs2010
C/C++ -> Advanced -> Calling Convention = _cdecl
C/C++ -> Advanced -> Compile As = Compile as C Code
@Vesnica
Vesnica / average.lua
Created September 8, 2012 06:54
Embed Lua example
avg, sum = average(10, 20, 30, 40, 50)
print("The average is ", avg)
print("The sum is ", sum)
print("Versioin is ", VERSION)
@Vesnica
Vesnica / gist:3685090
Created September 9, 2012 15:35
Some erl_interface hints
1. 编译命令:cl /I"include" /D "__WIN32__" /MT /Gd /TC main.c /link /LIBPATH:"lib" "wsock32.lib" "ei.lib" "erl_interface.lib" /OUT:"target.exe"
2. 定义__WIN32__是因为ei.lib需要这个定义
3. /MT表示构造支持多线程的exe,这是ei.lib的默认配置
4. /Gd表示调用约定为__cdecl,纯C代码的dll或lib一般都要用这个设置(比如Lua)
5. /TC表示按照C的格式来编译源代码,这个设置之后源代码里就不需要加入extern "C"的标记了
@Vesnica
Vesnica / main.cpp
Created September 10, 2012 09:32
Erlang Port Test
#include <ei.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <io.h>
#include "marsharling.h"
@Vesnica
Vesnica / Note
Created September 15, 2012 19:34
ei + lua working sample
1. 被lua调用的C函数里似乎不能动态分配太多内存(char s[1024*1024]),如果使用外面分配好的大内存则没有问题
2. lua_pop永远弹出栈顶的元素,很容易和其他函数的index用法弄混,必须小心
3. 使用setvbuf(stdout, NULL, _IOFBF, MAXBUFSIZE)设置stdout和stdin的buffer尺寸,让其和ei使用的buf尺寸匹配
@Vesnica
Vesnica / xml.conf
Last active December 11, 2015 05:58
Simple Erlang XML Parser
[
{xml, "F:/broadband/cwmp/tr-196-2-0-full.xml"},
{ignore_names, [description, bibliography]},
{ignore_attributes, ['xmlns:dm', 'xmlns:dmr', 'xmlns:xsi', 'xsi:schemaLocation', spec, file, 'dmr:version']}
].
@Vesnica
Vesnica / xfl.erl
Created February 2, 2013 20:10
.xfl extractor (Liar Soft)
-module(xfl).
-author("Wisher").
-email("hustitecwisher@gmail.com").
-export([extract/1]).
% All bgm is ogg format, but have a 66 bytes fake wave header.(Liar...)
extract(File) ->
{ok, Bin} = file:read_file(File),
@Vesnica
Vesnica / cwmp.erl
Created February 6, 2013 03:28
CWMP
-module(cwmp).
-author("Wisher").
-email("hustitecwisher@gmail.com").
-export([create_model/1]).
-include_lib("xmerl/include/xmerl.hrl").
create_model({_, _, Xml}) ->
Solved this by running
echo "export TERM=xterm" >> /etc/bash.bashrc
in my Dockerfile when building my container.
OR:
docker run -t -d reds