This file contains hidden or 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
#coding: utf-8 | |
def map(key, value): | |
for word in value: | |
yield (word,1) | |
def reduce(list_maps): | |
reduced = {} |
This file contains hidden or 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
#coding: utf-8 | |
from multiprocessing.pool import ThreadPool | |
def mapping(value): | |
return [(word,1) for word in value] | |
def reducing(list_maps): |
This file contains hidden or 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
var counter = 2; | |
fs.readFile(__filename, onRead); | |
fs.readFile("/etc/passwd", onRead); | |
function onRead(err, content) { | |
if (err) throw err; | |
// Do something with content | |
counter--; | |
if (counter === 0) done(); |
This file contains hidden or 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
typedef struct { | |
char key[8]; | |
void *value; | |
} BIWord; | |
//HOW TO USE IT IN OTHER SOURCECODE FILE? | |
BIWord word[10] = { {"_add", &_add}, | |
{"_dup", &_dup} | |
}; |
This file contains hidden or 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
class RangedDataStructure(object): | |
internal_elements = [] | |
class ParseError(BaseException): | |
"""Parser Error""" | |
class Element(object): | |
def __init__(self, initial, finish, open_i, open_f, value): | |
self.initial = initial |
This file contains hidden or 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
Interval structure | |
Implement an efficient data structure for storing keys in intervals | |
mapping to values. The interval is defined as a 2-tuple: {low, high}. | |
When creating a new map the user can choose if the interval is open or | |
closed, in both ends. | |
Eg. given the left-closed, right-open map M= | |
[1, 10) -> a | |
[10, 20) -> b |
This file contains hidden or 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
-module(rgb). | |
-export([marshall/3, unmarshall/1]). | |
marshall(R,G,B) -> | |
if | |
R > 31 -> | |
throw({overlimit, R}); | |
G > 63 -> | |
throw({overlimit, G}); | |
B > 31 -> |
This file contains hidden or 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 <iostream> | |
class Base | |
{ | |
public: | |
int value; | |
virtual int get_value_plus_one(); | |
}; | |
class Derived: public Base |
This file contains hidden or 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
search_filters = ([k.replace('__exact', ''),humanize_search_values(k, v)] for k, v in filters.items() if v) |
This file contains hidden or 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
class Schema(colander.Schema): | |
title = colander.SchemaNode( | |
colander.String(), | |
title='Book Title', | |
description='Book title without abbreviations', | |
) | |
schema = Schema() | |
form = deform.Form(schema) | |
form.render({'title':None}) # It is rendering a text field with the string None as content |