This file contains 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
urlConnection = (HttpURLConnection) imageURL.openConnection(); | |
String location = urlConnection.getHeaderField("Location"); | |
if (location != null ) | |
{ | |
URL newURL = new URL(location); | |
urlConnection = (HttpURLConnection) newURL.openConnection(); | |
} | |
//use the urlConnection now |
This file contains 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; | |
} |
This file contains 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 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 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 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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 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 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 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)" | |
} |
OlderNewer