Skip to content

Instantly share code, notes, and snippets.

View mecampbellsoup's full-sized avatar

Matt Campbell mecampbellsoup

View GitHub Profile
class SensitiveValue
attr_reader :value, :encrypted_value
def initialize(value)
@value = value
end
def encrypt
bin = value.unpack("B*")
encoded_bin = Base64.encode64(bin[0])

Authorizing Internal "System" Requests

Replicate user subject pattern

When a dashboard user requests protected API endpoints, we go through the following general steps in order to determine whether the user's request can be fulfilled.

  1. Extract the encoded authentication token from the request's Authorization header.
  2. Decode the token.
  3. Extract the token.jti claim, which represents the access token resource in the OTX DB. (i.e. AccessToken.find(token.payload.jti))
  4. Get the access token's associated subject (where AccessToken#subject is a polymorphic relationship) which should/will correspond to the dashboard user that made the request.
{
"data": {
"id": "{{transition.id}}",
"type": "ach-file-transitions",
"attributes": {
"to-state": "{{{transition.to_state}}}",
"most-recent": {{transition.most_recent}},
"metadata": {}
},
"relationships": {
#!/bin/bash
# This script inspects the present working directoy (`pwd`) and uses the
# current repository's name to return the first running kubernetes pod which
# matches the name of the repository.
# e.g. You are working in $HOME/zipmark/users-api
# Running `current-pod` should return something like `users-api-3769667108-1ybyz`
# /foo/users-api becomes /foo/users

Avatar loading

In SoundCloud's current design, we show comments on waveforms by drawing a small avatar of the author of each comment. One problem we have had was with network performance: on certain pages there are very many avatars to load. Sometimes a user will leave the current page before all the avatars have finished loading, however, after starting to load an Image element, there is no way to cancel that action.

In this challenge, we have constructed a contrived example of this situation for you to optimize.

  • Run the supplied index.html file.
  • Click on the 'Start' button, and 2000 images will start to preload. Depending on your connection speed, this could take up to 30-45 seconds to complete.
  • Click the button again before the 2000 images finish loading.
  • This is our way to simulate the user leaving the page, and therefore not needing draw the 2000 images, that is, all further requests to these images should be considered as unwanted.
@mecampbellsoup
mecampbellsoup / trigger-ci-builds.sh
Created November 28, 2016 18:20
'Trigger a build' script for (you guessed it) triggering builds to CircleCI for a list of projects. To be executed daily via crontab.
#!/bin/bash
# 1. Compose a list of all our services which need to be built
# 2. Ensure CIRCLE_TOKEN env var set and appropriate log file exists in filesystem
# 3. For each service make POST request to CircleCI's 'trigger new build' endpoint
# 4. Add this script to our crontab
# Ensure log file exists
LOG_FILE='/home/zipmark/zipmark/debug.log'
<!DOCTYPE html>
<html><head><title>Continuous Integration and Deployment</title><meta content="text/html; charset=utf-8" http-equiv="Content-Type"><meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"><meta content="width=device-width, initial-scale=1" name="viewport"><meta content="CircleCI" name="apple-mobile-web-app-title"><meta content="Hosted Continuous Integration for web applications. Set up your application for testing in one click, on the fastest testing platform on the internet." name="description"><link href="https://dmmj3mmt94rvw.cloudfront.net/favicon-undefined.ico" rel="icon" type="image/png"><link href="//dmmj3mmt94rvw.cloudfront.net/assets/css/app-557f2da6349f619795bf371f44971e21.css" rel="stylesheet" type="text/css"><script type="text/javascript">var circleEnvironment = "production";var circleHost = "i-eaf27fe4";var current_manifest_version_key = "frontend-releases/v3/a88498e17eed0df7a764129183b71706adc1c6be.json";var segmentUrl = '//dmmj3mmt94rvw.cloudfront.net/assets/js/hosted/segme

Who we are

Founded in 2011, Zipmark is a fintech startup focused on simplifying business payments. We originally focused on a branded, mobile business-to-business ("b2b") payment application, but subsequently pivoted to a white-label SaaS application called Zipmark Deposit.

Today, we have a portfolio of around a dozen customers that are using Deposit in order to move money through the banking system. As an example, an online lending company might use Deposit to send out their weekly loan issuances directly to their customers' bank accounts. Our software handles the complexities, intricacies, and general headaches associated with ACH transfers. We also provide end-to-end support to our business customers ("merchants") in the event that an issue arises downstream with one of their customers ("sub-merchants" or just "customers").

What we’re building

While we found some success with Zipmark Deposit, over time we realized that 'ACH as a service' had become commoditized and that there would be per

# WorldWideWebCoin: A Thought Experiment
<sub>
*WorldWideWebCoin - WWWCoin vs. Bitcoin - More usefulness leads to more adoption leads to more usefulness*
</sub>
Bitcoin is [many things](https://www.coinbase.com/what-is-bitcoin?locale=en) - open source peer-to-peer (p2p) digital money; an [alternative asset class for investors](http://fortune.com/2016/10/18/winklevoss-state-street-bitcoin-etf-administrator/); and possibly the global reserve currency of the future, when [machines are participating in marketplaces autonomously without human intervention](https://startupboy.com/2014/04/01/the-fifth-protocol/).
The value of one Bitcoin (1 BTC) in essence is a reflection of its **usefulness** across the many functions in which it's being used.
[24] pry(main)> u = User.first
User Load (0.8ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT $1 [["LIMIT", 1]]
#<User:0x007ff5557830c8> {
:id => "173e4d20-8487-4848-97b9-ef6fbd92ca78",
:email => "email",
:name => "matt",
:created_at => Fri, 22 Jul 2016 20:12:13 UTC +00:00,
:updated_at => Fri, 22 Jul 2016 20:12:13 UTC +00:00,
:email_verified_at => nil
}