Skip to content

Instantly share code, notes, and snippets.

@poppe1219
poppe1219 / parse_css.py
Created April 4, 2015 17:28
A test for parsing CSS to a json structure
# -*- coding: utf-8 -*-
cssText = '''article, aside, details, figcaption, figure, footer, header, hgroup, nav, section, summary { display: block; }
audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; }
audio:not([controls]) { display: none; height: 0; }
[hidden] { display: none; }
html { font-size: 100%; }
html, button, input, select, textarea { font-family: sans-serif; }
body, body { margin: 0; }
a:focus { outline: thin dotted; }
@poppe1219
poppe1219 / gist:71e32e1a6aeff3e0f1a0
Created April 3, 2015 12:09
Example of reading and writing json files, using utf-8 endcoding.
# -*- coding: utf-8 -*-
"""Json file module."""
import os
import json
import logging
logger = logging.getLogger()
def read_json_from_file(file_path):
@poppe1219
poppe1219 / cfg_overrides.py
Created June 29, 2014 14:38
Example of how custom dragonfly commands could be configured
class Key:
"""Mock class."""
def __init__(self, phrase):
self._phrase = phrase
class Function:
""" Mock class."""
def __init__(self, phrase):
self._phrase = phrase
@poppe1219
poppe1219 / json_with_comments.py
Last active August 29, 2015 14:03
An example module for parsing json with JS style comments.
"""An example module for parsing json with JS style comments.
Primarily intended for parsing config files in json format,
where the use of comments may be desirable.
As Douglas Crockford suggests:
"Suppose you are using JSON to keep configuration files,
which you would like to annotate. Go ahead and insert all
the comments you like. Then pipe it through JSMin before