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
| // ios8 and later | |
| var alert = UIAlertController(title: "Hey!", | |
| message: "How 'bout dat?", | |
| preferredStyle: .Alert) | |
| let textConfigClosure: ((UITextField!) -> Void)! = { text in | |
| text.placeholder = "Type something here" | |
| } | |
| alert.addTextFieldWithConfigurationHandler(textConfigClosure) | |
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
| class MIDISampler : NSObject { | |
| var engine:AVAudioEngine! | |
| var playerNode:AVAudioPlayerNode! | |
| var mixer:AVAudioMixerNode! | |
| var sampler:AVAudioUnitSampler! | |
| override init() { | |
| super.init() | |
| initAudioEngine() | |
| } |
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
| func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool { | |
| // Override point for customization after application launch. | |
| UIDevice.currentDevice().beginGeneratingDeviceOrientationNotifications() | |
| NSNotificationCenter.defaultCenter().addObserver(self, | |
| selector: "detectOrientation", | |
| name:UIDeviceOrientationDidChangeNotification, | |
| object:nil) | |
| return true |
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 bash | |
| # maven archetype helper script | |
| # Gene De Lisa | |
| # === the variables | |
| # your generated output | |
| myartifact=sampleproject | |
| mygroup=com.rockhoppertech |
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 bash | |
| # create a bare git repo | |
| # Gene De Lisa | |
| # === the variables | |
| gitdir=~/Dropbox/git | |
| # assumes you're in the project directory, so get the current dir name without the | |
| # full path. |
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
| func loopTrack(musicTrack:MusicTrack) { | |
| var trackLength = getTrackLength(musicTrack) | |
| println("track length is \(trackLength)") | |
| setTrackLoopDuration(musicTrack, duration: trackLength) | |
| } | |
| func getTrackLength(musicTrack:MusicTrack) -> MusicTimeStamp { | |
| //The time of the last music event in a music track, plus time required for note fade-outs and so on. |
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
| public class Foo : StringLiteralConvertible { | |
| var num:Int = 0 | |
| required public init(stringLiteral value: StringLiteralType) { | |
| self.num = value.toInt()! | |
| // of course you can do something more complicated by parsing the value. | |
| } | |
| public typealias UnicodeScalarLiteralType = StringLiteralType |
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
| /** | |
| Scroll to make the the given section header visible. | |
| The function scrollToItemAtIndexPath will scroll to the item and hide the section header. | |
| Swift 3. | |
| */ | |
| func scrollToSection(_ section:Int) { | |
| if let cv = self.collectionView { | |
| let indexPath = IndexPath(item: 1, section: section) | |
| if let attributes = cv.layoutAttributesForSupplementaryElement(ofKind: UICollectionElementKindSectionHeader, at: indexPath) { | |
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
| // the frame size doesn't matter; autolayout will change it | |
| var aButton = UIButton(frame: CGRect(x: 0, y: 0, width: 200, height: 200)) | |
| aButton.titleLabel?.text = "HEY" | |
| aButton.opaque = true | |
| aButton.backgroundColor = UIColor.yellow | |
| view.addSubview(aButton) | |
| aButton.translatesAutoresizingMaskIntoConstraints = false | |
| let margins = view.layoutMarginsGuide |
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
| if let nav = navigationController { | |
| nav.setToolbarHidden(false, animated: false) | |
| // doesn't really set the button's tint | |
| UIToolbar.appearance().tintColor = UIColor.black | |
| // instead of setting the text color of each bar button | |
| UIBarButtonItem.appearance().tintColor = UIColor.black | |