Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Frichette bfricka

  • Eturi Corp
  • San Diego
View GitHub Profile
View enable_trim.sh
#!/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 Mar 29, 2014
Sails.js + AngularJS: Supporting HTML5 routing.
View routes.js
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();
View .bowerrc
{
"directory": "components"
}
@bfricka
bfricka / bind-polyfill.coffee
Created Apr 6, 2013
Bind Polyfill in Coffeescript
View bind-polyfill.coffee
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 = ->
View mdn-bind.js
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 Mar 28, 2013
Package.json Boilerplate
View package.json
{
"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" },
View Emitter.coffee
###
Initialize a new `Emitter`.
@api public
###
module.exports = Emitter = (obj) ->
return mixin(obj) if obj
@_callbacks = {}
###
@bfricka
bfricka / storageClass.coffee
Last active Dec 10, 2015
Amplify.Store Storage Wrapper
View storageClass.coffee
# 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 Jan 1, 2013
AngularJS slideFade / fade directives
View angular-slide-fade.coffee
# 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 Jan 1, 2013
Simple User Agent
View ua.coffee
###
Adapted from jqMobi (appMobi)
https://github.com/appMobi/jQ.Mobi
MIT License
###
window.UserAgent = ->
self = @
self.ua = navigator.userAgent
self.os = {}