Skip to content

Instantly share code, notes, and snippets.

View fermion's full-sized avatar
👋

Rob Sterner fermion

👋
View GitHub Profile
@fermion
fermion / blinky
Created September 18, 2009 18:26
thanks tfluehr
javascript:(function(){function anc(e){var p='parentNode';e=$(e);var es=[];while(e=es[property])if(e.nodeType==1)es.push(e);return es;}function visible(el){el=$(el);if(!el){return false;}var a=anc(el);var c=a.length;var v=true;for(var i=0;i<c;i++){if(a[i].style.display=='none'||a[i].style.visibility=='hidden'){v=false;break;}}return v;}(function blinky(){var tmp=document.body.getElementsByTagName('*');tags=[];for(var j=0;j<tmp.length;j++)tags.push(tmp[j]);var fr=[];var ind=[];var l=tags.length;while(l--)var n=tags[l].tagName.toLowerCase();if(n=='iframe'||n=='script'||n=='link'){if(tags[l].tagName.toLowerCase()=='iframe')fr.push(tags[l]);tags[l]=null;ind.push(l);}while(ind.length)Array.splice.call(tags,ind.shift(),1);while(fr.length){try{tmp=fr.shift().contentWindow.document.body.getElementsByTagName('*');var tmp2=[];for(var j=0;j<tmp.length;j++)tmp2.push(tmp[j]);tags=Array.concat.apply(tags,tmp2);}catch(e){}}l=tags.length;if(typeof(lastTag)=='undefined')lastTag=null;if(lastTag)lastTag.style.visibility='';last
function showBlockingPopup(name) {
// make sure overlay covers the entire page
var dimensions = document.viewport.getScrollOffsets();
wrapper = $(name);
// center logo
$(name + '_popup').setStyle({top: (dimensions.top + (document.viewport.getHeight() / 2) - 68) + 'px'});
if(Prototype.Browser.IE) {
var newHeight = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight);
@fermion
fermion / a better window dimension script
Created September 21, 2009 14:18
Thanks Daniele_ (#prototype)
getPageSize: function() {
var xScroll, yScroll;
var pageWidth, pageHeight;
var viewportDimensions = document.viewport.getDimensions();
if ( window.scrollMaxY ) {
xScroll = window.scrollMaxX;
yScroll = window.scrollMaxY;
} else if ( document.body.scrollHeight > viewportDimensions['height'] ){
xScroll = document.body.scrollWidth-viewportDimensions['width'];
--ignore-dir=.git
--ignore-dir=log
--ignore-dir=tmp
--ignore-dir=vendor
--ignore-dir=public/generated
--sort-files
-a
@fermion
fermion / gist:254232
Created December 11, 2009 14:21
count number of Prototype Event observers on a page (thanks kangax)
javascript:alert($H(Event.cache).inject(0,function(m,p){m+=$H(p.value).values().flatten().size();return%20m}))
// Example
document.observe("lol:konami", function() {
$(document.body).insert(new Element('h1').update("KONAMI!!!").setStyle({fontWeight: "bold", color: "red"}));
});
# Created by Eric Lindvall <eric@sevenscale.com>
#
# WHAT: Provides a simple overview of memory allocation occuring during a
# require.
#
# For a longer explanation, see my post at:
#
# http://bitmonkey.net/post/308322913/tracking-initial-memory-usage-by-file-in-ruby
#
# NOTE: The numbers provided are of self + children, meaning the same will
//ported to prototype from http://www.csskarma.com/lab/slidinglabels/
function formatSliderLabels(form)
{
form = $(form);
var labelColor = '#999';
var restingPosition = 5;
var topPosition = 6;
var duration = 0.2;
var labelAdjust = 10;
form.select('.slider label').each(function(el){
# Newbie Programmer
def factorial(x)
if x == 0
return 1
else
return x * factorial(x - 1)
end
end
puts factorial(6)
puts factorial(0)
#####
## INITIAL CONFIGURATION
#####
# Fork sstephenson/prototype on GitHub
# Go to this url and click the fork button. This will create a prototype
# repository under your GitHub account.
http://github.com/sstephenson/prototype