Skip to content

Instantly share code, notes, and snippets.

[
{"title": "Option 1", "value": "option-1"},
{"title": "Option Two", "value": "option-2"},
{"title": "Option Three", "value": "option-3"},
{"title": "Yet another", "value": "option-4"},
{"title": "Yet another another", "value": "option-5"}
]
@lukewertz
lukewertz / abstraction.php
Created September 7, 2017 20:58
Improper Abstraction
<?php
/**
* This construct occurs when things aren't properly abstracted
*/
function huh($uid) {
$student = new Student($uid);
// The student is either in Alex or Chris' class.
if ($student->teacher == 'Alex') {
@lukewertz
lukewertz / duplicates.php
Created September 7, 2017 20:57
Duplicate code or Smart defaults
<?php
/**
* Very hard to see what is changing.
*
* Code is duplciated in conditionals that doesn't need to be.
*/
function what_was_that($one_of_these) {
$return = [];
@lukewertz
lukewertz / guards.php
Last active September 11, 2017 12:57
Guard Clauses
<?php
/**
* Hard-to-read code.
*
* The guard clauses in this code are intermixed with the logic of the function.
*/
function intermixed_guard_clauses($input = 42) {
if (empty($input)) {
throw new Exception("You really need an input to be meaningful");
@lukewertz
lukewertz / diff.diff
Created August 10, 2016 16:03
Remove notification email configuration in D8
diff --git a/conf/drupal/config/update.settings.yml b/conf/drupal/config/update.settings.yml
index aca754f..2870112 100644
--- a/conf/drupal/config/update.settings.yml
+++ b/conf/drupal/config/update.settings.yml
@@ -6,8 +6,6 @@ fetch:
max_attempts: 2
timeout: 30
notification:
- emails:
- - admin@example.com
@lukewertz
lukewertz / simple.com
Last active March 23, 2016 11:36
My thoughts on some of the features of Simple.com
Joint accounts:
In 2011, we heard "within the year". Now there's no promise of ever getting actual joint accounts. Instead I get an FAQ page that doesn't actually talk about joint accounts but rather why I don't need one.
Goals:
There are three ways to instantiate a goal and depending on how the transaction is going to happen (EFT, ACH, or mailed check) I have different options about creating repeating goals. This is just weird. I don't know for sure (I'm not a banker or regulator), but I'm assuming that this is not a regulated part of the industry. This just feels like the feature was partially developed and then y'all just kinda stopped trying. "Meh. Good enough."
Reports:
The way that reports are constructed are pretty arbitrary and don't really allow for any inspection of cashflow. Why only show ten categories? Why not 8? Why not 12? Why not let me choose?! Sure, I can export all of my transactions and create my own spreadsheet to duplicate the information in your reports, but I can do that with nearly
<?php
atLeastOne($things, $cb) {
$uncaught = true;
for ($i in $things) {
if ($cb($i) && $uncaught){
$uncaught = false;
return true;
}
}
return false;
@lukewertz
lukewertz / module.drush.inc
Created October 16, 2015 16:28
Drush plugin to validate requirements
<?php
/**
* Implements hook_drush_command().
*/
function module_drush_command() {
$items['requirements-update'] = array(
'description' => 'Validate that requirements of modules are met. Enable modules as necessary.',
'aliases' => array('ru'),
);
@lukewertz
lukewertz / gist:10140355
Created April 8, 2014 15:13
Do some mysql stuff with options to clear drupal cache dumps before inserting.
#!/bin/bash
mysql_user='root'
dbname=$1
sql_file=$2
cc=false
cont=true
# Create the database if it doesn't exist
mysql -u $mysql_user -e 'CREATE DATABASE IF NOT EXISTS '$dbname';'
### Keybase proof
I hereby claim:
* I am lukewertz on github.
* I am lukewertz (https://keybase.io/lukewertz) on keybase.
* I have a public key whose fingerprint is 00A8 9AEA BA11 F389 7489 2C31 B628 3CD7 A478 A58D
To claim this, I am signing this object: