Skip to content

Instantly share code, notes, and snippets.

@hharzer
hharzer / README.md
Created February 22, 2022 12:55 — forked from D2theR/README.md
Auto-generates Serializers & ModelViewSets in a Django API using just models

Why?

I got sick of writing the same Serializer & ModelViewSet classes over and over so I found and wrote some code to do it for me, and somehow it works! Please note that there are a lot of caveats to running an API like this and while this may work, I know there's A LOT of room for improvement, feel free to fork and help!

USAGE

Import the router module to your main sites urls.py file as the injection point like so... Make sure to remove any other imports from other viewsets that you don't need that may conflict!

@hharzer
hharzer / expose-response-headers.md
Created August 6, 2020 02:24 — forked from n400/expose-response-headers.md
Example observers to expose response headers from FaunaDB JS driver

When the FaunaDB JavaScript driver returns query results, it's exposing the the response payload, but not the response headers. However, the response headers contain query metrics you might want (e.g., read ops, write ops, transaction retires, query time, bytes in/out, storage bytes read/written, read ops).

The web shell/REPL at dashboard.fauna.com also presents this information to you through the GUI (click the "i" on left).

Here are some examples to help you get the repsonse headers

@hharzer
hharzer / nested-fql-manual.js
Created August 6, 2020 01:50 — forked from ptpaterson/nested-fql-manual.js
Template for building deeply nested FQL queries for FaunaDB
const baseQuery = q.Paginate(q.Match(q.Index(indexName), terms));
// or
// const baseQuery = q.Paginate(q.Collection(collectionName))
const expandedQuery = q.Map(baseQuery, (ref) =>
q.Let(
{
instance: q.Get(q.Var('ref'))
},
{
@hharzer
hharzer / index.js
Created August 5, 2020 05:39 — forked from PierBover/index.js
Micro router for Cloudflare Workers
const router = require('./router');
router.setRoutes([
{
path: '/ping',
method: 'GET',
handler: ping
},
{
path: '/hello/:name',
@hharzer
hharzer / Design document
Created May 19, 2020 02:11 — forked from rdmpage/Design document
Full text search in Cloudant
{
"_id": "_design/lookup",
"_rev": "2-2763d098bce604230bfc247ca06cba05",
"language": "javascript",
"indexes": {
"all": {
"index": "function(doc) {\n if (doc.title)\n {\n index(\"title\", doc.title, {\"store\": \"yes\"});\n }\n }"
}
}
}