Skip to content

Instantly share code, notes, and snippets.

@dphang
dphang / code.ts
Last active October 2, 2020 06:53
// Return from Lambda
return {
status: "200",
statusDescription: "OK",
headers: {
"content-type": [
{
key: "Content-Type",
value: "text/html"
}
@dphang
dphang / deployer.ts
Last active February 11, 2022 02:46
Deploy serverless-next.js to different stages
#!/usr/bin/env node
// Example (opinionated) configuration with yarn (I use TypeScript/Node environment, feel free to adapt this file to JS if needed). Note: I am running in Node 12.x environment with aws cli installed.
// 1. Copy this file to scripts/deployer.ts (or any other you prefer)
// 2. Add "deploy": "ts-node --project tsconfig.scripts.json scripts/deployer.ts deploy" to your package.json file
// 3. You may also need to install devDependencies like yargs, @types/node, @types/yargs, js-yaml, @types/js-yaml
// 4. I also add tsconfig.scripts.json like the following:
/*
{

Keybase proof

I hereby claim:

  • I am dphang on github.
  • I am dphang (https://keybase.io/dphang) on keybase.
  • I have a public key ASAkI9Pl6dIHYq31qLtagTK9FSCP5kKoahj0hVvEm_WsKwo

To claim this, I am signing this object:

@dphang
dphang / kwacros.py
Created March 2, 2014 18:57
Macro template tags for Django (tested on Python 3.3.4 and Django 1.6.2)
#
# templatetags/kwacros.py - Support for macros in Django templates
#
# Based on snippet by
# Author: Michal Ludvig <michal@logix.cz>
# http://www.logix.cz/michal
#
# modified for args and kwargs by Skylar Saveland http://skyl.org
# updated for Python 3 by Daniel Phang on March 2, 2014
#