Skip to content

Instantly share code, notes, and snippets.

@ektogamat
ektogamat / AnimateCamera.jsx
Created March 14, 2024 01:22
useGSAP with React Three Fiber Camera Animation
import { useThree } from '@react-three/fiber'
import { gsap } from 'gsap'
import { useGSAP } from '@gsap/react'
export default function AnimateCamera() {
// Accessing camera from Three.js
const { camera } = useThree()
useGSAP(() => { // The new hook will take care of context and life cicle.
gsap.fromTo( // Creates the animation
@vassvik
vassvik / Simulation_Projection.md
Last active March 27, 2024 09:31
Realtime Fluid Simulation: Projection

Realtime Fluid Simulation: Projection

The core of most real-time fluid simulators, like the one in EmberGen, are based on the "Stable Fluids" algorithm by Jos Stam, which to my knowledge was first presented at SIGGRAPH '99. This is a post about one part of this algorithm that's often underestimated: Projection

MG4_F32.mp4

Stable Fluids

The Stable Fluids algorithm solves a subset of the famous "Navier Stokes equations", which describe how fluids interact and move. In particular, it typically solves what's called the "incompressible Euler equations", where viscous forces are often ignored.

@dabit3
dabit3 / App.js
Last active November 16, 2022 05:46
Persisting a keypair for reading across clients
/*
* this file includes both a node.js script for creating a keypair
* as well as the client code for using it
*/
/* createKeypair.js */
const fs = require('fs')
const anchor = require("@project-serum/anchor");
const web3 = require('@solana/web3.js')
const account = anchor.web3.Keypair.generate();
@kennethnwc
kennethnwc / .dockerignore
Last active February 28, 2024 10:21
My docker-compose with nextjs and nginx
.next/
node_modules/
Dockerfile
yarn-error.log
.dockerignore
.git
.gitignore
@itsabdessalam
itsabdessalam / development.yml
Created August 17, 2020 06:49
development.yml
name: Development workflow
on:
push:
branches:
- develop
jobs:
build:
runs-on: ubuntu-latest
@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
}
@jennmueng
jennmueng / dragger.js
Created February 3, 2019 15:30
Snippet for the dragger animations.
// @flow
...
/*
this.animationKey is transitioned between 3 values: 0, 1, and 2.
0 is when dragger is not active.
1 is when a touch is active on dragger but not attached to a dropzone.
2 is when a touch is active on dragger and attached to dropzone.
*/
@bvaughn
bvaughn / index.md
Last active April 3, 2024 07:41
Interaction tracing with React

This API was removed in React 17


Interaction tracing with React

React recently introduced an experimental profiler API. After discussing this API with several teams at Facebook, one common piece of feedback was that the performance information would be more useful if it could be associated with the events that caused the application to render (e.g. button click, XHR response). Tracing these events (or "interactions") would enable more powerful tooling to be built around the timing information, capable of answering questions like "What caused this really slow commit?" or "How long does it typically take for this interaction to update the DOM?".

With version 16.4.3, React added experimental support for this tracing by way of a new NPM package, scheduler. However the public API for this package is not yet finalized and will likely change with upcoming minor releases, so it should be used with caution.

@chriseth
chriseth / snarktest.solidity
Last active December 3, 2023 07:03
zkSNARKs test code
// This file is MIT Licensed.
//
// Copyright 2017 Christian Reitwiessner
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF O