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 | |
# | |
# Find the IP address of a client by MAC on the same network. Sudo privilege and nmap required. | |
# | |
# usage: ./findbymac.sh <MAC_ADDRESS> | |
# | |
# The first argument to the script is the MAC address or part of the MAC address. | |
# | |
# example: sudo ./findbymac.sh "aa:b8" | |
# |
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
from collections import namedtuple | |
from hashlib import sha256 | |
from typing import List, Optional | |
def makehash(data: str) -> str: | |
return sha256(data.encode()).hexdigest() | |
Block = namedtuple("Block", ["data", "hash", "prevhash"]) |
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 TestContext extends MockContext { | |
@Override public MockResources getResources() { | |
return new TestResources(); | |
} | |
} | |
class TestResources extends MockResources { | |
@Override public String getString(int id) { | |
return "foo is a bar"; | |
} |
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
ArticleViewActivity a = new ArticleViewActivity(); | |
Bundle b = new Bundle(); | |
b.putString("articleId", "bab13"); | |
a.onCreate(b); | |
assertTrue(a.hasArticle()); |
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 Baby { | |
private Bottle mBottle; | |
public Baby() { | |
// rossz, nem tesztelhető kód | |
mBottle = new Bottle(); | |
} | |
} |
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
// injection via constructor | |
Baby baby = new Baby(new MockBottle()); | |
// injection via setter | |
Baby baby = new Baby(); | |
baby.giveBottle(new MockBottle()); |
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
Baby baby = new Baby(); | |
boolean exceptionWasThrown = false; | |
try { | |
baby.removeToy(); | |
} catch (ToyNotExistsException e) { | |
exceptionWasThrown = true; | |
} | |
assertTrue(exceptionWasThrown); |
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
Baby baby = new Baby(); | |
Bottle bottle = new MockBottle(); | |
// a csecsemőnek szüksége van egy üvegre a táplálkozáshoz | |
baby.feed(bottle); | |
assertTrue(bottle.isConsumeCalled()); | |
class MockBottle extends Bottle { | |
@Override void consume() { | |
mConsumeCalled = true; | |
} |
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
Baby baby = new Baby(); | |
boolean toyGiven = baby.giveToy(null); | |
assertFalse(toyGiven); |
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
Baby baby = new Baby(); | |
baby.removeToy(); | |
assertTrue(baby.isCrying()); |