Skip to content

Instantly share code, notes, and snippets.

@litch
litch / digtest.sh
Created April 18, 2024 20:07
Digtest for diagnosing DNS timings
#!/bin/bash
# depends on gawk
# if running in a netshoot container, you need to install it:
# apk add --no-cache gawk
# Filename to store the results
output_file="dig_results.txt"
times_file="query_times.txt"
# Clear files if they already exist
0xa8BA5E97DB500655c18A8aa3FEd6DA5d6c8e868F
@litch
litch / shopify.md
Last active March 20, 2019 07:50 — forked from lambtron/shopify.md
segment event tracking for shopify
title sidebar
Segment Event Tracking for Shopify
Shopify

Segment makes it simple for Shopify merchants to integrate analytics, email marketing, advertising and optimization tools. Rather than installing all your tools individually, you just install Segment once. We collect your data, translate it, and route it to any tool you want to use with the flick of a switch. Using Segment as the single platform to manage and install your third-party services will save you time and money.

The guide below explains how to install Segment in your Shopify store. All you need to get up and running is copy and paste a few snippets of code into your theme editor. (You don't have to edit the code or be versed in JavaScript.) The following guide will show you how, step by step.


@litch
litch / health.rb
Created July 1, 2016 19:48
Health check HTTP endpoint for a ruby (micro)service
# This is used to provide a Health Check HTTP endpoint
# 1- Each project should have a particular endpoint(s), they should not overlap
# so that mulitple services running on a single node will not confuse our
# operations (this isn't docker, there are rules.)
# 2- If you pass a block to the build method, that code will be evaluated and
# merged into the check. The return type of that block should be a hash
# Usage examples:
I inlined the code from microAjax there, to keep dependencies at 0. I think the following cite satisfies the license?
https://code.google.com/archive/p/microajax/
This code was referenced extensively:
https://bitbucket.org/snippets/jdubray/9dgKp/sam-sample
@litch
litch / tutorial.md
Created October 9, 2015 15:14 — forked from winhamwr/tutorial.md
Creating a repeatable, dynamic site to site VPN with OpenSwan on Ubuntu 10.04 from Amazon EC2

Creating a dynamic site-to-site VPN with OpenSwan on Ubuntu 10.04 on EC2

Wes Winham winhamwr@gmail.com

There are many tutorials floating around the web that almost get you a dynamic VPN in EC2. The goal of this tutorial is to be a one-stop-shop for this specific setup.

Reading of EventStore events should be idempotent.

When a handler reads an event, it will do two things. It will manipulate its current view of application state (change balance, whatever), and then it will take actions.

As an example, we want a registration service that will read the “wallet-*” category event stream and whenever a wallet is created by something (and creates a 'WalletCreated' event), it will begin an on boarding process. The service will keep a list of wallets in its current state snapshot (which it will act based on), and it will also send commands to send a welcome text message to a customer. Here is an example code snippet for the event handler:

def !
 # Mutate internal state
@litch
litch / sample_eventstore.rb
Created April 7, 2015 16:11
Sample EventStore Consumption
require 'http_eventstore'
client = HttpEventstore::Connection.new
stream_name = 'accounts-002'
#event_data = { event_type: "AccountCreated",
# data: { phoneNumber: '15128798439' }}
#client.append_to_stream(stream_name, event_data)
EventData = Struct.new(:data, :event_type)
@litch
litch / output
Last active August 29, 2015 14:16
Vert.X Polling EventStore Client
require 'vertx'
@client = Vertx::HttpClient.new
@client.port = 2113
@client.host = 'localhost'
module TestStream
class WriteEvent
attr_reader :event_data
attr_reader :client
require 'pry'
class SuperJustin < RTanque::Bot::Brain
include RTanque::Bot::BrainHelper
NAME = 'superjustin'
TURRET_FIRE_RANGE = RTanque::Heading::ONE_DEGREE * 15.0
WALL_DETECTION_DISTANCE = 50
def tick!