Skip to content

Instantly share code, notes, and snippets.

View bahamas10's full-sized avatar

Dave Eddy bahamas10

View GitHub Profile
@bahamas10
bahamas10 / README.md
Last active December 28, 2015 21:39
OS X disable crash dialog (used for XBMC)

Disable Crash Dialogs on OS X

You can disable the dialog that looks like "Application XXXX Crashed Unexpectedly" with the commands below.

I use this specifically for running XBMC nightlies on OS X that tend to crash periodically. This will make it so no popup is generated, and all you have to do is press the "menu" key on the Apple remote to start XBMC again.

launchctl unload -w /System/Library/LaunchAgents/com.apple.ReportCrash.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.ReportCrash.Root.plist

(yes, both commands are required, lanuchctl behaves differently when invoked as the superuser)

@bahamas10
bahamas10 / readme.md
Created December 5, 2013 01:39
find out what program has focus on os x

find out what program has focus on os x

dave @ [ bahamas10 :: (Darwin) ] ~ $ osascript -e 'tell application "System Events"' -e 'processes whose frontmost is true' -e 'end'
application process Terminal
dave @ [ bahamas10 :: (Darwin) ] ~ $ sleep 2; osascript -e 'tell application "System Events"' -e 'processes whose frontmost is true' -e 'end'
application process Google Chrome
@bahamas10
bahamas10 / readme.md
Last active December 30, 2015 23:18
mput etag

make a file called file and ensure it does NOT exist in manta

$ echo data > file 
$ mrm ~~/stor/file
mrm: ResourceNotFoundError: /bahamas10/stor/file was not found

try to put the file with if-none-match

@bahamas10
bahamas10 / arc4random_nsa.c
Created January 13, 2014 20:46
arc4random_nsa
unsigned int arc4random_nsa(unsigned int n) {
static unsigned int p = 0;
return p++;
}
@bahamas10
bahamas10 / main.m
Created March 11, 2014 17:57
ssh key fingerprint in objective C
#import <Foundation/Foundation.h>
@interface NSData (MD5)
- (NSString *)MD5String;
@end
#import <CommonCrypto/CommonDigest.h>
@implementation NSData (MD5)
- (NSString *)MD5String {
unsigned char result[16];
CC_MD5(self.bytes, self.length, result);
@bahamas10
bahamas10 / rsyslog.bash
Last active August 29, 2015 13:57
rsyslog bash cookbook
svcadm disable system-log
pkgin -y in rsyslog
if ! diff rsyslog.conf /opt/local/etc/rsyslog.conf; then
cp rsyslog.conf /opt/local/etc/rsyslog.conf
svcadm restart rsyslog
fi
svcadm enable rsyslog
@bahamas10
bahamas10 / foo.md
Created March 17, 2014 23:50
monks
dave @ [ bahamas10 :: (Darwin) ] ~/dev/chefreplacement $ sudo ./monks -vv smf/service pkgin/package
[Mon Mar 17 19:48:45 EDT 2014] main (./monks 174)  INFO: running as root on bahamas10.local in /Users/dave/dev/chefreplacement (pid 25449)
[Mon Mar 17 19:48:45 EDT 2014] main (./monks 190) DEBUG: attempting to load /opt/local/etc/monks.conf
[Mon Mar 17 19:48:45 EDT 2014] main (./monks 190) DEBUG: attempting to load /etc/monks.conf
[Mon Mar 17 19:48:45 EDT 2014] main (./monks 191)  INFO: successfully loaded /etc/monks.conf
[Mon Mar 17 19:48:45 EDT 2014] main (./monks 200) TRACE: chdir(2) to /Users/dave/dev/chefreplacement
[Mon Mar 17 19:48:45 EDT 2014] main (./monks 206) DEBUG: lockfile created at /var/run/monks.pid
[Mon Mar 17 19:48:45 EDT 2014] main (./monks 239)  INFO: 2 items - [smf/service pkgin/package]
[Mon Mar 17 19:48:45 EDT 2014] main (./monks 241)  INFO: loading item smf/service
@bahamas10
bahamas10 / djbdns.xml
Created April 7, 2014 21:06
djbdns smf manifest smartos
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='network/djbdns' type='service' version='0'>
<create_default_instance enabled='true'/>
<dependency name='dep0' grouping='require_all' restart_on='error' type='service'>
<service_fmri value='svc:/milestone/multi-user:default'/>
</dependency>
<exec_method name='start' type='method' exec='tinydns &amp;' timeout_seconds='10'>
<method_context working_directory='/opt/local/etc/tinydns'>
@bahamas10
bahamas10 / README.md
Last active August 29, 2015 13:58
slack preformat pastes automatically

drop this into the javascript console on a slack chat to have pastes automatically show up as preformatted text.

var TS_view_submit = TS.view.submit.bind(TS.view); TS.view.submit = function() { var msgInput = document.getElementById('message-input'); if (msgInput.value.indexOf('\n') > -1) msgInput.value = '```\n' + msgInput.value + '\n```'; return TS_view_submit.apply(this, arguments); }

a more readable version

// store the original function
@bahamas10
bahamas10 / foo.m
Created May 2, 2014 21:04
active application notification in os x
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSNotificationCenter *center = NSWorkspace.sharedWorkspace.notificationCenter;
[center addObserver:self
selector:@selector(callback:)
name:NSWorkspaceDidActivateApplicationNotification
object:nil];
}
- (void)callback:(NSNotification *)d