Skip to content

Instantly share code, notes, and snippets.

@rotemtam
rotemtam / add_cname_route53.py
Created August 3, 2016 16:36
Add a CNAME record in Route53 using python boto3
import boto3
client = boto3.client('route53')
def add_cname_record(source, target):
try:
response = client.change_resource_record_sets(
HostedZoneId='<hosted zone id>',
ChangeBatch= {
'Comment': 'add %s -> %s' % (source, target),
@rotemtam
rotemtam / kahoot-cline-player-service.js
Created September 12, 2015 16:27
Kahoot Clone player service
angular.module('kahootCloneApp')
.service('Player', function (fbutil, _, $cookieStore) {
// AngularJS will instantiate a singleton by calling "new" on this function
var self = this, _so;
self.getUniqId = function() {
// generate a unique idenftifier for the player and save it in a cookie to allow refreshes
if($cookieStore.get('playerId')) {
return self._id = $cookieStore.get('playerId');
} else {
@rotemtam
rotemtam / kahoot-clone-host-service.js
Created September 12, 2015 16:25
Kahoot Clone Host.js service
angular.module('kahootCloneApp')
.service('Host', function (fbutil, Trivia) {
var self = this, _so;
self.init = function(PIN) {
self.syncObject = fbutil.syncObject('games/' + PIN);
_so = self.syncObject;
return self.syncObject.$loaded();
};
@rotemtam
rotemtam / kahoot-partial-host-controller.js
Last active September 9, 2015 21:52
Using $scope.$watch to respond to game state changes
$scope.$watch('game.data.state', function(newValue, oldValue) {
switch(newValue) {
case 'preQuestion':
$scope.countdown = 5;
$interval(function() {
$scope.countdown--;
},1000, $scope.countdown)
.then(function() {
@rotemtam
rotemtam / kahoot-clone-schematic-host.html
Created September 9, 2015 21:37
Schematic Host view
<div class="row" ng-if="game.data.state == 'waitingForPlayers'">
...
</div>
<div class="row" ng-if="game.data.state == 'preQuestion'">
...
</div>
<div class="row" ng-if="game.data.state == 'question'">
...
angular.module('kahootCloneApp')
.service('Player', function (fbutil, _, $cookieStore) {
// AngularJS will instantiate a singleton by calling "new" on this function
var self = this, _so;
self.getUniqId = function() {
// generate a unique idenftifier for the player and save it in a cookie to allow refreshes
if($cookieStore.get('playerId')) {
return self._id = $cookieStore.get('playerId');
} else {
angular.module('kahootCloneApp')
.controller('PlayerCtrl', function ($scope, Player, $location,$routeParams) {
if(! $routeParams.hasOwnProperty('PIN')) {
$scope.game = {
data : {
state: 'joinGame'
}
}
} else {
<div class="row" ng-if="game.data.state=='joinGame'">
<div class="col-md-6 col-md-offset-3">
<form>
<div class="form-group">
<label for="PIN">Game PIN #</label>
<input ng-model="$parent.PIN" type="text" class="form-control" id="PIN" placeholder="Enter 6 digit number availible on main screen">
</div>
<div class="form-group">
<label for="screenName">Your name</label>
<input ng-model="$parent.screenName" type="text" class="form-control" id="screenName" placeholder="Choose a screen name">
angular.module('kahootCloneApp')
.service('Host', function (fbutil) {
var self = this;
self.init = function(PIN) {
self.syncObject = fbutil.syncObject('games/' + PIN);
return self.syncObject.$loaded();
};
});
yo angularfire:route Player
yo angularfire:service Player