Skip to content

Instantly share code, notes, and snippets.

View positlabs's full-sized avatar
🌶️
Focusing

Josh Beckwith positlabs

🌶️
Focusing
View GitHub Profile
@bartwttewaall
bartwttewaall / FitFillTest.js
Last active June 6, 2023 15:11
Fit, fill, stretch a texture on a mesh when given the mesh's aspect ratio
import {
Object3D,
Cache,
Texture,
PlaneGeometry,
MeshLambertMaterial,
Mesh,
ClampToEdgeWrapping,
RepeatWrapping,
MirroredRepeatWrapping,
@robertlugg
robertlugg / object_query.js
Created October 31, 2018 07:20
Lens Studio scene object hierarchy
// -----JS CODE-----
function showProps(obj, pre) {
pre = pre || ''
var result = '';
result += pre + "Properties\n";
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
result += pre + ' .' + i + ' = ' + obj[i] + '\n';
}
}
@NeuroWinter
NeuroWinter / ffmpeg cheatsheet for glitching
Last active April 13, 2024 09:09
ffmpeg cheatsheet for glitching
FFMPEG '-i', file, '-c:v', 'libopenjpeg', "jpeg2000\\" + name + ".jp2"\
Convert image to jpeg2000
ffmpeg -i in.png -c:v libopenjpeg out.jp2
Hex Edit out.jp2
ffmpeg -i in.jp2 -c:v png out.png
General Edit
ffmpeg -i input.avi -c:v mpeg2video -g 999 -q:v 1 output.avi
*edit in avidemux/whatever*
@xposedbones
xposedbones / map.js
Last active March 23, 2024 19:12
Javascript Map range of number to another range
Number.prototype.map = function (in_min, in_max, out_min, out_max) {
return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
@josteink
josteink / on_stateful_code.txt
Last active October 21, 2020 05:37
On why stateful code is bad
On why stateful code is bad
===========================
STUDENT: Sir, can I ask a question?
TEACHER: Yes!
STUDENT: How do you put an elephant inside a fridge?
TEACHER: I don't know.
STUDENT: It's easy, you just open the fridge and put it in. I have another question!
TEACHER: Ok, ask.
STUDENT: How to put a donkey inside the fridge?
@Vestride
Vestride / encoding-video.md
Last active March 12, 2024 16:41
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active April 16, 2024 13:06
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@rolftimmermans
rolftimmermans / compress-folder-with-tinypng.jsx
Created June 25, 2014 14:24
Compressing all PNG images in a folder and its subfolders with TinyPNG
#target photoshop
/* Open the given file, and compress with TinyPNG. */
function compressFile(file) {
var document = open(file);
if (document.mode == DocumentMode.INDEXEDCOLOR) {
document.changeMode(ChangeMode.RGB);
}
@butelo
butelo / crosswalkview.md
Created March 5, 2014 11:35
How to use CrossWalk runtime within an Android application

So, what is crosswalk and why do I care? Take a look at the website: https://crosswalk-project.org/

CrossWalk is a HTML5 runtime, you can use it to create HTML5 applications with 'native features' You can use CrossWalk to create HTML5-only applications for Android (x86 and arm architectures) and Tizen but you can also use CrossWalk as a View within an android project.

This means you can replace Android WebView with XWalkView and get some extra features like:

@addyosmani
addyosmani / headless.md
Last active July 18, 2023 18:47
So, you want to run Chrome headless.

Update May 2017

Eric Bidelman has documented some of the common workflows possible with headless Chrome over in https://developers.google.com/web/updates/2017/04/headless-chrome.

Update

If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md

Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.