Skip to content

Instantly share code, notes, and snippets.

-- See the most up to date version here where it says "Download the mrc-converter-suite zip archive" https://discussions.agilebits.com/discussion/30286/mrcs-convert-to-1password-utility/p1
--
-- Exports Safari's saved passwords to a CSV file formatted for use with the convert_to_1p4's csv converter
--
-- Version 1.4
-- mike (at) cappella (dot) us
--
use AppleScript version "2.5" -- runs on 10.11 (El Capitan) and later
use scripting additions
@GrahamWalters
GrahamWalters / script.sh
Created December 17, 2020 12:47
TimeMachine backup on APFS Volume
# Create a Journaled HFS+ disk image on the drive
# Size is limited to 250GB but you can change that
# Volume name is TM
# The image name is TimeMachine
# Note this image is not encrypted. Save this image to an encrypted volume.
hdiutil create -size 250gb -layout GPTSPUD -fs "Journaled HFS+" -volname "TM" -type SPARSEBUNDLE -nospotlight -tgtimagekey sparse-band-size=262144 /Volumes/T7/TimeMachine.sparsebundle
# Mount the disk image and then set TimeMachine to use the new disk
sudo tmutil setdestination /Volumes/TM/
@GrahamWalters
GrahamWalters / rename.sh
Created November 10, 2017 05:24
Packt.epub rename
#!/bin/bash
get_title () {
attr='title'
fileloc=`unzip -l "$1" | ggrep -Po '\b[^\s-]*\.opf\b'`
metafound=`zipgrep '<dc:'$attr'(.+)>(.+)</dc:'$attr'>' "$1" $fileloc`
echo `expr "$metafound" : '.*<dc:'$attr'.*>\(.*\)</dc:'$attr'>.*'`
}
for file in $(find . -type f -depth 1 -name "*.epub"); do
@GrahamWalters
GrahamWalters / index.html
Created August 5, 2017 13:01
Trianglify Background Generator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Trianglify Background Generator</title>
<style>
html, body {
margin: 0;
padding: 0;
}
@GrahamWalters
GrahamWalters / share.sh
Last active July 23, 2017 15:19
Place all MS Office apps in "Microsoft Office 2016". Place this file in that folder. Run as root
#!/bin/sh
if (( $EUID != 0 )); then
echo "Please run as root"
exit
fi
cd "/Applications/Microsoft Office 2016"
mkdir -p shared/DFonts \
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@GrahamWalters
GrahamWalters / bash.sh
Last active May 6, 2019 03:54
On supported systems, restarts computer and unlocks FileVault one time
sudo fdesetup authrestart
# It will ask for:
# 1. the sudo password
# 2. the drive password or recovery key
# -delayminutes <minutes> Number of minutes before restart.
# -1 to set the key but allow something like a software update the restart the computer.
sudo fdesetup authrestart -delayminutes -1
@GrahamWalters
GrahamWalters / trueTypeOf.js
Created October 6, 2016 13:04
Get the true type of a variable. Ex: null == "null"
function trueTypeOf (obj) {
return {}.toString.call(obj).split(' ')[1].slice(0, -1).toLowerCase();
}
console.log(trueTypeOf()); //undefined
console.log(trueTypeOf(null)); //null
console.log(trueTypeOf(NaN)); //number
console.log(trueTypeOf(5)); //number
console.log(trueTypeOf({})); //object
console.log(trueTypeOf([])); //array
@GrahamWalters
GrahamWalters / track.js
Created October 5, 2016 16:02
Track Event Listeners
(function(window, document) {
'use strict';
/* global getEventListeners */
window.listenerCount = 0;
var ael = Node.prototype.addEventListener;
Node.prototype.addEventListener = function() {
window.listenerCount++;
window.console.log('add', arguments);
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">