Skip to content

Instantly share code, notes, and snippets.

View ma77os's full-sized avatar

André Mattos ma77os

View GitHub Profile
@fscm
fscm / install_cmake.md
Last active July 16, 2024 11:23
[macOS] Install CMake

[macOS] Install CMake

Instructions on how to install the CMake tool on macOS.

Uninstall

First step should be to unsinstall any previous CMake installation. This step can be skipped if no CMake version was previously installed.

To uninstall any previous CMake installations use the following commands:

@playatwork
playatwork / SimplexNoise3Node.cs
Last active October 26, 2020 17:08
Simplex noise custom node for Shader Graph
//
// Simplex noise custom node for Shader Graph
//
// Original work (webgl-noise) Copyright (C) 2011 Ashima Arts.
// Translation and modification was made by Keijiro Takahashi.
// Ported to Shader Graph by Sergio L. Valladares
//
// This shader is based on the webgl-noise GLSL shader. For further details
// of the original shader, please see the following description from the
// original source code.
@mattdesl
mattdesl / glsl-background.glsl
Created April 26, 2017 18:02
Like CSS background-size: contain but in GLSL
vec2 backgroundUV (vec2 uv, vec2 resolution, vec2 texResolution) {
float tAspect = texResolution.x / texResolution.y;
float pAspect = resolution.x / resolution.y;
float pwidth = resolution.x;
float pheight = resolution.y;
float width = 0.0;
float height = 0.0;
if (tAspect > pAspect) {
height = pheight;
@mattdesl
mattdesl / MeshCustomMaterial.js
Last active June 4, 2024 08:51
Custom mesh standard material with glslify + ThreeJS r83dev
const glslify = require('glslify');
const path = require('path');
// This is the original source, we will copy + paste it for our own GLSL
// const vertexShader = THREE.ShaderChunk.meshphysical_vert;
// const fragmentShader = THREE.ShaderChunk.meshphysical_frag;
// Our custom shaders
const fragmentShader = glslify(path.resolve(__dirname, 'standard.frag'));
const vertexShader = glslify(path.resolve(__dirname, 'standard.vert'));
@wwdboer
wwdboer / gist:4943672
Created February 13, 2013 10:27
PHP: Get Vimeo ID
function get_vimeoid( $url ) {
$regex = '~
# Match Vimeo link and embed code
(?:<iframe [^>]*src=")? # If iframe match up to first quote of src
(?: # Group vimeo url
https?:\/\/ # Either http or https
(?:[\w]+\.)* # Optional subdomains
vimeo\.com # Match vimeo.com
(?:[\/\w]*\/videos?)? # Optional video sub directory this handles groups links also
\/ # Slash before Id
@abachman
abachman / color.coffee
Created September 13, 2012 18:11
color modifications in coffeescript
# rgb <-> hsl algorithms from
# http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
Colors =
#
# Converts an RGB color value to HSL. Conversion formula
# adapted from http://en.wikipedia.org/wiki/HSL_color_space.
# Assumes r, g, and b are contained in the set [0, 255] and
# returns h, s, and l in the set [0, 1].
#
@tbranyen
tbranyen / backbone_pushstate_router.js
Last active February 25, 2024 21:38
hijack links for pushState in Backbone
// All navigation that is relative should be passed through the navigate
// method, to be processed by the router. If the link has a `data-bypass`
// attribute, bypass the delegation completely.
$(document).on("click", "a[href]:not([data-bypass])", function(evt) {
// Get the absolute anchor href.
var href = { prop: $(this).prop("href"), attr: $(this).attr("href") };
// Get the absolute root.
var root = location.protocol + "//" + location.host + Application.root;
// Ensure the root is part of the anchor href, meaning it's relative.
@millermedeiros
millermedeiros / gist:712798
Created November 23, 2010 23:50
Simple string template parsing - AS3
/**
* Simple string replacement inspired by Mustache
* @param template String to be parsed
* @param data Object containing Key -> Value pairs.
* @return Formated string
*/
function parseTemplate(template : String, data : Object): String {
function replaceFn() : String{
var prop : String = arguments[1];
return (prop in data)? data[prop] : '';