Skip to content

Instantly share code, notes, and snippets.

View AlphaNerd's full-sized avatar
💭
Nerding as always

J.Coleman AlphaNerd

💭
Nerding as always
View GitHub Profile
@AlphaNerd
AlphaNerd / tsconfig.json
Created November 28, 2019 13:04
Typescript Basic Config for Web App
{
"compilerOptions": {
"target": "esnext",
"watch": true,
"lib": ["dom","es2017"]
}
}
@AlphaNerd
AlphaNerd / AvgRGBColor.js
Created August 25, 2019 15:22
A basic script to help calculate the average color between 2 supplied RGB values
// get the average color of two rgb colors.
function avgcolor(color1,color2){
/// declare vars
let avg,
hex16,ch16,
hex1,hex2,
r,g,b,
res;
// get average of channel hex
@AlphaNerd
AlphaNerd / Sample.js
Created August 24, 2019 18:42
A gist for sharing sample Javascript code to prospective employers/clients
/**
* GoJS Library
* @file GoJSDiagram.js
* @author Mariner Partners Inc
* @see https://gojs.net/
*/
import appEvents from 'app/core/app_events';
import angular from '../angularjs/index';
/**
@AlphaNerd
AlphaNerd / server.js
Created May 29, 2019 13:33
NodeJS Simple API and Request Example
// BASE SETUP
// =============================================================================
// call the packages we need
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var request = require('request');
// configure body parser
@AlphaNerd
AlphaNerd / highChartsDefaults.js
Created May 18, 2019 11:19
HighCharts basic defaults for Parakeeto data feed
this.defaultLargeChartOptions = {
chart: {
backgroundColor:'#f2f2f2'
},
credits: {
enabled: false
},
title : {
text : ''
},
@AlphaNerd
AlphaNerd / js
Created February 26, 2019 22:43
Content Editable Directive for Angular
angular.module('garago.directives.contenteditable', [])
.directive("contenteditable", function($timeout, $garagoAPI, $rootScope) {
function toInnerText(value) {
var tempEl = document.createElement('div'),
text;
tempEl.innerHTML = value;
text = tempEl.textContent || '';
return text.trim();
}
@AlphaNerd
AlphaNerd / index.html
Created July 31, 2018 11:50
Image Slider - Before & After Images
<figure>
<div id="twoface-demo"></div>
<figcaption>Before and after photos of Queensland</figcaption>
</figure>
@AlphaNerd
AlphaNerd / swap.txt
Created January 8, 2018 16:25
Facebook Graph access_token; swap from Short Live to Long Live token
https://graph.facebook.com/oauth/access_token?client_id=<app_id>&client_secret=<app_secret>&grant_type=fb_exchange_token&fb_exchange_token=<token_to_exchange>
@AlphaNerd
AlphaNerd / Array.Prototype.move.js
Created May 13, 2017 03:35
Move an item in Array from one position to another easily
Array.prototype.move = function (old_index, new_index) {
if (new_index >= this.length) {
var k = new_index - this.length;
while ((k--) + 1) {
this.push(undefined);
}
}
this.splice(new_index, 0, this.splice(old_index, 1)[0]);
return this; // for testing purposes
};
@AlphaNerd
AlphaNerd / controllers.js
Created May 5, 2016 10:57
AngularJS promises in a nut shell. $q boilerplate
function TodoCtrl($scope, $q, $timeout) {
function createPromise(name, timeout, willSucceed) {
$scope[name] = 'Running';
var deferred = $q.defer();
$timeout(function() {
if (willSucceed) {
$scope[name] = 'Completed';
deferred.resolve(name);
} else {
$scope[name] = 'Failed';