Skip to content

Instantly share code, notes, and snippets.

View TaylorAckley's full-sized avatar

Taylor Ackley TaylorAckley

View GitHub Profile
@TaylorAckley
TaylorAckley / origins-cache.js
Last active August 15, 2021 05:09
Origins Cache
'use strict';
const NodeCache = require('node-cache');
const chalk = require('chalk');
const origins = new NodeCache();
const ApiKey = require('./models/api-key.model');
// https://www.npmjs.com/package/node-cache
const cache = {};
@TaylorAckley
TaylorAckley / api-key-model-.js
Last active May 13, 2018 03:51
Allowed Origins
'use strict';
const mongoose = require('mongoose');
const sid = require('shortid');
const ident = require('crypto-random-string');
const origins = require('../origins-cache');
const schema = new mongoose.Schema({
client_id: { // Used for Public API Keys. Kept in for context to show you would most likely reuse this table if you have a table for storing and generating public API keys.
type: String,
@TaylorAckley
TaylorAckley / class.js
Last active December 28, 2017 20:01
Boilerplate SDK
// Super Class
class FooAPI {
static get(endpoint) {
// logic to get a token and send a GET request to the API
}
}
// Child Class (aka Module)
class Ping extends Foo {
static checkHealth() {
// Use the super keyword to call the parent FooAPI class get method.
@TaylorAckley
TaylorAckley / gulp.task.js
Last active August 14, 2017 17:34
Gulp File - Modular Style
"use strict";
module.exports = function (gulp, _p, _o, s, d) {
if (!d) {
d = _o.global.outDir;
}
return function () {
gulp.src(s)
.pipe()
.dest(d);
@TaylorAckley
TaylorAckley / AwsController.cs
Created June 16, 2017 16:36
AWS Upload Example with Stream
[HttpPost, Route("api/aws/upload")]
public async Task<IHttpActionResult> Upload()
{
if (!Request.Content.IsMimeMultipartContent())
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
var provider = new MultipartMemoryStreamProvider();
await Request.Content.ReadAsMultipartAsync(provider);
foreach (var file in provider.Contents)
{
@TaylorAckley
TaylorAckley / lazy-helpers.css
Created May 2, 2017 17:48
CSS Helpers for the lazy. Works great for wireframing.
.helper-no-margin {
margin: 0
}
.helper-no-padding {
margin: 0
}
.helper-no-margin-left {
margin-left: 0 !important;
@TaylorAckley
TaylorAckley / scaffold.js
Last active May 2, 2017 17:10
Faker Scaffold/Replacer
// Requires momentjs and faker.js.
//usage
/*
<div class="scaffold-user">
<span class="scaffold-name"></span> OR <span class="scaffold-name">{{scaffold-name}} - other text here</span>
<span class="scaffold-initials"></span>
<span class="scaffold-email"></span>
</div>
{"lastUpload":"2018-05-20T18:35:09.653Z","extensionVersion":"v2.9.2"}
@TaylorAckley
TaylorAckley / toggle.js
Created April 7, 2017 23:18
jquery show/hide with toggleable icons
//usage --
//<i class="show-hide" data-elem="#hidden-content"></i>
//<div id="my-content" class="hidden">I'm hidden until the icon is clicked</div>
$(document).ready(function() {
$('.show-hide').on('click', function(e) {
e.preventDefault();
var elem = $(this).attr('data-elem');
$(elem).toggleClass('hidden');
$(this).toggleClass('glyphicon-menu-down');
'use strict';
require('dotenv').config();
let fs = require('fs');
let moment = require('moment');
let ts = moment().format('YYY_MM_DD');
let filename = `unit/${ts}_unit.jpg`