Skip to content

Instantly share code, notes, and snippets.

@timwis
timwis / api.apib
Created June 12, 2017 16:38
Dataface API spec
FORMAT: 1A
# Dataface
Build and manage data with a spreadsheet-like interface.
# Group Sheets
Resources related to sheets (which is what dataface calls database tables).
@timwis
timwis / get-schema.sql
Last active May 4, 2017 10:38
Get postgres table schema including keys/constraints
SELECT
cols.column_name,
cols.data_type,
cols.character_maximum_length,
cols.column_default,
cols.is_nullable::boolean,
constr.constraint_type,
pg_catalog.col_description(cls.oid, cols.ordinal_position::int)::jsonb
FROM
pg_catalog.pg_class cls,
@timwis
timwis / grid.js
Last active April 23, 2017 16:13
Combining HyperList with Nanocomponent
const html = require('choo/html')
const css = require('sheetify')
const HyperListComponent = require('./hyperlist-component')
const prefix = css`
thead, tbody {
display: block;
}
`
@timwis
timwis / docker-compose.yml
Last active April 12, 2017 11:36
PostgREST via docker-compose
version: '2'
services:
db:
image: postgres
volumes:
- ./scripts/contacts.sql:/docker-entrypoint-initdb.d/contacts.sql
ports:
- "5432:5432"
restart: always
environment:
const html = require('choo/html')
const component = require('nanocomponent')
const menu = require('../components/menu')
module.exports = function home (state, emit) {
return component({
render: (state, emit) => {
return html`
<body>
import React from 'react'
import 'foundation-sites/dist/css/foundation.css'
import TopBar from './TopBar'
class Layout extends React.Component {
render () {
<div className='container'>
<TopBar />
{this.props.children}
const html = require('bel')
['Hello', 'world'].map((text) => {
return html`<p><span>${text}</span></p>`
})
@timwis
timwis / README.md
Last active December 29, 2016 12:33
Indent multi-line string

Indent multi-line string

`
<div>
  ${indent(JSON.stringify(data, null, 2), 2)}
</div>
`
@timwis
timwis / list.py
Created December 28, 2016 21:51
Get a list of OpenDataPhilly datasets that have resources hosted on Socrata
import csv
import sys
import requests
odp_packages_url = 'https://opendataphilly.org/api/3/action/package_search?rows=10000'
odp_dataset_prefix = 'https://opendataphilly.org/package/'
socrata_keyword = '//data.phila.gov'
response = requests.get(odp_packages_url)
const choo = require('choo')
const html = require('choo/html')
const widget = require('cache-element/widget')
const app = choo()
app.model({
state: {
rows: [ {a: 'a'}, {b: 'b'} ]
},