Skip to content

Instantly share code, notes, and snippets.

Harlow Ward harlow

Block or report user

Report or block harlow

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
@harlow
harlow / streams_to_firehose.go
Last active May 9, 2018
Golang lambda function to send Streams data to Firehose
View streams_to_firehose.go
package main
import (
"github.com/apex/go-apex"
"github.com/apex/go-apex/kinesis"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/firehose"
)
@harlow
harlow / kinesis.js
Last active Apr 27, 2018
Lambda Functions
View kinesis.js
console.log('Loading function');
exports.handler = function(event, context) {
//console.log('Received event:', JSON.stringify(event, null, 2));
event.Records.forEach(function(record) {
// Kinesis data is base64 encoded so decode here
var payload = new Buffer(record.kinesis.data, 'base64').toString('ascii');
console.log('Decoded payload:', payload);
});
context.succeed("Successfully processed " + event.Records.length + " records.");
@harlow
harlow / lookup_found_webhook.json
Last active Sep 6, 2015
Example webhook from Company API
View lookup_found_webhook.json
{
"id": "custom_id", // the webhook_id passed in the lookup params
"status": 200,
"type": "company",
"body": {
// Company attributes
}
}
@harlow
harlow / golang_job_queue.md
Last active Aug 18, 2019
Job queues in Golang
View golang_job_queue.md
View issues_with_modules.md

My issues with Modules

In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.

A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval.

You can find instance_eval used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.

class Article < ActiveRecord::Base
@harlow
harlow / hoteltonight.json
Created Apr 15, 2015
HotelTonight lookup on Clearbit
View hoteltonight.json
{
"id": "d5639304-f15a-48b5-9711-7bd42e6c4d72",
"name": "HotelTonight",
"legalName": "HotelTonight, Inc",
"domain": "hoteltonight.com",
"url": "http://hoteltonight.com",
"site": {
"url": "http://hoteltonight.com",
"title": "HotelTonight | Last-Minute Deals on Great Hotels",
"h1": "PLAN LESS. ",
@harlow
harlow / fake_github.rb
Last active Aug 29, 2015
Have stubbed service emulate failures
View fake_github.rb
require 'sinatra/base'
class FakeGitHub < Sinatra::Base
cattr_reader :emulate_failure
def self.reset!
@@emulate_failure = false
end
def self.emulate_failure!
View 0000_packages.config
# Install Git needed for Git based gems
packages:
yum:
git: []
@harlow
harlow / recipe.md
Last active Aug 7, 2019
Drink Positive
View recipe.md

Mezcal Bone Crusher

Here is a variation of a Bone Crusher, a drink originally inspired by acclaimed cocktail writer David Wondrich's Bone cocktail made from rye whiskey, lime juice, sugar and a few dashes of Tabasco.

Here, this spicy, earthy, smoky drink was made from Del Maguey's Single Village Mezcal (Minero), El Tesoro Reposado Tequila, demerara sugar simple syrup, lime and Tabasco.

The Breakdown

3 Fresh Limes
View config_for.rb
module YourApp
class Application < Rails::Application
# Convenience for loading config/foo.yml for the current Rails env.
#
# Example:
#
# config/cleversafe.yml:
#
# production:
# url: http://127.0.0.1:8080
You can’t perform that action at this time.