Skip to content

Instantly share code, notes, and snippets.

@kcrawford
kcrawford / gist:00994c6246472d73e6a8893cb84d3e9c
Last active April 20, 2024 20:23 — forked from chbeer/gist:3666e4b7b2e71eb47b15eaae63d4192f
Calling AppleScript from Swift App, passing a parameter. Basic
import Carbon
//guard let url = Bundle.main.url(forResource: "SendFinderMessage", withExtension: "scpt") else {
// exit(0)
//}
//guard let script = NSAppleScript(contentsOf: url, error: &errors) else {
// exit(0)
//}
@kcrawford
kcrawford / gist:83c955220b50805e98ad10c044eedd2e
Last active April 25, 2016 20:16 — forked from peon-pasado-zeitnot/gist:1242279
This D-trace script lists all run programs with their arguments - works with OSX
#!/usr/sbin/dtrace -C -s
#pragma D option quiet
proc::posix_spawn:exec-success,proc::__mac_execve:exec-success
{
this->isx64=(curproc->p_flag & P_LP64)!=0;
#define SELECT_64_86(x64, x86) (this->isx64 ? (x64) : (x86))
#define GET_POINTER(base, offset) (user_addr_t)SELECT_64_86(*(uint64_t*)((base)+sizeof(uint64_t)*(offset)), *(uint32_t*)((base)+sizeof(uint32_t)*(offset)))
@kcrawford
kcrawford / go_scp.go
Created November 5, 2015 21:04 — forked from jedy/go_scp.go
an example of scp in golang
// https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works
package main
import (
"fmt"
"golang.org/x/crypto/ssh"
)
const privateKey = `content of id_rsa`
@kcrawford
kcrawford / self_signed_cert.rb
Last active August 29, 2015 14:27 — forked from nickyp/self_signed_cert.rb
create a self-signed certificate using ruby-openssl
We couldn’t find that file to show.
@kcrawford
kcrawford / gist:5725057
Last active June 15, 2018 19:03
active directory account and password one-liner OS X
account=`dsconfigad -show | awk '/Computer *Account/ { print $4 }'` \
&& printf "Account: ${account}\nPassword: \
`sudo security find-generic-password -a ${account} -w /Library/Keychains/System.keychain`\n"
@kcrawford
kcrawford / gist:5474622
Created April 27, 2013 20:41
postflight installer script to reload a LaunchAgent
#!/bin/bash
# if someone is logged in
if who | grep -q console; then
# get the logged in user's uid
LOGGED_IN_UID=`ls -ln /dev/console | awk '{ print $3 }'`
# use the uid and pgrep to find the Finder process id
FINDER_PID=`pgrep -U ${LOGGED_IN_UID} Finder`
ARCHFLAGS='-arch i386 -arch x86_64'
rvm install 1.8.7 --debug --reconfigure -C --enable-shared=yes
curl -L -o ~/Downloads/RubyCocoa-1.0.5.tar.gz http://sourceforge.net/projects/rubycocoa/files/RubyCocoa/1.0.5/RubyCocoa-1.0.5.tar.gz/download
cd ~/Downloads && tar xzf RubyCocoa-1.0.5.tar.gz && rm RubyCocoa-1.0.5.tar.gz && cd RubyCocoa-1.0.5
rvm use 1.8.7
ruby install.rb config --target-archs="x86_64"
ruby install.rb setup
sudo ruby install.rb install
rvm 1.8.7 do ruby -e 'require "osx/cocoa";OSX::NSLog "Cocoa should work now!"'