Skip to content

Instantly share code, notes, and snippets.

Chad Armstrong edenwaith

View GitHub Profile
@edenwaith
edenwaith / lcd_exp.ino
Created Nov 27, 2018
Take input from the keyboard and print it to a 16x2 LCD display.
View lcd_exp.ino
#include <LiquidCrystal.h>
// LiquidCrystal display with:
// rs on pin 12
// rw on pin 11
// enable on pin 10
// d4-7 on pins 5 - 2
// LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
// LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
@edenwaith
edenwaith / clear_cal_cache.sh
Last active Oct 24, 2018
Clear the cached calendars for macOS Calendar
View clear_cal_cache.sh
#!/bin/sh
# Author: Chad Armstrong
# Date: 29 August 2018
# Description: Clear the cached calendars for macOS Calendar
# References:
# https://michaelkummer.com/technology/fix-calendar-cant-save-event-x-exchange/
# https://wilkinsit.ca/mac-osx/clear-calendar-cache-mac-os/
# https://stackoverflow.com/a/3510850/955122
@edenwaith
edenwaith / rle.swift
Last active Jul 22, 2018
Swift example of encoding a string using Run Length Encoding
View rle.swift
#!/usr/bin/swift
import Foundation
/*
* rle.swift
*
* Author: Chad Armstrong
* Date: 21 July 2018
* Description: Example of encoding a string using Run Length Encoding
* Example: The string aabbbaaaac will be encoded as 2a3b4a1c
@edenwaith
edenwaith / export_words_tok.m
Last active Jul 3, 2018
Reverse engineer the WORDS.TOK file from an AGI Sierra game.
View export_words_tok.m
/*
* export_words_tok.m
*
* Description: Reverse engineer the WORDS.TOK file from an AGI Sierra game.
* The results are saved into two files: words.txt and words.json
* Author: Chad Armstrong (chad@edenwaith.com)
* Date: 25-28 June 2018
* To compile: gcc -w -framework Foundation export_words_tok.m -o export_words
*
* Resources:
@edenwaith
edenwaith / filesize.m
Last active Apr 21, 2018
Multiple ways to calculate the size of a file's resource fork
View filesize.m
/*
* filesize.m
* Description: Multiple ways to calculate the size of a file's resource fork
* Author: Chad Armstrong
* Date: 14 April 2018
* To compile: gcc -w -framework Cocoa filesize.m -o filesize
*/
/* References:
* https://stackoverflow.com/questions/32003590/check-for-resource-fork-in-objective-c
@edenwaith
edenwaith / Force Empty Trash.scpt
Last active Apr 12, 2018
Force empty the Mac Trash using an AppleScript
View Force Empty Trash.scpt
-- Source: http://hints.macworld.com/article.php?story=2002041207430253
display dialog "Force Empty Trash?" buttons ¬
{"Cancel", "Trash"} default button "Trash" with icon note
set the user_choice to the button returned of the result
if the user_choice is "Trash" then
display dialog "Are you sure?" buttons {"No", "Yes"} ¬
default button "No" with icon note
set the user_choice to the button returned of the result
@edenwaith
edenwaith / checkFilePermissions.m
Last active Apr 9, 2018
Check if a file can be deleted on a Mac
View checkFilePermissions.m
/*
* checkFilePermissions.m
* Description: A collection of methods which checks if a given file can be deleted
* and checks other permissions and properties.
* Author: Chad Armstrong
* Date: 1 December 2017
* To compile: gcc -w -framework Foundation -framework AppKit checkFilePermissions.m -o checkFilePermissions
*/
#import <Foundation/Foundation.h>
@edenwaith
edenwaith / DiskManagement.h
Last active Mar 1, 2019
Get the available free space on the root drive using the method volumeFreeSpaceForDisk from the private framework DiskManagement
View DiskManagement.h
//
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#pragma mark Blocks
typedef void (^CDUnknownBlockType)(void); // return type and parameters are unknown
@edenwaith
edenwaith / lock-screen.scpt
Last active Oct 25, 2017
Lock the screen in macOS High Sierra using an AppleScript
View lock-screen.scpt
tell application "System Events" to tell process "Finder"
-- Menu bar item 1 is the Apple menu
click menu item "Lock Screen" of menu 1 of menu bar item 1 of menu bar 1
end tell
@edenwaith
edenwaith / erasefreespace.m
Created Oct 6, 2017
Example code for erasing free disk space by calling diskutil from an NSTask
View erasefreespace.m
/*
* erasefreespace.m
* Description: Parse a string for the percentage of freespace erased
* Author: Chad Armstrong
* Date: 3 October 2017
* To compile: gcc -framework Foundation erasefreespace.m -o erasefreespace
*/
#import <Foundation/Foundation.h>
You can’t perform that action at this time.