Skip to content

Instantly share code, notes, and snippets.

View kevindb's full-sized avatar

Kevin Morris kevindb

View GitHub Profile
@kevindb
kevindb / prepare-commit-msg
Last active February 10, 2021 21:19
Prepend commit message with ticket number from branch name
#!/usr/bin/env python
# https://gist.github.com/kevindb/a360c8e90bcdf6364f1523a5787c8d89
import sys, re
from subprocess import check_output
commit_msg_filepath = sys.argv[1]
branch = check_output(['git', 'branch', '--show-current'])
@kevindb
kevindb / Enum.php
Last active September 17, 2020 00:35
Enum wrapper for use with https://github.com/spatie/laravel-enum
<?php
namespace App\Enums;
use Illuminate\Support\Arr;
use Spatie\Enum\Laravel\Enum as BaseEnum;
class Enum extends BaseEnum
{
public static function getValues(): array
@kevindb
kevindb / exception.cfc
Created October 21, 2016 16:58
Elements of a CF Application
component displayname="exception" output=false {
public struct function handleException(
required exception,
boolean log = true,
numeric loadTime = 0
){
transaction action="rollback";
local.trace = this.getTrace(arguments.exception);
@kevindb
kevindb / f_truncateWithEllipsis.sql
Created July 6, 2016 18:55
SQL Server function to truncate a string and add an ellipsis
CREATE FUNCTION [dbo].[f_truncateWithEllipsis]
(
@value VARCHAR(8000),
@maxLength INT
)
RETURNS VARCHAR(8000)
AS
BEGIN
SET @value = LTRIM(RTRIM(@value));
@kevindb
kevindb / f_nullForBlank.sql
Created July 6, 2016 18:52
SQL Server function to return NULL for blank columns
CREATE FUNCTION [dbo].[f_nullForBlank]
(
@value VARCHAR(8000)
)
RETURNS VARCHAR(8000)
AS
BEGIN
RETURN NULLIF(LTRIM(RTRIM(@value)), '')
END
@kevindb
kevindb / recursiveSort.cfc
Created June 15, 2016 14:21
Basic recursive sort in ColdFusion
component {
public array function sort (
required array arr,
numeric pos = 1
) {
local.nextPos = arguments.pos + 1;
if (arguments.arr[arguments.pos] > arguments.arr[local.nextPos]) {
local.tempLeft = arguments.arr[arguments.pos];
arguments.arr[arguments.pos] = arguments.arr[local.nextPos];
@kevindb
kevindb / menuHeritage.sql
Created September 30, 2015 19:57
SQL Server generates string for recursive menu parents
CREATE FUNCTION [dbo].[f_menuHeritage]
(
@menuId INT
)
RETURNS VARCHAR(1000)
AS
BEGIN
DECLARE @result VARCHAR(1000);
SET @result = '';
@kevindb
kevindb / jQuery.coldfusionQuery.js
Created August 3, 2015 02:36
Looping Over ColdFusion JSON Queries In jQuery
/*---------------------------------------------------------------------------------------
Blog Entry:
Looping Over ColdFusion JSON Queries In jQuery
Author:
Ben Nadel / Kinky Solutions
Link:
http://www.bennadel.com/index.cfm?event=blog.view&id=1755
@kevindb
kevindb / gist:7f3494b273ab2410a110
Created June 14, 2015 23:21
Lines of code in a git repository
git diff --shortstat `git hash-object -t tree /dev/null`
git config --global alias.lg "log --oneline --decorate --all --graph"
git config --global alias.s "status -s"