Skip to content

Instantly share code, notes, and snippets.

@ajpiano
ajpiano / portland-2013-speaker-qa.md
Last active Dec 12, 2015 — forked from rmurphey/portland-2013-speaker-qa.md
jQuery Portland 2013 Prospective Speaker Q&A
View portland-2013-speaker-qa.md

You're Invited!

View the hangout

Have you been thinking about proposing a talk for jQuery Portland 2013 (or any other tech conference, for that matter)? You should be! We're looking to put together a roster of speakers that can bring a diverse set of experiences together to create a program that goes above and beyond just what's new in jQuery.

@ajpiano
ajpiano / gist:2954965
Created Jun 19, 2012 — forked from anonymous/gist:2952418
Web dev horror story: Double billing bug
View gist:2954965

Early in my career I found myself working at a mobile content provider on a PHP/MySQL app that was developed in Eastern Europe by a plucky but perhaps not the most best practice oriented entrepreneurial developer.

A rather large business had been built on top of this platform and it was suffering from the strains of scaling (revenue was in the multiple millions by this point).

One day, I was working on some code clean up and refactoring to improve some functionality in the billing piece when I realized there was an error in the logic that would cause the customer to be double-billed for each piece of content. I dutifully filed a ticket for the bug, committed a fix, and deployed it to production.

In less than 2 hours, our sysadmin had rolled back my fix and the ticket changed to closed, won't fix, as the impact on the company sales projections was too much... I didn't stick around long after that!

@ajpiano
ajpiano / iife.js
Created Apr 29, 2011 — forked from rwaldron/iife.js
Running collection of IIFE Patterns
View iife.js
(function( window, document, undefined ){
})( this, this.document );
(function( global, undefined ){
})( this );
// miketaylr
View screening.js
// 1: how could you rewrite the following to make it shorter?
// Naming methods with superfluous characters that are not descriptive is a waste of time, so I would shorten the method names.
if (foo) {
bar.something(el);
} else {
bar.somethingElse(el);
}
View gist:509039
$('.inp input').keyup(function(e) {
up = $(this).val();
if ((+up) > (+max)) { // +val converts string to number
alert('too high '+e.which);
return false;
};
});
View gist:476041
var vid = $('#product_video').toggle(
function() {
$(this).show();
}, function () {
$(this).hide();
}
);
$('#product_video_link').toggle(
View omgreally.js
// controller that manages our UX indicators
var indicatorController = {};
(function(c) {
var classes = "state-insecure state-good state-caution state-fixing state-inprogress";
// helpers for changing scanner state
var showScannerDomAsScanning = function(dom) {
dom.removeClass(classes).addClass("state-inprogress")
};
var showScannerDomAsGood = function(dom) {
dom.removeClass(classes).addClass("state-good");
View jquery.pollute.js
(function ($) {
$.fn.pollute = function (pollution) {
var pollutants = {
air:"SMOAK",
water:"OIL",
noise:"BLAH"
}
function emit(type) {
View gist:359233
// HTML structure
for( var i = 0; i < AMOUNTOFCOLORS; i++ ) {
$('#colors').append('<li> \
<input style="width: 1em; height: 1em;" class="clickableColor" /> \
</li>');
}
$('.clickableColor :first').addClass('activeColor');
// shortcuts for changing color. XXX: selector fails!
View jquery.delegate.js
(function() {
function live(selector, context, event, data, handler){
jQuery.each(event.split(/\s+/), function(){
jQuery({length:0, selector:selector, context:context}).live(this.toString(), data, handler);
});
}
function die(selector, context, event, handler){
jQuery.each(event.split(/\s+/), function(){