Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
old and eccentric

Shawn McCool ShawnMcCool

💭
old and eccentric
View GitHub Profile
@ShawnMcCool
ShawnMcCool / 0-readme.md
Last active Apr 23, 2021
Are named parameters a risk to all that we hold near and dear? News at 11.
View 0-readme.md

This tests behavior on the process "CreateConferenceTicketsForWebinarCustomers".

It's possible to create a working test that looks like the "minimum possible" example. But the "actual" example has additional information that supplements the test. The null parameter with default values pattern is not new.

In this case, the named parameters improve the comprehensibility of the tests.

This is one of hundreds of tests that I've used this technique for. When testing various paths through the same process, being able to swap values in then given/when/then steps can be really beautiful.

View KalmanFilter.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Tabi.DataObjects;
namespace Tabi.Logic
{
public class KalmanLatLong : PositionEntry // Implementation taken from: https://stackoverflow.com/questions/1134579/smooth-gps-data/15657798#15657798
{
@ShawnMcCool
ShawnMcCool / .zshrc
Last active Jul 19, 2017
Moves the most recently modified file from the source directory to the destination directory.
View .zshrc
alias mvltr="~/scripts/mvltr.sh"
alias ltr="ls -ltr"
@ShawnMcCool
ShawnMcCool / A Simple PHP Postmark Library.md
Last active Feb 21, 2017
Simple postmark email send / batching.
View A Simple PHP Postmark Library.md

Examples:

public function sendSingleExample() {
    (new SendMailViaAPI('<postmark-server-token>'))->single(
        new Mail('sender name', 'sender email', 'recipient email', 'hello from exampletown', '<strong>this is bold</strong> this is not.')
    );
}

public function sendBatchExample() {
@ShawnMcCool
ShawnMcCool / lowresvga.sh
Last active Jun 23, 2016
XRANDR Scripts for Dutch PHP Conference for 16:9 laptops
View lowresvga.sh
#!/bin/bash
# "./lowresvga.sh" to enable 1024x768
# "./lowresvga.sh off" to return
# This was made for a Thinkpad T450s, substitute your devices.
if [ "$1" = "off" ] ; then
echo "disabling"
xrandr --output DP2 --off
xrandr --output eDP1 --mode 1920x1080
View idiomatic-ar.php
<?php
# Discussion about idiomatic ActiveRecord usage
## Please help me to determine the idiomatic approach for creating a member and attaching an invoice ONLY IF the member doesn't already have 5 invoices.
class Member extends Eloquent {
}
$member = Member::create([
@ShawnMcCool
ShawnMcCool / gist:16cac102e06d02365403
Created Jun 17, 2015
A Sequence Collecton for C#
View gist:16cac102e06d02365403
using System.Collections.Generic;
using Infrastructure;
using NUnit.Framework;
namespace Collections {
[TestFixture] public class SeqTests {
[Test]
public void can_access_the_head() {
var seq = new Seq<DomainEvent>();
var first = new TestEvent();
@ShawnMcCool
ShawnMcCool / php-visibility
Last active Aug 29, 2015
PHP Visibility by Example
View php-visibility
<?php
namespace PrivateExample {
class Animal {
private $innermostFeelings = "HUNGER";
public function __construct() {
echo "Animal feels $this->innermostFeelings\n";
}
public function empathy(Animal $other) {
@ShawnMcCool
ShawnMcCool / instance-reference-sugar-rfc-0.2.php
Last active Aug 29, 2015
PHP RFC: Instance Reference Sugar 0.2
View instance-reference-sugar-rfc-0.2.php
====== PHP RFC: Instance Reference Sugar ======
* Version: 0.2
* Date: 2015-03-09
* Author: Shawn McCool, shawn@heybigname.com
* Status: In Discussion
===== Summary =====
In order to access instance variables and methods, one must use the `$this->` prefix.
View gist:e7fea18b5695f8c499ad
com_android_browser
graphic-avatar-text-back
graphic-background
graphic-bootloader-usb-wakeup
graphic-busyindicator-large-background
graphic-busyindicator-large
graphic-busyindicator-medium-background
graphic-busyindicator-medium
graphic-busyindicator-small
graphic-button