Skip to content

Instantly share code, notes, and snippets.

@ptheofan
ptheofan / nginx.conf
Created February 3, 2022 21:15 — forked from mreschke/nginx.conf
Nginx config for multiple laravel sites based on /api/v1 url paths
# This config will host your main [Laravel] GUI application at /, and any additional [Lumen] webservices at /api/v1 and /api/v2...
# This also works perfectly for all static file content in all projects
# This is full of debug comments so you can see how to print debug output to browser! Took me hours to nail this perfect config.
# Example:
# http://example.com - Main Laravel site as usual
# http://example.com/about - Main Laravel site about page as usual
# http://example.com/robots.txt - Main Laravel site static content as usual
# http://example.com/api/v1 - Lumen v1 api default / route
# http://example.com/api/v1/ - Lumen v1 api default / route
@ptheofan
ptheofan / latestOnly.js
Last active February 16, 2022 14:39
Run only the latest promise. Will cancel all the previous ones. Similar to AbortController which couldn't get to work with Axios. This one works.
// Couldn't get the AbortController to work with Axios post so real quick and dirty, similar solution.
// This does NOT abort the request, it just rejects the concurrently previously running promises.
// Can make it abort also though no need to if AbortController works for you.
//
// How to use
// Just wrap your axios call (or any promise in it).
// first parameter is a uid (use some convenient name)
// latestOnly('mySearchCall', ....)
// if you call latestOnly('mySearchCall') before the promise has resolved the previous (still running) promise will
// return error "AbortError"
@ptheofan
ptheofan / copilot-fun.md
Created March 21, 2023 12:18
copilot-infinite-loop

Having fun with copilot... all I had was a class Token with a handful of properties and then with every new line it went from withoutX to withoutXandXandX.... enjoy... no idea if it would ever really run out of suggesstions there.

get payloadWithoutNulls(): any {
    const payload = this.payload;
    Object.keys(payload).forEach(key => payload[key] == null && delete payload[key]);
    return payload;
  }
  
@ptheofan
ptheofan / docker-compose.yml
Last active January 24, 2024 00:12
Typesense + Mongodb
version: "3.8"
volumes:
imdb-mongodb-primary: {}
imdb-mongodb-secondary: {}
imdb-mongodb-arbiter: {}
services:
mongodb-primary:
image: mongo:latest