Skip to content

Instantly share code, notes, and snippets.

@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
#!/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 / 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)
@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 / 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 / settings.php
Last active May 30, 2017 18:42
Drupal 8 basic settings file (for development)
<?php
assert_options(ASSERT_ACTIVE, TRUE);
\Drupal\Component\Assertion\Handle::register();
$databases = [
'default' => [
'default' => [
'driver' => 'mysql',
'database' => '',
'username' => '',
@robballou
robballou / rule_config.php
Created December 14, 2015 17:20
Get Drupal Rules configuration settings
<?php
$rule = 'some_rule';
$config = db_query('SELECT data FROM rules_config WHERE name=:name', array(':name' => $rule))->fetchColumn(0);
$rule_config = json_decode(unserialize($config)->export());
// $rule_config = $rule_config->$rule->DO[0]->rule->thing->value->settings;
@robballou
robballou / output_data.js
Created November 19, 2015 17:30
Output data scratch script (node js)
// Reads stdin and divides that into the output trasnform
//
// Usage: pbpaste | node output_data.js | pbcopy
var _ = require('lodash');
process.stdin.setEncoding('utf8');
var data = [];
process.stdin.on('readable', function() {
@robballou
robballou / someModule.js
Created October 29, 2014 23:04
Testing jQuery code in Mocha
// The hacky bit of this approach is that this module uses
// jQuery, but it is not referenced here. This is because I
// am populating it in the test via global namespace.
//
// In the browser this still works because I am adding jQuery
// via a Browserify transform (browserify-global-shim).
function someModule() {
}
modules.export = someModule;
@robballou
robballou / gist:b96138966998595f1fa0
Last active August 29, 2015 14:07
Alfred app web search for Atom editor packages