Skip to content

Instantly share code, notes, and snippets.

View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
hifi: Ember.inject.service(),
actions: {
play() {
const url = "https://stream.wqxr.org/wqxr";
const mimeType = 'audio/mpeg';
@paulgoetze
paulgoetze / assert_valid_schema.py
Last active May 30, 2017
Testing Your Python API App with JSON Schema - assert_valid_schema
View assert_valid_schema.py
assert_valid_schema(json_data, 'user.json')
@paulgoetze
paulgoetze / test_users.py
Last active May 30, 2017
Testing Your Python API App with JSON Schema - tests/test_users.py
View test_users.py
# tests/test_users.py
import json
from .support.assertions import assert_valid_schema
def test_get_user(client):
# Do whatever is necessary to create a user here…
response = client.get('/users/1')
@paulgoetze
paulgoetze / user.json
Last active Apr 29, 2022
Testing Your Python API App with JSON Schema - tests/support/schemas/user.json
View user.json
// tests/support/schemas/user.json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "User response schema",
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
@paulgoetze
paulgoetze / assertions.py
Last active May 30, 2017
Testing Your Python API App with JSON Schema - tests/support/assertions.py
View assertions.py
# tests/support/assertions.py
import json
from os.path import join, dirname
from jsonschema import validate
def assert_valid_schema(data, schema_file):
""" Checks whether the given data matches the schema """
@paulgoetze
paulgoetze / test_get_user.py
Last active Feb 19, 2019
Testing Your Python API App with JSON Schema - test_get_user()
View test_get_user.py
def test_get_user(client):
# Do whatever is necessary to create a user here…
response = client.get('/users/1')
json_data = json.loads(response.data)
assert 'data' in json_data
assert 'type' in json_data['data']
assert 'id' in json_data['data']
assert 'attributes' in json_data['data']
@paulgoetze
paulgoetze / user.json
Last active May 30, 2017
Testing Your Python API App with JSON Schema - GET /users/:id response
View user.json
{
"data": {
"type": "users",
"id": 1,
"attributes": {
"email": "paul@grammofy.com",
"username": "paul"
}
}
}
@paulgoetze
paulgoetze / cities.ex
Last active Aug 18, 2019
Compiling an extensive cities list from free geonames.org data
View cities.ex
# This module provides a function to compile city data using the free data
# provided on http://download.geonames.org/export/dump.
# It uses following files to compile a list of 4.4 mio. cities world-wide,
# including their name, state (administrative level 1), country, time zone,
# latitude, and longitude:
#
# * allCountries.txt (included in allCountries.zip)
# * countryInfo.txt
# * admin1CodesASCII.txt
#
@paulgoetze
paulgoetze / google_cloud_store.py
Created Mar 10, 2017
sqlalchemy_media GoogleCloudStore
View google_cloud_store.py
from os import path
from io import BytesIO
from sqlalchemy_media import Store
from sqlalchemy_media.typing_ import FileLike
from sqlalchemy_media.constants import KB
from google.cloud import storage
class GoogleCloudStore(Store):
""" Store for dealing with Google Cloud Storage """
View Keybase.md

Keybase proof

I hereby claim:

  • I am paulgoetze on github.
  • I am paulgoetze (https://keybase.io/paulgoetze) on keybase.
  • I have a public key whose fingerprint is 5F17 19BA 57E1 EBFD 39CA 144A E338 4A2D 3B25 3BC9

To claim this, I am signing this object: