Skip to content

Instantly share code, notes, and snippets.

@bharath2020
bharath2020 / Download 'data' from Android without roooting
Last active January 25, 2024 21:13
Download manifest from Android APK
//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
@bharath2020
bharath2020 / Custom ImplicitOptionalDescription.swift
Created April 1, 2017 20:31
Custom ImplicitOptionalDescription
extension Optional : CustomStringConvertible {
public var description: String {
switch (self) {
case .none:
return "nil"
case let .some(value):
return "\(value)"
}
}
}
@bharath2020
bharath2020 / unwrappedDescription.swift
Last active April 1, 2017 20:31
Optional description
func unwrappedDescription<T>(_ value: Optional<T>) -> String {
guard let value = value else {
return "None."
}
return "\(value)"
}
//test case #1
func testVMInvalidSelection{
//Prepare
let vendingMachine = VendingMachine()
var didReceiveInvalidSelectionError = false
//Execute
do{
try vendinMachine.vend("Coke")
@bharath2020
bharath2020 / VendingMachine.swift
Last active February 22, 2016 03:07
VendingMachine Test Cases
struct Item {
var price: Int
var count: Int
}
enum VendingMachineError: ErrorType {
case InvalidSelection
case InsufficientFunds(coinsNeeded: Int)
case OutOfStock
}
@bharath2020
bharath2020 / testPlayer1WinnerHorizontally.swift
Created January 24, 2016 02:21
Tic-Tac-Toe Test if there is a win for player Horizontally
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);
@bharath2020
bharath2020 / 0_reuse_code.js
Created January 24, 2014 00:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@bharath2020
bharath2020 / TTBoardTests.swift
Created December 29, 2015 14:33
Prerparation, Execution, Verification
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)
@bharath2020
bharath2020 / TTBoard.swift
Last active December 29, 2015 10:52
TTBoard.swift class from Tic-Tac-Toe
//
// 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
@bharath2020
bharath2020 / gist:9f156d8f6e6dfe719552
Created February 4, 2015 21:01
Synchronized array in JAVA
import java.util.ArrayList;
/**
* Created by bbooshan on 2/3/15.
*/
public class FTSynchronizedArray<T> {
private ArrayList<T> itemStore;