Skip to content

Instantly share code, notes, and snippets.

View ItsWendell's full-sized avatar

Wendell Misiedjan ItsWendell

View GitHub Profile
@Ventanas95Dev
Ventanas95Dev / StoryblokPreviewSyncer
Last active October 6, 2024 10:43
Next.js (app router) React server components and Storyblok Preview "real time update" 🎉
'use client'
import { useEffect, useTransition } from 'react'
import { registerStoryblokBridge } from './registerStoryblokBridge'
import { previewUpdateAction } from '../../app/actions/previewUpdateAction'
export const StoryblokPreviewSyncer = ({ storyId, pathToRevalidate }) => {
let [isPending, startTransition] = useTransition()
useEffect(() => {
const id = storyId
@colelawrence
colelawrence / createTrpcDurableObject.ts
Last active March 27, 2024 22:10
Create strongly typed Durable Objects with TRPC wrappers (requires trpc@10)
import { createTRPCProxyClient, httpLink } from "@trpc/client";
import { AnyRouter, initTRPC, MaybePromise, Router } from "@trpc/server";
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import type { ParserWithInputOutput, ParserWithoutInput } from "@trpc/server/dist/core/parser";
import type { AnyRouterDef } from "@trpc/server/dist/core/router";
import type { ResponseMetaFn } from "@trpc/server/dist/http/internals/types";
import { getParseFn } from "./getParseFn";
export type TrpcDurableObjectRouter<Router extends AnyRouter> = {
router: Router,
@maaft
maaft / mutate-schema.py
Created June 2, 2022 16:43
This will mutate an extracted GraphQL Schema from Hasura to add client-side custom type support for JSONB columns
from pathlib import Path
from typing import Optional, Set
from gql import gql
from graphql import GraphQLEnumType, GraphQLFieldMap, GraphQLInputObjectType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, extend_schema, build_ast_schema
from graphql.utilities import print_schema
#############
# HOWTO
@joelonsql
joelonsql / PostgreSQL-EXTENSIONs.md
Last active November 13, 2024 09:01
1000+ PostgreSQL EXTENSIONs

🗺🐘 1000+ PostgreSQL EXTENSIONs

This is a list of URLs to PostgreSQL EXTENSION repos, listed in alphabetical order of parent repo, with active forks listed under each parent.

⭐️ >= 10 stars
⭐️⭐️ >= 100 stars
⭐️⭐️⭐️ >= 1000 stars
Numbers of stars might not be up-to-date.

@kjmph
kjmph / A_UUID_v7_for_Postgres.sql
Last active November 6, 2024 19:57
Postgres PL/pgSQL function for UUID v7 and a bonus custom UUID v8 to support microsecond precision as well. Read more here: https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
-- Based off IETF draft, https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
create or replace function uuid_generate_v7()
returns uuid
as $$
begin
-- use random v4 uuid as starting point (which has the same variant we need)
-- then overlay timestamp
-- then set version 7 by flipping the 2 and 1 bit in the version 4 string
return encode(
@codefrau
codefrau / cloudflare-timeout.mjs
Last active September 6, 2021 21:06
Workaround for "Cannot clear a timeout created in a different request context" error in Cloudflare Workers
// Replacement for setTimeout/clearTimeout in Cloudflare Workers
// Avoids "Cannot clear a timeout created in a different request context" error
//
// Usage:
// import { setTimeout, clearTimeout } from "./cloudflare-timeout.mjs"
//
// Author: Vanessa "Codefrau" Freudenberg <[email protected]>
export function setTimeout(func, ...opts) {
const timeout = { cancelled: false };
@SuperSpyTX
SuperSpyTX / README.md
Last active February 20, 2022 12:10
42 Norminette linter for ALE.

Norminette Linter for ALE (Asynchronous Linting Engine)

https://github.com/w0rp/ale

Installation

Install this in your ale plugin directory (For Vundle + NeoVim that may be ~/.config/nvim/bundle/ale/ale_linters/c/norminette.vim)

You will of course, need the norminette ruby gem in your PATH. gem install --user --pre norminette

@saqueib
saqueib / 0_uploader.blade.php
Last active June 9, 2021 15:57
Reusable upload component in Laravel with Dropzone.js - visit http://wp.me/p8cmxL-9Q for tutorial
@php $dropzoneId = isset($dz_id) ? $dz_id : str_random(8); @endphp
<div id="{{$dropzoneId}}" class="dropzone">
<div class="dz-default dz-message">
<h3>{{ $title or 'Drop files here or click to upload.'}}</h3>
<p class="text-muted">{{ $desc or 'Any related files you can upload' }} <br>
<small>One file can be max {{ config('attachment.max_size', 0) / 1000 }} MB</small></p>
</div>
</div>
<!-- Dropzone {{ $dropzoneId }} -->
@gregblass
gregblass / App.js
Last active September 21, 2019 17:30
Expo/React Navigation - Google Analytics Integration
import React, { Component } from 'react'
import { RootNavigator } from './navigators'
import { GoogleAnalyticsTracker } from './utils/analytics'
import { GA_TRACKING_ID } from './constants'
class App extends Component {
// gets the current screen from navigation state
getCurrentRouteName = (navigationState) => {
if (!navigationState) {
return null