Skip to content

Instantly share code, notes, and snippets.

@leeonix
leeonix / Premake5.lua
Created June 28, 2015 06:41
Premake5.lua for Stormlib
solution 'StormLib'
location 'build'
language 'C++'
configurations { 'Debug', 'Release', }
platforms { 'x32', 'x64' }
targetdir 'bin'
objdir 'bin'
@leeonix
leeonix / extract_winrar.lua
Last active March 4, 2017 15:33
Use lua to extract rar file for Total Commander
--
-- FILE: extract_winrar.lua
-- AUTHOR: LeeoNix
-- DESCRIPTION:
-- NOTES: ---
--
--[[
TOTALCMD#BAR#DATA
@leeonix
leeonix / genpremake.py
Last active March 8, 2017 01:33
premake5.lua or premake4.lua generator
import os, sys, getopt, string
import uuid
template4 = """
newoption {
trigger = 'to',
value = 'path',
description = 'Set the output location for the generated files'
}
@leeonix
leeonix / array.c
Created May 13, 2015 12:18
dynamic array structure
/*
* =====================================================================================
*
* Filename: array.c
* Description: array structure
* Created: 2011-10-14 9:52:47
*
* =====================================================================================
*/
@leeonix
leeonix / strbuf.c
Created August 16, 2014 08:36
git's strbuf
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <errno.h>
@leeonix
leeonix / three_num_add.dpr
Last active August 29, 2015 14:05
计算123456789,所有3位数加法的组合。
program three_num_add;
{$APPTYPE CONSOLE}
uses
Classes,
SysUtils;
type
PResult = ^TResult;
@leeonix
leeonix / genmakefile.py
Last active December 3, 2018 19:45
generate Makefile template using python
import sys, string
template = """
CC = gcc
CXX = g++
AR = ar
DEFINES +=
CFLAGS = $(DEFINES) -c -O2 -Wall
INCLUDES +=
# coding: gbk
<%!
from textwrap import wrap
import re
%><%
def replacer(s):
try:
return '(event == %s)' % (machine.event(s.group()).name)
except KeyError:
return '%s(param)' % machine.input(s.group()).name
@leeonix
leeonix / csv.lua
Created June 12, 2014 08:49
parse csv file use state machine
-- vi: syntax=lua ts=4 sw=4 et:
--
-- FILE: csv.lua
-- AUTHOR: LeeoNix
-- DESCRIPTION: parse csv file use state machine
-- NOTES: ---
--
local C_INV = 1 -- invalid characters
local C_COMMA = 2 -- ,
# coding: gbk
<%!
from textwrap import wrap
%>
local ${machine.name} = require '${machine.name}'
local delegate = {}
--------------------------------------------------------------------------------
-- input
% for i in machine.inputs: