Skip to content

Instantly share code, notes, and snippets.

View rmangino's full-sized avatar

Reed Mangino rmangino

View GitHub Profile
class ViewController: NSViewController {
@IBOutlet weak var button: NSButton!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func buttonClicked(_ sender: NSButton) {
let centerX = (sender.bounds.minX + sender.bounds.maxX) / 2.0
import Foundation
// This example comes from https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Subscripts.html
struct Matrix {
let rows: Int, columns: Int
var grid: [Double]
init(rows: Int, columns: Int) {
self.rows = rows
self.columns = columns
let json = "{\"foo\" : 5}"
let decoded = try! JSONSerialization.jsonObject(with: Data(json.utf8), options: []) as! [String : Any]
print(decoded)
if let int8 = decoded["foo"] as? Int8 {
print(int8)
}
else {
@rmangino
rmangino / gist:2d2280f6bb139a61ab5e
Last active August 29, 2015 14:24
Bash: Completion - Single [tab]

The Bash shell (as of version 2.04) supports tab completion. By default if tab completion is activated (you hit the tab key once) no results are shown if more than one match exists. To view all matching completions you must hit the tab key a second time.

If you would like the completion feature to always return all results when pressing the tab key once add the following to ~/.inputrc (you may either source .inputrc or restart bash.

set show-all-if-ambiguous on

### Keybase proof
I hereby claim:
* I am rmangino on github.
* I am reedm (https://keybase.io/reedm) on keybase.
* I have a public key whose fingerprint is 8360 51B8 D2E5 2168 7F55 0EE3 0A2D E2F2 E735 3D47
To claim this, I am signing this object:
@rmangino
rmangino / gist:8388849
Created January 12, 2014 18:57
Disable the automatic muting of system audio during Dictation under OS X 10.9 (Mavericks)
defaults write com.apple.SpeechRecognitionCore AllowAudioDucking -bool NO
defaults write com.apple.speech.recognition.AppleSpeechRecognition.prefs DictationIMAllowAudioDucking -bool NO