Friday 22 April 2016

Anpan

There was supposed to be another bread post between the apple cinnamon rolls and anpan, where I discussed my adventures with brioche, but it probably doesn't matter, and Mpanda wanted me to post about anpan. Anpan is a sweet Japanese bun, filled with red bean, and even though I'm not supposed to eat it, I do anyway. I think I had it for breakfast nearly every day when we were in Japan!



The recipe I followed was this one: http://www.justonecookbook.com/anpan/ (and I have been drooling over the rest of her blog). She has a video and instructions with photos, which was super helpful. I also tried making this recipe dairy-free, and egg-free. The dairy-free and egg-free attempt didn't go so well. The taste was nice, but the glaze didn't really turn out as nice (as you'll see in photos at the moment). The photo above is from the dairy-free-only attempt.

Ingredients
225 g (1 ¾ cup) bread flour and extra for sprinkling
25 g (scant ¼ cup) cake flour (No cake flour? The author says 1cup minus 2tbsp of plain flour + 2 tbsp of cornstarch = 1 cup of cake flour)
50 g (¼ cup) granulated sugar
4 g (1 tsp.) kosher salt
3 g (1 tsp.) instant dry yeast
1 large egg (46-50 g/ml) - or one egg's equivalent of No-egg egg replacement powder
50 ml (3 ½ Tbsp.) soy milk
50 ml (3 ½ Tbsp.) water, keep at 86F (30C)
35 g (2 ½ Tbsp.) Nuttelex buttery butter substitute

(optional)
I tried the tangzhong method again here, and I think it made it slightly softer, but I'm not 100% sure it made a noticeable difference. If you want to do it too, you'll also need:
12.5g bread flour (roughly 1/8 cup)
5/8 cup of water

Filling
280 g (35 g x 8) Anko, sweet azuki red bean paste (I found some at the Asian supermarket)

Toppings
1 egg
2 Tbsp. water (replace with soy milk if you want it to be more brown)
2 tsp. black sesame seeds

Method
(slight variation to the website)
If you are using the tangzhong, put the 12.5g of flour and 5/8 cups water on a small saucepan, and heat over low heat, whisking constantly until your whisk starts to leave a trail and it becomes a bit paste-like. Remove from heat and allow to cool.

(all methods)
Heat the water to the required temp, and add the yeast, giving it a stir so that all the yeast gets submerged in the water. Allow to sit while you mix the rest of the stuff.

Mix the bread flour, cake flour, sugar, salt in a bowl. Add the egg or egg replacement, and soymilk. It'll be a bit dry and lumpy at this stage, that's OK. If using the tangzhong, add it now. Then add the water + yeast and stir until all combined. If you used the tangzhong, you might find it's quite wet at this stage, so slowly add more flour until it doesn't stick to the bowl.

Lightly flour a flat surface / pastry mat, and begin kneading the dough (fold it over on itself, and press down to flatten it, then rotate 90 degrees and repeat). It might be a bit sticky, so keep adding flour to your surface / hands while you knead.

After about 5 minutes, once you find you can stretch it without breaking, stretch it out to about 25cm, add the Nuttelex along the dough, and roll it up. Then continue kneading. It will get messy right about now. Just trust me that if you keep going, it'll start to smooth out. If you've been going at it for 10 minutes, and it's still crazily sticky, then slowly add a bit of flour at a time. You do NOT want to add too much flour - that's the mistake I made once, and I'll never make it again. If you do, your bread will be heavy and yucky.

The author says to use the windowpane test to see when it's ready, and unfortunately, I couldn't take a photo while I was doing it, because my hands were tied up, so you'll have to see her blog for a photo of what that means.

Once it's ready, fold the sides under the dough into the middle, so it wraps into a ball. Cover with plastic wrap, and leave in a warm place for 2 hours to proof.


After two hours, it should have increased in size. If you can poke into it, and it doesn't spring back into a smooth ball, you are ready for the next stage!

