146aPdVmwzwzwzWe:)P
14Pd:)P2022
import λ from "apex.js"; | |
import { Pool } from "pg"; | |
// connection details inherited from environment | |
const pool = new Pool({ | |
max: 1, | |
min: 0, | |
idleTimeoutMillis: 120000, | |
connectionTimeoutMillis: 10000 | |
}); |
146aPdVmwzwzwzWe:)P
14Pd:)P2022
GET /foo/bar
['GET /foo/bar']
POST /users/{userId}/edit
or POST /users/{userId:*/}edit
['POST /users/', match('userId', '*/'), '/edit']
GET /static/{filename:*}
['GET /static/', match('filename', '*')]
GET /users{userId?:/*/}
['GET /users']
andconst enum CONST { | |
MAX_LENGTH = 128, | |
} | |
class BigArrayRef<T> { | |
constructor (public readonly arr: BigArray<T>, public readonly pos: number) {} | |
} | |
export class BigArray<T> { | |
public length = 0; |
Smallest possible CSS-in-JS library.
Specify required fields, rest will be optional.
export type Required<T, K extends keyof T> = Partial<T> & Pick<T, K>;
Specify which fields to omit.
export type Omit = Pick>;
# Stop PostgreSQL from auto starting | |
sudo launchctl unload -w /Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist | |
# Enable PostgreSQL to auto start | |
sudo launchctl load -w /Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist | |
# Start postgres | |
$ sudo su postgres | |
Password: | |
bash-3.2$ pg_ctl -D /Library/PostgreSQL/9.3/data/ start |
PubSub
class like this:
class PubSub {
constructor () {
this.el = document.createElement('div');
}
subscribe (eventName, handler) {
this.el.addEventListener(eventName, handler);
Load data on client and server:
async function * MyComponent() {
yield (<div>Loading...</div>);
const users = await fetch('/users');
yield () =>
<div>
<UserList users={users} />
{this.props.buttonLabel}
const React = require("react"); | |
const Lifecycles = React.createLifecycleEvents({ | |
didMount({ setState }) { | |
setState({ | |
disabled: false, | |
}); | |
}, | |
didUpdate({ inputRef }) { | |
if (document.activeElement !== inputRef.value) { |