Skip to content

Instantly share code, notes, and snippets.

View vanstee's full-sized avatar
💭
🛠

Patrick Van Stee vanstee

💭
🛠
View GitHub Profile
          +--------+
          |Homepage|
          +--------+
              +
              |
              v
          +-------+      +------+
          |Sign up|      |Log in| * Pick first account
          +-------+      +------+
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=''"

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
@vanstee
vanstee / gist:6433029
Last active December 22, 2015 06:48 — forked from bruce/gist:6433003
oks = Enum.filter items, &match?({ :ok, _ }, &1)

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

iex(1)> # doesn't work
nil
iex(2)> String.strip("cat猫猫猫", ?猫)
"cat猫猫猫"
iex(3)> # works
nil
iex(4)> String.strip("cat---", ?-)
"cat"
@vanstee
vanstee / router.js
Last active December 20, 2015 10:49
// Non-nested resources
App.Router.map(function() {
this.resource('users', function() {
this.route('index');
this.route('new');
});
// The documentation uses /user/:id for these signular resources which
// seems wrong if we want to keep them RESTful (at least like rails).