Skip to content

Instantly share code, notes, and snippets.

View Stiivi's full-sized avatar

Stefan Urbanek Stiivi

View GitHub Profile
@Stiivi
Stiivi / presetner_app.py
Created November 8, 2012 16:58
Rickshaw Presenter (early draft implementation)
from flask import Flask, render_template, request
import cubes
import json
app = Flask(__name__)
#
# Data we aregoing to browse and logical model of the data
#
MODEL_PATH = "model.json"
@Stiivi
Stiivi / application.py
Created October 30, 2012 18:52
Presenter Flask Example
from flask import Flask, render_template, request
import cubes
app = Flask(__name__)
#
# Data we aregoing to browse and logical model of the data
#
MODEL_PATH = "model.json"
DB_URL = "sqlite:///data.sqlite"
@Stiivi
Stiivi / htmltable.py
Created October 17, 2012 05:36
Cubes Presenters (preliminary implementation)
# Run this script in cubes/examples/hello_world
import cubes
model = cubes.load_model("model.json")
workspace = cubes.create_workspace("sql", model,
url='sqlite:///data.sqlite')
cube = model.cube("irbd_balance")
@Stiivi
Stiivi / gist:3815251
Created October 1, 2012 23:47
Arrayed brewery simple test
import brewery
stream = brewery.Stream()
main = stream.fork()
main.csv_source("examples/data2.csv")
main.field_filter(drop=["category_code", "subcategory_code", "line_item"])
main.pretty_printer()
stream.run()
@Stiivi
Stiivi / gist:3711515
Created September 13, 2012 02:47
sqlalchemy to carray
import sqlalchemy
import carray
from sqlalchemy.types import *
BUFFER_SIZE = 100
dtype_map = [
(BigInteger, "i"),
(SmallInteger, "i"),
(Boolean, "i"),
@Stiivi
Stiivi / gist:3004766
Created June 27, 2012 15:19
Sublime Text 2 key remap (from TextMate)
[
{ "keys": ["ctrl+q"], "command": "wrap_lines" },
{ "keys": ["super+shift+v"], "command": "paste" },
{ "keys": ["super+v"], "command": "paste_and_indent" }
]
@Stiivi
Stiivi / date_model_example.json
Created June 12, 2012 22:56
Cubes: Mapping of date parts in date datatype columns
{
"cubes": [
{
"name": "example",
"measures": ["amount"],
"dimensions": ["date"],
"mappings": {
"date.year": {"column":"date", "extract":"year"},
"date.month": {"column":"date", "extract":"month"},
"date.day": {"column":"date", "extract":"day"}
@Stiivi
Stiivi / crosstable_example.py
Created June 8, 2012 22:41
Cubes OLAP - Drill-down Cross Table
import sqlalchemy
import cubes
import cubes.tutorial.sql as tutorial
DATA = "../examples/hello_world/data.csv"
MODEL = "../examples/hello_world/model.json"
engine = sqlalchemy.create_engine('sqlite:///:memory:')
tutorial.create_table_from_csv(engine,
DATA,
@Stiivi
Stiivi / slicer.ini
Created May 28, 2012 22:38
OpenSpending/Cubes test Slicer Configuration
[server]
debug=yes
log_level=debug
reload=yes
backend = sql.star
prettyprint = true
[workspace]
url = postgres://postgres@localhost/openspending
@Stiivi
Stiivi / os_to_cubes.py
Created May 28, 2012 22:37
OpenSpending model to Cubes model conversion
from sqlalchemy import create_engine, MetaData, Table
import json
OS_DATASET = "de-bund"
def get_os_metadata(dataset_name):
engine = create_engine("postgres://postgres@localhost/openspending")
md = MetaData(bind=engine)
table = Table("dataset", md, autoload=True)