Skip to content

Instantly share code, notes, and snippets.

View benrowe's full-sized avatar
😀
building things!

Ben Rowe benrowe

😀
building things!
View GitHub Profile
@benrowe
benrowe / scss-pseudo-empty-spinner.scss
Created November 17, 2015 23:36
Create a loading spinner using font-awesome when an element is empty
/**
* Example usage
* .container {
* @extends %empty-spinner;
* }
}
*/
%empty-spinner {
// empty
@benrowe
benrowe / slugify.js
Created November 24, 2015 00:07 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@benrowe
benrowe / NullIfEmptyTrait.php
Created December 1, 2015 05:16
NullIfEmptyTrait for Laravel models
<?php
/**
* @author Ben Rowe <ben.rowe.83@gmail.com>
*/
namespace App\Models;
/**
* Defines a list of model attributes that need to be handled as null fields
@benrowe
benrowe / htmlentities.js
Created December 10, 2015 22:03
htmlentities for javascript
function htmlEntities(value)
{
return value.
replace(/&/g, '&amp;').
replace(/</g, '&lt;').
replace(/>/g, '&gt;').
replace(/"/g, '&quot;');
}
@benrowe
benrowe / common.sh
Created February 9, 2016 23:08
common bash functionality for echo'ing
#!/bin/bash
# text colours
text_error='\033[0;31m'
text_success='\033[0;32m'
text_warning='\033[0;33m'
text_info='\033[0;34m'
text_default='\033[0m'
function e() {
@benrowe
benrowe / readme.md
Last active February 27, 2018 00:33
composer and php 7 on unraid via docker

Install composer

  1. sudo nano /usr/local/bin/composer
  2. Add
    #!/bin/sh
    export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
    echo "Current working directory: '"$(pwd)"'"
    docker run --rm -v $(pwd):/app -v ~/.ssh:/root/.ssh composer/composer $@
    
  3. chmod +x /usr/local/bin/composer
@benrowe
benrowe / git-find-parent-branch.sh
Last active October 16, 2017 02:39
Based on the currently checked out branch, find where it branched from
git show-branch -a \
| grep '\*' \
| grep -v `git rev-parse --abbrev-ref HEAD` \
| head -n1 \
| sed 's/.*\[\(.*\)\].*/\1/' \
| sed 's/[\^~].*//'
@benrowe
benrowe / .hyper.js
Last active October 27, 2017 04:15
Hyper Terminal Sync Settings
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// Choose either "stable" for receiving highly polished,
// or "canary" for less polished but more frequent updates
updateChannel: 'stable',
@benrowe
benrowe / .aliases
Last active July 10, 2023 03:26
Local machine config
alias dk_restart="osascript -e 'quit app \"Docker\"' && open -a Docker"
alias dkps="docker ps --format '{{.ID}} - {{.Names}} - {{.Status}} - {{.Image}}'"
alias dk="docker"
alias dkl="docker logs"
alias dklf="docker logs -f"
alias dki="docker images"
alias dks="docker service"
alias dkrm="docker rm"
alias dkrmi="docker rmi"
@benrowe
benrowe / Makefile
Last active June 16, 2020 01:55 — forked from prwhite/Makefile
Add a help target to a Makefile that will allow all targets to be self documenting
.PHONY: help
# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
TARGET_MAX_CHAR_NUM=20