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
#!/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
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
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
// 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! | |
/// soundbanks are either dls or sf2. see http://www.sf2midi.com/ | |
var soundbank:NSURL! | |
let melodicBank:UInt8 = UInt8(kAUSampler_DefaultMelodicBankMSB) | |
/// general midi number for marimba | |
let gmMarimba:UInt8 = 12 |
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 setSessionPlayer() { | |
let session:AVAudioSession = AVAudioSession.sharedInstance() | |
var error: NSError? | |
if !session.setCategory(AVAudioSessionCategoryPlayback, error:&error) { | |
println("could not set session category") | |
if let e = error { | |
println(e.localizedDescription) | |
} | |
} | |
if !session.setActive(true, error: &error) { |
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 Sound : NSObject { | |
/// The player. | |
var avPlayer:AVAudioPlayer! | |
/** | |
Uses AvAudioPlayer to play a sound file. | |
The player instance needs to be an instance variable. Otherwise it will disappear before playing. | |
*/ | |
func readFileIntoAVPlayer() { |
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
/// soundbanks are either dls or sf2. see http://www.sf2midi.com/ | |
var soundbank:NSURL! | |
var mp:AVMIDIPlayer! | |
func playMIDIFile() { | |
// Load a SoundFont or DLS file. | |
self.soundbank = NSBundle.mainBundle().URLForResource("GeneralUser GS MuseScore v1.442", withExtension: "sf2") | |
// a standard MIDI file. |
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 playSoundWithAVAudioPlayer() { | |
var alertSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("alert", ofType: "mp3")) | |
var error:NSError? | |
if !AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, error: &error) { | |
if let err = error { | |
println("could not set session category: \(err.localizedDescription)") | |
} | |
} |