Skip to content

Instantly share code, notes, and snippets.

View connor's full-sized avatar

Connor Montgomery connor

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / .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 / pre-commit.sh
Created January 11, 2012 22:14
Check your files against JSHint before committing
# WHAT IS THIS?
# This is a pre-commit hook that runs your js code against jshint before committing.
# If you ever want to make a commit without it running this, simply run:
# git commit -n
# INSTRUCTIONS:
# 1. Install jshint-runner: npm install -g jshint-runner
# 2. In your git project, rename .git/hooks/pre-commit.sample to .git/hooks/pre-commit
# 3. Create a .jshintrc file in ~/. This is simply an object with the options you want. See mine here: https://gist.github.com/1597131
# 4. Paste the code below line 14 in that ~/.jshintrc file
@connor
connor / gist:1591714
Created January 10, 2012 22:53 — forked from founddrama/gist:1013614
a jshint pre-commit hook for git
#!/bin/sh
# A pre-commit hook for git to lint JavaScript files with jshint
# @see https://github.com/jshint/jshint/
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
@connor
connor / external-url.html
Created January 9, 2012 20:01
index file using external-url
---
layout: default
title: "Blog"
date: 2011-12-29 11:34
---
<h3 class="subhead small-margins">Posts</h3>
<ul class="posts">
{% assign index = true %}
@connor
connor / external-url.markdown
Created January 9, 2012 19:57
Example using external-url