Skip to content

Instantly share code, notes, and snippets.

View vanstee's full-sized avatar
💭
🛠

Patrick Van Stee vanstee

💭
🛠
View GitHub Profile
@vanstee
vanstee / Makefile
Created May 28, 2015 17:39
Building frontend stuff with make
# Base dirs
SRC_DIR = src
TMP_DIR = tmp
DEV_DIR = dev
SRC_PUBLIC_DIR := $(SRC_DIR)/public
SRC_STYLES_DIR := $(SRC_DIR)/styles
SRC_SCRIPTS_DIR := $(SRC_DIR)/scripts
TMP_SCRIPTS_DIR := $(TMP_DIR)/scripts
DEV_PUBLIC_DIR := $(DEV_DIR)/public
DEV_STYLES_DIR := $(DEV_DIR)/styles
@vanstee
vanstee / main.go
Last active September 30, 2021 01:28
Run go tests with verbose flag in coderpad
package main
import (
"flag"
"testing"
)
func main() {
// register test flags
testing.Init()
@vanstee
vanstee / INFO.md
Last active May 27, 2020 15:06
Docker COPY busting cache on CentOS

Docker COPY busting cache on CentOS

We build a large number of images in CI and rely on images built with buildkit that contain inline cache. Recently, after switching from using buildctl build directly to using docker build with DOCKER_BUILDKIT=1 exported and the BUILDKIT_INLINE_CACHE=1 build arg, we've noticed that cache works as expected only up until a COPY instruction, as shown with steps to reproduce below.

Build on OS X and push to Docker Hub

We expect this exercise to take about 1 hour to complete. You may choose any programming language, and you may use online references/documentation/etc just as you would in your normal programming. Assume that you are writing production-level code and be sure to include test cases.

Write a program to connect to a TCP server, running at palindromer-bd7e0fc867d57915.elb.us-east-1.amazonaws.com, TCP port 7777. The server uses a raw, line-oriented text protocol: this is not an HTTP server.

For each list of words that the server sends, your program should send back only the words that are palindromes (words whose letters are the same in reverse order).

For example, if the server sends:

zittmttiz xfiyisggdt rzainiazr moqwyke

Recurrences and Conflicts

To support recurrences and easily resolve conflicting events, we need to support storing multiple events at the same time in the same room. The first event scheduled will be booked as normal. However each subsequent event overlapping that first event will be flagged as conflicting. This will give the user a chance to see the context of their conflicting event and resolve it directly from the normal event view without having to worry about losing their work at any point in the process.

API Changes

POST /events/:event_id/bookings

How do you see detaching bookings from the recurrence working?

This isn't implemented yet, but I was planning on letting you do a normal reschedule, except if the booking belonged to a recurrence the original booking would be set to hidden while a separate booking would be created with the updated attributes. Altering the recurrence would no longer change the newly created booking. Implementing booking deletion would work the same way just without creating a new booking in it's place.

Example:

# Create a recurrence and generate bookings

POST /events/1/recurrences
Booking.where('LOWER(duration) > ?', 10.weeks.ago).
group("DATE_TRUNC('week', LOWER(duration))").
pluck("DATE_TRUNC('week', LOWER(duration)) AS week, COUNT(DISTINCT(bookings.*))")
@vanstee
vanstee / runner.ex
Last active December 30, 2015 22:19
Ugh gross. Needs some refactoring love.
def evaluate_filters(filters, tags) do
results = Enum.flat_map tags, fn tag ->
Enum.map filters, fn filter ->
{ { elem(filter, 0), elem(tag, 0) }, evaluate_filter(filter, tag) }
end
end
results = Enum.reduce results, HashDict.new, fn { key, evaluation }, dict ->
Dict.update dict, key, evaluation, &(evaluation || &1)
end
git branch | tr -d " *" | xargs git show -s --format="%ci %cr %d" | sed /^\s*$/d | sort -r
#!/usr/bin/env bash
INTERFACE=${INTERFACE:="en0"}
ADDRESS=$(ifconfig $INTERFACE | grep "inet " | cut -d " " -f 2)
PATTERN="s/^.*$ADDRESS.([0-9]+).*$/\1/p"
PORTFILE="$TMPDIR$$"
sudo tcpdump -i $INTERFACE -vv -l 2> /dev/null | sed -l -n -E $PATTERN > $PORTFILE &
watch "cat $PORTFILE | sort | uniq | xargs -I % lsof -t -i :% | sort | uniq -c | sort -n | awk '{ print $2 }' | xargs -I % ps -p % -c -o command=''"