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
# Newbie Programmer | |
def factorial(x) | |
if x == 0 | |
return 1 | |
else | |
return x * factorial(x - 1) | |
end | |
end | |
puts factorial(6) | |
puts factorial(0) |
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
//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){ |
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
# Created by Eric Lindvall <[email protected]> | |
# | |
# 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 |
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
// Example | |
document.observe("lol:konami", function() { | |
$(document.body).insert(new Element('h1').update("KONAMI!!!").setStyle({fontWeight: "bold", color: "red"})); | |
}); |
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:alert($H(Event.cache).inject(0,function(m,p){m+=$H(p.value).values().flatten().size();return%20m})) |
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
--ignore-dir=.git | |
--ignore-dir=log | |
--ignore-dir=tmp | |
--ignore-dir=vendor | |
--ignore-dir=public/generated | |
--sort-files | |
-a |
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
Element.addMethods({ | |
viewable: function(el) { | |
// INIT | |
el = $(el); | |
var scroll = document.viewport.getScrollOffsets(); | |
var viewport = document.viewport.getDimensions(); | |
var offsets = el.cumulativeOffset(); | |
var dimensions = el.getDimensions(); | |
// Sanity check |
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
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']; |
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 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); |
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:(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 |