This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| enum ClockDirection { | |
| case Clockwise | |
| case CounterClockwise | |
| } | |
| enum DirectionOfDiskMoved { | |
| case ToTower | |
| case FromTower |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class TowerStack<T:_Comparable> : Stack<T> { | |
| override func push(key:T) { | |
| let current:Node<T>! = top | |
| if (top == nil) { | |
| super.push(key) | |
| } | |
| else if (top.key! > key) { | |
| super.push(key) | |
| } else { | |
| NSException(name: "Tower Collapse", reason: "A larger disk is placed on top of a smaller disk", userInfo: nil).raise() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import XCTest | |
| import SwiftTower | |
| class SwiftTowerTests: XCTestCase { | |
| override func setUp() { | |
| super.setUp() | |
| // No extra setup code here. | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import XCTest | |
| class SwiftTowerTestStack: XCTestCase { | |
| let stack:Stack<Int> = Stack<Int>() | |
| override func setUp() { | |
| super.setUp() // No extra setup code here. | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum Tower : String { | |
| case Tower1 = "Tower 1" | |
| case Tower2 = "Tower 2" | |
| case Tower3 = "Tower 3" | |
| } | |
| func tower(numberOfDisks: Int, source x: Tower, dest y: Tower, temp z: Tower, finalDest f:Tower, destStack:Stack<Int>) { | |
| if (numberOfDisks > 0) { | |
| tower(numberOfDisks - 1, source:x, dest:z, temp:y, finalDest:f, destStack) | |
| println("Move disk \(numberOfDisks) from \(x.toRaw()) to \(y.toRaw())") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node<T> { | |
| var key: T? = nil | |
| var next: Node? = nil | |
| } | |
| public class Stack<T> { | |
| private var N:Int = 0 | |
| private var top: Node<T>! = nil | |
| public func size() -> Int { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //By Kevin Le | |
| //10-19-2014 | |
| enum Tower : String { | |
| case Tower1 = "Tower 1" | |
| case Tower2 = "Tower 2" | |
| case Tower3 = "Tower 3" | |
| } | |
| func tower(#numberOfDisks: Int, source x: Tower, dest y: Tower, temp z: Tower) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # An init.d script for running a Node.js process as a service using iptables, forever and bouncy | |
| # Reference: | |
| # 1- https://github.com/nodejitsu/forever | |
| # 2- https://www.exratione.com/2013/02/nodejs-and-forever-as-a-service-simple-upstart-and-init-scripts-for-ubuntu/ | |
| source /home/kevin/.nvm/nvm.sh | |
| NAME="Connect5" | |
| ##NVM_VERSION="v0.10.31" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (!window.location.origin) { | |
| window.location.origin = window.location.protocol + '//' + window.location.host; | |
| } | |
| var socketIo = io.connect(window.location.origin, { | |
| port: window.location.port === '' ? '80' : window.location.port, | |
| transports: ['websocket'] | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('plunker', ['ui.bootstrap', 'angular.directives-round-progress']); | |
| var ModalDemoCtrl = function ($scope, $modal) { | |
| $scope.launchModalTimer = function () { | |
| var modalInstance = $modal.open({ | |
| templateUrl: 'modalContent.html', | |
| controller: ModalInstanceCtrl | |
| }); | |
| }; | |
| }; |