Skip to content

Instantly share code, notes, and snippets.

@esamattis
esamattis / graphql.php
Last active May 11, 2020 10:43
wp-graphql cache
<?php
// UPDATE! Checkout this plugin https://github.com/valu-digital/wp-graphql-cache
// Requires some persistent object cache such as wp-redis.
define( 'WP_GRAPHQL_CACHE_AGE', 10 ); // in seconds
add_action( 'do_graphql_request', function () {
@inorganik
inorganik / bash_profile.sh
Created August 22, 2018 19:25
nvmrc hook for bash profile
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
enter_directory() {
if [[ $PWD == $PREV_PWD ]]; then
return
fi
PREV_PWD=$PWD
@liborvanek
liborvanek / transition.js
Last active April 26, 2023 11:43
Page transition mixin for Nuxt.js with GreenSock GSAP
import { TimelineMax, TweenMax, Power2, Back } from 'gsap'
let curtainsOpenTimeline = () => {
return new TimelineMax()
.set('.curtains', { transformOrigin: '0%' })
.fromTo('.curtains', 0.6, { scaleX: 0 }, { scaleX: 1, ease: Power2.easeInOut })
.fromTo('.curtains-logo', 0.3, { x: '-100%', autoAlpha: 0 }, { x: '-50%', autoAlpha: 1, ease: Power2.easeInOut }, '-=0.45')
}
let curtainsCloseTimeline = () => {
@David-Melo
David-Melo / feathers-express-multipart.js
Created June 22, 2018 14:42
Feathers.js/Express.js Multi-Part Upload Handler
const BlobService = require('feathers-blob');
const fs = require('fs-blob-store');
const multer = require('multer');
const multipartMiddleware = multer();
const { getBase64DataURI } = require('dauria');
const blobStorage = fs(__dirname + '/uploads');
module.exports = function (app) {
@akella
akella / facebook-normalize-wheel.js
Created November 25, 2017 22:49
Facebook attempt at normalizing wheel event
/**
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule normalizeWheel
* @typechecks
@Strae
Strae / check_if_entity_is_in_the_viewport.js
Created November 15, 2017 11:20
Aframe entity in viewport / visible
//RETURNS TRUE/FALSE BASED ON WHETHER OR NOT THE ENTITY IS VISIBLE
checkIfVisible(entity, camera){
let entityMesh = entity.object3DMap.mesh;
let frustum = new THREE.Frustum();
let cameraViewProjectionMatrix = new THREE.Matrix4();
camera.updateMatrixWorld();
camera.matrixWorldInverse.getInverse(camera.matrixWorld);
cameraViewProjectionMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
@troyharvey
troyharvey / deployment.yml
Last active June 7, 2024 15:09
Using Kubernetes envFrom for environment variables
# Use envFrom to load Secrets and ConfigMaps into environment variables
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: mans-not-hot
labels:
app: mans-not-hot
spec:
replicas: 1
@teocci
teocci / compile_ffmpeg.md
Last active December 18, 2022 00:15
Compile FFmpeg on Ubuntu 16.04

Compile FFmpeg on Ubuntu

This basic guide supports Ubuntu Xenial Xerus 16.04 and will enable several external encoding and decoding libraries: libfaac (AAC encoder), libfdk-aac (AAC encoder), libmp3lame (MP3 encoder), libopencore-amr (AMR encoder/decoder), librtmp (for additional RTMP protocols), libtheora (Theora encoder), libvorbis (Vorbis encoder), libvpx (VP8 encoder/decoder), and libx264 (H.264 encoder). These are optional and may be omitted if desired. This guide will also install many filters (see the filter list in the [Filtering Guide][1].

Note: Copy and paste the whole code box for each step.

Preparation

@javisperez
javisperez / interceptors.js
Last active December 4, 2022 16:47
Axios interceptor for cache with js-cache
// Usually I use this in my app's config file, in case I need to disable all cache from the app
// Cache is from `js-cache`, something like `import Cache from 'js-cache';`
const cacheable = true,
cache = new Cache();
// On request, return the cached version, if any
axios.interceptors.request.use(request => {
// Only cache GET requests
if (request.method === 'get' && cacheable) {
@dmnsgn
dmnsgn / WebGL-WebGPU-frameworks-libraries.md
Last active June 6, 2024 15:56
A collection of WebGL and WebGPU frameworks and libraries

A non-exhaustive list of WebGL and WebGPU frameworks and libraries. It is mostly for learning purposes as some of the libraries listed are wip/outdated/not maintained anymore.

Engines and libraries ⚙️

Name Stars Last Commit Description
three.js ![GitHub