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
extension Optional : CustomStringConvertible { | |
public var description: String { | |
switch (self) { | |
case .none: | |
return "nil" | |
case let .some(value): | |
return "\(value)" | |
} | |
} | |
} |
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
func unwrappedDescription<T>(_ value: Optional<T>) -> String { | |
guard let value = value else { | |
return "None." | |
} | |
return "\(value)" | |
} |
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
//test case #1 | |
func testVMInvalidSelection{ | |
//Prepare | |
let vendingMachine = VendingMachine() | |
var didReceiveInvalidSelectionError = false | |
//Execute | |
do{ | |
try vendinMachine.vend("Coke") |
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
struct Item { | |
var price: Int | |
var count: Int | |
} | |
enum VendingMachineError: ErrorType { | |
case InvalidSelection | |
case InsufficientFunds(coinsNeeded: Int) | |
case OutOfStock | |
} |
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
func testWinnerHorizontally(){ | |
//Prepare: Setup the board and place markers such that player wins in horizontal direction | |
let board = TTBoard(boardIDString: NSUUID().UUIDString) | |
board.markPosition(0, playerCode: 1); | |
board.markPosition(3, playerCode: 2); | |
board.markPosition(1, playerCode: 1); | |
board.markPosition(5, playerCode: 2); | |
board.markPosition(2, playerCode: 1); | |
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
func testWinnerHorizontally(){ | |
//PREPARATION | |
//Prepare a board and mark position so that playerCode '1' wins | |
let board = TTBoard(boardIDString: NSUUID().UUIDString) | |
board.markPosition(0, playerCode: 1) | |
board.markPosition(3, playerCode: 2) | |
board.markPosition(1, playerCode: 1) | |
board.markPosition(5, playerCode: 2) | |
board.markPosition(2, playerCode: 1) |
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
// | |
// TTBoard.swift | |
// Tic-Tac-Toe-Swift | |
// | |
// Created by Bharath Booshan on 9/12/15. | |
// Copyright (c) 2015 FeatherTouch. All rights reserved. | |
// | |
import Foundation | |
import UIKit |
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 java.util.ArrayList; | |
/** | |
* Created by bbooshan on 2/3/15. | |
*/ | |
public class FTSynchronizedArray<T> { | |
private ArrayList<T> itemStore; |
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
//download data.ab (encrypted) and DONOT GIVE ANY PASSWORD when prompted | |
adb backup -f ~/data.ab -noapk app.package.name | |
//decrypt and extract the data.ab [this worked most of the time except for few instances ] | |
//this will output all the contents of app into 'apps' directory | |
dd if=data.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" | tar -xvf - | |
//SOURCE: http://blog.shvetsov.com/2013/02/access-android-app-data-without-root.html |
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 void turnOFF() | |
{ | |
param = cam.getParameters(); | |
param.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); | |
cam.setParameters(param); | |
cam.stopPreview(); | |
cam.release(); | |
cam=null; | |
} |
NewerOlder