Skip to content

Instantly share code, notes, and snippets.

View kkdai's full-sized avatar

Evan Lin kkdai

View GitHub Profile
# Makefile for a go project
#
# Author: Jon Eisen
# site: joneisen.me
#
# Targets:
# all: Builds the code
# build: Builds the code
# fmt: Formats the source files
# clean: cleans the code
@kkdai
kkdai / gist:6dcf3f31fc5f27b5c282
Created January 8, 2015 01:44 — forked from philfreo/gist:cbab6aad493a6a3c21e8
Email server settings

IMAP

Gmail/Google Apps:

Host: imap.gmail.com
Port: 993
Username: youremail@gmail.com or youremail@yourdomain.com (Google Apps)
Password: Your email password
SSL: Yes
import simplejson as json
import lxml
class objectJSONEncoder(json.JSONEncoder):
"""A specialized JSON encoder that can handle simple lxml objectify types
>>> from lxml import objectify
>>> obj = objectify.fromstring("<Book><price>1.50</price><author>W. Shakespeare</author></Book>")
>>> objectJSONEncoder().encode(obj)
'{"price": 1.5, "author": "W. Shakespeare"}'
"""
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""xml2json.py Convert XML to JSON
Relies on ElementTree for the XML parsing. This is based on
pesterfish.py but uses a different XML->JSON mapping.
The XML->JSON mapping is described at
http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html
@kkdai
kkdai / parse.py
Created May 7, 2014 16:07 — forked from honza/parse.py
"""
Convert an XML list of Tim Hortons restaurant locations to JSON
Usage: python parse.py sourcefile destfile
E.g.: python parse.py locations.xml locations.json
"""
import json
import sys
try: