Skip to content

Instantly share code, notes, and snippets.

View soutar's full-sized avatar
🤖
automating things

John Soutar soutar

🤖
automating things
  • London, UK
  • 11:41 (UTC +01:00)
View GitHub Profile
@soutar
soutar / update.sh
Last active August 29, 2015 14:10
Pull all repos in the current directory
#!/bin/bash
stash_name="wip"
echo "> Updating master on all git repositories in the current directory"
for dir in */
do
if [ -d ${dir}/.git ]; then
cd ${dir}
stashed=false
@soutar
soutar / get_template_part_with.php
Last active August 29, 2015 14:07
get_template_part_with()
<?php
/**
* This function extends get_template_part to include the ability
* to pass variables to the template file
*
* @param $template_names array|string Either a single template name or an array of template names, ordered by priority
* @param $variables array The variables to make available to the template
*/
function get_template_part_with($template_names, $variables = array()) {
@soutar
soutar / retina.less
Created October 14, 2014 14:47
Retina background image mixin for LESS
// Set the background image for retina devices
.background-image-retina(@url, @ext, @width, @height) {
@lowres: "@{url}.@{ext}";
@highres: "@{url}@2x.@{ext}";
background-image: url(@lowres);
background-size: @width @height;
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
@soutar
soutar / add_spacer.sh
Last active August 29, 2015 14:06
Add x spacers to your Dock in Mac OS X (./add_spacer.sh x)
#!/bin/bash
function add_spacer {
[[ $1 =~ ^[0-9]+$ ]] && times=$1 || times=1
echo "Adding $times spacer(s)"
i=0;
while [[ $i -lt $times ]]; do
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'
((i++))
@soutar
soutar / .bash_profile
Created September 17, 2014 13:15
Bash profile
# Path set for homebrew
export PATH="/usr/local/bin:$PATH"
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
alias lwj='cd /Volumes/CC\&A\ LIVE\ WEB\ JOBS/'
alias reinit='cd "`pwd`"'
@soutar
soutar / zip.sh
Created July 14, 2014 12:26
Zip up a project without the node_modules or git files
zip -r <project_name>.zip Site -x *.git* -x *node_modules*
@soutar
soutar / related-category.php
Created July 11, 2014 12:41
"Related category" functions from a widget built for S. Collins & Son
@soutar
soutar / over-engineered.js
Created July 11, 2014 10:57
How to massively over-engineer a method which is possible natively with getBoundingClientRect() - A guide by someone who didn't know about getBoundingClientRect()
calculateWidthOld: function (elem) {
var tr, values, transform,
a, b,
angle, width, height,
adjustedWidth;
transform = [
elem.css('-webkit-transform'),
elem.css('-moz-transform'),
elem.css('-ms-transform'),
@soutar
soutar / between.less
Last active August 29, 2015 14:01
LESS: Combine mixins, bubbling and ruleset params to create more readable media queries
.branding {
display: block;
.between(@grid-float-breakpoint, @screen-md, {
display: none;
});
}
.between(@min, @max, @rules) {
@media screen and (min-width: @min) and (max-width: @max) {
@soutar
soutar / colestrap.sh
Last active August 29, 2015 14:01
Colestrap
#!/bin/bash
blue="\e[0;34m"
purple="\e[0;35m"
orange="\e[0;33m"
green="\e[0;32m"
white="\e[0;37m"
red="\e[0;31m"
echo "-------------------------------------------"