Skip to content

Instantly share code, notes, and snippets.

View connor's full-sized avatar

Connor Montgomery connor

View GitHub Profile
@connor
connor / .jshintrc.js
Created January 11, 2012 22:20
jshintrc example
// NOTE: I added the .js extension to this gist so it would have syntax highlighting. This file should have NO file extension
{
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 100, // Maximum error before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
@connor
connor / test.rb
Created January 27, 2012 02:47
test
# loops
3.times do |t|
puts t
end
# assignment
professors = ["Chambers", "Goldwasser", "Scannell"]
# iterators
professor.each do |professor|
@connor
connor / addelogo.css
Created February 23, 2012 07:47
Addepar Logos - Firefox, also. <3
/**
Height = 2/3 * width
*/
.addelogo {
position: relative;
height: 100px;
width: 150px;
}
.addelogo .al-left {
@connor
connor / keysocket-rdio.js
Created March 18, 2012 02:06
Updated Rdio keysocket code
// goes with Boris Smus's keysocket extension <https://github.com/borismus/keysocket/>
var PREV = 20;
var PLAY = 16;
var NEXT = 19;
var fake_prev_el = document.createElement('button');
fake_prev_el.id = "fake_prev_el";
fake_prev_el.style.height = 0;
fake_prev_el.style.width = 0;
@connor
connor / introduction to events.markdown
Created March 29, 2012 00:54
learning jQuery issue #79 progress

Introduction to Events

Events are at the heart of most pages utilizing JavaScript. For our JavaScript to perform an action, we must wait for a specific event to happen, and then execute the predefined action.

What an event is

While it was hinted at earlier, events are things that happen on the page. The majority of events utilized in JavaScript applications are user-driven, like: clicking a button, hovering over an element, and pressing a key. However, there are many other events that the browser fires, like: loading all of the resources on a page or going offline. MDN has a good reference of available DOM events.

Performing an action when an event happens

@connor
connor / featureDetection.markdown
Created April 2, 2012 18:09
feature detection writeup (in progress)

what is feature detection?

Feature detection is the concept of detecting if a specific feature is available, instead of developing against a specific browser. This way, developers can write their code for two cases: the browser does support said feature, or the browser does not support said feature.

Developing against specific features, instead of developing against a specific browser, not only clears up the peripheral logic of your application, but also makes your job easier as a developer, for several reasons.

user-agent testing

Without getting into too many specifics, there are two specific reasons why User-Agent testing (developing against a specific browser) is looked down upon, instead of checking to see if a specific feature is supported: they are inconvenient and unreliable.

@connor
connor / left arrow.js
Created April 29, 2012 23:02
BEFORE left arrow keydown cubism.js
case 37: // left
if (focus == null) focus = size - 1;
if (focus > 0) context.focus(--focus);
break;
@connor
connor / after_leftarrow.js
Created April 29, 2012 23:03
AFTER left arrow cubism.js
case 37: // left
if (d3.event.shiftKey && focus > 20) context.focus(focus -= 20);
else {
if (focus == null) focus = size - 1;
if (focus > 0) context.focus(--focus);
}
break;
@connor
connor / right.js
Created April 29, 2012 23:03
right keydown cubism.js
case 39: // right
if (d3.event.shiftKey && size - focus > 20) context.focus(focus += 20);
else {
if (focus == null) focus = size - 2;
if (focus < size - 1) context.focus(focus++);
}
break;
@connor
connor / shiftdiff.js
Created April 29, 2012 23:04
shift diff var
// previous js vars, like step, size, clientDelay, etc...
shiftDiff = 20,
// other js vars, like event, scale, timeout, etc...