Skip to content

Instantly share code, notes, and snippets.

@tpavlek
tpavlek / bike-lanes.md
Last active June 21, 2016 16:42
Scott McKeen on Bike Lanes

All City Council votes on topics related to bike or bicycle can be found here.

In the case of Councillor McKeen, he has voted in favour of every bicycle lane removal:

  • 40th Street, on 2015-07-07. Note, item 3 of the motion contains That Administration prior to the 2019 Capital Budget provide to Council through Transportation Committee a proposed revised bicycle transportation implementation strategy to include plans for a high quality (segregated from traffic) network of cycle infrastructure and neighbourhood (local road) routes informed by the 2015-2018 Bike Lane Infrastructure Plan enhanced public engagement strategies approved by Council on June 5 2015
  • 95th Avenue, on 2015-07-07. Note, there was [a motion in June of that year](https://yegvotes.info/motions/12832c5e-3070-495b-812e-3
@tpavlek
tpavlek / combinations.php
Created June 2, 2016 22:12
Get all combinations of two collections
<?php
/**
* If you have two sets of collections, which you would previously have used a nested foreach to do something to each unique
* combination of items, you can use this macro to get it done instead!
*
* It will return a collection of tuples that represent the combination of the two collections. If you'd like to add keys to the tuple
* you can pass that in as an optional second argument!
*/
@tpavlek
tpavlek / ets.md
Last active May 10, 2016 22:45
Looks like ETS doesn't actually make money

I spoke at Executive Committee today and one of my stronger points was that ETS was allegedly making a profit off core routes, which meant that core neighbourhoods were subsidizing sprawl with their user fees. Unfortunately, it looks like that was a bit off base due to a miscommunication in our Mayor's blog post (cost vs loss symmetry in wording).

Given the some recent data in the open data catalogue (which is from September of 2013), the annual ridership for the year ending Setpember 2013 was 86,305,040.

When we look at the 2013 operating budget, the total cost of operating transit was 438,875,000 (with 309,476,000 from city subsidies and 129,399,000 from fares.

Some back of the envelope calculations yield a cost-per-trip of about $5.09, which after fare

@tpavlek
tpavlek / collections.php
Created March 11, 2016 18:09
Rolling up Data in a collection
The purpose of this is we pull a SQL query, and then by grouping together we will get sets of two and we want to see if the most
recent item in the set has increased or decreased relative to the other items. The final form of the result needs to take the form
[
'decreased' => $count,
'no-change' => $count,
'increased' => $count,
]
What I have is below. I especially don't like the last three lines where I'm forced to move out of the functional style and use
null coalescing three times. I think it could look better.
@tpavlek
tpavlek / test.php
Created November 27, 2015 13:49
Value of late-static typehints
class AbstractValueObject {
public static funtion sum(static ...$values) {
$total = 0;
foreach ($values as $value) {
$total += $value->getIntegerRepresentation();
}
@tpavlek
tpavlek / gist:3708a8ff1d908bd511af
Created October 27, 2015 16:27
Multiple laravel routes with same signature, different constraints
get('persons/{id}', function ($id) {
dd("string name");
})->name('test1');
get('persons/{id}', function ($id) {
dd("matching numeric ID");
})->name('test2')->where('id', '^[0-9,]+\d$');

Maybe the studies know a lot more than I do and perhaps I'm wrong, but from where I'm sitting people who espouse the value code reviews act like it exists in a black-and-white vacuum; code reviews are either mandatory for absolutely every commit, or your team doesn't do code review. People who champion unit testing also have a similar mindset.

We're professional developers. It would be absurd to suggest that we shouldn't perform code reviews, nor test our code. What I'm arguing is that with a team of highly-competent developers there is no need to handcuff them with mandatory processes to slow them down and come between them and releasing software. I work at a university and it's absolutely soul-sucking that a CSS colour change takes at least 3 weeks with a minimum of 4 hours of overtime to hit production.

What I'm saying is that a team of competent developers can decide what to review, what to test. If I'm doing a big refactor, I should obviously have tests for that before starting the refactor, and I sh

class UsersController < ApplicationController
def index
@users = User.all
end
def create
@user = User.new(params[:user])
if @user.save