This file contains 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
javascript:document.querySelector(%22meta%5Bname=viewport%5D%22).setAttribute(%22content%22,%20%22%22); |
This file contains 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 | |
/** | |
* Include this file if you wish to tie into the SilverStripe framework to test your code in a separate workbench area | |
* without having to build a page controller, data object and then go through the full request cycle. This is good for | |
* rapid prototyping before rolling out any sort of final code. NOTE: This *is* suitable for use in the command line as | |
* well. | |
* | |
* @author Patrick Nelson, [email protected] | |
* @since 2015-01-06 |
This file contains 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 | |
class Foo extends Exception {} | |
class Bar extends Foo {} // Bar is a technically different but Foo-like exception. | |
class Baz extends Exception {} | |
try { | |
throw new Foo(); | |
} catch (Foo $e) { | |
echo 'Case 1'; | |
} catch (Baz $e) { |
This file contains 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
cd() { | |
if [ -d .git ] && [ ! -d $@ ]; then | |
git checkout "$@" | |
else | |
command cd "$@" | |
fi | |
} |
This file contains 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 randColor() { | |
var color = "#"; | |
for(var i = 1; i <= 3; i++ ) { | |
var num = Math.round(Math.random() * 255); | |
color += num.toString(16); | |
} | |
return color; | |
} |
This file contains 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
// This has moved to: https://github.com/patricknelson/dubtrack-tweaks |
This file contains 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 | |
/** | |
* SilverStripe doesn't typically use exceptions, but we may still need a programmatic method of encapsulating code | |
* and catching errors. Here we can wrap code in a callback which will trigger an exception instead of user_error()'s. | |
* | |
* @param callable $closure | |
* @throws Exception | |
*/ | |
function withExceptions(callable $closure) { |
This file contains 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 | |
class Injector extends Nestception { | |
// ... rest of class... | |
public static function unnestTemp($callable) { | |
// Retain current instance so we can revert back to it momentarily. | |
$revertTo = self::inst(); | |
This file contains 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
// Full shader example demonstrating how to use a quaterionion to rotate a vertex around a specific point. Note that this is just a plain | |
// vanilla unlit shader which includes the necessary functions (see section below) and example code in the vertex shader. | |
// | |
// Forked from https://gist.github.com/nkint/7449c893fb7d6b5fa83118b8474d7dcb | |
// Converted from GLSL to Cg. For help with that, see https://alastaira.wordpress.com/2015/08/07/unity-shadertoys-a-k-a-converting-glsl-shaders-to-cghlsl/ | |
// | |
// quaternion code from https://github.com/stackgl/gl-quat | |
// rotation from https://twistedpairdevelopment.wordpress.com/2013/02/11/rotating-a-vector-by-a-quaternion-in-glsl/ | |
Shader "Unlit/Quaternion" |
This file contains 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
using UnityEngine; | |
using Valve.VR; | |
/// <summary> | |
/// Override the material and texture of the HTC Vive controllers, with your own material after SteamVR has loaded and | |
/// applied the original material. This is useful to help preserve interactions in the model itself. | |
/// | |
/// NOTE: This is only compatible with the default HTC vive controllers (see UpdateControllerMaterial() below). | |
/// | |
/// Modified by Patrick Nelson / chunk_split ([email protected]) from original "OverrideControllerTexture" class |
OlderNewer