- jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
- Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
- AngularJS - Conventions based MVC framework for HTML5 apps.
- Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
- lawnchair - Key/value store adapter for indexdb, localStorage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
directive = -> | |
{ | |
restrict: 'A' | |
scope: true | |
require: 'ngModel' | |
link: (scope, elem, attrs, control) -> | |
control.$parsers.unshift (value) -> | |
clearTimeout scope.match_password_timeout if scope.match_password_timeout | |
if value != '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setting up environment configuration on Heroku. | |
heroku config --app myapp | |
heroku config:add ENV_VAR=somevalue --app myapp | |
# Apply SSL Certs to Heroku | |
heroku certs --app myapp | |
heroku certs:add ssl.crt ssl.key --app myapp | |
# Generally useful commands for Heroku | |
heroku logs --tail --app myapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description: Add the nestCollection method to the Backbone.Model prototype. | |
# | |
# This method accepts an attribute name on the model you're currently referencing, | |
# along with a collection that you would like to use the attributes of. Making it | |
# easier to bubble events between a collection/model. | |
# | |
# TODO: Fix comparator issues that could be introduced if the dependent collection changes sort order. | |
Backbone.Model::nestCollection = (attribute_name, collection_to_nest) -> | |
# Make sure that there is an array available in the attribute_name that hsa been passed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The MIT License | |
# Copyright (c) 2012 Christopher WJ Rueber | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | |
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation | |
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, | |
# and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all copies or substantial | |
# portions of the Software. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trim_the_fat = (str) -> str.replace(/\D+/g, '') | |
numerals_only = /[^0-9]+/ | |
double_sum_array = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9] | |
is_valid_credit_card = (card_number) -> | |
card_number = trim_the_fat(card_number) | |
return false if card_number.length < 13 or numerals_only.test(card_number) | |
len = card_number.length | |
sum = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NodeJS Asset Helper. | |
fs = require 'fs' | |
asset_dir = './public/assets/' | |
pull_assets_manifest = -> | |
fs.readFile asset_dir+'manifest.json', (err, file) -> | |
koaris.locals.assets = JSON.parse(file) | |
console.log "Refreshing Asset Manifest" | |
pull_assets_manifest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PRE_AND_POST_UNDERSCORES = /^_+|_+$/g | |
EMAIL = /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i | |
URL = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/ | |
# HTML Based | |
SINGLE_TAG = /^<(\w+)\s*\/?>(?:<\/\1>|)$/ | |
HTML = /<|&#?\w+;/ | |
TAG_NAME = /<([\w:]+)/; | |
XHTML_TAG = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prodAssetHelpers = require("./middleware/prod_asset_helpers") | |
if app.get('env') == 'production' | |
app.use express.static(path.join(__dirname, "/../public"), maxAge: constant.one_week) | |
prodAssetHelpers(app, path.join(__dirname, "/../public")) | |
else | |
app.use express.static(path.join(__dirname, "/../public"), maxAge: constant.one_second) | |
app.use connectAssets(paths: [ "public/css", "public/js" ], helperContext: app.locals, build: false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note on globals: _, app, logger, and Data are global. Everything else is standard node. | |
# npm libs: aws-sdk, mongoose, express, coffeescript, lo-dash... At least, where this came frome. | |
# Lo-dash could easily be replaced with a for-each, but I use it all over the place in my apps. | |
aws = require 'aws-sdk' | |
aws.config.update accessKeyId: app.get('s3_access_key'), secretAccessKey: app.get('s3_secret_key') | |
sqs = new aws.SQS(region: app.get('aws_region')) # aka 'us-east-1' | |
queue_url = "http://sqs.us-east-1.amazonaws.com/#{app.get('aws_user_id')}/#{app.get('s3_bucket')}" |