Skip to content

Instantly share code, notes, and snippets.

@shshaw
shshaw / svgclass.js
Last active January 3, 2016 22:19
Modifies Add/Remove class for jQuery to work with SVG elements.
(function($){
var addClass = $.fn.addClass;
$.fn.addClass = function(value) {
var orig = addClass.apply(this, arguments);
var elem,
i = 0,
len = this.length;
for (; i < len; i++ ) {
@shshaw
shshaw / JSfixForResponsiveSVGsInSafari.js
Created January 14, 2016 15:47
A vanilla JavaScript fix (of sorts) for responsive SVGs in Safari and some other WebKit browsers.
/*
Title: Vanilla JavaScript to fix responsive SVGs in some versions of Safari.
What it does: Stops the problem I described here: http://stackoverflow.com/q/17158717/1147859 Reference URL of the issue: http://codepen.io/benfrain/full/fhyrD
It will work on all SVGs referenced inside objects as long as given the class .emb:
<object class="emb" data="img/cup.svg" type="image/svg+xml"></object>
And also any inline SVGs.
@shshaw
shshaw / functions.php
Last active August 22, 2016 10:39 — forked from fardog/functions.php
Fixes a `Creating default object from empty value` on [line 61](https://gist.github.com/fardog/9356458#file-functions-php-L61)
<?php
function north_cast_api_data($content) {
if (is_numeric($content)) $content = intval($content);
else {
$unserialized_content = @unserialize($content);
// we got serialized content
if ($unserialized_content !== false) {
// make sure that integers are represented as such, instead of str
foreach ($unserialized_content as $fn => &$c) {
@shshaw
shshaw / index.html
Last active September 22, 2016 18:50
ozBpBA
<ul id="scene">
<li class="layer" data-plax="0.00"></li>
<li class="layer" data-plax="0.20"></li>
<li class="layer" data-plax="0.40"></li>
<li class="layer" data-plax="0.60"></li>
<li class="layer" data-plax="0.80"></li>
<li class="layer" data-plax="1.00"></li>
</ul>
@shshaw
shshaw / hose-curve-generation.markdown
Created October 20, 2016 16:42
Hose curve generation
@shshaw
shshaw / index.html
Last active October 25, 2016 17:07
Listener Reactive Animation Helper [WIP]
<button>Click me</button>
<script>console.clear();</script>
@shshaw
shshaw / script.babel
Last active December 1, 2016 16:19
Smudge & Randomize Image with PIXI.js Mesh
console.clear();
let mesh;
let cloth;
let spacingX = 5;
let spacingY = 5;
let opts = {
image: 'http://brokensquare.com/Code/assets/face.png',
pointsX: 40,
@shshaw
shshaw / 3december-day-1.markdown
Created December 2, 2016 15:58
#3December - Day 1
@shshaw
shshaw / script.js
Last active December 3, 2016 13:59
Waving Hairs (#3December - Day 3)
console.clear();
var gui, scene, camera, renderer, orbit, lights;
function initScene () {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 400 );
camera.position.x = -20;
camera.position.z = 30;