Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍👩‍👦‍👦
married

Vadim Dalecky streamich

👨‍👩‍👦‍👦
married
  • Zurich
View GitHub Profile
View The-Router.md

Requirements

  • Ability to match static routes GET /foo/bar
    • ['GET /foo/bar']
  • Ability to match a single step in a route POST /users/{userId}/edit or POST /users/{userId:*/}edit
    • ['POST /users/', match('userId', '*/'), '/edit']
  • Ability to wildcard the ending of a route GET /static/{filename:*}
    • ['GET /static/', match('filename', '*')]
  • Ability to make the last route step optional GET /users{userId?:/*/}
  • ['GET /users'] and
View BigArray.ts
const 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;
@streamich
streamich / pub.md
Last active January 29, 2022 20:00
View pub.md

146aPdVmwzwzwzWe:)P

14Pd:)P2022

@streamich
streamich / lambda.js
Last active April 28, 2023 19:35 — forked from maxbeatty/lambda.js
using node-postgres (`pg`) in AWS Lambda
View lambda.js
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
});
View typescript.md

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&gt;;
@streamich
streamich / gist:03d109062e4b330359dd6e11481fbd6f
Created August 31, 2018 08:12 — forked from kingbin/gist:9435292
Manually Start/Stop PostgresSQL on Mac
View gist:03d109062e4b330359dd6e11481fbd6f
# 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
View tweet-css.md

tweet-css

Smallest possible CSS-in-JS library.

View pubsub.md

PubSub class like this:

class PubSub {
  constructor () {
    this.el = document.createElement('div');
  }

  subscribe (eventName, handler) {
 this.el.addEventListener(eventName, handler);
@streamich
streamich / async-render.md
Last active March 5, 2018 09:34
Usage cases for async generator render functions: https://github.com/reactjs/rfcs/issues/29
View async-render.md

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}
View 1-future-ideas.js
const React = require("react");
const Lifecycles = React.createLifecycleEvents({
didMount({ setState }) {
setState({
disabled: false,
});
},
didUpdate({ inputRef }) {
if (document.activeElement !== inputRef.value) {