Skip to content

Instantly share code, notes, and snippets.

Shipping 🔥 & ⚡️

Andrew Hammond andrhamm

Shipping 🔥 & ⚡️
Block or report user

Report or block andrhamm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
andrhamm / deepChangeKeyCase.js
Last active Oct 18, 2019
Javascript Deep Change Key Case
View deepChangeKeyCase.js
// deeply changes the case of object keys, including in sub arrays of objects
const _ = require('lodash');
function deepChangeKeyCase(value, fn) {
if (Array.isArray(value)) {
return => deepChangeKeyCase(v, fn));
} else if (_.isPlainObject(value)) {
return Object.entries(value).reduce((acc, [k, v]) => {
acc[fn(k)] = deepChangeKeyCase(v, fn);
return acc;
andrhamm / await-state-machine-execution.js
Last active Jun 14, 2019
API Gateway Synchronous Step Function Execution
View await-state-machine-execution.js
// handlers/await-state-machine-execution.js
import AWS from 'aws-sdk';
import { snakeCaseObj } from '../lib/common';
const stepfunctions = new AWS.StepFunctions({apiVersion: '2016-11-23'});
const {
} = process.env;
andrhamm / AWS JavaScript SDK - Configure AWS Service Client from an API Service Model (JSON files).md
Last active May 9, 2019
AWS JavaScript SDK - Configure AWS Service Client from an API Service Model (JSON files)
View AWS JavaScript SDK - Configure AWS Service Client from an API Service Model (JSON files).md

The AWS JavaScript SDK (and presumably SDKs for other langauges) are dynamically configured from JSON files that specify all the possible API endpoints and their request/response structure for the given service.

In the case of Amazon Personalize, the minimal documentation only describes how to "load" these JSON files for the CLI SDK:

Here is an example of how to configure a service client object in the JavaScript SDK. I arrived at this conclusion by exploring the node_modules/aws_sdk directory, specifically the apis, and clients subdirectory.

(Download the service models from the page linked above.)

andrhamm / signing.rb
Created May 10, 2018
Signing in Ruby/Rails with no dependencies
View signing.rb
# JWT-like tokens in Rails
require 'openssl'
require 'base64'
# Generate encrypted signing key
key =
cipher ='AES-128-CBC')
andrhamm / callbacks.js
Last active Jul 31, 2019
Paginating Scans & Queries in DynamoDB with Node.js using Callbacks OR Promises
View callbacks.js
const AWS = require('aws-sdk');
AWS.config.logger = console;
const dynamodb = new AWS.DynamoDB({ apiVersion: '2012-08-10' });
let val = 'some value';
let params = {
TableName: "MyTable",
ExpressionAttributeValues: {
andrhamm / killsticky.js
Created Oct 13, 2017
Kill Sticky Header (Bookmarklet)
View killsticky.js
// Found this bookmarklet on a blog post somewhere and it is awesome.
// Save to bookmark bar and click to kill any annoying floating headers that take up you vertical resolution
andrhamm / delete-reddit-history.js
Created Sep 6, 2017
Delete reddit comment and post history
View delete-reddit-history.js
// Load user profile page, if using RES scroll so many comments are loaded onto the page
// then enter the following in the browser's developer console.
// it will delete 1 post/comment every 1500ms
var $domNodeToIterateOver = $('.del-button .option .yes'),
currentTime = 0,
timeInterval = 1500;
$domNodeToIterateOver.each(function() {

Keybase proof

I hereby claim:

  • I am andrhamm on github.
  • I am andrhamm ( on keybase.
  • I have a public key ASD1L_zjBmhhjwPN9qUKs_j3afa7VxjZaxsSRq_qahht_Ao

To claim this, I am signing this object:

View emotional_support_pig.html
_._ _..._ .-', _.._(`))
'-. ` ' /-._.-' ',/
) \ '.
/ _ _ | \
| a a / |
\ .-. ;
'-('' ).-' ,' ;
'-; | .'
\ \ /
andrhamm / redis-expireeq.rb
Last active Aug 29, 2015
Redis LUA script for atomically setting a key's expiration if its value is unchanged
View redis-expireeq.rb
# EXPIREEQ key value_assertion seconds
# Set a timeout on key if the current value equals value_assertion.
# EXPIREEQ is short for "EXPIRE if EQual"
# The lua script:
expireeq = <<-EOF
local key = KEYS[1]
local val_assert = ARGV[1]
local ex = ARGV[2]
local val ="GET", key)
You can’t perform that action at this time.