Skip to content

Instantly share code, notes, and snippets.

View tokafish's full-sized avatar

Thomas Fisher tokafish

  • Plaid
  • San Francisco
View GitHub Profile
@tokafish
tokafish / edit.html
Last active August 29, 2015 13:56
ngModel and scope inheritance
<div ng-controller="EditController">
<span>{{message}}</span>
<div ng-if="userIsAdmin">
<span>Edit Message</span>
<input ng-model="message"/>
</div>
</div>
@tokafish
tokafish / edit.html
Last active August 29, 2015 13:56
ngModel and scope inheritance
<div ng-controller="EditController">
<span>{{message}}</span>
<div ng-if="userIsAdmin">
<span>Edit Message</span>
<input ng-model="$parent.message"/>
</div>
</div>
@tokafish
tokafish / controller.js
Last active August 29, 2015 13:56
Simple Scopes
app.controller('SimpleController', function($scope) {
$scope.message = 'Hello Angular!';
});
@tokafish
tokafish / controllers.js
Last active August 29, 2015 13:56
Multiple scopes
app.controller('HelloController', function($scope) {
$scope.message = 'Hello World!';
});
app.controller('GoodbyeController', function($scope) {
$scope.message = 'Goodbye World!';
});
@tokafish
tokafish / controllers.js
Last active August 29, 2015 13:56
Nested scopes
app.controller('OuterController', function($scope) {
$scope.outer = 'From the outside';
});
app.controller('InnerController', function($scope) {
$scope.inner = 'looking in.';
});
@tokafish
tokafish / edit.html
Created February 10, 2014 18:03
ngModel and scope inheritance
<div ng-controller="EditController">
<span>{{message.content}}</span>
<div ng-if="userIsAdmin">
<span>Edit Message</span>
<input ng-model="message.content"/>
</div>
</div>
@tokafish
tokafish / directive.js
Last active August 29, 2015 13:56
Isolated scopes
app.directive('isolated', function() {
return {
scope: {},
template: '<input ng-model="message.content"><span>{{message.content}}</span>'
};
});
app.directive('isolated', function() {
return {
scope: {
message: '='
},
template: '<input ng-model="message.content"><span>{{message.content}}</span>'
};
});
@tokafish
tokafish / getUserMedia.html
Last active August 29, 2015 14:06
getUserMedia
<!DOCTYPE html>
<html>
<head><title>getUserMedia</title></head>
<body>
<video autoplay></video>
<script>
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
var constraints = { audio: false, video: true };
@tokafish
tokafish / pusher_controller.rb
Last active December 9, 2016 20:44
Pusher Authentication
class PusherController < ApplicationController
protect_from_forgery except: :auth
def auth
response = Pusher[params[:channel_name]].authenticate params[:socket_id],
user_id: params[:id],
user_info: { name: params[:name] }
render json: response
end