Skip to content

Instantly share code, notes, and snippets.

View bfricka's full-sized avatar

Brian Frichette bfricka

  • Eturi Corp
  • San Diego
View GitHub Profile
#!/bin/bash
#
# Enable TRIM support for 3rd Party SSDs. Works for Mountain Lion, should work on earlier OSes too.
# Tested on 10.8.2, 10.8.3, 10.8.5, 10.9.0, 10.9.1, 10.9.2, 10.9.3, and 10.9.4
#
# You may have to re-apply the fix after some system updates, including but not limited to those below:
# 10.9.X to 10.9.4
# 10.9.X to 10.9.3
# 10.9.X to 10.9.2
# 10.8.X to 10.8.3
@bfricka
bfricka / routes.js
Created March 29, 2014 22:46
Sails.js + AngularJS: Supporting HTML5 routing.
var STATIC_ASSET_REGEX = /\..*/;
var routingTable = {
'/foo': true,
'/bar': true
};
module.exports.routes = {
'get /*': function(req, res, next) {
// Fast check for static assets
if (STATIC_ASSET_REGEX.test(req.path)) return next();
{
"directory": "components"
}
@bfricka
bfricka / bind-polyfill.coffee
Created April 6, 2013 03:15
Bind Polyfill in Coffeescript
unless Function::bind
Function::bind = (oThis) ->
# closest thing possible to the ECMAScript 5 internal IsCallable function
if typeof this isnt "function"
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable")
aArgs = Array::slice.call(arguments, 1)
fToBind = this
fNOP = ->
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function () {},
@bfricka
bfricka / package.json
Created March 28, 2013 06:42
Package.json Boilerplate
{
"name": "",
"description": "",
"version": "0.0.0",
"private": true,
"author": "Brian Frichette",
"homepage": "",
"contributors": [ "Brian Frichette <brian.frichette@gmail.com> (https://github.com/brian-frichette)" ],
"bugs": { "url": "" },
"scripts": { "start": "nodemon app.js" },
###
Initialize a new `Emitter`.
@api public
###
module.exports = Emitter = (obj) ->
return mixin(obj) if obj
@_callbacks = {}
###
@bfricka
bfricka / storageClass.coffee
Last active December 10, 2015 17:08
Amplify.Store Storage Wrapper
# This is really just an interaction wrapper for amplify
# I prefer this syntax for interacting with storage.
class Stor
# Constructor sets defaults for amplify
# and optionally for expiration and key
constructor: (key, exp) ->
@key = if key? then key else undefined
@exp = if exp? then exp else null
@amp = amplify.store
@bfricka
bfricka / angular-slide-fade.coffee
Created January 1, 2013 07:01
AngularJS slideFade / fade directives
# Requires jQuery.slideFade.coffee gist
# https://gist.github.com/4425644
app.directive 'slideFadeShow', ->
(scope, elem, attrs) ->
$elem = $(elem)
exp = attrs.slideFadeShow
duration = 600
slideElem = (toShow, init = false) ->
@bfricka
bfricka / ua.coffee
Created January 1, 2013 06:56
Simple User Agent
###
Adapted from jqMobi (appMobi)
https://github.com/appMobi/jQ.Mobi
MIT License
###
window.UserAgent = ->
self = @
self.ua = navigator.userAgent
self.os = {}