Back to the pastry mat (I didn't need any more flour at this stage to stop it sticking), flatten the dough out, and then fold it like a business letter: into third, folding one side in, then the other on top. Then rotate 90 degrees and do it again. Divide the dough into 8 pieces, and leave those pieces somewhere warm to proof for about 15 minutes.

Once that's done, starting with one piece, flatten that out, do the business letter fold, 90 degrees, another business letter fold. Flatten it out again, and fill with redbean paste (I put about a tablespoon or more in, but I really like red bean paste. In fact, one of the reasons I wanted to make this myself is because sometimes I get an anpan, and I think it's more like a bun that may contain traces of redbean, and I feel super ripped off! This way I can put as much as I like).


The flatter you get the dough at this point, the better, as your bun will be less bready and more redbeany! Fold the sides up over the red bean, and pinch together, then turn upside down and make sure the red bean is all sealed up (the seam should be on the bottom). Then gently press down on it to flatten it a bit so it's not just a ball.

Repeat with the others. I found that it helps to do the first egg glaze here, to get extra brown, but doing two egg glazes is optional. Anyway, mix the egg + water / milk for the glaze, and do one coating now if you like. Leave the buns in a warm place for 30 minutes. Now is a good time to pre-heat your oven to 200 degrees Celcius.

Do a coat of the glaze, and sprinkle the black sesame seeds on top.


Bake for 13-15 minutes, turn halfway if your oven doesn't heat evenly.

(This is from a one glaze batch.)

(This is from my failed attempt to make kumanpan / anpanda). This was also the no-egg version, and you can see how sad the glaze looks, it's not shiny at all. :( Apparently it's the egg yolk that gives the shine.

Mmmm, tasty red bean paste.

Oracle Java SE 7 Programmer II - Sample Questions

Well, it's that time of the year again. My previous boss wanted me to sit this exam (which is the second part of the exam I sat last year), and my new boss had no objection to me doing it. Today is the big day. As the last part of my study, I'm going through the sample questions, which don't seem to have reasoning for their answers, so here's my attempt at explaining it to get a better understanding myself.

1.Given: 

import java.util.*;
public class Primes2 {
public static void main(String[] args) {
Integer[] primes = {2, 7, 5, 3};
MySort ms = new MySort();
Arrays.sort(primes, ms);
for(Integer p2: primes)
System.out.print(p2 + " ");
}
static class MySort implements Comparator {
public int compare(Integer x, Integer y) {
return y.compareTo(x);
}
}
}

What is the result?
A) 2 3 5 7
B) 2 7 5 3
C) 7 5 3 2
D) Compilation fails.

The answer is: D
It looks like it's OK, but MySort says it implements Comparator, but doesn't override compare(Object o1, Object o2), so it won't compile.


2. Given: 

class Class1 {
String v1;
}
class Class2 {
Class1 c1;
String v2;
}
public class Class3 {
Class2 c1;
String i3;
}

Which three options correctly describe the relationship between the classes?
A) Class2 has-a i3
B) Class1 has-a v2
C) Class2 has-a v2
D) Class3 has-a v1
E) Class2 has-a Class3
F) Class2 has-a Class1

The answer is: C, D, F
I think this is a stupid question, but oh well. Class2 has-a v2, which you can see in the class declaration (it contains String v2). Class3 has-a v1, which it gets through Class2's Class1's v1. Class2 has-a Class1, which is also in the class declaration.


3. Given this code snippet: 

Map m = new HashMap();
MyKeys m1 = new MyKeys(1);
MyKeys m2 = new MyKeys(2);
MyKeys m3 = new MyKeys(1);
MyKeys m4 = new MyKeys(new Integer(2));
m.put(m1, "car");
m.put(m2, "boat");
m.put(m3, "plane");
m.put(m4, "hovercraft");
System.out.print(m.size());

And this class:

class MyKeys {
Integer key;
MyKeys(Integer k) { key = k; }
public boolean equals(Object o) {
return ((MyKeys)o).key == this.key;
}
}

What is the result?
A) 2
B) 3
C) 4
D) Compilation fails.
E) An exception is thrown at run time.

The answer is : C

