Skip to content

Instantly share code, notes, and snippets.

View gabesullice's full-sized avatar

Gabe Sullice gabesullice

View GitHub Profile

Keybase proof

I hereby claim:

  • I am gabesullice on github.
  • I am gabesullice (https://keybase.io/gabesullice) on keybase.
  • I have a public key whose fingerprint is D7C7 1832 D46A 2A1C CB7A 50FB 7BBD 313F 2606 387C

To claim this, I am signing this object:

const shapeFactory = {
make: function () {
console.log(arguments)
}
}
class Monad {
constructor ({type = undefined, scale = undefined} = {}) {
this.type = type

Status

This extension was developed as part of the jsonapi module for Drupal.

Introduction

The JSON API specification is agnostic about how a server implements filtering strategies. In fact, the spec says:

Note: JSON API is agnostic about the strategies supported by a server. The filter query parameter can be used as the basis for any number of filtering strategies.

@gabesullice
gabesullice / ResponseSubscriber.php
Last active May 5, 2022 22:56
Dynamically Redirecting Drupal 8 Node Pages
<?php
/**
* This file should live at my_module/src/EventSubscriber/ResponseSubscriber.php
*/
namespace Drupal\my_module\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\Event;
@gabesullice
gabesullice / shell_scripting.md
Last active August 24, 2023 07:05
Shell Scripting for Fun and Profit

A few days ago, I mentioned to Rob Ballou, that there's just something very satisfying about shell scripting. Once you've groked all its little idiosyncracies, it's really quite addictive. As developers, I think we all get some gratification from getting things done, but also from building elegant, complete systems. For me, shell scripting really scratches all those itches. I get to build a system from start to finish, completely self-contained and solve a real problem.

Elegant, complete systems might at first seem antithetical to what most people think of shell scripting. Shell scripting is plagued by weird quoting, strange unfamiliar constructions, and a lack useful data types. However, once you embrace the things that shell scripting is good at and learn a few strategies for writing scripts tidily, it can become a fantastic tool for solving real, every day problems.

So, what are those strategies and what are things that the shell does well?

The Last Template You'll Ever Need

#!/bin/bash
watch: .watch
while true; do sleep .5; make -s checksum; done;
checksum:
cat `find . -type f ! -path *./.git* ! -name .watch` | base64 | md5sum --status -c .watch || make -s test
test: .watch
printf "Change detected. Running tests...\n"
- go test -v || printf "Failed to run test suite.\n"
build:
docker build -t node-portal .
stopdev:
- docker kill node-portal
- docker rm node-portal
startdev:
docker run \
-v $(shell pwd)/app/src:/var/node/app/src \
<?php
function get($thing, $reset = FALSE) {
return cache_anything(__FUNC__, 'something_expensive', array($thing), $reset);
}
function get_something_else($other_thing, $reset = FALSE) {
$slow = function ($other_thing) {
// slow query with $other_thing
};
@gabesullice
gabesullice / vim.md
Last active January 14, 2016 20:05
A Reluctant Guide to Vim

A Reluctant Guide to Vim

Face it, it's better than nano and easier than emacs. You're going to edit some file, somewhere, sometime on some server. You won't be able to click to move your cursor or scroll to the bottom of a 2000 line long configuration file. As it would for any developer, holding down the arrow keys will get old, fast.

This is the reluctant guide to Vim. I'm not going to try to convince you that Vim is God's gift to man. Here's the low-hanging fruit that got me hooked, maybe it will hook you too.

Too often Vim power-users will try to explain some super-powerful thing you can do and how easy it is. Honestly, it is easy for us. The thing is, it's not really all that simple. The truth is that the power of Vim comes from knowing a few basics, and then composing those simple, one character keystrokes into powerful one-liners. Of course, all those things presuppose that you know the fundamentals. Which, as a reluctant Vim user, you probably don't.

These are the fundamentals:

@gabesullice
gabesullice / site_reset.sh
Last active August 29, 2015 14:17
Drupal Local Update Script
sitereset () {
source $HOME/sql_slurp.sh
if [[ $# < 2 ]]; then
echo "You must specify at least an alias and a multisite directory name."
return
fi
read -p "Would you like to run updates (y/n)? " updb
alias=$1
site=$2