Skip to content

Instantly share code, notes, and snippets.

View stecman's full-sized avatar

Stephen Holdaway stecman

View GitHub Profile
@stecman
stecman / hhclient_use.py
Created February 21, 2015 22:32
Hack lang: Sublime Text 3 plugin to copy fully qualified class name to clipboard using hh_client
from subprocess import Popen, PIPE, STDOUT
import json
import sublime, sublime_plugin
"""
hhclient_use: copy fully qualified class name to clipboard
Copy the full class name at the current cursor position (or first class in the file)
to the clipboard. Requires the hh_client command line program to provide a JSON formatted
outline of the code in the focused buffer.
@stecman
stecman / dev_spam_fix.sh
Last active August 29, 2015 14:17
Save yourself the expense of buying cupcakes for the dev team
#!/bin/bash
#
# Make sure all untracked _ss_environment.php files use SS_SEND_ALL_EMAILS_TO
# Save yourself the expense of buying cupcakes for the dev team
#
function is_tracked() {
local filename="$1"
@stecman
stecman / grid.less
Last active March 5, 2021 03:51
Mixin based grid for LESS with scoped grid settings
//
// Based on Semantic.gs
//
// Defaults
@columns: 12;
@gutter-width: 25px;
@total-width: 100%;
// Uncomment these two lines and the star-hack width/margin lines below to enable sub-pixel
@stecman
stecman / d2git.py
Last active August 29, 2015 14:18
Convert folders named d1, d2, d3, etc into git repository
#!/usr/bin/env python
#
# Convert "versioning" with folders called d1, d2, d3.. into a git repository in the directory
# containing those folders. Written for use on *nix systems for people who weren't using version
# control software for a long time.
import os
import re
import time
import sys
@stecman
stecman / php-server-helper-shell-profile.bash
Last active August 30, 2015 11:28
Shell helper function for starting PHP dev servers
# Run a PHP dev server on the first available port starting at 8000
function serve()
{
local port=8000
# Try ports until an unused one is found
while nc -z localhost $port > /dev/null; do ((port++)); done;
echo -e "\033[44m>> Listening on port $port <<\033[0m"
php -S "0.0.0.0:$port" "$@";
@stecman
stecman / slice-convert.py
Last active May 12, 2016 04:39
heyday/silverstripe-slices 0.x to 1.0 config conversion script
#!/usr/bin/env python
# YAML config conversion script for heyday/silverstripe-slices 0.x going to 1.0
#
# Comments and whitespace aren't preserved - this is more to help you out by doing
# the repeatitive part of the conversion. The converted config is written to stdout.
#
# Note that this needs a python module installed to work:
#
# $ pip install pyyaml
@stecman
stecman / less-fix.php
Last active October 6, 2015 02:43
Script to fix vertical whitespace in LESS/CSS-like files
#!/usr/bin/env php
<?php
/**
* Fix vertical whitespace in LESS/CSS-like files
*
* This script fixes selectors that are bunched together with no spacing, and selectors
* that are bunched together with properties and have no vertical spacing. This could be
* done with sed, but the regex escaping was a pain and it's harder to document.
*
@stecman
stecman / beam-shell-profile.bash
Created August 14, 2015 22:29
Beam shell helpers
# Helper shell functions and completions for use with Beam
# https://github.com/heyday/beam
# Print the .beamlog file for a beam target.
# Target defaults to live if not given
#
# usage: whatsup [target]
#
function whatsup() {
local server="${1-live}";
@stecman
stecman / _README.md
Last active March 6, 2023 11:42
bash-completion extract for dealing with colons

Extract from bash-completion for working with stecman/symfony-console-completion

This is an example extract of the minimum amount of the bash-completion project required to use these two functions:

  • __ltrim_colon_completions
  • _get_comp_words_by_ref

The functions here are copied verbatim from the bash_completion source. I recommend not using this extract unless there are no other alternatives. Instead, prefer installing the bash-completion package from your package manager, or install bash-completion from source.

@stecman
stecman / silverstripe-remove-empty-tabs.php
Last active August 13, 2019 22:45
Remove empty tabs in the SilverStripe CMS
/**
* Recurse through tabs and remove any with no child fields
*
* The way SilverStripe's field scaffolding works can leave empty tabs around after
* fields are moved or removed by the slices module.
*
* @param FieldList $fields
* @return FieldList
*/
protected function removeEmptyTabs(FieldList $fields)