Skip to content

Instantly share code, notes, and snippets.

@mvaz
mvaz / gist:938737
Created April 23, 2011 16:05
FisicaGraph
package net.mvaz.examples.visualization.processingparis;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@mvaz
mvaz / gist:973464
Created May 15, 2011 19:35
Graph listener example
package net.mvaz.examples.graph;
import org.jgrapht.DirectedGraph;
import org.jgrapht.alg.DijkstraShortestPath;
import org.jgrapht.event.ConnectedComponentTraversalEvent;
import org.jgrapht.event.TraversalListenerAdapter;
import org.jgrapht.event.VertexTraversalEvent;
import org.jgrapht.graph.SimpleDirectedGraph;
import org.jgrapht.traverse.DepthFirstIterator;
import org.jgrapht.traverse.GraphIterator;
@mvaz
mvaz / gist:1011768
Created June 7, 2011 06:21
mvn install weka
mvn install:install-file -Dfile=weka.jar -DgroupId=nz.ac.waikato -DartifactId=weka -Dversion=3.7.3 -Dpackaging=jar -DgeneratePom=true -Dsources=weka-src.jar
@mvaz
mvaz / TzCronTrigger.py
Created August 31, 2011 22:05
TzCronTrigger
class TzCronTrigger(CronTrigger):
def __init__(self,**values):
self.tz = values.pop('tz', None)
if self.tz:
if self.tz not in pytz.all_timezones:
raise ValueError("invalid specified timezone '%s'" % self.tz)
self.tz = pytz.timezone( self.tz )
super(TzCronTrigger, self).__init__(**values)
def get_next_fire_time(self, start_date):
@mvaz
mvaz / virtualenv.py
Created August 31, 2011 22:14
script for ipython to work with virtualenv
import site
from os import environ
from os.path import join
import sys
if 'VIRTUAL_ENV' in environ:
virtual_env = join(environ.get('VIRTUAL_ENV'),
'lib',
'python%d.%d' % sys.version_info[:2],
'site-packages')
@mvaz
mvaz / index.html
Created December 3, 2011 16:23
OpenSeedData (Polymaps + D3)
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.6.1"></script>
<script type="text/javascript" src="http://polymaps.org/polymaps.min.js?2.5.0"></script>
<style type="text/css">
@import url("http://polymaps.org/style.css");
html, body {
@mvaz
mvaz / get_metadata.sql
Created December 12, 2011 19:59
Getting metadata from oracle sql tables
select --*
col.table_name, col.column_name, cc.constraint_name , rel.table_name, rel.column_name
from user_tab_columns col,
user_cons_columns con,
user_constraints cc,
user_cons_columns rel
where col.table_name = con.table_name
and col.column_name = con.column_name
and con.constraint_name = cc.constraint_name
and cc.constraint_type = 'R'
@mvaz
mvaz / query_mdb.py
Created March 7, 2012 13:28
short snippet for querying an access database
# http://code.google.com/p/pyodbc/wiki/GettingStarted
# http://code.google.com/p/pyodbc/wiki/ConnectionStrings
import pyodbc
cnxn_string = r'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\PATH\TO\FILE.mdb'
cnxn = pyodbc.connect(cnxn_string)
cursor = cnxn.cursor()
cursor.execute("SELECT * from MY_TABLE")
@mvaz
mvaz / cx_oracle_to_pandas.py
Created March 9, 2012 13:24
Example of executing and reading a query into a pandas dataframe
import cx_Oracle
import pandas
connection = cx_Oracle.connect('username/pwd@host:port/dbname')
def read_query(connection, query):
cursor = connection.cursor()
try:
cursor.execute( query )
names = [ x[0] for x in cursor.description]
@mvaz
mvaz / dump_oracle.py
Created March 18, 2012 21:27
Dump Oracle db schema to text
# http://code.activestate.com/recipes/576534-dump-oracle-db-schema-to-text/
#!/usr/bin/env python
# -*- coding: utf8 -*-
__version__ = '$Id: schema_ora.py 928 2012-01-12 19:09:34Z tt $'
# export Oracle schema to text
# usable to compare databases that should be the same
#