Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
UNAME := $(shell uname -s) | |
ifeq ($(UNAME),Darwin) | |
OSFLAGS=-D_OSX | |
endif | |
ifeq ($(UNAME),Linux) | |
OSFLAGS=-D_LINUX | |
endif | |
CC=gcc | |
CFLAGS=-std=gnu99 -lm -s -x c -O2 -Wall -Wno-unused -fno-optimize-sibling-calls -fno-strict-aliasing -DONLINE_JUDGE $(OSFLAGS) | |
SOURCES=my_strategy.c runner.c remote_process_client.c model/world.c platform/net.c |
class DeepOpenStruct < OpenStruct | |
def to_h | |
convert_to_hash_recursive self.dup | |
end | |
def self.load item | |
raise ArgumentError, "DeepOpenStruct must be passed a Hash or Array" unless(item.is_a?(Hash) || item.is_a?(Array)) | |
self.convert_from_hash_recursive item | |
end |
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.""" |
<html> | |
<head> | |
<script src="https://raw.github.com/remy/twitterlib/master/twitterlib.min.js"></script> | |
<script src="https://raw.github.com/timrwood/moment/2.0.0/min/moment.min.js"></script> | |
</head> | |
<body> | |
<div id="tweet" data-username="bountify"></div> | |
<script> | |
var tweet = document.getElementById('tweet'); | |
var username = tweet.getAttribute('data-username'); |