Skip to content

Instantly share code, notes, and snippets.

# List all files with the wrong nameapace.
list_php_files_with_wrong_namespace() {
git ls-files --cached --modified '*.php' | while read PHP_FILE ; do
local EXPECTED_NAMESPACE="$(
echo "$PHP_FILE" | \
sed -e 's/^src\///' -e 's/\//\\/g' -e 's/\.php$//' | \
rev | cut -d'\' -f2- | rev
)"
local NAMESPACE="$(grep '^namespace ' "$PHP_FILE" | cut -d' ' -f2 | sed -e 's/;$//')"
#!/usr/bin/env bash
# vim: filetype=sh
REPO_1="$(readlink -f "${1:-$(pwd)}")"
REPO_2="$(readlink -f "$2")"
quit() {
echo "quit_with_error()"
echo "ERROR: $@" >&2
exit 1
@jacks0n
jacks0n / string-to-pascal-case.js
Last active April 19, 2024 04:00
Convert a string in JavaScript to Pascal Case (removing non alphabetic characters).
/**
* Convert a string to Pascal Case (removing non alphabetic characters).
*
* @example
* 'hello_world'.toPascalCase() // Will return `HelloWorld`.
* 'fOO BAR'.toPascalCase() // Will return `FooBar`.
*
* @returns {string}
* The Pascal Cased string.
*/
@jacks0n
jacks0n / Fill the GitHub PR Review Summary.js
Created December 20, 2016 00:31
Tampermonkey / Greasemonkey script to fill the GitHub PR review summary based on the resolution chosen.
// ==UserScript==
// @name Auto-fill GitHub PR Review Summary
// @namespace http://jacksonc.com/
// @version 0.1
// @description Fill the GitHub PR review summary based on the resolution chosen.
// @author Jackson Cooper <jackson@jacksonc.com>
// @match https://github.com/*/*/pull/*/files
// @grant none
// ==/UserScript==
@jacks0n
jacks0n / Remove Drupal's Contextual Destination Parameters.js
Created December 15, 2016 05:22
Tampermonkey / Greasemonkey script which removes the `destination=` query parameter from Drupal's contextual links (e.g. edit panel, menu item, block, etc).
// ==UserScript==
// @name Remove Drupal's Contextual Destination Parameters
// @namespace http://jacksonc.com
// @version 1.0
// @description Removes the `?destination=` parameter from Drupal's contextual links.
// @author Jackson Cooper <jackson@jacksonc.com>
// @grant none
// @require https://cdnjs.cloudflare.com/ajax/libs/URI.js/1.18.4/URI.min.js
// ==/UserScript==
@jacks0n
jacks0n / git-maintain.sh
Created November 21, 2016 13:04
Git maintenance commands
# Remove dangling commits/blobs.
git reflog expire --expire=now --all
# Verify connectivity and validity of the DB objects.
git fsck --full --unreachable
# Cleanup unused branches.
git remote | xargs --no-run-if-empty git remote prune
# Re-pack repository objects.
/**
* Execute a function only once per instance.
*
* @param {...*} arguments
*
* @return {*}
* The return value of the function's first execution.
*/
Function.prototype.once = function() {
var _self = this,
@jacks0n
jacks0n / drupal-hide-admin-menu.bookmarklet.js
Created August 4, 2016 22:50
Bookmarklet to hide the Drupal admin menu.
// Generated with http://chriszarate.github.io/bookmarkleter/
javascript:void%20function(){(function(n){n(%22%23admin-menu,%20.header-wrap%22).hide(),n(%22body.admin-menu%22).css(%22cssText%22,%22margin-top:%200%20!important%22)})(jQuery)}();
@jacks0n
jacks0n / jira-git-branch.bookmarklet.js
Last active June 15, 2017 17:20
Generate a Git branch name from a JIRA ticket's project and title slug.
// Generated with http://chriszarate.github.io/bookmarkleter/
javascript:!function(){var%20e=document.getElementById(%22key-val%22).text,t=document.getElementById(%22summary-val%22).textContent,a=t.trim().replace(%22+%22,%22and%22).replace(/[^a-z0-9+]+/gi,%22_%22),n=%22feature/%22+e+%22_%22+a;window.prompt(%22Copy%20to%20clipboard%22,n)}();
@jacks0n
jacks0n / scss-lint-disable-inline
Created July 13, 2015 00:40
Disable scss-lint errors/warnings inline.
// scss-lint:enable DuplicateProperty
Linter list: https://github.com/brigade/scss-lint/blob/master/lib/scss_lint/linter/README.md