Skip to content

Instantly share code, notes, and snippets.

@nvahalik
nvahalik / ScheduleList.php
Created October 16, 2020 20:19 — forked from M165437/ScheduleList.php
PHP Artisan command that lists all scheduled tasks: php artisan schedule:list (Credit: https://stackoverflow.com/a/35559970/2714126)
<?php
namespace App\Console\Commands;
use Carbon\Carbon;
use Cron\CronExpression;
use Illuminate\Console\Command;
use Illuminate\Console\Scheduling\CallbackEvent;
use Illuminate\Console\Scheduling\Schedule;
@nvahalik
nvahalik / git-split-commit.sh
Created October 29, 2019 21:19
git-split-commit
STAGED_CHANGES=`git status -s --untracked=no --porcelain | grep -v '^[\s\?]' | wc -l`
if [ "$STAGED_CHANGES" -eq 0 ]; then
echo "Nothing to commit. Quitting."
exit;
fi;
if [ "$TMUX" == "" ]; then
SESS="sc$$"
tmux new-session -d -s "$SESS" 'exec git diff --cached'
@nvahalik
nvahalik / README.md
Created October 3, 2019 21:33
Git branch listing with JIRA integration

Overview

This shell script allows one to list all branches in the current repo and also do a lookup within JIRA to show the results. Example:

Ref      Name                                              Upstream  JIRA Status      Last update
689f9e7  PROJ-776-something-something-reconfigure          origin    Code Review      13 days ago
043ff1e  PROJ-827-some-particular-task                     origin    Failed Testing   13 days ago
3fa55b0  PROJ-849-yet-another-task.                        origin    Code Review      2 hours ago
818602e  dev                                               origin    -                2 hours ago
@nvahalik
nvahalik / ArrayModel.php
Last active June 3, 2019 10:07
A QnD class for keeping arrays straight
<?php namespace App\Models;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Fluent;
class ArrayModel extends Fluent
{
public function __construct($data)
{
if (($validator = Validator::make($data, $this->rules()))->fails()) {
@nvahalik
nvahalik / backup-this-site.sh
Created March 8, 2019 15:45
Maintains hourly backups for a given site on Pantheon...
# Assumes you have installed Terminus and already authenticated using a machine token.
# Just call this script using a cronjob:
# 0 * * * * /home/backups/backup-this-site.sh site.env
TERMINUS_BIN="/home/backups/vendor/bin/terminus"
if [ "$1" == "" ]; then
echo "You must specify which host."
exit
fi
@nvahalik
nvahalik / dpp.md
Last active August 10, 2018 14:59
A basic data protection policy for sub/contractors

Background

We've been trying to codify some ways to convey to people what we do and what we expect them to do regarding how they manage and handle customer-related data. Curious on any thoughts or feedback anyone might have. This is the first draft!

Data Protection Policy

As a contractor for the Company, you agree to undertake the following in the daily course of business:

  • Take all necessary measures to ensure that any source code, client-related data, secrets, etc. will remain in secure storage while they are being worked on.
  • Promptly remove any and all assets for a client in the event of a project becoming terminated or a lapse in work for a client for a period of 6 weeks. This includes and all backups of all client-related data.
  • Encrypt all backups or you will exclude from backups all source code, databases, and assets for each client.
@nvahalik
nvahalik / drupal_request.json
Created November 16, 2016 03:58
Drupal Request lnav format
{
"drupal_request": {
"title": "Drupal Request Format",
"description": "A log record following Acquia's Drupal Request log file format.",
"regex": {
"default": {
"pattern": "\\[(?<timestamp>\\d{2}/\\w{3}/\\d{4}:\\d{2}:\\d{2}:\\d{2} (\\+|-)\\d{4})\\] (?<host>[\\w-\\.]+) (?<method>GET|POST|) (?<url>[\\S]+) http_code=(?<http_code>\\d{3}|) query=(?<query>\\S*) uid=(?<uid>\\d+) php_pid=(?<php_pid>\\d+) php_time=(?<php_time>\\d+\\.?\\d*) queue_wait=(?<queue_wait>-?\\d+) request_id=\"(?<request_id>[\\w-]+)\""
}
},
"opid-field": "uid",
/*
$type = 'commerce_order_order_confirmation';
$order = commerce_order_load(1);
$message = message_create($type);
$wrapper = entity_metadata_wrapper('message', $message);
$wrapper->message_commerce_order->set($order);
$wrapper->save();
dpm($wrapper->value());
@nvahalik
nvahalik / dpatch.py
Created December 2, 2015 03:30
Drupal patch maker
#!/usr/local/bin/python
import json
import re
import urllib2
import subprocess
class Issue:
def __init__(self, number):
self.number = number
@nvahalik
nvahalik / Doxyfile
Created August 21, 2015 17:33
My "standard" Doxyfile which generates super-nice docs.
# Doxyfile 1.8.9.1
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
#
# All text after a double hash (##) is considered a comment and is placed in
# front of the TAG it is preceding.
#
# All text after a single hash (#) is considered a comment and will be ignored.
# The format is: