Skip to content

Instantly share code, notes, and snippets.

View benja2729's full-sized avatar

Ben Fischer benja2729

  • ServiceNow
  • Chicago, IL
View GitHub Profile
@benja2729
benja2729 / url_regexp.js
Last active January 29, 2016 18:43
Nearly definitive url RegExp
// Based off of definitions defined at https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
// scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
// NOTE:
// 1. The regex will only match urls with username AND password present. I don't care about tackling an optional password atm.
// Might not even be necessary for WWW use
// 2. Will not match a url without a host (no /relative/paths)
// 3. Any (non-)capture groups can be taken-out to fit your needs
//
// See it in action at: http://regexr.com/3cmin
@benja2729
benja2729 / mediaBreakPoints.js
Last active December 28, 2015 08:39
Helper to manage media query breakpoints in javascript. This script is predefined for use alongside Bootstrap v3.0.
!function(win) {
// Define breakpoint values and aliases
var mq = win.mediaBreakPoints = {
xs: 480,
xsMax: 767,
sm: 768,
smMax: 991,
md: 992,
mdMax: 1199,
@benja2729
benja2729 / Ember-Titleize
Last active December 23, 2015 04:39
This is an Ember Handlebars helper used to transform a String into title case. Will always capitalize the first word in the String. This will not change a String if it is already capitalized, so feel free to blindly throw this helper in your code. :)
shortWords = Ember.A ['of','a','the','and','an','or','nor','but','is','if','then','else','when','at','from','by','on','off','for','in','out','over','to','into','with']
titleize = (str) ->
strArray = str.split ' '
strArray = Ember.ArrayPolyfills.map.call strArray, (slug) ->
if index is 0 or not shortWords.contains(slug)
Ember.String.capitalize slug
else slug
strArray.join ' '