Skip to content

Instantly share code, notes, and snippets.

View versae's full-sized avatar

Javier de la Rosa versae

View GitHub Profile
@versae
versae / README.md
Created November 4, 2012 15:20
Global Profiling for Django using `hotshot`, including the result as HTML comments, even in XML and JSON responses.

Adapted from this: http://www.no-ack.org/2010/12/yet-another-profiling-middleware-for.html Settings:

  • PROFILE_MIDDLEWARE_SORT: A list of criteria according to which the profiler stats will be sorted. Equivalent to Stats.sort_stats.
  • PROFILE_MIDDLEWARE_RESTRICTIONS: A list of restrictions used to limit the profiler stats. Each restriction is either an integer (to select a count of lines) or a decimal fraction between 0.0 and 1.0 inclusive (to select a percentage of lines), or a regular expression (to pattern match the standard name that is printed). Equivalent to the arguments passed to Stats.print_stats.
  • PROFILE_MIDDLEWARE_STRIP_DIRS: If set to True, removes all leading path information from filenames in the profiler stats. Equivalent to Stats.strip_dirs.
  • PROFILE_MIDDLEWARE_JSON: Enabl
@versae
versae / is_vampire.py
Created November 8, 2012 07:09
Function is_vampire for CS2110
def is_vampire(row):
"""
Decides if the element given by row is a vampire or not
Analyzing the box plots, we see that the first and second columns,
height(cm) and weight(kg), don't give us much information.
However, the third, 4th, 5th and 6th, stake aversion, garlic aversion,
reflectance, and shiny, provide decissive information.
:param rom: A vector with measures
:return: A probability of being a vampier, between 0 and 1
@versae
versae / query_grammar.py
Last active December 15, 2015 14:29
Playing with Parsley to generate grammars on the fly to parse graph queries in a subset of Natural Language. The resulting structure can be transformed into Cypher or Gremlin with no much effort.
import parsley
from pprint import pprint
class Types(dict):
def __init__(self, *args, **kwargs):
super(Types, self).__init__(*args, **kwargs)
self.types = dict()
#/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
try:
import day2
except ImportError:
import dia2 as day2
class TestCase(unittest.TestCase):
@versae
versae / ipython_display_d3.py
Last active December 25, 2015 13:49
Showing a D3 bar chart inside IPython, taking advantage of the `new Function` alternative syntax in Javascript for creating functions
import json
class BarChart(object):
def __init__(self, val, values):
self.val = val
self.values = values
def _repr_html_(self):
def function(code, args=None):
@versae
versae / ipython_display_d3.ipynb
Created October 15, 2013 06:08
Showing a D3 bar chart inside IPython, taking advantage of the `new Function` alternative syntax in Javascript for creating functions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"patterns":[
{
"source":{
"alias":"n3_0",
"type":"node",
"type_id":3
},
"relation":{
"alias":"r2_0",
@versae
versae / Neo4j IPython.ipynb
Last active August 29, 2015 13:57
Neo4j IPython integration through neo4jrestclient
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am versae on github.
  • I am versae (https://keybase.io/versae) on keybase.
  • I have a public key whose fingerprint is 872D 6087 2EC5 092D 75FE 7928 AB45 22BF F23E A91A

To claim this, I am signing this object:

@versae
versae / media_counts.csv
Last active August 29, 2015 14:02
Get total counts for different media from WorldCat
year books music newspapers scores videos
1002 30 5 5 5
1003 45 2 1 1
1004 49 7 6 3
1005 57 5 5 5
1006 59 4 2 4
1007 83 5 1 3
1008 45 5 2 19
1009 63 6 6 4
1010 68 5 1 7