Skip to content

Instantly share code, notes, and snippets.

View seanhess's full-sized avatar

Sean Hess seanhess

View GitHub Profile
@seanhess
seanhess / code.js
Created October 11, 2013 12:10
Directive
var app = angular.module('app', []);
app.controller('ConsumingCtrl', function($scope) {
// I want to have the ability for specialIframe to publish an API I can consume, for example a "reload".
// I am aware of events on scope but that is not what I am looking for.
// I could pass in a reference for a specialIframe to bind to on my scope...
// The question is, if specialIframe can publish an API... E.G. "reload" what is the best way to do that.
// $scope.something = "hello"
<html>
<head>
</head>
<body>
<h3>Risk Calculator</h3>
<script type='text/javascript'>
<html>
<head>
</head>
<body>
<h3>Hello Jason</h3>
<script type='text/javascript'>
console.log("Hello Jason")
@seanhess
seanhess / Book.ts
Last active December 22, 2015 22:59
///<reference path="../def/angular.d.ts"/>
///<reference path="../def/underscore.d.ts"/>
///<reference path="../types.ts"/>
///<reference path="../services/Books"/>
///<reference path="../services/Files.ts"/>
interface BookParams extends ng.IRouteParamsService {
bookId: string;
@seanhess
seanhess / TestViewController.m
Created June 5, 2013 00:26
ReactiveCocoa is better than KVO and delegates
//
// TestViewController.m
// iOSDemo
//
// Created by Sean Hess on 6/4/13.
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
//
#import "TestViewController.h"
#import "User.h"
declare module "rethinkdb" {
export function connect(host:IHost, cb:OnConnect);
export function dbCreate(name:string):AdminOperation;
export function dbDrop(name:string):AdminOperation;
export function dbList():NamesOperation;
export function db(name:string):Db;
export function table(name:string):Table;
-(id)init {
if (self == [super init]) {
// ... other init stuff
// self.player doesn't even have to be set to set up the binding!
[[RACAble(self.player.health) distinctUntilChanged] subscribeNext:^(id value) {
[self renderHealth];
}];
[self.playersNode observeEventType:FEventTypeChildAdded withBlock:^(FDataSnapshot *snapshot) {
Player * player = [Player new];
[player setValuesForKeysWithDictionary:snapshot.value];
[self.players addObject:player];
if ([player.name isEqualToString:self.currentPlayer.name]) {
self.currentPlayer = player;
} else {
self.opponentNode = [self.playersNode childByAppendingPath:player.name];
self.opponentPlayer = player;
// I had to set the navigation bar to hidden, then add the top and bottom controls as a view.
// I don't think you can control the navigation bar directly.
- (void)viewDidLoad {
[self.navigationController setNavigationBarHidden:YES animated:NO];
}
- (void)showControls {
[UIView animateWithDuration:0.2 animations:^{
CGRect bottomFrame = self.bottomControlsView.frame;
bottomFrame.origin.y = self.view.frame.size.height - bottomFrame.size.height;
// I had to set the navigation bar to hidden, then add the top and bottom controls as a view.
// I don't think you can control the navigation bar directly.
- (void)viewDidLoad {
[self.navigationController setNavigationBarHidden:YES animated:NO];
}
- (void)showControls {
[UIView animateWithDuration:0.2 animations:^{
CGRect bottomFrame = self.bottomControlsView.frame;
bottomFrame.origin.y = self.view.frame.size.height - bottomFrame.size.height;