Skip to content

Instantly share code, notes, and snippets.

View iamkirkbater's full-sized avatar

Kirk Bater iamkirkbater

View GitHub Profile
<?php
namespace Illuminate\Foundation\Testing;
/**
* Assert that a given where condition does not matches a soft deleted record
*
* @param string $table
* @param array $data
* @param string $connection
@iamkirkbater
iamkirkbater / old.Controller.php
Created February 14, 2016 04:34
Converting to Laravel Validator instead of doing the logic in the controller:
$start = $request->get('start');
$end = $request->get('end');
$project = $request->get('project_id');
$task = $request->get('task_id');
if ( ! $start || ! is_int($start))
{
return new Response(["error" => true, "message" => "Start time is not valid."], HTTP::BAD_REQUEST);
}
@iamkirkbater
iamkirkbater / macros.forms.twig
Created April 5, 2016 15:00
Twig Macros for forms. Uses an array of attributes instead of 400 separate parameters for separate values. Also abstracts HTML5 text types for ease of reading in your template files.
{% macro input(name, value, type, attributes) %}
<input name="{{ name }}" type="{{ type }}" value="{{ value }}"{% for attr, value in attributes %} {{ attr }}="{{ value }}"{% endfor %}{% if not attributes.id is defined %} id="{{ name }}"{% endif %}/>
{% endmacro %}
{% macro text(name, value, attributes) %}
{% from _self import input %}
{{ input(name, value, "text", attributes) }}
{% endmacro %}
{% macro password(name, value, attributes) %}
@iamkirkbater
iamkirkbater / calendar.twig
Created July 11, 2016 20:34
Twig Calendar in divs format because tables are hard for responsive. Don't remember where I got this from originally, so if you know or see it let me know and I'll attribute.
{#
Creates a faux table twig calendar.
Takes the following variables:
month
currentDay
calendarContent
month can be any string acceptable by http://www.php.net/strtotime, the
template will output that time's month.
@iamkirkbater
iamkirkbater / CommandPattern.java
Created October 6, 2016 00:21
This is an example of the command pattern for the ISTE 422 Final Project at RIT.
public interface InputParser {
// variables
Database database;
// methods
void parseFile(File inputFile);
Database getDatabase();
}
@iamkirkbater
iamkirkbater / instructions.md
Created May 19, 2017 14:38
Github SSO To Name Extension Instructions

Hi,

Thanks for using my Github SSO to Name Chrome Extension. This gist is to help you get all set up.

First off, I want to address any complaints that the extension asks permission to ALL web pages. This is due to the fact that the extension asks you to fill in your specific enterprise URL, and then only runs the code on pages with that URL. We don't use the browser functionality for that because otherwise we'd need to know your enterprise URL, and I'm not putting that into code. Sorry. Please feel free to check out the code, it shouldn't be doing anything shady.

Configuration

To configure the extension, either navigate to chrome://extensions and then find the extension, or click on the icon next to your location bar, and then click on Options. This should give you a page with three options to configure.

@iamkirkbater
iamkirkbater / cd.sh
Created January 10, 2018 13:31
Auto Change NVM version on `cd` command
cd () {
builtin cd "$@" && [ -f ".nvmrc" ] && nvm use
}
@iamkirkbater
iamkirkbater / check_default.tf
Created December 18, 2018 19:37
No default workspaces in terraform
resource "null_resource" "have_you_specified_a_workspace" {
count = "${terraform.workspace == "default" ? 1 : 0}"
"ERROR: Select a non-default workspace" = true
}
resource "aws_acm_certificate" "cert" {
domain_name = "*.${var.domain_name}"
validation_method = "DNS"
lifecycle {
create_before_destroy = true
}
}
data "aws_route53_zone" "zone" {
@iamkirkbater
iamkirkbater / scaffold.sh
Last active May 7, 2020 18:06
A quick options set and verbosity output scaffold for new bash scripts
#!/bin/bash
usage() {
cat <<EOF
usage: $0 [ OPTIONS ]
Options
-d --dry-run Do not make any modifications but preview the expected operations
-h --help Show this message and exit
-q --quiet Be Quiet
-v --verbose Be Loud