Skip to content

Instantly share code, notes, and snippets.

View genedelisa's full-sized avatar
💭
Feeding the cats

Gene De Lisa genedelisa

💭
Feeding the cats
View GitHub Profile
@genedelisa
genedelisa / init.el
Created April 19, 2012 22:24
A simple init for using Clojure and lein in inferior lisp mode in the Emacs
;; a simple .emacs.d/init.el to set up
;; inferior lisp mode for Clojure with lein
;; this also add Marmalade as a package repository to obtain clojure-mode and paredit
(setq inferior-lisp-program "lein repl")
;; On OSX set the command key to be the meta key
(setq ns-command-modifier 'meta)
(require 'package)
@genedelisa
genedelisa / init.el
Created April 27, 2012 17:15
Markdown config in Emacs init.el
;;; Markdown
(defun turn-on-outline-minor-mode ()
(outline-minor-mode 1))
(when (require 'markdown-mode nil 'noerror)
(setq auto-mode-alist
(cons '("\\.md" . markdown-mode) auto-mode-alist))
(setq auto-mode-alist
(cons '("\\.markdown" . markdown-mode) auto-mode-alist))
(setq markdown-command "/usr/local/bin/Markdown.pl")
@genedelisa
genedelisa / main.js
Last active December 13, 2015 19:18
Handle tab selection/activation in jQuery UI 1.10
$(document).ready(function () {
var tabOpts = {
activate: handleTabSelect,
// fx has been deprecated
show: {
height: 'toggle',
opacity: 'toggle'
}
};
@genedelisa
genedelisa / gist:f9d350f0ac90cc079f3d
Created June 30, 2014 23:24
Create a calendar event with alarm
var store:EKEventStore = EKEventStore()
store.requestAccessToEntityType(EKEntityTypeEvent,
completion:{(granted:Bool, error:NSError?) -> Void in
if let e = error {
println("Error \(e.localizedDescription)")
}
if granted {
@genedelisa
genedelisa / gist:354e171c72377f77280c
Last active August 29, 2015 14:03
Set map location from string
self.geocoder.geocodeAddressString("Haddonfield, NJ",
completionHandler: {(placemarks, error:NSError!) in
if error? {
println("Error \(error!.localizedDescription)")
if error!.code == 8 {
println("not found")
}
return
}
@genedelisa
genedelisa / playSoundWithAVAudioPlayer
Created August 5, 2014 22:00
Play a sound with AVAudioPlayer
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)")
}
}
@genedelisa
genedelisa / MidIPlayer
Last active April 4, 2020 20:43
Swift AVMIDIPlayer
/// 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.
@genedelisa
genedelisa / AudioPlayer
Last active January 20, 2017 10:16
Swift AVAudioPlayer
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() {
@genedelisa
genedelisa / Audio Session
Created August 11, 2014 09:31
Swift setup AVAudioSession
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) {
@genedelisa
genedelisa / MIDISampler
Created August 11, 2014 11:53
Swift MIDI sampler
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