Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ecarter's full-sized avatar

E. T. Carter ecarter

View GitHub Profile
!!! 5
| <!--[if lt IE 7]>
html.no-js.ie6.lt-ie9.lt-ie8.lt-ie7(lang='en')
| <![endif]-->
| <!--[if IE 7]>
html.no-js.ie7.lt-ie9.lt-ie8(lang='en')
| <![endif]-->
| <!--[if IE 8]>
html.no-js.ie8.lt-ie9(lang='en')
| <![endif]-->
!!! 5
//if lt IE 7
html(class="no-js ie6 oldie", lang="en")
//if IE 7
html(class="no-js ie7 oldie", lang="en")
//if IE 8
html(class="no-js ie8 oldie", lang="en")
// [if gt IE 8] <!-->
html(class="no-js", lang="en")
@ecarter
ecarter / snippet.js
Created February 2, 2012 16:21
!function + jQuery
// http://stackoverflow.com/questions/5422585/preceding-function-in-javascript/5422658#5422658
!function ($) {
// body
}( window.jQuery );
@ecarter
ecarter / mapOrder.js
Created December 2, 2011 15:40
Order an array of objects based on another array order
/**
* Sort array of objects based on another array
*/
function mapOrder (array, order, key) {
array.sort( function (a, b) {
var A = a[key], B = b[key];
@ecarter
ecarter / Makefile
Created November 30, 2011 17:12
Makefile - coffee/jade/stylus
# Output Directory
OUTPUT = ../lib
all: css html js
css:
@echo "stylus => css"
@stylus \
-c \
@ecarter
ecarter / CakeFile
Created November 30, 2011 17:08
Cakefile - with specified jade/coffee/stylus files
#
# Module Dependencies
#
{exec} = require 'child_process'
fs = require 'fs'
path = require 'path'
jade = require 'jade'
stylus = require 'stylus'
nib = require 'nib'
@ecarter
ecarter / ext.coffee
Created November 5, 2011 15:00
get file extension from path in coffeescript
# get file extension from path
ext = (path) ->
index = path.lastIndexOf('.')
extension = path.substr(index).replace('.', '')
@ecarter
ecarter / encode-html.coffee
Created November 5, 2011 14:55
encode html in coffeescript
# encode html
escape = (text) ->
replacements =
[/&/g, '&amp;']
[/</g, '&lt;']
[/"/g, '&quot;']
[/'/g, '&#039;']
for r in replacements
text.replace r[0], r[1]
# Debugging Magic!
import pprint
p = pprint.PrettyPrinter(indent=2)
p.pprint(result)
@ecarter
ecarter / major_us_city_dma_codes.py
Created May 25, 2010 16:18
Major US Cities with Latitude/Longitude and DMA Codes
# Major US Cities with DMA Codes
major_cities = [
{'city': 'Anchorage', 'dma_code': 743, 'latitude': 61.2180556, 'longitude': -149.9002778, 'region': 'AK', 'slug': 'anchorage-ak'},
{'city': 'Fairbanks', 'dma_code': 745, 'latitude': 64.837777799999998, 'longitude': -147.7163889, 'region': 'AK', 'slug': 'fairbanks-ak'},
{'city': 'Juneau', 'dma_code': 747, 'latitude': 58.301944399999996, 'longitude': -134.4197222, 'region': 'AK', 'slug': 'juneau-ak'},
{'city': 'Birmingham', 'dma_code': 630, 'latitude': 33.520660800000002, 'longitude': -86.802490000000006, 'region': 'AL', 'slug': 'birmingham-al'},
{'city': 'Dothan', 'dma_code': 606, 'latitude': 31.223231299999998, 'longitude': -85.3904888, 'region': 'AL', 'slug': 'dothan-al'},
{'city': 'Decatur', 'dma_code': 691, 'latitude': 34.605925300000003, 'longitude': -86.983341699999997, 'region': 'AL', 'slug': 'decatur-al'},
{'city': 'Florence', 'dma_code': 691, 'latitude': 34.799810000000001, 'longitude': -87.677250999999998, 'region': 'AL', 'slug': 'florence-al'},