Skip to content

Instantly share code, notes, and snippets.

View jamesstout's full-sized avatar

James Stout jamesstout

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jamesstout on github.
  • I am stouty (https://keybase.io/stouty) on keybase.
  • I have a public key whose fingerprint is 8E09 B47D 6297 FBD2 ED28 7BAC 32A1 D7DD 8361 0D0F

To claim this, I am signing this object:

CGFloat BNRTimeBlock (void (^block)(void));
@jamesstout
jamesstout / vox2.sh
Last active December 21, 2015 00:49
Vox errors
james@Jamess-iMac: /private/var/log
grep "Vox" system.log | grep -v AppFresh | grep -v ImageOpt | grep -v MZStore.woa \
| grep -v png | grep -v Bartender | wc -l
3379
grep "Vox" system.log | grep -v AppFresh | grep -v ImageOpt | grep -v MZStore.woa \
| grep -v png | grep -v Bartender | cut -d ":" -f4- | sort | uniq -c
1 "\"Vox\""
8 -[TUITableView(MultiCell) __endDraggingMultipleCells:offset:location:]
2 Dist notification pref changed
tell application "Notes"
activate
delay 0.1
end tell
try
tell application "Notes" to get note "geeknotes"
on error
set output to "No current note called geeknotes"
function cpuuu (){
declare pids=($(ps aux | grep -E *(ImageOp|ImageAl) | grep -v grep | awk '{print $3}'))
pidCount=${#pids[@]}
while [ "$pidCount" -gt 0 ]
do
let timeSpent=0
@jamesstout
jamesstout / convertToHuman.sh
Last active September 15, 2021 23:15
Takes the output from du -k - file block count in 1024-byte (1-Kbyte) blocks and converts to a human readable form.
# $1 = file block count in 1024-byte (1-Kbyte) blocks.
# i.e. output from du -k
# no floating points, just ints, but check anyway
function convertToHuman {
size=$(echo $1 | sed -e 's/^\./0./') # add 0 for cases like ".0001"
size=${size/\.*} # convert to int
for unit in KB MB GB TB PB EB ZB YB; do
if [ "$size" -lt 1024 ]; then
echo "${size} ${unit}";
break;
@jamesstout
jamesstout / ActivateBTDevice.applescript
Last active December 20, 2015 11:29
Activate Bluetooth device
set mouseName to "James Mouse" -- edit as appropriate
-- SystemUIServer controls the right hand side of the Menu bar - AHA!
tell application "System Events" to tell the front menu bar of process "SystemUIServer"
activate
delay 0.5
tell menu bar item 1
click
tell menu item mouseName of menu 1
click
@jamesstout
jamesstout / BTDeviceStatus.applescript
Created July 31, 2013 17:21
Determine Bluetooth Device Status on OS X
on run
-- determine if we are looking for the mouse or the trackpad
set doWhat to system attribute "KMVAR_checkWhichDevice" -- set in Keyboard Maestro as M or TP
-- create a temp file
set theFile to (path to temporary items as string) & "test1.plist"
-- system_profiler - reports system hardware and software configuration.
-- try it out in a terminal
@jamesstout
jamesstout / make_deps.sh
Created July 18, 2013 02:01
Get build dependencies for ImageAlpha
#!/usr/bin/env bash
#set -o nounset
source ./utils.sh
ZLIB_VERSION=1.2.8
ZLIB_URL=http://prdownloads.sourceforge.net/libpng/zlib-$ZLIB_VERSION.tar.gz?download
ZLIB_DIR=zlib
@jamesstout
jamesstout / gist:5990388
Last active December 19, 2015 17:19
Improved AppleScript to close all Finder Get Info windows
tell application "Finder"
set theWindowList to windows (* get all Finder windows *)
repeat with i from 1 to number of items in theWindowList (* loop through them *)
set shouldClose to false (* reset to false *)
set this_item to item i of theWindowList (* get a window from the list *)
set windowName to name of this_item (* get the window'ss name *)
(* this list should contain class property that tells you the type of window - which is nice *)
(* Class would be either "Finder window" for normal windows or "information window" for the Info windows *)