Skip to content

Instantly share code, notes, and snippets.

View jdewind's full-sized avatar

Justin DeWind jdewind

  • LifeWorks
  • Grand Rapids
View GitHub Profile
(ns com.atomicobject.state
(def ^:private config-file* (ref nil))
(defn config-file [] (@config-file*))
(defn set-config-file! [new-config]
{:pre? [(string? new-config)]}
(dosync
(ref-set config-file new-config)))
(ns com.atomicobject.config
(defn with-config-fn [config-file] (fn [] config-file)))
(defn -main [& args]
(let [{:keys [config] inputs}] (cli args ["--config" "Config file"])
(def config-file (with-config-fn config))))
(ns com.atomicobject.config
(def ^:private config-file* (ref nil))
(defn config-file [] (@config-file*))
(defn set-config-file! [new-config]
{:pre? [(string? new-config)]}
(dosync
(ref-set config-file new-config))))
#
# Lighting
#
lighting
.turnOn()
.adjustLightingBy(value)
.onFailure(=> tellTheUserWeHadTroubleAdjustingTheLighting())
#
#
# Lighting
#
success = connectToDevice '/dev/tty.usb1', 14400
if success
sendToDevice "VOLTS " + volts
else
console.log "ERROR: Couldn't connect to analog voltage device"
@jdewind
jdewind / gist:2470996
Created April 23, 2012 13:41
Pick Mirrored Route
@implementation MyClass
- (void)pickAMirroredRoute {
MPAudioDeviceController *audoDeviceController = [[MPAudioDeviceController alloc] init];
audoDeviceController.routeDiscoveryEnabled = YES;
[audoDeviceController determinePickableRoutesWithCompletionHandler:^(NSInteger value) {
NSMutableArray *routes = [NSMutableArray array];
[audoDeviceController clearCachedRoutes];
NSUInteger index = 0;
@jdewind
jdewind / gist:2470841
Created April 23, 2012 13:13
A/V Metadata
(
{
AVAudioRouteName = Speaker;
AlternateUIDs = (
);
RouteCurrentlyPicked = 1;
RouteName = Speaker;
RouteType = Default;
},
{
@jdewind
jdewind / gist:2467675
Created April 23, 2012 00:12
iOS mirroring selection
// Make sure MediaPlayer.framework has been added and the MPAudioVideoRoutingPopoverController interface has been declared.
@interface MyViewController ()
@property (strong, nonatomic) MPAudioVideoRoutingPopoverController *airplayPopoverController;
@end
- (void)someButtonTapped:(id)sender {
self.airplayPopoverController = [[MPAudioVideoRoutingPopoverController alloc] initWithType:0 includeMirroring:YES];
self.airplayPopoverController.delegate = self;
[self.airplayPopoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Pod::Spec.new do |s|
config.platform :ios do
s.frameworks = ['CFNetwork']
end
config.platform :osx do
s.frameworks = ['CoreServices']
end
end
@jdewind
jdewind / gist:2322233
Created April 6, 2012 19:25
C GCD Monad Implementation
typedef struct _gcd_monad {
struct _gcd_monad* (*then)(id(^)(id));
struct _gcd_monad* (*then_with_queue)(id(^)(id), dispatch_queue_t);
struct _gcd_monad* (*error)(id(^)(id));
struct _gcd_monad* (*error_with_queue)(id(^)(id), dispatch_queue_t);
struct _gcd_monad* (*finally)(id(^)(id));
struct _gcd_monad* (*finally_with_queue)(id(^)(id), dispatch_queue_t);
} gcd_monad;
gcd_monad * monad_dispatch(id object);