Skip to content

Instantly share code, notes, and snippets.

View stolinski's full-sized avatar
💭
Syntax.fm

Scott Tolinski stolinski

💭
Syntax.fm
View GitHub Profile
@stolinski
stolinski / drizzle-error.ts
Created January 4, 2024 04:59
Error: There is not enough information to infer relation "__public__.habits.checks" at normalizeRelation
// Schema
import { relations } from 'drizzle-orm';
import { serial, text, timestamp, pgTable, date, integer } from 'drizzle-orm/pg-core';
export const habits = pgTable('habits', {
id: serial('id').primaryKey(),
name: text('name'),
days_per_month: integer('days_per_month'),
created_at: timestamp('created_at'),
updated_at: timestamp('updated_at')
@stolinski
stolinski / mockingvite.ts
Last active July 19, 2022 17:25
Mockingoose Vitest
// Mockingvite = Vitest + Mockingoose aka Mongoose Mocking for Vitest
// A Vitest compatable version of Mockingoose
// Docs avaiable here https://github.com/alonronin/mockingoose
// Support my work by becoming a Level Up Pro - leveluptutorials.com
import { vi } from 'vitest'
import mongoose from 'mongoose'
if (!/^5/.test(mongoose.version)) {
@stolinski
stolinski / Example.tsx
Last active June 8, 2022 05:54
Route Transitions with Framer Motion
const FakeComponent = () => {
return (
<AnimatedRoutes exitBeforeEnter initial={false}>
<RouteTransition exact path="/some-route">
<NewUsers />
</RouteTransition>
<RouteTransition exact path="/yo" >
<Users />
</RouteTransition>
</AnimatedRoutes>
@stolinski
stolinski / Routes.js
Last active June 8, 2022 05:53
React Spring React Router Starter
import React from 'react';
import { BrowserRouter as Router, Switch, Route, Link } from 'react-router-dom';
const Routes = () => {
return (
<Router>
<ul className="router-nav">
<NavLink to="/">One</NavLink>
<NavLink to="/two">Two</NavLink>
<NavLink to="/three">Three</NavLink>
@stolinski
stolinski / providerCompose.js
Created April 23, 2019 17:40
ProviderComposer
function ProviderComposer({ contexts, children }) {
return contexts.reduceRight(
(kids, parent) =>
React.cloneElement(parent, {
children: kids,
}),
children
);
}
@stolinski
stolinski / Waypoints.js
Created April 18, 2019 19:22
Waypoints Component For Animating React
import React from 'react'
const Waypoints = () => {
return (
<div className="waypoints">
<p>
Lorem ipsum dolor amet poutine pitchfork tattooed venmo, heirloom cliche chartreuse gentrify mumblecore hammock single-origin coffee banh mi. Sartorial unicorn 90's edison bulb iPhone. Leggings pickled brunch neutra tousled. Occupy fixie affogato pinterest vaporware aesthetic, tbh subway tile hammock next level prism vape lomo taiyaki kale chips. Jianbing knausgaard taxidermy squid artisan thundercats, gochujang subway tile air plant taiyaki master cleanse cray.
</p>
<p>
Pug godard pour-over 90's direct trade, PBR&B +1 next level organic edison bulb quinoa DIY. Taiyaki sriracha unicorn, cronut taxidermy chicharrones four dollar toast keytar cold-pressed raclette yuccie cray iceland. Roof party knausgaard neutra plaid, pork belly chambray banh mi chia. Blue bottle narwhal iceland health goth cornhole fam humblebrag flannel pitchfork pickled.
@stolinski
stolinski / useMeasure.js
Created April 18, 2019 18:16
useMeasure - taken from React Spring example
import { useRef, useState, useEffect } from 'react'
import ResizeObserver from 'resize-observer-polyfill'
export default function useMeasure() {
const ref = useRef()
const [bounds, set] = useState({ left: 0, top: 0, width: 0, height: 0 })
const [ro] = useState(() => new ResizeObserver(([entry]) => set(entry.contentRect)))
useEffect(() => (ro.observe(ref.current), ro.disconnect), [])
return [{ ref }, bounds]
}
@stolinski
stolinski / mongoose+5.11.8.patch
Created February 2, 2021 17:33
Patch to fix mongoose for esbuild
diff --git a/node_modules/mongoose/lib/index.js b/node_modules/mongoose/lib/index.js
index 1425cfa..631eba5 100644
--- a/node_modules/mongoose/lib/index.js
+++ b/node_modules/mongoose/lib/index.js
@@ -732,19 +732,19 @@ Mongoose.prototype.connections;
* Driver dependent APIs
*/
-const driver = global.MONGOOSE_DRIVER_PATH || './drivers/node-mongodb-native';
+
@stolinski
stolinski / gist:455135717c9e146f83955533860d58b0
Created November 13, 2020 22:12
Fake Contract - DO NOT USE
This Freelance Contract (this “Contract” or this “Freelance Contract”), is entered into and made effective as of [date] (the “Effective Date”), by and between [customer] (“Customer”), and [freelancer] (“Freelancer”).
WHEREAS:
Customer has a need for [services] and
Freelancer has an interest in performing such services for Customer; and
The parties wish to set forth the terms and conditions upon which such services will be provided to Customer;
NOW THEREFORE, in consideration of the foregoing, and the mutual promises herein contained, the parties hereby agree as follows:
Terms and Conditions
@stolinski
stolinski / react-cloudinary.js
Created October 18, 2017 14:23
Client side Image Upload To Cloudinary React Dropzone
// get's called from react dropzone when file is dropped
onImageDrop = (files) => {
this.handleImageUpload(files[0]);
}
async handleImageUpload(file) {
const data = new FormData();
data.append('file', file);
data.append('upload_preset', CLOUDINARY_UPLOAD_PRESET);
const upload = await fetch(CLOUDINARY_UPLOAD_URL, {