Skip to content

Instantly share code, notes, and snippets.

View peterp's full-sized avatar

Peter Pistorius peterp

View GitHub Profile
➜ x yarn rw build -v
[STARTED] Generating Prisma Client...
Prisma schema loaded from db/schema.prisma
✔ Generated Prisma Client (v5.9.1) to ./../node_modules/@prisma/client in 31ms
Start using Prisma Client in Node.js (See: https://pris.ly/d/client)
```
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
@peterp
peterp / Dockerfile
Created May 30, 2023 13:22
Snaplet Instant Preview Databases PostgreSQL on Fly Machines
FROM postgres:14.4-alpine
COPY postgresql.conf /etc/postgresql/
COPY stop-postgres-on-idle.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/stop-postgres-on-idle.sh
RUN echo '* * * * * /usr/local/bin/stop-postgres-on-idle.sh' > /etc/crontabs/root
COPY custom-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/custom-entrypoint.sh
@peterp
peterp / 1.js
Last active June 2, 2022 13:37
Mapped data values with Copycat
faker.internet.email.()
'Elva67@hotmail.com'
faker.internet.email.()
'Lonny74@yahoo.com
'faker.internet.email.()
'Clara16@hotmail.com’
faker.internet.email.()
'Gaetano87@yahoo.com’
import { transformSync } from '@swc/core'
import path from 'path'
import { AliasPathResolver } from './index'
test('named `src` imports', () => {
// create resolved path.
const out = transformSync(
`
import { woof } from 'src/lib/dog.ts'
@peterp
peterp / svgs2pngs.sh
Created July 23, 2017 07:48
React Native: Convert SVG images to PNG images
#!/bin/sh
rsvg-convert -v > /dev/null 2>&1 || { echo "rsvg-convert is not installed, use: brew install librsvg." >&2; exit 1; }
ASSETS_FOLDER=$1
if [ "$ASSETS_FOLDER" == "" ]; then
echo "Usage: $0 /path/to/svg/assets/" >&2
exit 1
fi
@peterp
peterp / gist:5199702
Last active December 15, 2015 04:09
Regex to parse a URL.
(?:http://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.
)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)
){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F
\d]{2}))|[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{
2}))|[;:@&=])*))*)(?:\?(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{
2}))|[;:@&=])*))?)?)|(?:ftp://(?:(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?
:%[a-fA-F\d]{2}))|[;?&=])*)(?::(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-
fA-F\d]{2}))|[;?&=])*))?@)?(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-
)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?
:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?))(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!