Skip to content

Instantly share code, notes, and snippets.

View fearphage's full-sized avatar
⌨️
Cache rules everything around me.

Phred Lane fearphage

⌨️
Cache rules everything around me.
View GitHub Profile
!function() {
var doc = document,
htm = doc.documentElement,
lct = null, // last click target
nearest = function(elm, tag) {
while (elm && elm.nodeName != tag) {
elm = elm.parentNode;
}
return elm;
};
// This might be useful for certain size-limited JS competitions, or not. #js
function super_shrinkify( str ){
var prefix = 'eval("',
suffix = '".replace(/./g,function(a){return String.fromCharCode((a=a.charCodeAt())/128,a%128)}))',
out = prefix + str.replace( /(.)(.)/g, function(a,b,c){
return String.fromCharCode( 128 * b.charCodeAt() + c.charCodeAt() );
}) + suffix;
console.log( 'overhead: ' + ( prefix.length + suffix.length ) + ' chars' );
(function () {
var forEach = [].forEach,
regex = /^data-(.+)/,
dashChar = /\-([a-z])/ig,
el = document.createElement('div'),
mutationSupported = false,
match
;
function detectMutation() {
@fearphage
fearphage / gist:579032
Created September 14, 2010 13:33
IS THE LEAKED HDCP MASTER KEY REAL? Discuss your thoughts here
HDCP MASTER KEY (MIRROR THIS TEXT!)
This is a forty times forty element matrix of fifty-six bit
hexadecimal numbers.
To generate a source key, take a forty-bit number that (in
binary) consists of twenty ones and twenty zeroes; this is
the source KSV. Add together those twenty rows of the matrix
that correspond to the ones in the KSV (with the lowest bit
in the KSV corresponding to the first row), taking all elements
// So what I'm doing here seems cool, but I'm not sure exactly what it should be
// called. Is this partial application? Currying? Something else? Vindaloo maybe?
//
// Either way, it's a pretty interesting pattern.. I wonder if it has any
// real-world application. Probably not.
//
// Invoking the partially applied function will always return a function until
// ALL arguments are satisfied, at which point the original function is invoked,
// returning its result. This means that all function arguments are required,
// which also allows the function to be called either like foo( 1, 2, 3 ) or
(function () {
var forEach = [].forEach,
regex = /^data-(.+)/,
dashChar = /\-([a-z])/ig,
el = document.createElement('div'),
mutationSupported = false,
match
;
function detectMutation() {
/*
* from WebReflection
* http://webreflection.blogspot.com/2007/06/simple-settimeout-setinterval-extra.html
*
*/
(function (f) {
global.setTimeout = f(global.setTimeout);
global.setInterval = f(global.setInterval);
})(function (f) {
return function (c, t) {
@fearphage
fearphage / jquery.pngFix.js
Created October 7, 2010 20:16
Edit to view the plain text content
/**
* --------------------------------------------------------------------
* jQuery-Plugin "pngFix"
* Version: 1.2, 09.03.2009
* by Andreas Eberhard, [email protected]
* http://jquery.andreaseberhard.de/
*
* Copyright (c) 2007 Andreas Eberhard
* Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
*
/**
* --------------------------------------------------------------------
* jQuery-Plugin "pngFix"
* Version: 1.2, 09.03.2009
* by Andreas Eberhard, [email protected]
* http://jquery.andreaseberhard.de/
*
* Copyright (c) 2007 Andreas Eberhard
* Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
*
@fearphage
fearphage / .opera-stats.sh
Created October 17, 2010 23:52
Prints opera stats. (Used for conky)
#!/bin/bash
#version 0.1
cd ~/browser-installs/profile/
#Opera tab count
if [ -e "sessions/autosave.win" ]; then
tab_opera_c=`egrep 'window count=([0-9]*)' sessions/autosave.win | awk '{split($2, s, "="); print s[2]}'`
window_opera_c=`grep -c 'type=0' sessions/autosave.win`
actual_opera_c=$(($tab_opera_c - $window_opera_c))
echo "- "$actual_opera_c" tabs in "$window_opera_c" windows"