The reason why it's 4 is because each MyKeys being put in the map is a new instance of key (see the fact that it's being created with the new keyword). Because MyKeys' equals() method does an == comparison, which checks for object instance equality, and each instance is new, m1 != m2 != m3 != m4, so each will be its own entry in the HashMap. It might look like it won't compile, because m4 is being created with new Integer(2), and the rest are ints, but with autoboxing, that'll be converted to an int, too, and I'm pretty sure with old pre-1.5 Java, it doesn't care.

4. Given: 

import java.util.*; 
public class MyScan { 
public static void main(String[] args) { 
String in = "1 a 10 . 100 1000"; 
Scanner s = new Scanner(in); 
int accum = 0; 
for(int x = 0; x < 4; x++) { 
accum += s.nextInt(); 
System.out.println(accum); 


What is the result? 
A) 4
B) 10
C) 111
D) 1111
E) Compilation fails.
F) An exception is thrown at run time.

The answer is: F
It will scan the 1, but when you call nextInt() again, it hits "a", which is not an int, nor can it be made into an int. So it throws an InputMismatchException.

5. Given: 

public class Truthy {
public static void main(String[] args) {
int x = 7;
assert(x == 6) ? "x == 6" : "x != 6";
}
}


What is the result if you try to compile Truthy.java and then run it with assertions enabled? 

A) Truthy.java does NOT compile. 
B) Truthy.java compiles and the output is "x != 6".
C) Truthy.java compiles and an AssertionError is thrown with no additional output.
D) Truthy.java compiles and an AssertionError is thrown with "x != 6" as additional output.

The answer is: A
Truthy does not compile because you can't assert Strings. Kinda unexpected, as I picked A because I thought it would fail due to the ternary operator, but assert(x==6)? true: true; compiles and runs successfully. So it seems to fail to compile, because you are returning Strings from the ternary operator, instead of the boolean that assert expects. So perhaps it's doing the equivalent of assert(x==6 ? "x==6" : "x!=6");, which I do not expect to compile - and it doesn't.

6.Given the code fragment: 

try {
// assume "conn" is a valid Connection
// assume a valid Statement object is created
// assume rollback invocations will be valid

// use SQL to add 10 to a checking account
Savepoint s1 = conn.setSavePoint();
// use SQL to add 100 to the same checking account

Savepoint s2 = conn.setSavePoint();
// use SQL to add 1000 to the same checking account

// insert valid rollback method invocation here

} catch (Exception e) { }



Which two statements are true? 
A) If conn.rollback(s1) is inserted, account will be incremented by 10.
B) If conn.rollback(s1) is inserted, account will be incremented by 1010.
C) If conn.rollback(s2) is inserted, account will be incremented by 100. 
D) If conn.rollback(s2) is inserted, account will be incremented by 110.
E) If conn.rollback(s2) is inserted, account will be incremented by 1000.

The answer is: A, D

Assuming this particular database supports multiple save points, if you rollback to s1, then you've only added 10 at that point. If you roll back to s2, then you've added 10 and 100, to give a total of 110. 

7. Given: 

public class Bees {
public static void main(String[] args) {
try {
new Bees().go();
} catch (Exception e ) {
System.out.println("thrown to main");
}
}
synchronized void go() throws InterruptedException {
Thread t1 = new Thread();
t1.start();
System.out.print("1 ");
t1.wait(5000);
System.out.print("2 ");
}
}


What is the result? 
A) 1 then 2 with little delay 
B) 1 then 2 after 5 seconds
C) 1 thrown to main 
D) 1 2 thrown to main
E) Compilation fails.


The answer is: C
So the first trick into working this one out is to work out what type of Exception is being thrown, because it's not an InterruptedException! Turns out it's an IllegalMonitorStateException, which is thrown when the current thread does not own the object's monitor. But what does that mean, since we're in a synchronized block, so shouldn't we own the current monitor? We own the monitor on Bees, and not the thread t1.

8. Given: 

import java.text.*;
public class Align {
public static void main(String[] args) {
String[] sa = {"111.234", "222.5678"};
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(3);
for(String s: sa) 
System.out.println(nf.parse(s));
}
}


What is the result? 
A) 111.234
222.567 
B) 111.234
222.568 
C) 111.234
222.5678
D) Compilation fails. 
E) An exception is thrown at run time.

