Skip to content

Instantly share code, notes, and snippets.

View pdevito3's full-sized avatar

Paul DeVito pdevito3

View GitHub Profile
@d1820
d1820 / BuilderResult.cs
Last active November 27, 2023 22:17
.Net Controller Unit Test Mock Builder
using System.Security.Claims;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Moq;
namespace Infrastructure.Testing.Builders
{
public class BuilderResult : HttpContextBuilderResult
{
@gvdonovan
gvdonovan / App.js
Last active March 22, 2020 16:42
TW UI Application Shell - React
import React, { Component } from "react";
import UserProfileMenu from "./UserProfileMenu";
function classNames(...classes) { return classes.filter(Boolean).join(" "); }
class App extends Component {
constructor(props) {
super(props);
this.state = { isToggleOn: false };
}

Converting Tailwind UI Alpine transitions to Vue transitions

After you copy a component from the Tailwind UI library and begin to adapt it from Vue JS to Alpine JS .. you may wonder what to do about the transitions. As I'm exploring this myself, I am documenting it for others in the same boat.

Things to be aware of:

  • Alpine calls the beginning and ending states "start" & "end"
  • Vue calls the beginning and ending states "from" and "to"
  • Alpine has inline "directives" ie x-transition:enter="classes"
  • Vue has a wrapper component that applies classes to the child
  • Alpine applies the classes you pass it for each state, :enter-start="class"
@morajabi
morajabi / useRect.js
Created February 18, 2019 14:35
useRect — getBoundingClientRect() React Hook with resize handler
import { useLayoutEffect, useCallback, useState } from 'react'
export const useRect = (ref) => {
const [rect, setRect] = useState(getRect(ref ? ref.current : null))
const handleResize = useCallback(() => {
if (!ref.current) {
return
}
@jboner
jboner / latency.txt
Last active May 10, 2025 11:02
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD