Skip to content

Instantly share code, notes, and snippets.

View thanos's full-sized avatar

thanos vassilakis thanos

View GitHub Profile
<thead>
<tr bgcolor="lightgray" class="header-row">
<th id="id" class="data-sort" >Id</th>
<th id="date" class="data-sort" >Date</th>
<th id="hourEnd" class="data-sort" >Hour</th>
<th id="loadAvgHourlyDAY" class="data-sort" >Load</th>
</tr>
</thead>
<table id="example-4" bgcolor="gray" class="grid-test">
<thead>
<tr bgcolor="lightgray" class="header-row">
<th id="id" class="column" >Id</th>
<th id="date" class="column" >Date</th>
<th id="hourEnd" class="column" >Hour</th>
<th id="loadAvgHourlyDAY" class="column" >Load</th>
</tr>
</thead>
<tbody class="data-body">
'''
Usage:
>python server.py PORT
where PORT defaults 8000
Serves files from the current working directory
'''
from SimpleHTTPServer import test as run
if __name__ =='__main__':
{
"_id": "_design/erlang_reports",
"_rev": "10-3d4e646c0990861c315e984056c397a7",
"language": "erlang",
"views": {
"revisions": {
"map": "fun({Doc}) ->\u000a <<K,_/binary>> = proplists:get_value(<<\"_rev\">>, Doc, null),\u000a V = proplists:get_value(<<\"_id\">>, Doc, null),\u000a Emit(<<K>>, V)\u000aend.\u000a\u000a",
"reduce": "fun(Keys, Values, ReReduce) -> length(Values) end."
},
}
@thanos
thanos / Couchdb_byDate.erl
Created September 23, 2010 21:41
CouchDB: An erlang couchdb map function
% An a simple erlang couchdb view
%
% For the date see: https://gist.github.com/1125467
%
fun({Doc}) ->
case {proplists:get_value(<<"book">>, Doc)} of
{undefined} ->
ok;
{Name} ->
class Node:
"""
>>> Node(1).append(
... Node(2)).append(
... Node(3)).append(
... Node(4)).append(
... Node(5)).append(
... Node(6)).append(
... Node(7)).append(
... Node(8)).pprint()
@thanos
thanos / Python_Sub_Class_Discoverer.py
Created February 14, 2011 18:58
Returns a list of all the sublasses and returns them. A nice way of implementing plug-ins.
def discover(root, classes=[]):
"""
Returns a list of all the sublasses and returns them. A nice way of implementing plug-ins.
"""
for cls in root.__subclasses__():
classes.append(cls)
discover(cls, classes)
return classes
@thanos
thanos / see_django_sql.py
Created June 2, 2011 14:27
to see the SQL used when I'm in the django python shell
# to see the SQL used when I'm in the django python shell
import logging
l = logging.getLogger('django.db.backends')
l.setLevel(logging.DEBUG)
l.addHandler(logging.StreamHandler())
@thanos
thanos / django_fields.py
Created June 7, 2011 19:26
django model instance fields
def fields(obj):
return self._meta.fields[:]
@thanos
thanos / load_modules.py
Created June 29, 2011 14:25
imports python modules from a package
import os, sys
def load_modules(dir):
package = os.path.realpath(dir)
sys.path.append(package)
for module in [os.path.splitext(fn)[0] for fn in os.listdir(package) if fn.endswith('.py')]:
m = __import__(module)