Skip to content

Instantly share code, notes, and snippets.

View neefrehman's full-sized avatar
♻️
.reduce() reuse recycle

Neef Rehman neefrehman

♻️
.reduce() reuse recycle
View GitHub Profile
import React, { useRef, useEffect } from "react";
import glsl from "glslify";
import { useAnimationFrame } from "hooks/useAnimationFrame";
import {
compileShader,
getAttributeLocation,
getUniformLocation,
GL,
@neefrehman
neefrehman / ReactP5Renderer.js
Last active August 12, 2020 14:24
A react wrapper for p5 sketches. Handles rendering and cleanup.
/* eslint-disable no-new */ /* <- p5 constructor required */
/* eslint-disable new-cap */ /* <- p5 constructor used with lowercase p */
import React, { useRef, useEffect } from "react";
import p5 from "p5";
/**
* A wrapper component for running P5 sketches. Handles rendering and cleanup.
*/
export const P5Wrapper = ({
sketch,
@neefrehman
neefrehman / tag_time_travel.sh
Created December 18, 2018 12:55
Edit the date of git tags to the dates of the associated commits, while keeping messages for annotated tags
$ git tag -l | while read -r tag ; do COMMIT_HASH=$(git rev-list -1 $tag) COMMIT_MSG=$(git tag -l --format='%(contents)' $tag | head -n1) && GIT_COMMITTER_DATE="$(git show $COMMIT_HASH --format=%aD | head -1)" git tag -a -f $tag -m"$COMMIT_MSG" $COMMIT_HASH ; done
$ git tag -l -n1 #check by listing all tags with first line of message
$ git push --tags --force #push edited tags up to remote
@neefrehman
neefrehman / lzy.js
Last active December 14, 2018 15:43
lil' lazy loader
const lzy = ({ offset } = {}) => {
const images = document.querySelectorAll("[data-src]");
const config = {
rootMargin: offset ? `${offset}px ${offset}px` : "200px 200px",
threshold: 0.01
};
function loadImage(imageEl) {
const imageSource = imageEl.getAttribute("data-src");
@neefrehman
neefrehman / bling.js
Last active December 7, 2018 12:42 — forked from paulirish/bling.js
bling dot js + $$
/* bling.js */
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@neefrehman
neefrehman / wipe.css
Last active November 9, 2018 12:09
Wipe image in when hovering on a different element, with only HTML/CSS - as seen on https://neef.co
img.bg {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 100vh;
height: 100vh;
z-index: -2;
clip-path: circle(0% at center);
transition: clip-path 0.5s cubic-bezier(0.65, 0.05, 0.36, 1);