Skip to content

Instantly share code, notes, and snippets.

View scottsb's full-sized avatar

Scott Buchanan scottsb

View GitHub Profile
@scottsb
scottsb / casesafe.sh
Last active January 16, 2024 08:47 — forked from Hais/workspace.sh
Create and manage a case-sensitive disk-image on macOS (OS X).
#!/bin/bash
# ---------------------------------------------------------
# Customizable Settings
# ---------------------------------------------------------
MOUNT_POINT="${CASE_SAFE_MOUNT_POINT:-${HOME}/casesafe}"
VOLUME_PATH="${CASE_SAFE_VOLUME_PATH:-${HOME}/.casesafe.dmg.sparseimage}"
VOLUME_NAME="${CASE_SAFE_VOLUME_NAME:-casesafe}"
VOLUME_SIZE="${CASE_SAFE_VOLUME_SIZE:-60g}"
@scottsb
scottsb / sugit
Last active February 2, 2016 16:26
Run Git as Repo Owner
#!/bin/sh
# Execute git commands passed on command line as whatever user owns the current Git repository.
# Script can be substituted 1:1 for git in commands.
# Available under the MIT license.
sudo -u $(stat -c %U $(git rev-parse --git-dir)) git "$@"
@scottsb
scottsb / gist:b67753b2c196fc33946c
Last active November 28, 2015 19:19
Bookmarklet to create Google Now reminder
javascript:open('https://www.google.com/webhp?#q=set+a+reminder','targetname','height=480,width=980');
@scottsb
scottsb / example.php
Created September 28, 2015 13:45
Comedy of Errors
<?php
class Example {
protected $_defaultItemKey;
protected $_items;
// BUG: forces a zero-base reindex when default item is added to front of array
public function __construct($defaultItem) {
// Pretend these are loaded from the database
$this->_items = [
@scottsb
scottsb / resetting-csync2-cluster.md
Last active October 25, 2021 20:28
Guide to Resetting a csync2 Cluster

Guide to Resetting a csync2 Cluster

Introduction

These are possible steps to reset a csync2 cluster that has been seriously fubared. This is an apocalyptic approach and should only be used when more surgical fixes (like correcting an individual conflict) aren't workable.

Use Cases

@scottsb
scottsb / example.php
Last active September 11, 2015 22:01
Hack to handle multiple Exception types with a single block
<?php
class Foo extends Exception {}
class Bar extends Exception {}
class Baz extends Exception {}
try {
throw new Foo();
} catch (Exception $e) {
switch (get_class($e)) {
case 'Foo':
@scottsb
scottsb / gist:ebd4e00be4eb2cb18cc2
Last active August 29, 2015 14:10
All CSS Slide-Out Menu
<html>
<head>
<style type="text/css">
body {
font-family: helvetica, sans-serif;
margin: 0;
}
p {
margin: 0 0 1em;
}