This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Autodict class | |
# Create new autodict if accessing undefined key | |
# support dot access syntax (mydict.test == mydict['test']) | |
class autodict(dict): | |
def __getitem__(self, name): | |
if not name in self: | |
dict.__setitem__(self, name, autodict()) | |
return dict.__getitem__(self, name) | |
def __getattr__(self, name): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "xml_writer.hpp" | |
#include <iostream> | |
int main() | |
{ | |
Writer writer(std::cout); | |
writer.openElt("Movies"); | |
writer.openElt("Goldeneye").attr("date", "1998").content("This is a James Bond movie").endElt(); | |
writer.openElt("Leon").attr("director", "Luc Besson"); | |
writer.openElt("Actor").attr("role", "Leon").attr("name", "Jean Reno").endAll(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fcntl | |
import os | |
from subprocess import * | |
def non_block_read(output): | |
fd = output.fileno() | |
fl = fcntl.fcntl(fd, fcntl.F_GETFL) | |
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK) | |
try: | |
return output.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "hash.hh" | |
HashFunc::HashFunc () | |
{ | |
} | |
HashFunc::~HashFunc () | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shell $ g++ mergetest.cpp | |
shell $ cat f1.txt | |
a:1 | |
c:2 | |
f:3 | |
h:4 | |
j:5 | |
l:6 | |
shell $ cat f2.txt | |
a:1 |