Skip to content

Instantly share code, notes, and snippets.

View du2x's full-sized avatar

Eduardo Monteiro du2x

View GitHub Profile
@du2x
du2x / js2table.js
Created April 18, 2017 14:53
Javascript list to html table
// see http://stackoverflow.com/questions/5180382/convert-json-data-to-a-html-table
// Builds the HTML Table out of myList.
function buildHtmlTable(myList) {
var res = '<table>';
var columns = [];
var headerTr$ = $('<tr/>');
for (var i = 0; i < myList.length; i++) {
var rowHash = myList[i];
def count_words(s, n):
"""Return the n most frequently occuring words in s ordered by number
of ocurrences and alfabetically."""
ws = {}
for w in s.split():
if w in ws.keys():
ws[w]+=1
else:
ws[w]=1
@du2x
du2x / consumeRawBSON.py
Last active February 18, 2016 19:21
Consume Mongo BSON File
import bson
bs = open('filename.bson').read()
b = bson.BSON(bs)
for line in bson.decode_all(b):
# do stuff
#del(line['_id'])