Skip to content

Instantly share code, notes, and snippets.

View fermion's full-sized avatar
👋

Rob Sterner fermion

👋
View GitHub Profile
// everyone's new favorite closure pattern:
(function(window,document,undefined){ ... })(this,this.document);
// when minified:
(function(w,d,u){ ... })(this,this.document);
// which means all uses of window/document/undefined inside the closure
// will be single-lettered, so big gains in minification.
// it also will speed up scope chain traversal a tiny tiny little bit.
<div id="manageable_id_102" class="ep_manageable">
<div class="ep_manageable_data">
<input type="checkbox" name="bulkaction_eprintids" value="102" id="select-102" class="ep_resource_manager_select_check">
<a href="http://resourcemanager.quango-vm.local/102/"><span class="ep_manageable_data_title">My New EdShare Resource</span></a>
<span class="ep_manageable_data_viewperms">Just me</span>
</div>
<div class="ep_manageable_controls">
<ul>
<li><a href="http://resourcemanager.quango-vm.local/102/">View</a></li>
<li><a href="http://resourcemanager.quango-vm.local/cgi/users/home?screen=EPrint::Edit&amp;eprintid=102">Edit</a></li>
#####
## 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
# Newbie Programmer
def factorial(x)
if x == 0
return 1
else
return x * factorial(x - 1)
end
end
puts factorial(6)
puts factorial(0)
//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){
# 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
// Example
document.observe("lol:konami", function() {
$(document.body).insert(new Element('h1').update("KONAMI!!!").setStyle({fontWeight: "bold", color: "red"}));
});
@fermion
fermion / viewable.js
Created September 24, 2009 16:53 — forked from gf3/viewable.js
Percentage of element in viewport
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
namespace :db do
task :pull do
run "cd #{current_release} && RAILS_ENV=#{rails_env} rake db:data:dump"
download "#{current_release}/db/data.yml", "db/data.yml"
`rake db:reset db:data:load`
end
end
document.observeSelect = function(){
$$('select.get').each(function(element){
if(!element.observingChange){
element.observe('change', function(event){
var e = event.element();
if(e.isActive()){
e.indicate();
document.ajaxRequest(e, e.readAttribute('src'), 'get', event, e.serialize());
}
});