Skip to content

Instantly share code, notes, and snippets.

@drewwells
drewwells / index.js
Created November 12, 2011 16:53
PhiloGL Lesson 6 using canvas as image source
function webGLStart() {
var c = document.createElement( 'canvas' ),
ctx = c.getContext( '2d' ),
img = new Image();
c.width = 256; c.height = 256;
ctx.save();
ctx.strokeStyle = 'Red';
ctx.font = 'normal 24px helvetica, arial';
@drewwells
drewwells / still-sopa-sucks.js
Created January 18, 2012 21:22
Blackon Wikipedia
$(":hidden").show();
$("#mw-sopaOverlay").remove();
Saving file /Users/drew/work/retailmenot/httpdocs/gui/scripts/userbar.js...
Wrote /Users/drew/work/retailmenot/httpdocs/gui/scripts/userbar.js
Auto-saving...done
Quit [2 times]
Saving file /Users/drew/work/retailmenot/includes/templates/master.php...
Wrote /Users/drew/work/retailmenot/includes/templates/master.php
Saving file /Users/drew/work/retailmenot/includes/templates/master.php...
Wrote /Users/drew/work/retailmenot/includes/templates/master.php
Undo! [4 times]
Saving file /Users/drew/work/retailmenot/includes/templates/master.php...
@drewwells
drewwells / gist:1870099
Created February 20, 2012 16:56
Hover Blur menu effect
/*
* Two parts, anchors that will drop down some sort of menu ".nav.user a"
* ".nav.login" is shown and stays shown when hovered
*/
var loginModule = $(".nav.login"),
fade;
$(".nav.user a").add( loginModule ).hover(function( ){
@drewwells
drewwells / Facet.js
Created September 19, 2012 23:47
The first file creates a new model and pairs it with a controller
var Facets = Spine.Controller.sub({
tag: "li",
events: {
"change": "click"
},
init: function(){
this.item.bind( "update", this.proxy( this.render ));
},
render: function(){
@drewwells
drewwells / install.md
Created October 7, 2012 17:04
Mystcraft install instructions
@drewwells
drewwells / unique.php
Created November 9, 2012 20:35
find unique characters
$output = '';
foreach($input as $char){
//if it's in our output already, don't concatenate it
//triple equals to avoid 0 issue
//strpos is searching for a position of the character
if(strpos($char,$output)===false){
$output.=$char;
}
}
return $output;
@drewwells
drewwells / gist:4219907
Created December 5, 2012 22:02
Webkit+Moz detect device pixel ratio
var ratio = window.devicePixelRatio ||
(function(i){
var wmq = window.matchMedia;
while( !window.devicePixelRatio && i > 0 &&
!wmq("(min--moz-device-pixel-ratio:" + i/10 + ")").matches ){
i=i-1;
}
return i/10;
})(30);
@drewwells
drewwells / gist:6322177
Created August 23, 2013 18:00
Test what browsers autoprefixer is working with.
var autoprefixer = require('autoprefixer');
var prefixed = autoprefixer("android 4", "ios 7", "ios 6.1", "ff 23", "ios 6", "android 2.3", "android 2.2").inspect();
console.log(prefixed)
@drewwells
drewwells / criticalcss-bookmarklet-devtool-snippet.js
Last active December 22, 2015 11:58 — forked from PaulKinlan/criticalcss-bookmarklet-devtool-snippet.js
Add reporting at the end. I build the original CSS from webkit's parser. The original CSS will be larger than this if no minification is used.
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");