Skip to content

Instantly share code, notes, and snippets.

@robballou
robballou / drush_functions.sh
Created January 21, 2016 15:29
Some functions for shells and drush
# drestore()
#
# Restore a drush database backup:
#
# drestore [backup]
function drestore() {
drush sql-drop --yes
pv $1 | drush sqlc
if [[ -e ./core ]]; then
drush cache-rebuild
@robballou
robballou / csv_headers.py
Created January 28, 2016 18:31
Output the CSV header row items
#!/usr/bin/env python
import csv
with open('example.csv', 'rb') as original_file:
data = csv.reader(original_file)
for row in data:
for item in row:
print "%s" % item
break
@robballou
robballou / commit_everything.sh
Last active December 14, 2022 21:23
A script to commit the git parent repo and any submodule changes too
#!/bin/bash
#
# Usage: ./commit_everything.sh "Commit message"
BOLD=$(tput bold)
BLACK=$(tput setaf 0)
WHITE=$(tput setaf 7)
BLUE=$(tput setaf 4)
GREEN=$(tput setaf 2)
NORMAL=$(tput sgr0)
#!/usr/bin/env python
import itertools
import argparse
import sys
import time
def get_permutations(number, delimiter=''):
for seq in itertools.product((0,1), repeat=number):
yield delimiter.join(map(str, seq))
@robballou
robballou / eject_thing.osa
Last active December 1, 2016 16:05
AppleScript to shutdown iTunes and eject an external drive. Change the volumename "Example" to the volume you want to eject. You can run this in Alfred if you want to be extra cool
# Stops iTunes and ejects an external drive
set appname to "iTunes"
set volumename to "Example"
tell application appname to quit
repeat until application appname is not running
delay 1
end repeat
@robballou
robballou / commit_everything.sh
Last active May 10, 2018 14:53
Updated commit everything script
#!/bin/bash
#
# Usage: ./commit_everything.sh "Commit message"
#
# This script will commit everything! This means that it will commit changes
# in submodules, subprojects, and the parent repo (if there is one). This came
# about after working on several projects with varying git repo setups and
# provides a single interface for all kinds of committing!
#
# The commit message provided is used on all commits except those commits
#!/usr/bin/env python
"""
workTime.py
Coded by: Rob Ballou ([email protected])
Calculates the number of hours that have passed
in a work day (starting at 8:30).
The start time can be changed by passing the hour and min
@robballou
robballou / ffmpeg_commands.md
Last active March 21, 2017 19:31
Various commands for ffmpeg

Various ffmpeg commands:

  • Audio rate: limit audio rate to 44100: ffmpeg -i INPUT -ar 44100 OUTPUT
@robballou
robballou / branch.sh
Created March 28, 2017 15:50
Branch sub folders
#!/bin/bash
#
# Change git branches in all subfolders (that are git repos)
#
# Usage: ./resources/scripts/branch.sh BRANCH
#
set -e
@robballou
robballou / example.sh
Last active January 9, 2018 20:38
Bash examples for my own memory's sake...
#!/bin/bash
# check number of arguments, output a message to STDERR
if [[ "$#" -eq "0" ]]; then
2>&1 echo "Usage: $0 FILE"
exit 1
fi
# check if an argument equals a string
if [[ "$1" = "dev" ]]; then