Skip to content

Instantly share code, notes, and snippets.

View chrisguitarguy's full-sized avatar

Christopher Davis chrisguitarguy

View GitHub Profile
<?php
/**
* @group example
*/
trait ExampleGroup
{
// utility methods here I guess?
}
@chrisguitarguy
chrisguitarguy / evident_io_terraform.tf
Last active February 17, 2021 19:45
Terraform configuration for an Evident.io IAM Role
variable "evident_account" {
type = "string"
}
variable "evident_id" {
type = "string"
}
data "aws_iam_policy_document" "evident" {
statement {
<?php
use Symfony\Component\HttpKernel\Kernel;
class AppKernel extends Kernel
{
public static function fromEnvironment()
{
$env = getenv('APP_ENVIRONMENT') ?: 'prod';
$debug = filter_var(getenv('APP_DEBUG'), FILTER_VALIDATE_BOOLEAN);
<?php
add_filter('page_template', function ($template) {
$page = get_queried_object();
$slugs = [];
do {
$slugs[] = $page->post_name;
$page = empty($page->post_parent) ? null : get_post($page->post_parent);
} while ($page);
@chrisguitarguy
chrisguitarguy / functions.php
Created April 13, 2016 02:18
WordPress ribosome example.
<?php
/**
* Child theme's function.php. This is loaded *before* the parent theme's so you can
* unhook things here as you wish. See: https://github.com/WordPress/WordPress/blob/e9dbea9aac6300550f1637cda24948df65752a68/wp-settings.php#L366-L369
*
* STYLESHEETPATH === child theme path
* TEMPLATEPATH === parent theme path
*
* For example, in Ribosome https://wordpress.org/themes/ribosome/ say you didn't like the way
<?php
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Acme\Example\Auth\AppUser;
/**
* Replaces the `date` filter with one that uses the user's timezone if a
* user is present.
*/
final class TimeZoneExtension extends \Twig_Extension
@chrisguitarguy
chrisguitarguy / Test.php
Created April 4, 2016 19:00
Some interesting behavior with PHPUnit mocks & return types that are final classes.
<?php
// The return type of a method, imagine this is a
// nice value object.
final class Foo
{
}
// interface that returns a `Foo` value object
interface Bar
(defn- read-int-line []
(Integer/parseInt (read-line)))
(defn- spring? [current-cycle]
(= 0 (mod current-cycle 2)))
(defn- tree-height-after [total-cycles]
(loop [current-cycle 0
height 1]
(if (>= current-cycle total-cycles)
(defn- str->int [s]
(Integer/parseInt s))
(defn- read-test-case []
(str->int (read-line)))
(defn- divisible-by-3 [n]
(= 0 (mod n 3)))
(defn- decent-number-for [digit-count]
(require '[clojure.string :as string])
(defn- str->int [s]
(Integer/parseInt s))
(defn- split-spaces [s]
(string/split s #"\s+"))
(defn- read-test-case []
(let [[students threshold] (split-spaces (read-line))