Skip to content

Instantly share code, notes, and snippets.

View supahfunk's full-sized avatar

Supah supahfunk

View GitHub Profile
@hayageek
hayageek / Google URL Shortener API
Last active May 21, 2019 11:57
Google URL Shortener API Javascript Example
<html>
<head>
</head>
<script type="text/javascript">
function makeShort()
{
var longUrl=document.getElementById("longurl").value;
var request = gapi.client.urlshortener.url.insert({
'resource': {
'longUrl': longUrl
@jeanlescure
jeanlescure / TransformationShader.js
Last active August 24, 2023 02:06
ThreeJS: Vertex shader for translating, scaling, and rotating. Fragment shader for adding texture and controlling opacity.
THREE.TransformationShader = {
defines: {},
uniforms: {
"tDiffuse": { type: "t", value: texture },
"opacity": { type: "f", value: 1.0 },
"translationX": { type: "f", value: 1.0 },
"translationY": { type: "f", value: 1.0 },
"translationZ": { type: "f", value: 1.0 },
"scaleX": { type: "f", value: 1.0 },
@paulirish
paulirish / what-forces-layout.md
Last active June 26, 2024 20:47
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@superguigui
superguigui / README.md
Last active December 13, 2022 21:38
Three-orbit-controls with rotation set methods

I added a few methods to three-orbit-controls to be able to manually define phi or theta and be able to rotate to a given point.

// rotation in Y
controls.setAzimuthalAngle(theta);

// rotation in X
controls.setPolarAngle(phi);
@only-cliches
only-cliches / pixibackground.js
Last active March 14, 2024 12:07
PixiJS Background Cover & Background Container
/*
* PixiJS Background Cover/Contain Script
* Returns object
* . {
* container: PixiJS Container
* . doResize: Resize callback
* }
* ARGS:
* bgSize: Object with x and y representing the width and height of background. Example: {x:1280,y:720}
* inputSprite: Pixi Sprite containing a loaded image or other asset. Make sure you preload assets into this sprite.
@markreid
markreid / gitflowrebasing.md
Created January 17, 2017 04:30
git flow with rebasing
@Volcanoscar
Volcanoscar / greyscale.frag
Created January 19, 2017 08:28 — forked from wiseoldduck/greyscale.frag
A simple glsl color -> greyscale shader, using luminosity method
// fragment shader
//
// RGBA color to RGBA greyscale
//
// smooth transition based on u_colorFactor: 0.0 = original, 1.0 = greyscale
//
// http://www.johndcook.com/blog/2009/08/24/algorithms-convert-color-grayscale/
// "The luminosity method is a more sophisticated version of the average method.
// It also averages the values, but it forms a weighted average to account for human perception.
// We’re more sensitive to green than other colors, so green is weighted most heavily. The formula
@ayamflow
ayamflow / gist:96a1f554c3f88eef2f9d0024fc42940f
Last active May 15, 2024 12:37
Threejs Fit plane to screen
var cameraZ = camera.position.z;
var planeZ = 5;
var distance = cameraZ - planeZ;
var aspect = viewWidth / viewHeight;
var vFov = camera.fov * Math.PI / 180;
var planeHeightAtDistance = 2 * Math.tan(vFov / 2) * distance;
var planeWidthAtDistance = planeHeightAtDistance * aspect;
// or
@companje
companje / map.glsl
Created January 23, 2018 22:46
map() function for GLSL known from Processing & openFrameworks
float map(float value, float min1, float max1, float min2, float max2) {
return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
}
@martinruenz
martinruenz / ffmpeg-snippets.md
Last active November 15, 2022 06:39
ffmpeg snippets / cheatsheet