Skip to content

Instantly share code, notes, and snippets.

View rinkeby-faucet
0xa8BA5E97DB500655c18A8aa3FEd6DA5d6c8e868F
@litch
litch / shopify.md
Last active Mar 20, 2019 — forked from lambtron/shopify.md
segment event tracking for shopify
View shopify.md
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 Jul 1, 2016
Health check HTTP endpoint for a ruby (micro)service
View health.rb
# 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:
View make-request.html
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 Oct 9, 2015 — forked from winhamwr/tutorial.md
Creating a repeatable, dynamic site to site VPN with OpenSwan on Ubuntu 10.04 from Amazon EC2
View tutorial.md

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.

View event_store_handler_idempotency.md

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 Apr 7, 2015
Sample EventStore Consumption
View sample_eventstore.rb
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 Aug 29, 2015
Vert.X Polling EventStore Client
View output
require 'vertx'
@client = Vertx::HttpClient.new
@client.port = 2113
@client.host = 'localhost'
module TestStream
class WriteEvent
attr_reader :event_data
attr_reader :client
View superjustin.rb
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!
View latency.markdown

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns  = 250 µs