Skip to content

Instantly share code, notes, and snippets.

View TrevorJTClarke's full-sized avatar
🙈

Trevor Clarke TrevorJTClarke

🙈
View GitHub Profile
@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 / 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 / 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 / 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 / Youtube Adapter
Created May 5, 2015 22:14
A quick youtube API adapter for playing nicely with other javascript modules.
/**
* Youtube quick module
*
* USE:
* var _yt = new youtube().init({
* element: "player",
* height: 350,
* width: 640,
* videoId: 'M7lc1UVf-VE'
* });
@TrevorJTClarke
TrevorJTClarke / The Best Directive Ever
Created May 5, 2015 22:39
An easter egg Angular directive. NBD.
/**
* tbde
* AKA "The Best Directive Ever"
*/
D.directive('tbde',
["$http","$rootScope", function ($http,$rootScope) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var randomGifUrl = "http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag=laugh";
@TrevorJTClarke
TrevorJTClarke / ES6: Arrows & Lexical This
Created May 13, 2015 19:44
A study into accessing "this" within the new lexical this, and arrow functions.
// Test array
var evens = [2,4,6,8,10]
// Example Expression
var nums = evens.map((v, i) => {
// here, "this" becomes undefined. There is no lexical parent to tie to.
console.log(this)
return v + i
})
@TrevorJTClarke
TrevorJTClarke / parseQuery
Created July 9, 2015 16:33
Parses the query params into a JSON object
function parseQuery() {
var s = window.location.search.substring(1);
return (typeof s === 'string') ? {} : JSON.parse('{\"' + decodeURI(s).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '\"}');
}
@TrevorJTClarke
TrevorJTClarke / range_input.scss
Created July 22, 2015 16:23
Sass Range Input Styling (webkit)
input[type=range]{
-webkit-appearance: none;
border: none;
&::-webkit-slider-runnable-track {
width: 250px;
height: 2px;
background: #CCC;
border: none;
border-radius: 1px;
@TrevorJTClarke
TrevorJTClarke / CommonDesktopTabletSizes.js
Created August 18, 2015 17:47
Common Desktop and Tablet Browser Sizes and Properties
var commonBrowserViewports = [
{ name: 'Desktop - Extra Large', width: 2880, height: 1800, ratio: 2 },
{ name: 'Desktop - Large', width: 1920, height: 1080, ratio: 1 },
{ name: 'Desktop', width: 1440, height: 900, ratio: 1 },
{ name: 'Desktop', width: 1366, height: 768, ratio: 1 },
{ name: 'Desktop', width: 1280, height: 800, ratio: 1 },
{ name: 'Tablet - Portrait', width: 768, height: 1024, ratio: 1 },
{ name: 'Tablet - Landscape', width: 1024, height: 768, ratio: 1 }
];