Skip to content

Instantly share code, notes, and snippets.

// apps/api/src/models/Match.ts
import { Schema, model, Document } from 'mongoose';
// Define constants locally (synchronized with shared/types.ts)
const MATCH_STATUSES = ['scheduled', 'ongoing', 'completed', 'cancelled'] as const;
// Match interface (matches shared/types.ts IMatch but extends Document)
export interface IMatch extends Document {
date: Date;
time: string;
@pengcc
pengcc / colorify.sh
Last active June 30, 2020 15:38
bash-snippet
#!/bin/bash
# Usage
# import this script in your file
# make sure that get the correct source file path
# DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# source "${DIR}/_colorify.sh"
# colort red example text in red
# echo "$(colort red 'red text') bla bla $(colort green 'green text')"
@pengcc
pengcc / ssh-login-vps.md
Last active July 7, 2020 06:49
SSH login without password

SSH connect to VPS without password (we assume login as root, but better with a different user)

Check if you have generated public and private keys via cd ~/.ssh in command line

If not, generate new keys via ssh-keygen -t rsa as following:

Generating public/private rsa key pair.
Enter file in which to save the key (/{your user path}/.ssh/id_rsa):

checkt if the public and private keys have been generated correctly

@pengcc
pengcc / pubsub.js
Created August 30, 2016 12:12 — forked from learncodeacademy/pubsub.js
Basic Javascript PubSub Pattern
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path