Skip to content

Instantly share code, notes, and snippets.

@ptheofan
ptheofan / create-react-18-app-after-react-19-is-out.md
Last active February 12, 2025 10:15
Create React 18 app after React 19 is out.

React 19 came out and npx create app is using it but it's not working as expected as testing library is not up-to-date yet.

Original Post

facebook/react#32016 (comment)

Posted Solution

The workflows that solve version incompatibility issues without --force or --legacy-peer-deps and restrict the versions to current up-to-date ones. Make sure the last command runs without errors (vulnerability warnings don't count)

Javascript

@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
@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 / 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 / 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 / Color.js
Created January 14, 2022 17:42
Color Handling Class (v0.0.1)
export class Color {
/** @type {number} range 0 to 1 */
#r = 0.0;
/** @type {number} range 0 to 1 */
#g = 0.0;
/** @type {number} range 0 to 1 */
#b = 0.0;
/** @type {number} range 0 to 1 */
#h = 0.0;
/** @type {number} range 0 to 1 */
1. First go to the console, click the volume, actions and grow it.
2. ssh to the machine
```bash
> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 89.1M 1 loop /snap/core/8039
loop1 7:1 0 18M 1 loop /snap/amazon-ssm-agent/1480
loop2 7:2 0 89.1M 1 loop /snap/core/8213
nvme0n1 259:0 0 40G 0 disk
<?php
[
'dsn' => 'mongodb://username:[email protected]:27017/database_name',
'options' => [
'ssl' => true,
'tlsAllowInvalidCertificates' => true,
'tlsAllowInvalidHostnames' => true,
'tlsCAFile' => '/apps/certificates/rds-combined-ca-bundle.pem',
],
]
local ret_status="$FG[255]$BG[$THEME_HOST_BG] %m %{$reset_color%} %(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
RPROMPT="[ %D{%H:%M} ]"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
<?php
use yii\db\ActiveQuery;
use yii\db\ActiveRecord;
class Account extends ActiveRecord
{
public static function tableName()
{
return 'account';
}