Skip to content

Instantly share code, notes, and snippets.

View alexanderk23's full-sized avatar

Alexander Kovalenko alexanderk23

View GitHub Profile
###
# Read in XML as a stream, write out JSON as a stream. As little information
# is kept in memory as possible.
require 'nokogiri'
require 'psych'
class JSONTranslator < Nokogiri::XML::SAX::Document
attr_reader :emitter
def initialize emitter
@alexanderk23
alexanderk23 / tree.md
Created November 10, 2013 19:20 — forked from hrldcpr/tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

namespace :symfony do
namespace :assets do
desc "Updates assets version"
task :update_version do
run "sed -i 's/\\(assets_version: \\)\\(.*\\)$/\\1 #{real_revision}/g' #{latest_release}/app/config/config.yml"
end
end
end
before "symfony:assetic:dump" do
"""Generic linux daemon base class for python 3.x.
Source: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/"""
import sys, os, time, atexit, signal, errno
class daemon:
"""A generic daemon class.
Usage: subclass the daemon class and override the run() method."""