Skip to content

Instantly share code, notes, and snippets.

View jamesstout's full-sized avatar

James Stout jamesstout

View GitHub Profile
@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 / 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 / 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;
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
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"
@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
CGFloat BNRTimeBlock (void (^block)(void));

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:

@jamesstout
jamesstout / makefile
Last active June 5, 2016 21:16
makefile settings for unrar on OpenSolaris 5.11 snv_134
#
# Makefile for UNIX - unrar
# Linux using GCC
# CXX=g++
# CXXFLAGS=-O2
# LIBFLAGS=-fPIC
# DEFINES=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DRAR_SMP
# STRIP=strip
# LDFLAGS=-pthread
@jamesstout
jamesstout / HKWUIDeviceHardware.h
Last active December 19, 2017 15:55
Determine iOS device being used and other device info
//
// HKWUIDeviceHardware.h
//
#import <Foundation/Foundation.h>
@interface HKWUIDeviceHardware : NSObject
- (NSString *) platform2;
- (NSString *) platformString;