Skip to content

Instantly share code, notes, and snippets.

View GauSim's full-sized avatar

Simon Gausmann GauSim

View GitHub Profile
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<body>
<!-- start of drop-in script -->
<style>
.pretty-button {
background-color: #FAFBFC;
border: 1px solid rgba(27, 31, 35, 0.15);
border-radius: 6px;
@GauSim
GauSim / postgres-cheatsheet.md
Created November 16, 2021 18:51 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@GauSim
GauSim / gist:ecff85b28f7c82eadaabb354bd28c7c2
Created November 16, 2021 18:47 — forked from dirkgroenen/gist:07c3e8e4bc7e08bc3232ae0bdd6a0ba5
Backup Heroku Postgres database and restore to local database

Grab new backup of database

Command: heroku pgbackups:capture --remote production

Response: >>> HEROKU_POSTGRESQL_COLOR_URL (DATABASE_URL) ----backup---> a712

Get url of backup download

Command: heroku pgbackups:url [db_key] --remote production

@GauSim
GauSim / slow-tree-test.ts
Last active August 18, 2020 20:31
slow but compact tree search
type P = {
job_id: string;
path_id: string;
path_predecessor: string | null;
module: string;
module_predecessor: string | null;
module_entry_point: boolean;
// scripts/seed.ts
import * as _ from 'lodash';
import { createConnection, ConnectionOptions } from 'typeorm';
import { configService } from '../config/config.service';
import { User } from '../user.decorator';
import { ItemService } from '../item/item.service';
import { Item } from '../model/item.entity';
import { ItemDTO } from '../item/item.dto';
// main.ts
async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  if (!configService.isProduction()) {

    const document = SwaggerModule.createDocument(app, new DocumentBuilder()
      .setTitle('Item API')
 .setDescription('My Item API')
  // item.controller.ts
  @Get()
  public async getAll(): Promise<ItemDTO[]> {
    return await this.serv.getAll()
  }

  @Post()
  public async post(@User() user: User, @Body() dto: ItemDTO): Promise<ItemDTO> {
 return this.serv.create(dto, user);
// item.dto.ts
import { ApiModelProperty } from '@nestjs/swagger';
import { IsString, IsUUID, } from 'class-validator';
import { Item } from '../model/item.entity';
import { User } from '../user.decorator';

export class ItemDTO implements Readonly<ItemDTO> {
  @ApiModelProperty({ required: true })
  @IsUUID()
// item.module.ts

import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ItemService } from './item.service';
import { ItemController } from './item.controller';
import { Item } from '../model/item.entity';

@Module({
// item.controller.ts

import { Controller, Get } from '@nestjs/common';
import { ItemService } from './item.service';

@Controller('item')
export class ItemController {
  constructor(private serv: ItemService) { }