Skip to content

Instantly share code, notes, and snippets.

View JasonOffutt's full-sized avatar

Jason Offutt JasonOffutt

  • Infusionsoft
  • Gilbert, AZ
View GitHub Profile
@JasonOffutt
JasonOffutt / HttpStatusCode.ts
Created September 23, 2019 15:54 — forked from scokmen/HttpStatusCode.ts
Typescript Http Status Codes Enum
"use strict";
/**
* Hypertext Transfer Protocol (HTTP) response status codes.
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
*/
enum HttpStatusCode {
/**
* The server has received the request headers and the client should proceed to send the request body
@JasonOffutt
JasonOffutt / gmail-sync.js
Last active September 8, 2018 00:50
Thinking through how we might fetch email messages from google's api
const { google } = require('googleapis');
const moment = require('moment');
// Assuming we have authed against Google's API and we have permission...
const getRecentEmails = (auth, from, daysAgo = 14) => {
const gmail = google.gmail({ version: 'v1', auth });
const date = moment().subtract(daysAgo, 'days').format('YYYY/MM/DD');
gmail.users.messages.list({ userId: 'me', q: `label:inbox from:${from} newer:${date}` }, handleListResponse(gmail));
};
// components/search/factory.js
// Grab singleton instance of DI container
import { container } from './depdendencies';
import actionFactory from '../../actions';
export const createActions = () => {
const http = container.instance('HTTP');
return actionFactory(http);
@JasonOffutt
JasonOffutt / index.phtml
Last active August 29, 2015 13:56
Inject env variable into Angular.js code
<html>
<head>
<title>Some page</title>
<script src="path/to/angular.js"></script>
<script src="path/to/scripts.js"></script>
<script type="text/javascript">
// Setting a constant/value in Angualr allows it to be accessed via dependency injection
angualr.module('someApp').value('apiUrlBase', '<?php echo getenv('API_URL_BASE'); ?>');
</script>
</head>
@JasonOffutt
JasonOffutt / extensions.js
Created September 16, 2013 17:16
Adding Backbone.js extensions to a Require.js project.
define(['backbone'], function (Backbone) {
return {
init: function () {
Backbone.View.prototype.close = function () {
this.remove();
this.unbind();
if (typeof this.onClose === 'function') {
this.onClose();
}
@JasonOffutt
JasonOffutt / Rock.settings.js
Last active December 21, 2015 19:48
Rock settings module
(function () {
'use strict';
window.Rock = window.Rock || {};
Rock.settings = (function () {
var _settings = {},
exports = {
initialize: function (options) {
if (typeof options === 'object') {
_settings = options;
}
@JasonOffutt
JasonOffutt / CheckinSchedule.cs
Created May 14, 2013 16:55
Example refactoring large nested foreach loops with linq queries.
//
// THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION-NONCOMMERCIAL-
// SHAREALIKE 3.0 UNPORTED LICENSE:
// http://creativecommons.org/licenses/by-nc-sa/3.0/
//
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Linq;
@JasonOffutt
JasonOffutt / SomeBlock.ascx
Last active December 15, 2015 05:19
Capturing CC type
<asp:HiddenField ID="hfCardType" runat="server"/>
<asp:Panel ID="View1" runat="server">
<!-- your card selection script goes here... -->
<asp:LinkButton ID="fooButton" runat="server" Text="Foo" OnClick="fooButton_Click"/>
</asp:Panel>
<asp:Panel ID="View2" runat="server">
<asp:Literal ID="lCardType" runat="server"/>
</asp:Panel>
@JasonOffutt
JasonOffutt / Receipt.ascx
Last active December 14, 2015 23:19
Emitting values in HTML...
<h3 class="header-text" >Confirm your Contribution: </h3>
<p><b><asp:Literal ID="lName" runat="server" /></b>, thank you for your generosity! You are about to give a gift totalling <b><asp:Literal ID="lTotal" runat="server"/></b> to the following funds:</p>
<asp:Repeater ID="rptGifts" runat="server">
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li><%# Eval("Amount").ToString("C") %> to the <%# Eval("Fund") %>.</li>
</ItemTemplate>
<FooterTemplate>
@JasonOffutt
JasonOffutt / TemplateManager.coffee
Last active December 14, 2015 15:59
CoffeeScript implementation of TemplateManager
TemplateManager =
partials: [] # e.g. - 'loginForm'
templates: {}
get: (id, callback) ->
# If the template is already in the cache, just return it.
if @templates[id] then return callback @templates[id]
# Otherwise, use Traffic Cop to load up the template.
url = "/templates/#{id}.html"
promise = $.trafficCop url