Skip to content

Instantly share code, notes, and snippets.

View patriciogonzalezvivo's full-sized avatar

Patricio Gonzalez Vivo patriciogonzalezvivo

View GitHub Profile
@patriciogonzalezvivo
patriciogonzalezvivo / load-files-dir.md
Last active July 14, 2018 06:42
Load all files on a folder with OF
ofDirectory dir(_path);
if(dir.exists()){
	dir.listDir();
    int total = dir.getFiles().size();
    for (int i = 0; i < total; i++) {
        cout << "Loading " << dir.getName(i) << endl;
    }
}
@patriciogonzalezvivo
patriciogonzalezvivo / Tri-planar.md
Created July 1, 2014 19:28
GLSL Triplanar Texture Mapping
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Lights.md
Last active November 16, 2022 01:46
GLSL Shaders Lights Funtions
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active May 10, 2024 02:42
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);
@patriciogonzalezvivo
patriciogonzalezvivo / php-webhook-script.md
Last active August 29, 2015 14:03
Highly insecure way to auto update a repo in a website using WebHooks
<?php
{
    $output = shell_exec("cd /var/www/html/; git pull origin master;");
    echo "<pre>$output</pre>";
}
die("done " . mktime());
?>
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-color.md
Last active August 29, 2022 15:54
GLSL color functions

RGB - YUB

mat3 yuv2rgb = mat3(1.0, 0.0, 1.28033, 1.0, -0.21482, -0.38059, 1.0, 2.12798, 0.0);
mat3 rgb2yuv = mat3(0.2126, 0.7152, 0.0722, -0.09991, -0.33609, 0.43600, 0.615, -0.5586, -0.05639);

RGB - HSV

@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Math.md
Last active April 15, 2024 20:34
GLSL Math functions

Trigonometry

const float PI = 3.1415926535897932384626433832795;
const float PI_2 = 1.57079632679489661923;
const float PI_4 = 0.785398163397448309616;

float PHI = (1.0+sqrtf(5.0))/2.0;
@patriciogonzalezvivo
patriciogonzalezvivo / dd.md
Last active August 29, 2015 14:01
DiskImage Backup and restore

Backup

diskutil list
sudo dd if=/dev/disk1 of=~/Desktop/diskImg.dmg

Restore

@patriciogonzalezvivo
patriciogonzalezvivo / rpi.md
Last active March 25, 2018 09:28
RaspberryPi post-installation

THE BASIC

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install avahi-daemon 

Apache Server

@patriciogonzalezvivo
patriciogonzalezvivo / csv.md
Last active December 27, 2015 19:39
Reading a CSV on OF
ofBuffer buffer = ofBufferFromFile(_file);

while(!buffer.isLastLine()) {
	string temp = buffer.getNextLine();
        
    if(temp.length() != 0) {
        vector<string> values = ofSplitString(temp, ",");
            
 // ofToInt(value[0]);