Skip to content

Instantly share code, notes, and snippets.

View fermion's full-sized avatar
👋

Rob Sterner fermion

👋
View GitHub Profile
// Code
Function.prototype.curry = function() {
var func = this, a = Array.prototype.slice.call(arguments, 0);
return function() {
var a_len = a.length, length = arguments.length;
while (length--) a[a_len + length] = arguments[length];
return func.apply(this, a);
}
};
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
var NoiseEeeCalendarDateSelect = Class.create(CalendarDateSelect, {
initialize: function($super, target_element, options) {
// something to observe for a custom event on `this`
$super(target_element, options);
}
});
var dateSelect = new NoiseEeeCalendarDateSelect();
function select_towns(towns_string) {
var towns_arr = towns_string.split(','),
options = $$('#search_town_data option');
towns_arr.each(function(town_id_string) {
options.select(function(opt) {
return opt.value.match(town_id_string);
}).invoke('writeAttribute','selected',true);
});
}
new Effect.Parallel([
new Effect.BlindDown(area, {scaleFrom: 100, scaleTo: new_area_height_percentage }),
new Effect.Fade(element, { sync: true }),
new Effect.Appear(area.getElementsBySelector('.editor').first(), { sync: true,
afterSetup: function(effect) {
console.log(effect.element);
}
})
], { ..... }
});
// 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.
before_filter :ensure_https
def ensure_https
if Rails.env == "production" && !request.ssl?
redirect_to "https://" + request.host + request.request_uri
flash.keep
return false
end
end
<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>
<html>
<head>
<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/scriptaculous.js" type="text/javascript"></script>
<script>
document.observe('click', function(event){
if(event.findElement().match('a.add_row')) {
event.stop();
new Ajax.Request(this.href, {
onSuccess: function(transport){
#####
## 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