Skip to content

Instantly share code, notes, and snippets.

View stympy's full-sized avatar

Benjamin Curtis stympy

View GitHub Profile

Terraforming API Gateway to SQS queue

Example of a bare-minimum terraform script to setup an API Gateway endpoint that takes records and puts them into an SQS queue.

SQS

Start by creating the SQS queue.

resource "aws_sqs_queue" "queue" {
@stympy
stympy / slack.sh
Created July 12, 2019 10:24 — forked from naveenarun/slack.sh
Function for sending a verbose slack message (containing path, command, error code, and custom message) after a process or series of processes exit
# Place this in your .bashrc
# Covers several corner cases such as nested apostrophes, history extraction in screens/subshells, Slack being down, etc.
# Strings to replace with your own credentials:
## {your email address} (1 instance)
## {slack webhook url} (1 instance)
## {your computer name} (2 instances)
slack() {
# Get slack message when a command exits
# Example usage: python long_job.py; slack
@stympy
stympy / Dockerfile
Last active February 3, 2018 12:25 — forked from dogweather/Dockerfile
Docker dev environment for Ruby on Rails
# Ruby on Rails Development Environment
FROM ruby:2.5.0
# Set up Linux
RUN apt-get update
RUN apt-get install -y build-essential inotify-tools libpq-dev nodejs postgresql-client
WORKDIR /app
EXPOSE 3000
@stympy
stympy / 1 app-models-session.rb
Created March 23, 2017 13:13 — forked from KieranP/1 app-models-session.rb
A Ruby on Rails implementation of a Database and Cookie hybrid session storage for Devise that supports session revocation and storage of session ip and user agent for security (similar to Github)
# A user session class, a simplified mix of the following code samples:
# * https://github.com/blog/1661-modeling-your-app-s-user-session
# * http://www.jonathanleighton.com/articles/2013/revocable-sessions-with-devise/
class Session < ActiveRecord::Base
# Uncomment if you use Hobo Fields, else add these yourself
# fields do
# session_id :string, :index => true, :unique => true
# accessed_at :datetime
# user_ip :string
@stympy
stympy / README.md
Created January 26, 2016 21:36 — forked from ralph-tice/README.md
SolrCloud backups

A little background on my context:

We run multiple Solr JVMs per box, which live in directories like:

/mnt/solr_8983
/mnt/solr_8984
/mnt/solr_8985
...
/mnt/solr_${PORT}
@stympy
stympy / solr_side_join.txt
Created December 21, 2015 12:56 — forked from phact/solr_side_join.txt
Solr Side Join to replace collections / dynamic fields
CREATE KEYSPACE IF NOT EXISTS docstore WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
CREATE TABLE IF NOT EXISTS docstore.metadata (
userid text,
docid text,
joinkey text,
title text,
body text,
PRIMARY KEY(userid, docid));

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60
@stympy
stympy / .gitignore
Created December 21, 2012 13:10 — forked from karmi/.gitignore
.DS_Store
Gemfile.lock
*.pem
node.json
tmp/*
!tmp/.gitignore
@stympy
stympy / js.demo.rb
Created September 5, 2012 21:52 — forked from Zapotek/js.demo.rb
V8 interpreter with basic DOM in Ruby using TheRubyRacer and Taka
require 'v8'
require 'open-uri'
require 'pp'
require 'ap'
require 'taka'
require 'ostruct'
#
# Monkey patch all elements to include a 'style' attribute
#
@stympy
stympy / session_cookie_dump.rb
Created January 31, 2012 22:06
Rails utility class for manually decoding session cookie values