Skip to content

Instantly share code, notes, and snippets.

View desandro's full-sized avatar

David DeSandro desandro

View GitHub Profile
@desandro
desandro / require-js-discussion.md
Created January 31, 2013 20:26
Can you help me understand the benefit of require.js?

I'm having trouble understanding the benefit of require.js. Can you help me out? I imagine other developers have a similar interest.

From Require.js - Why AMD:

The AMD format comes from wanting a module format that was better than today's "write a bunch of script tags with implicit dependencies that you have to manually order"

I don't quite understand why this methodology is so bad. The difficult part is that you have to manually order dependencies. But the benefit is that you don't have an additional layer of abstraction.


@desandro
desandro / halftone-cartesian.pde
Last active October 4, 2022 11:48
Half-ton halftones Processing sketch
// options
String imagePath = "img/desandro-avatar.jpg";
float res = 10; // resolution, dot density
float zoom = 3.0; // proportion to zoom image
boolean isAdditive = true; // true = RGB, false = CMY
float offsetAngle = 1; // affects dot pattern
/*
0 = no patter
0.05 = slight offset
1 = slight offset
@desandro
desandro / jquery.imagesloaded.js
Created January 26, 2011 18:01 — forked from paulirish/README.md
$.fn.imagesLoaded jQuery plugin
// $('img.photo',this).imagesLoaded(myFunction)
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images
// Modified with a two-pass approach to changing image
// src. First, the proxy imagedata is set, which leads
// to the first callback being triggered, which resets
// imagedata to the original src, which fires the final,
// user defined callback.
@desandro
desandro / jquery-layout-review.md
Created January 28, 2013 18:13
layout thrashing in jQuery
@desandro
desandro / bower.json
Last active January 12, 2022 21:08
jQuery UI Draggable
{
"name": "jquery-ui-draggable",
"version": "1.11.4",
"main": "jquery-ui-draggable.js"
}
@desandro
desandro / bower-logo.md
Last active December 30, 2021 23:11
Bower logo

In addition to awesome docs #228, Bower deserves a proper logo. See below for sketches. I'm curious if you think any of these are worth me putting more effort into.


Take a look at Yeoman right now.

Screen Shot 2013-02-19 at 4 43 10 PM

The other two entities have awesome logos. Bower's got to represent.

@desandro
desandro / dabblet.css
Created January 17, 2012 17:03
Chrome 3D transform translateZ bug
/**
* Chrome 3D transform translateZ bug
*/
#env {
width: 200px;
height: 200px;
border: 2px solid;
-webkit-perspective: 1000;

I've been struggling to come up with a good answer to this question: What is good code?

Programming is such a technical subject. It appears to be something you can definitively analyze. But when I think about it through this question, programming seems entirely subjective.

I know good code can be readable, terse, eloquent, standardized, innovative. But it can't be just one of these qualities.

Good code can be highly stylized — utilizing nuanced patterns rarely seen elsewhere. Or good code can be highly structured — following strict guidelines and established conventions. Bad code can be either as well.

I think the answer to "What is good code?" is that there is no answer. You can't put it in words. Like asking "What makes a joke funny?"

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@desandro
desandro / add-event.js
Created November 15, 2012 03:04
add/remove event with handleEvent helper
// modified John Resig's http://ejohn.org/projects/flexible-javascript-events/
var div = document.createElement('div');
var addEvent, removeEvent;
if ( div.addEventListener ) {
addEvent = function( elem, type, fn ) {
elem.addEventListener( type, fn, false );
};