- 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
aba_check_digit = (t) -> | |
7 * (t[0] + t[3] + t[6]) + | |
3 * (t[1] + t[4] + t[7]) + | |
9 * (t[2] + t[5]) | |
aba_check_sum = (t) -> | |
3 * (t[0] + t[3] + t[6]) + | |
7 * (t[1] + t[4] + t[7]) + | |
1 * (t[2] + t[5] + t[8]) |
This file contains hidden or 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 hidden or 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')}" |
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
This file contains hidden or 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
mongoose = require 'mongoose' | |
Model = mongoose.model 'Room' | |
single_model = 'room' | |
plural_model = 'rooms' | |
# exports.before_filters = [] | |
# exports.after_filters = [] | |
# exports.secure = (req, is_nested, is_secure_callback) -> is_secure_callback(null, true) |
This file contains hidden or 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 != '' |