Skip to content

Instantly share code, notes, and snippets.

View matthewmorek's full-sized avatar
🙈
Breaking builds

Matthew Morek matthewmorek

🙈
Breaking builds
View GitHub Profile
@realvjy
realvjy / ChoasLinesShader.metal
Last active May 10, 2024 08:31
Choas Lines - Metal Shader
// Lines
float hash( float n ) {
return fract(sin(n)*753.5453123);
}
// Slight modification of iq's noise function.
float noise(vector_float2 x )
{
vector_float2 p = floor(x);
vector_float2 f = fract(x);
import SwiftUI
struct ChatGPTTextField: View {
// MARK: - State
/// State to hold our `TextField` query.
@State private var queryMessage: String = ""
/// Focus state for our `TextField`.
@bbauman1
bbauman1 / AlertItem.swift
Created August 13, 2023 19:39
SwiftUI Alerts
//
// AlertItem.swift
//
// Created by Brett Bauman on 7/25/23.
import Foundation
import SwiftUI
struct AlertItem: Identifiable {
@kylewelsby
kylewelsby / 20230504090000_tracks.sql
Last active May 17, 2023 11:05
Slugify and Pathify
CREATE TABLE public.artists (
title character varying NOT NULL,
slug character varying NOT NULL,
id SERIAL PRIMARY KEY -- I use a different ID technique
);
ALTER TABLE public.artists OWNER TO postgres;
CREATE TABLE public.tracks (
@mathesond2
mathesond2 / react-performance.md
Last active January 25, 2024 09:26
Notes on React Performance

React Performance

Notes From Steve Kinney's "React Performance" Frontend Masters Course

General

re: optimizations: "Start with a problem first, then solve it. dont go looking for problems."

"measure first before you optimize for performance. And then measure again."

//
// Created by Adam Whitcroft on 2023-01-23.
//
import SwiftUI
struct SimpleDragGesture: View {
@State private var focussedItem: String = "middle"
@State private var offset = CGSize.zero
@State private var accumulatedOffset = CGSize.zero
@stammy
stammy / LiquidBlobs.swift
Last active April 3, 2024 20:55
Liquid Blob effect with SwiftUI
//
// ContentView.swift
// LiquidCircles
//
// Created by Paul Stamatiou on 10/10/22.
//
import SwiftUI
struct ContentView: View {
@mhaecal
mhaecal / middleware.ts
Created July 19, 2022 08:25
Protected Routes Middleware NextJS 12
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function middleware(req: NextRequest) {
// get cookie token
const hasToken = req.cookies.get('token')
// protected routes (admin routes)
if (req.nextUrl.pathname.startsWith('/admin')) {
if (hasToken) {
@ramirezsandin
ramirezsandin / useRouterParams.ts
Last active October 23, 2023 07:58
React hook to be used with Next.js, it uses useRouter internally and offers some helper functions to manipulate the url query params.
import { useRouter } from "next/router";
import { ParsedUrlQuery } from "querystring";
interface UseRouterParamsOptions {
method?: "push" | "replace";
shallow?: boolean;
}
const useRouterParams = (options?: UseRouterParamsOptions) => {
const { query, pathname, push, replace } = useRouter();
@magalhaespaulo
magalhaespaulo / Modal.tsx
Last active June 1, 2023 21:46
Accessible <Modal /> with Framer Motion and Tailwind CSS
// Accessible Modal.tsx with
// Framer Motion and Tailwind CSS
// 10 Examples in the comments section below
import { createPortal } from 'react-dom'
import { Dispatch, HTMLAttributes, SetStateAction, useEffect, useState } from 'react'
import { AnimatePresence, motion } from 'framer-motion'
import FocusLock from 'react-focus-lock'
const effect = {
hidden: {