Skip to content

Instantly share code, notes, and snippets.

View gabesullice's full-sized avatar

Gabe Sullice gabesullice

View GitHub Profile
@gabesullice
gabesullice / secreview.sh
Created February 11, 2015 20:11
Drupal Security Review Script
#!/bin/bash
drush dl drupalgeddon -y; drush dl site_audit --dev -y; drush dl hacked --dev -y; drush en hacked -y; drush en security_review -y
mkdir secreview
drush aa --html --bootstrap --detail --skip=insights > ./secreview/report.html
drush hacked-list-projects --force-rebuild | tee ./secreview/hacked.txt
cat ./secreview/hacked.txt | grep '\s.hanged' | grep -v 'Status' | sed 's/\s\s\+/|/g' | awk -F '|' '{print $2}' | xargs -I{} sh -c "drush hacked-diff '{}' > './secreview/hacked.{}.patch'"
@gabesullice
gabesullice / entitycache.php
Created February 25, 2015 23:33
Demonstrates enabling entitycache for custom entities.
<?php
/**
* @file
* The Bean Entity cache module.
*/
/**
* Implements hook_entity_info_alter().
*/
@gabesullice
gabesullice / gist:e1935a75ccba1e16b294
Created February 26, 2015 21:30
Go lang DB Connection Config
func NewStorage(settings ...StorageConfig) *Storage {
var s Storage
s.ConnectOpts = r.ConnectOpts{
Address: "localhost:28015",
Database: "dbname",
MaxIdle: 10,
Timeout: time.Second * 10,
}
@gabesullice
gabesullice / drupal_root.sh
Last active August 29, 2015 14:16
Find the Drupal root quickly in bash
#!/bin/bash
test_root () {
if [ "$(pwd)" != "/" ]; then
lnct=$(find . -maxdepth 2 -type f -path './includes/bootstrap.inc' | wc -l)
if [ $lnct -gt 0 ]; then
drupal_root=$(pwd)
return 0
else
cd ..
@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
@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:

<?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
};
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 \
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"
const shapeFactory = {
make: function () {
console.log(arguments)
}
}
class Monad {
constructor ({type = undefined, scale = undefined} = {}) {
this.type = type