Skip to content

Instantly share code, notes, and snippets.

Tim Wisniewski timwis

Block or report user

Report or block timwis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@timwis
timwis / grid.js
Last active Apr 23, 2017
Combining HyperList with Nanocomponent
View grid.js
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 Apr 12, 2017
PostgREST via docker-compose
View docker-compose.yml
version: '2'
services:
db:
image: postgres
volumes:
- ./scripts/contacts.sql:/docker-entrypoint-initdb.d/contacts.sql
ports:
- "5432:5432"
restart: always
environment:
View onload-multiple.js
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>
View layout.js
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}
View bel-example.js
const html = require('bel')
['Hello', 'world'].map((text) => {
return html`<p><span>${text}</span></p>`
})
@timwis
timwis / README.md
Last active Dec 29, 2016
Indent multi-line string
View README.md

Indent multi-line string

`
<div>
  ${indent(JSON.stringify(data, null, 2), 2)}
</div>
`
@timwis
timwis / list.py
Created Dec 28, 2016
Get a list of OpenDataPhilly datasets that have resources hosted on Socrata
View list.py
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)
View cache-element-loop.js
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'} ]
},
View reorder.js
function reorder (state, data) {
const { from, to } = data
const rowsCopy = state.rows.slice()
const fromRowCopy = rowsCopy[from.row].slice()
const item = fromRowCopy[from.index]
fromRowCopy.splice(from.index, 1) // remove from row
rowsCopy[from.row] = fromRowCopy // replace 'from' row
@timwis
timwis / choo-async-await.js
Created Dec 18, 2016
Use promises and async/await in effects in choo
View choo-async-await.js
app.use({
wrapEffects: (cb) => {
return async (state, data, send, done) => {
const psend = promisify(send)
try {
await cb(state, data, psend)
done()
} catch (err) {
done(err)
}
You can’t perform that action at this time.