Skip to content

Instantly share code, notes, and snippets.

View jccrosby's full-sized avatar
🏠
Working from home

John Crosby jccrosby

🏠
Working from home
View GitHub Profile
@jccrosby
jccrosby / degrade_quite_console.js
Created July 24, 2012 14:06
Degrade/Quiet console
console = {};
var i, max, funcs = [
'log', 'debug', 'info', 'warn', 'error', 'assert', 'dir', 'dirxml',
'trace', 'group', 'groupCollapsed', 'groupEnd', 'time', 'timeEnd',
'profile', 'profileEnd', 'count'
];
for( i = 0, max = funcs.length; i < max; i++ ) {
console[ funcs[ i ] ] = function(){};
}
@jccrosby
jccrosby / constructor.js
Created July 24, 2012 14:16
RealEyes Coding Standards
function Animal( name, health ) {
this.name = name;
this.health = health;
}
Animal.prototype.eat = function( value ) {
this.health += value;
};
@jccrosby
jccrosby / backbone-require-view-modules.js
Created July 24, 2012 20:23
Backbone/Require View Module Definitions
define(
[
// Template
'text!tpl/HomeView.tpl'
// Control
'realeyes/control/Dispatcher'
// Model
'realeyes/model/AppModel'
@jccrosby
jccrosby / classy-javascript.js
Created August 4, 2012 16:50
Example of a class-style javascript object (using jquery extend())
(function(ns){
var Application = function Application(options) {
this.initialize(options);
}
$.extend(Application.prototype, {
initialize: function(options) {
console.log('Application::initialize()', options);
@jccrosby
jccrosby / epl-httpNotResource
Last active December 21, 2015 06:29
Using $http instead of $resource for the EPL services
// Creating the service
factory('GetMajorEventsTimelineSvc', ['$q', '$http', '$window', function($q, $http, $window) {
return function() {
return {
get: function() {
var uri = 'http://overlays.nbcsports.com/services/lowttl/pl.asmx/GetMajorEventsTimeline';
var method = 'JSONP';
var params = {};
params.GameID = 694904;
params.callback = 'onGetMajorEvents';
@jccrosby
jccrosby / sublime-text-user-settings
Created August 27, 2013 16:45
Sublime Text User Settings Nice tabbed based indentaion
{
"caret_style": "phase",
"color_scheme": "Packages/Theme - Flatland/Flatland Dark.tmTheme",
"detect_indentation": false,
"auto_indent": true,
"smart_indent": true,
"detect_slow_plugins": false,
"font_face": "Andale Mono",
"font_size": 13.0,
"ignored_packages":
@jccrosby
jccrosby / gist:6369175
Created August 28, 2013 18:00
dt player error codes
switch(errorType) {
case 1: {
console.log('unknown', 1);
$(self).trigger('errorMessage', playerModel.playerConfig.errorMessages.unknown);
break;
}
case 2: {
console.log('videoNotFound', 2);
$(self).trigger('errorMessage', playerModel.playerConfig.errorMessages.videoNotFound);
break;
@jccrosby
jccrosby / tabs.html
Last active December 22, 2015 15:18
<!DOCTYPE html>
<html>
<head>
<title>ngTabs</title>
<style type="text/css" media="screen">
ul {
list-style: none;
padding: 0;
margin: 0;
}
@jccrosby
jccrosby / lat-long-dist.js
Created January 8, 2014 02:02
Distance between two points using latitude and longitude
function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) {
var R = 6371; // Radius of the earth in km
var dLat = deg2rad(lat2-lat1); // deg2rad below
var dLon = deg2rad(lon2-lon1);
var a =
Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
Math.sin(dLon/2) * Math.sin(dLon/2)
;
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
@jccrosby
jccrosby / getting-comfortable-module-controller.html
Created January 12, 2014 00:07
Creating a module and controller
<div ng-app="SliderModuleApp" class="sample">
<div ng-controller="SliderModuleCtrl">
<div id="slider02"></div>
<div id="view02">
<h1>I'm The View</h1>
<img id="image02" src="images/view-two.jpg" alt="View">
</div>
</div>
<script>
var SliderModuleApp = angular.module('SliderModuleApp', [function(){