Skip to content

Instantly share code, notes, and snippets.


James Crowley jamescrowley

View GitHub Profile
phawk / graphql.js
Created Aug 23, 2019
Lambda Shopify graphql proxy endpoint
View graphql.js
const https = require("https")
const fetch = require("isomorphic-fetch")
const Account = require("./models/account")
const authenticated = require("./lib/auth")
exports.handler = authenticated(async (event, context) => {
const { id: shopId, shopifyToken } = context.account
try {
const resp = await fetch(`https://${shopId}/admin/api/2019-07/graphql.json`, {
phawk / authentication.js
Created Aug 23, 2019
Lambda HoC for authenticating requests with dynamoDB
View authentication.js
const Account = require("../models/account")
module.exports = (handler) => async (event, context) => {
let auth = event.headers.authorization
auth = auth.replace(/^Basic\s/, "")
auth = Buffer.from(auth, 'base64').toString()
const [id, token] = auth.split(":")
const account = await Account.get({ id })
andyyou /
Last active Sep 26, 2020
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collects all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
ydnar / index.es6.js
Last active Aug 30, 2020
Versioned documents with Firestore Cloud Functions
View index.es6.js
import * as admin from 'firebase-admin'
import * as functions from 'firebase-functions'
const db = admin.firestore()
async function writeIntegerVersion(event) {
const ref =
if (ref.path.indexOf('/_versions/') >= 0) {
return false
BravoTango86 / OtpAuthenticator.cs
Created Sep 20, 2016
C# OTP Implementation with TOTP and HOTP
View OtpAuthenticator.cs
* Copyright (C) 2016 BravoTango86
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
ashtonkj / CustomModelBinder.fs
Created Sep 9, 2014
WebApi Default Args Binder
View CustomModelBinder.fs
type CustomBinder() =
interface IModelBinder with
member this.BindModel(actionContext:HttpActionContext, bindingContext :ModelBindingContext) =
let qs = HttpUtility.ParseQueryString(actionContext.Request.RequestUri.Query)
bindingContext.Model <-
if (qs.AllKeys |> Seq.exists(fun q -> q.ToLower() = bindingContext.ModelName.ToLower())) then
qs.[bindingContext.ModelName] |> Some
View ImmutableAppendOnlyList.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace Voron.Util
/// <summary>
/// A list that can be used by readers as a true immutable read-only list
/// and that supports relatively efficient "append to the end" and "remove
/// from the front" operations, by sharing the underlying array whenever
joefitzgerald / Vagrantfile
Last active Jul 6, 2018
Windows Vagrantfile - Installs .NET 4.5, VS 2012, VS 2012 Update 3, then a bunch of utilities, then syspreps the machine. Get for the base box and add it with the name "windows2008r2".
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define "vagrant-windows" = "windows2008r2"
# You should be using the vagrant-windows Vagrant Plugin!
# Admin user name and password
config.winrm.username = "Administrator"
ltudury / nxlog_loggly.conf
Last active Jan 14, 2020
NXLog configuration that can be used to send Windows events to Loggly. Include your unique customer token where specified.
View nxlog_loggly.conf
## This is a sample NXLog configuration file created by Loggly. June 2013
## See the nxlog reference manual about the configuration options.
## It should be installed locally and is also available
## online at
## Please set the ROOT to the folder your nxlog was installed into,
## otherwise it will not start.
#define ROOT C:\Program Files\nxlog
define ROOT C:\Program Files (x86)\nxlog
mbenford / Bootstrap.bat
Created May 27, 2013
Bootstrap script to register a Tentacle with an Octopus server and deploy a release to its environment/role. Requires a Tentacle installer and Octo.exe in the same directory of the script.
View Bootstrap.bat
start /wait msiexec /i Octopus.Tentacle.<version>.msi /quiet INSTALLLOCATION=C:\Octopus
cd C:\Octopus\Agent
tentacle configure --appdir="C:\Applications" --port=10933 --trust=<server-thumbprint>
tentacle new-certificate
tentacle install
tentacle register-with --server=<server-url> --environment=<environment> --role=<role> --apikey=<some-user-apikey>
octo deploy-release --project=<project-name> --deployto=<environment-to-deploy> --version=<version-to-deploy> --server=<server-url> --apikey=<some-user-apikey>