Skip to content

Instantly share code, notes, and snippets.

@failbottt
failbottt / nocheckin
Created September 29, 2025 15:16
Pre-commit script to bail if there's a `@nocheckin` comment in the code anywhere.
#!/bin/bash
# Find all files to be committed (respects .gitignore, staged files only)
files=$(git diff --cached --name-only --diff-filter=ACM | grep -vE '^(vendor|node_modules|\.git/)')
found=0
matchfiles=()
MSG="🚫 Commit aborted: @nocheckin found in staged files. Fix."
@failbottt
failbottt / gist:7da15a4982ed7a9d80dfd0a933fc988d
Created October 5, 2023 15:14
Autocomplete makefile commands from the terminal
# .bashrc
function _makefile_targets {
local curr_arg;
local targets;
# Find makefile targets available in the current directory
targets=''
if [[ -e "$(pwd)/Makefile" ]]; then
targets=$( \
@failbottt
failbottt / gist:c4a119fdf692a41fac3f61aeeb7f0377
Created July 20, 2019 11:31
One way to parse command line arguments using C
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int opt;
while ((opt = getopt(argc, argv, "ilw")) != -1) {
switch(opt) {
@failbottt
failbottt / gist:6175dc3928a29f2e98dc916768294f5a
Created May 24, 2019 20:02
How to compile command-t with a specific ruby version
https://coderwall.com/p/dhftbw/compile-command-t-vim-plugin-with-homebrew-and-macvim
cd ~/.vim/bundle/command-t/ruby/command-t/
/usr/local/Cellar/ruby/<ruby_version>/bin/ruby extconf.rb
/usr/local/Cellar/ruby/<ruby_version>/bin/rake make
@failbottt
failbottt / gist:f36c201ed3a173c0cc5b8938fa152ec3
Last active September 7, 2018 10:59
Quick sort algorithm in php
<?php
$unsorted = [43,21,2,1,9,24,2,99,23,8,7,114,92,5];
function quick_sort($array)
{
// Find the length of the array
$length = count($array);
// If the count is less than or greater to one, return the array.
// At that point there's nothing to sort.