Skip to content

Instantly share code, notes, and snippets.

View TrevorJTClarke's full-sized avatar
🙈

Trevor Clarke TrevorJTClarke

🙈
View GitHub Profile
@TrevorJTClarke
TrevorJTClarke / chromeInstall.js
Created April 6, 2015 17:56
Chrome Inline Install Angular Directive
/**
* chromeInstall
* a directive for inline install of a chrome extension from a website using Angular
*
* Make sure that the head meta data contains:
* <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/CHROME_EXTENSION_ID">
*/
yourApp.directive('chromeInstall',
[function() {
return {
@TrevorJTClarke
TrevorJTClarke / Module Starter
Created March 31, 2015 23:10
A standard for building javascript modules -- pre-ES6
/**
* Module Starter
*/
var NS = "ModuleName";
// load the module into global
window[NS] = (function(){
/**
* Internal - encapsulates all logic
*
@TrevorJTClarke
TrevorJTClarke / state-list.js
Created November 12, 2014 17:43
Angular states and abbreviations list. Only using the 50 main states without outlying properties. Found the need to use on multiple projects, so gist for easy use!!
/**
* States
* A simple value store of states
*/
D.value("States", [{
"name": "Alabama",
"abbr": "AL"
},{
"name": "Alaska",
"abbr": "AK"
@TrevorJTClarke
TrevorJTClarke / MediaFormat
Last active July 24, 2023 08:25
MediaFormat - A regex system for finding the media ID for each type of popular social site. Can identify YouTube, Vimeo, Spotify, and Soundcloud.
/**
* MediaFormat
* format and return only needed pieces of media from their public sources
* Author: Trevor Clarke
*/
function MediaFormat (){
// http://www.youtube.com/embed/m5yCOSHeYn4
var ytRegEx = /^(?:https?:\/\/)?(?:i\.|www\.|img\.)?(?:youtu\.be\/|youtube\.com\/|ytimg\.com\/)(?:embed\/|v\/|vi\/|vi_webp\/|watch\?v=|watch\?.+&v=)((\w|-){11})(?:\S+)?$/;
// http://vimeo.com/3116167, https://player.vimeo.com/video/50489180, http://vimeo.com/channels/3116167, http://vimeo.com/channels/staffpicks/113544877
var vmRegEx = /https?:\/\/(?:vimeo\.com\/|player\.vimeo\.com\/)(?:video\/|(?:channels\/staffpicks\/|channels\/)|)((\w|-){7,9})/;
@TrevorJTClarke
TrevorJTClarke / API_Router
Created May 31, 2014 07:17
API Route Module
function API (){
this._apiString = "";
//TODO: add this to check if we already have a param or not, then finish route
this.addQueryParam = function (){
// console.log(this._apiString.toString().search("\?"));
}
this.v = function (){
@TrevorJTClarke
TrevorJTClarke / .update()
Created March 8, 2013 02:28
Firebase .update() function in Node.js
function setThis () {
firebaseRef.child('users').child(user.name).set(user);
};
data.forEach(function (user) {
module.user(user.name, function(err, data){
firebaseRef.child('users').child(user.name).update(user, setThis());
});
});