Skip to content

Instantly share code, notes, and snippets.

@GrahamWalters
GrahamWalters / gist:5848822
Created June 24, 2013 09:21
Reset QuickLook Thumbnail Cache: Open Terminal and run the following commands
sudo find /var/folders/ -name com.apple.QuickLook.thumbnailcache -type d
# Enter your password and hit enter (it will not display your password).
cd COPY-AND-PAST-THE-ABOVE-OUTPUT-HERE
cd ../
sudo mv com.apple.QuickLook.thumbnailcache com.apple.QuickLook.thumbnailcache-BACK
# Restart your computer.
### If anything goes wrong run the following:
sudo find /var/folders/ -name com.apple.QuickLook.thumbnailcache-BACK -type d
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body ng-app="app">
<div ng-controller="Ctrl1"></div>
<div ng-controller="Ctrl2"></div>
<!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">
@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);
@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 / 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 \
@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 / 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