Skip to content

Instantly share code, notes, and snippets.

View danielstenson's full-sized avatar

Daniel Stenson danielstenson

View GitHub Profile
@thecodeboss
thecodeboss / prisma-slonik-usage.ts
Created July 22, 2022 22:01
Prisma/Slonik Usage Example
import { PrismaClient } from '@prisma/client';
import type { User } from '@prisma/client';
import { createPool, sql } from 'slonik';
export const buildBaseConnectionURL = (config) => {
return (
'postgresql://' +
config.DB_USER +
':' +
config.DB_PASS +
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}