Skip to content

Instantly share code, notes, and snippets.

View texdc's full-sized avatar
🕶️

George Cooksey texdc

🕶️
  • Nashville, TN
View GitHub Profile
@texdc
texdc / hosted_zone_id.yml
Created October 6, 2017 21:06
Two ansible commands to get the Route53 zone id for a given DNS zone
---
- name: get hosted zone info
route53_facts:
query: hosted_zone
register: zone_info
- name: get zone id
set_fact:
zone_id: "{{ zone.Id | regex_replace('/hostedzone/', '') }}"
when: zone.Name == route53_zone + '.'
import boto3
import copy
table = "${destTableName}"
def handler(event, context):
// do some assume role stuff into another account here
// client = boto3.client('iam')
// response = client.assume_role(
// RoleArn=arn,
// RoleSessionName=username,
// DurationSeconds=timeout
@texdc
texdc / application.config.php
Last active September 15, 2017 18:31
A "better" ZF2 application config
<?php declare(strict_types=1);
namespace {owner}\{project}\environment;
final class ApplicationConfig
{
public const ENV_DEVELOPMENT = 'development';
public const ENV_TEST = 'test';
public const ENV_STAGING = 'staging';
public const ENV_PRODUCITON = 'production';
<?php
// generic helpers
interface NameProvider
{
public function getName();
}
trait NameProviderTrait
@texdc
texdc / 1-EventfulLocator.md
Last active August 8, 2017 15:20
A paper-napkin sketch exploring the use of SRP decorators for ZF's service locator.

A use-case for events on a service locator is rare. The most obvious would be logging, but there may be others, good or bad. Still, this should illustrate a more flexible, extensible, and maintainable architecture based around the SRP and decorators.

Pros

  • Locators don't need access to the cross-cutting concerns anymore, reducing the number of dependencies and increasing maintainability and testability.
  • Handles cross-cutting concerns, that can make the code very complex otherwise, in a clean way.
  • All the concerns are easily composable and the result is a SOLID approach towards them.
  • The decorator pattern also allows us to add or remove concerns later at one central location without having to change the business code.
  • The locator can be tailored to the application itself and end up being very small and easily understandable.
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
@texdc
texdc / account.dart
Last active February 6, 2017 20:10
Assuming that Akka had a Dart SDK...
library ddd.account;
import 'account_event.dart';
import 'package:akka/akka.dart' show TypedActor;
class _AccountState {
static const String _UNKNOWN_ACCOUNT = 'unknown';
final String accountNumber;
@texdc
texdc / application.php
Last active February 3, 2017 01:29
Higher-Order application building
<?php declare(strict_types=1);
namespace proj\http;
interface ApplicationInterface {
public function run();
public function use(callable $aMiddleware);
public function respondTo(string $anHttpMethod, string $aUriPath, callable $aResponder);
@texdc
texdc / string.js
Last active December 27, 2016 18:29
utility ("sugar") properties and functions inspired by Dart and C#
if (String.prototype.isEmpty == undefined) {
Object.defineProperty(String.prototype, 'isEmpty', {
get: function() { return this.trim() == ''; }
});
}
if (String.prototype.isNotEmpty == undefined) {
Object.defineProperty(String.prototype, 'isNotEmpty', {
get: function() { return this.trim() != ''; }
});
<?php declare(strict_types=1);
class CallbackIterator implements Iterator
{
private $index = 0;
private $maxIterations = 0;
private $callback;
public function __construct(int $anIterationCount, callable $aCallback)
{