The answer is: D
nf.parse() has a checked Exception: ParseException, so that call needs to be in a try block.

Sunday 10 April 2016

Game Review: Clash Royale

Slight delay in the cooking posts, because... I dropped my phone in the toilet. Why did I drop my phone in the toilet? Because I have started playing a game called Clash Royale, and though I'm not a take-my-phone-with-me-to-the-toilet kind of person, I temporarily became one.

A few people from the uni video games club started a games club, which is like a book club, except we get together and play / discuss games. Each month, there are a few games chosen, one of which will be a free-to-play one, and this month's free-to-play game was Clash Royale. Although the club meeting is tonight, I thought I'd get my thoughts in before they are influenced by others. (Even though it's now after the games club meeting, I wrote most of this before, just tidied it up afterwards.)

So the game itself is pretty straightforward. It's set in the "Clash universe", i.e. the same universe as Clash of Clans. Cards represent troops, and you have a deck consisting of 8 different cards. You play against an opponent's deck, and have 4 cards at a time to play - each with a different elixir cost. Your elixir goes up over time. Each player gets 2 arena towers, and King's tower.



At the beginning, you can only summon troops on your side of the battlefield. Once you've destroyed on of the arena towers on your opponent's side, you can also begin summoning troops where the tower was destroyed. You can't control troops once they've been summoned, they will just walk towards, and attack, their nearest preferred target (some units only target ground units and buildings, some units only target buildings, some can attack ground, air and buildings).

The player who manges to destroy the most towers wins - however, destroying the king's tower is an instant win. Games last 3 minutes, and after 2 minutes, you gain double elixir (sorry, I tried to take a screenshot at 1 minute remaining, but I was too engrossed in the game! You can see the x2 in the top right corner).


If the game is still tied after 3 minutes, an extra minute over overtime is added, and it becomes "Sudden Death mode" where the first player to take a tower wins. If neither player manages to take a tower after that, the game is a draw. The winner of the game gets a treasure chest.

However, and here's where the monetary aspect comes into it, you only have 4 slots for chests, so if you have filled all the slots, you will not be able to win new chests from games.


Opening chests takes time, but you can open them instantly using gems. Gems you can buy with real-world money:


You can also get gems from the free chests and crown chests. Free chests can be opened every 4 hours, and you get one crown chest per day. To open the crown chests, you must destroy 10 towers in multiplayer games (doesn't matter if you win or lose the match). Opening chests gets you cards, and you need to collect a certain number of the same card to upgrade your troops.



You can also hope the card you want is in your shop, where you can purchase it directly with gold (which you get from opening chests, or you can buy with gems). There are twice as many cards in the shop on Sundays.


If you are in a clan, you can request cards from your clanmates. The incentive to donate cards to others is that you get gold and exp from donating cards. The more exp you get, faster you level up, and the stronger your towers are.


-------------------------------------

OK, that's the gist of the game. On to the review. When you start the game, you are in the training camp, and playing against the AI. You can't change your deck at the moment, but playing the AI teaches you the basics, and you win chests from beating it. Once you've finished with the training camp, you'll start playing against real players. The game matches you against players with a similar trophy count. Trophies are like your matchmaking rank, so at the start, you'll be playing others with 0 trophies. I found all of these games pretty fair. Games at this point were pretty short, and unlocking the crown chest was pretty easy, as most games were three-crown wins.

At this level, almost nobody has a clan, because you must be level 3 to join a clan. Here's where we hit our first stumbling block.

I guess as part of the review process, we needed to find out what it was like to start a clan. Well, it's 1000 gold to start a clan, which is a lot when you're new to the game. Given that I was only going to be playing for a month, I figured I would just spend the starting gems you get to buy gold and start the clan. Auto also volunteered, but he was planning to continue playing, so it made sense for him to keep his gems for real stuff.

I found once we had a few people in the clan, gold started rolling in from donations. And it became easier to level up cards, as people were donating cards they weren't using. Now that we're a few weeks into the game, our clan has grown to 17 people, and I'm starting to find that a lot of people are running similar decks, so it's becoming harder and harder to request the cards you actually need. I've given up, and am just requesting commons so that everyone can level up, and we can move up in the ranks and get better chests which contain more cards, so it makes it more likely we'll be able to donate cards people want.

For the game itself, it seems simple, but I was surprised at how much strategy there is in the game. Troop placement, troop timing, when to let your towers take a few hits, when to save up elixir. Once you advance past the first couple of arenas, strategy plays a larger part. Especially because that's when people's decks start to diversify. As you can only request commons and rares, the epics that you manage to get along the way will shape your deck, and in some ways, determine which opponents you will crush, and which ones you'll struggle against.

For a while, I really struggled against baby dragons, which fly and do AoE damage. I also struggled a lot against giants and princes, because I didn't really have the nuke damage to kill them before they started pounding on my towers. But over time, I worked out ways to work around it. I think like 7uckingmad says about playing Dota, the best way to learn how to beat something is to play with it. I thought balloons were crazy strong for so long, and when they appeared in my shop, I decided to shell out the 2k gold and buy one for myself. I won a few games with it, but as I ranked up, I noticed that the balloon was dying so quickly, and even when I paired it with other things to try and keep it alive, my opponents had such a simple method for dealing with it.

I watched a few games linked by my clanmates, and watched how they dealt with particular strategies, and that helped me win a few more games.

Looking at the pay model of the game, I think it's definitely not a pay to win game. After a month of playing, and spending no money on the game, I managed to make it to arena 5 (for reference, there are a total of 8 arenas). I have come across a few people who had much stronger cards than I did, and I wondered if they had spent money on the game, but those opponents are quite rare. They probably move out of the lower brackets quite quickly, so you will rarely see them. The game doesn't seem to have any incentive for you to move upwards. I mean, there are nicer cards from later arenas, but I never felt an urge to grind as far as I could with the cards that I had.

Seeing as you only get 4 chest slots, I found that I'd play my games, get my crown chest, and then be done for the day (except to open the app and start unlocking a new chest). At least, that's how it was at first. As I got further through the arenas, it was taking longer and longer to unlock the crown chest. I'd normally do it before going to sleep, 3 three-crown wins plus one other game for my 10 crowns. But at later levels, I was only getting 1 crown per game on average, and not winning that many of them. So I'd be playing a few games before bed, and then a few games in the morning to get my 10 crowns. It seemed so much more of a chore in the higher arenas than in the lower ones.

Plus, I feel like you hit a certain point where you struggle to advance, because it takes so many cards to upgrade your troops. So it starts off at 2 cards, then 10 cards, then 20 cards, then 100 cards, then 200 cards. It takes a long time to get 200 of the same card, and a long time to save up the gold to pay the upgrade cost. Auto called it the 1200 trophy wall.



I think that's what turned me off the game in the end. I stopped playing to enjoy the game, and started playing just to fill up my chests and open my crown chest. Winning was rewarding for a while, but the more I won, the more time consuming it became to open my crown chest. I went from playing 15 minutes a day to over an hour some days. And for what I expected to be a somewhat casual game, that isn't what I wanted!

Overall, I'd rate it a B. It's fun, can be addictive (hence the toilet dropping), and you aren't overly disadvantaged by not paying money, as long as you are patient.


Tuesday 5 April 2016

Apple Cinnamon Rolls

Over the weekend, I had my first attempt at dairy-free anpan (a Japanese bun filled with red-bean). It wasn't great, so I'm going to attempt to do better.

But we need to go back to go forward. I thought I had posted this earlier, but I guess I hadn't. It all started because I was reading a reddit thread where people were talking about how amazing Cinnabon is. Suddenly, I had a huge craving for cinnamon, and nothing goes with cinnamon like apple does.



Here's the recipe I started with:

http://sallysbakingaddiction.com/2013/02/15/caramel-apple-cinnamon-rolls/

The first time I made it, I found the bread a bit bready. Which isn't a bad thing, but what I was fantasising about was warm, soft, sticky buns, straight out of the oven. Key component being soft buns. What I had was about the softness of sliced bread - which is still soft, but not as soft as I was after! The benefits of making your own bread is that you can modify the recipe however you like! A bit of Googling and I discovered the tangzhong method, a technique used in Asian cooking for making soft, fluffy bread. It involves taking some of the flour for the bread, and making a roux with it, before mixing it in.

Ingredients:

DOUGH:
1 package active dry yeast (I think mine has 7g of yeast in it, I don't know if that's what they all have)
1/2 cup warm water
1/2 cup apple juice or apple cider
1/4 cup sugar
1 teaspoon salt
1 large egg (I used one egg worth of no-egg egg replacement powder)
1 and 1/2 teaspoons vanilla extract
2 Tablespoons unsalted butter, softened to room temperature (I used Nuttelex buttery instead, so I assume any kind of margarine can substitute)
3 – 3.5 cups all-purpose flour (measured correctly)

FILLING:
2 tablespoons unsalted butter, softened to room temperature (again, Nuttelex / margarine can be used here)
2 medium sized apples, peeled, cored, & thinly sliced (about 1.5 cups)
1/2 cup packed dark brown sugar (the original recipe has 1 cup, but I think that's a bit much)
2 Tablespoons ground cinnamon

The original author also added a caramel sauce on top, but I think it's sweet enough without.

Method:

1. Dissolve the yeast in the warm water. Important: The post says 105-115F degrees. Hot-to-the-touch / boiling water is bad. You will kill your yeast - which is what I did the first time because I thought it was 100 degrees Celcius! I tend to consider warm as water where you touch it and think it's slightly above not-warm. That sound stupid. I don't know how to describe it.

2. While the yeast is warming up, in a small saucepan, mix 1/4 cup of the flour with 1 1/4 cups of water. Heat over low heat, whisking, until it becomes a paste - running your whisk in the mixture should leave lines. Allow to cool to room temp. This is the tangzhong.

3. In a large bowl, mix the apple juice, sugar, salt, egg, vanilla, margarine, 1.5 cups of the flour, and the yeasty water. You can use an electric mixer, but I don't think it's required, and I'm all for washing less stuff at the end. Mix until well combined. Add the tangzhong.

4. Slowly add the remaining flour, starting with half a cup at a time, and adding less each time, until you get dough that's not sticky and springs back when you poke it. Knead for 5-6 minutes. Cover it and let it sit in a warm place for about 1.5 hours. I like to turn my oven on to 200 degrees Celcius for a couple of minutes, then turn it off and leave the dough in there.

6. While the dough is proofing, melt the 2 tablespoons of margarine in a saucepan. Add the apples and cook over a medium heat until the apples get really soft. Drain the liquid and allow to cool in the fridge (you want it to dry a bit).

7. Grease your baking pan / line with baking paper. I used a roasting pan, but the original recipe says a 9 x 13 inch pan.

8. Once the dough has doubled in size, lightly flour a pastry mat / other clean, flat surface and roll the dough out into a rectangle. The original recipe suggests a 15 x 9 rectangle, but I roll until I get it about 1.5cm thick.

9. Mix the cinnamon and brown sugar in a bowl. Sprinkle half the cinnasugar mix on to the rectangle. Then make a layer with the apples. Then cover with the rest of the cinnasugar mix. Roll it up, starting from the long end. Cut into as many rolls as you'd like. I did 15 in the photo below.




10. Place the rolls into your baking pan. Allow to rise in a warm place for 30 minutes to an hour.

11. Preheat your oven to 180 degrees Celcius. Cover the tray with aluminium foil and bake for 25-30 minutes. It should be golden brown (this photo was taken from a different batch - that's why the number of rolls is different. They do not magically multiply while in the oven!).



12. Allow to cool in the pan for a couple of minutes while you gently cut them. This isn't in the original recipe, but I do this because this gives it time to absorb some of that yummy apple, cinnamon, sugar liquid that'll be on the bottom of the pan. Remove them from the pan and cool on a cooling rack. Flip them upside down, so the side that's the top in the pan is now the bottom. They will have a nice sugary glaze on top (that's why I don't think the caramel sauce is necessary, but I'll leave that up to you).



Om nom nom. Best eaten when warm - but don't burn yourself eating one straight out of the oven! And because of the tangzhong, it doesn't go stale as quickly, so you can enjoy them over a few days.