This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env swift | |
// Run this command line tool as a dynamic script or compile a binary | |
// using the following command: | |
// swiftc -sdk `xcrun --show-sdk-path` LocateMe.swift | |
import Cocoa | |
import CoreLocation | |
extension String { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set content to missing value | |
display dialog ¬ | |
"Which contents do you want to insert?" buttons {"Cancel", "Complete Buffer", "Currently visible content"} ¬ | |
default button ¬ | |
"Currently visible content" cancel button ¬ | |
"Cancel" with title ¬ | |
"Copy contents from Terminal.app" giving up after 10 | |
if button returned of result is "Complete Buffer" then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
def m = [ | |
nephew1:[name:"Huey", age:10], | |
nephew2:[name:"Dewey", age:12], | |
nephew3:[name:"Louie", age:13] | |
] | |
println m.collectEntries { [(it.key) : (it.value.name)] } | |
// [nephew1:Huey, nephew2:Dewey, nephew3:Louie] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env swift | |
import Foundation | |
let args = Process.arguments | |
if (args.count != 2) { | |
print("usage: \(args[0]) <file>\n") | |
exit(-1) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env swift | |
import Foundation | |
let args = Process.arguments | |
if (args.count != 2) { | |
print("usage: \(args[0].lastPathComponent) <file>\n") | |
exit(-1) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set aws to missing value | |
tell application "Safari" | |
tell current tab | |
set aws to do JavaScript "document.getElementsByClassName(\"AOB\")[0].textContent.match(/DNS: (.*\\.amazonaws\\.com)/)[1]" | |
end tell | |
end tell | |
if aws is not missing value then | |
tell application "Terminal" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set serversList to {} | |
set serverGroups to {"MyGroup1", "MyGroup2", "MyGroup3"} | |
set alertTitle to "Open AWS Servers with SSH" | |
on openServers(servers) | |
set csshx to "/usr/local/bin/csshX -y 4 --slave_settings_set CSSHX --ssh_args \"-oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null\" " | |
set saveTID to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to {" "} | |
set command to (csshx & servers as text) & " &" | |
get do shell script command |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CGFloat { | |
var radians: CGFloat { | |
let degree = Double(self) | |
return CGFloat(degree * M_PI / 180.0) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct Platform { | |
/// Check if the current platform is the simulator. | |
/// | |
/// - Returns: true if the current platform is the simulator | |
static let isSimulator: Bool = { | |
var isSim = false | |
#if arch(i386) || arch(x86_64) | |
isSim = true |