Skip to content

Instantly share code, notes, and snippets.

View RayLuxembourg's full-sized avatar

Ray Luxembourg RayLuxembourg

View GitHub Profile
@RayLuxembourg
RayLuxembourg / bind.tsx
Last active May 21, 2019 08:26
bind argument without effecting this
class PoseSwiper extends Component<Props> {
state = {
activeIndex: 0
};
config = {
slidesPerView: 1,
observer: true,
on: {
slideChange: function(applyNewIndex: (index: number) => void) {
applyNewIndex(this.activeIndex);
type QueryParam = "size" | "color" | "page"
export const parseQueryParam = <T extends QueryParam>(queryParam: T) : T => {
return queryParam
}
@RayLuxembourg
RayLuxembourg / typescript.json
Last active May 21, 2020 19:40
emotion basic snippet for nextjs
{
// Place your snippets for typescript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
{
// Place your snippets for typescriptreact here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@RayLuxembourg
RayLuxembourg / Dockerfile
Created April 6, 2021 19:56
Nestjs multi stage production dockerfile
FROM node:14-alpine AS backend-builder
RUN apk --no-cache add curl
RUN apk --no-cache add bash
RUN curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash -s -- -b /usr/local/bin
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn --frozen-lockfile
COPY . .
@RayLuxembourg
RayLuxembourg / logger.js
Created June 18, 2021 21:21 — forked from ludwig/logger.js
winston logger with filename:linenumber
// NOTE: this adds a filename and line number to winston's output
// Example output: 'info (routes/index.js:34) GET 200 /index'
var winston = require('winston')
var path = require('path')
var PROJECT_ROOT = path.join(__dirname, '..')
var logger = new winston.logger({ ... })
// this allows winston to handle output from express' morgan middleware
@RayLuxembourg
RayLuxembourg / System Design.md
Created August 21, 2021 18:32 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?