This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Hook into WP init and add custom rewrite rule(s) | |
| */ | |
| add_action('init', 'wuhhh_add_rewrites'), 1, 0); | |
| function wuhhh_add_rewrites() { | |
| // Add a rewrite rule according to your requirements | |
| add_rewrite_rule( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * The generic function loggingIdentity takes a type parameter T, and | |
| * an argument arg which is an array of Ts, and returns an array of Ts. | |
| */ | |
| function loggingIdentity<T>(arg: T[]): T[] { | |
| console.log(arg.length); // Array has a .length, so no more error | |
| return arg; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function parseVideo(url) { | |
| // - Supported YouTube URL formats: | |
| // - http://www.youtube.com/watch?v=My2FRPA3Gf8 | |
| // - http://youtu.be/My2FRPA3Gf8 | |
| // - https://youtube.googleapis.com/v/My2FRPA3Gf8 | |
| // - Supported Vimeo URL formats: | |
| // - http://vimeo.com/25451551 | |
| // - http://player.vimeo.com/video/25451551 | |
| // - Also supports relative URLs: | |
| // - //player.vimeo.com/video/25451551 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * From: https://stackoverflow.com/a/23529943 | |
| * | |
| * Add or update a query string parameter. If no URI is given, we use the current | |
| * window.location.href value for the URI. | |
| * | |
| * Based on the DOM URL parser described here: | |
| * http://james.padolsey.com/javascript/parsing-urls-with-the-dom/ | |
| * | |
| * @param (string) uri Optional: The URI to add or update a parameter in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Returns the element height including margins | |
| * @param element - element | |
| * @returns {number} | |
| */ | |
| function outerHeight(element) { | |
| const height = element.offsetHeight, | |
| style = window.getComputedStyle(element) | |
| return ['top', 'bottom'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * A simple parallax plugin for Vue | |
| * Add the v-parallax directive to elements you want to... parallaxify. | |
| * Directive argument should be an object with single argument, 'target' | |
| * Target specifies the final offset amount (in px) for the element | |
| * | |
| * For example: | |
| * | |
| * <my-element v-parallax="{ target: -500 }"> | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Hex to RGB | |
| // e.g. vec3 rgbBlue = hexToRGB(0xD0F5F7); | |
| vec3 hexToRGB(int h) { | |
| float rValue = float(h / 256 / 256); | |
| float gValue = float(h / 256 - int(rValue * 256.0)); | |
| float bValue = float(h - int(rValue * 256.0 * 256.0) - int(gValue * 256.0)); | |
| return vec3(rValue / 255.0, gValue / 255.0, bValue / 255.0); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| float map(float value, float low1, float high1, float low2, float high2) { | |
| return low2 + (value - low1) * (high2 - low2) / (high1 - low1); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Limit OrbitControls pan | |
| */ | |
| const controls = useRef(); | |
| const minPan = new THREE.Vector3(-2, 1, 0); | |
| const maxPan = new THREE.Vector3(2, -1, 0); | |
| useEffect(() => { | |
| const _v = new THREE.Vector3(); |
OlderNewer