Skip to content

Instantly share code, notes, and snippets.

def get_content_type():
return 'application/octet-stream'
def parse_xml(key,xml):
""" Simple XML parser """
key = key.lower()
for tag in xml.split("<"):
tokens = tag.split()
if tokens and tokens[0].lower().startswith(key):
return tag.split(">")[1].strip()
@saga
saga / Lua print table
Created January 4, 2010 06:42
Lua print table
local tconcat = table.concat
local tinsert = table.insert
local srep = string.rep
function print_table(root)
local cache = { [root] = "." }
local function _dump(t,space,name)
local temp = {}
for k,v in pairs(t) do
local key = tostring(k)
@saga
saga / std::string split function
Created January 4, 2010 06:38
std::string split function
void split(const string& str, const string& delim, vector<string>* pParts)
{
size_t start, end = 0;
while (end < str.size()) {
start = end;
while (start < str.size() && (delim.find(str[start]) != string::npos))
{
start++; // skip initial whitespace
}