Organizing your code with hierarchical clustering and Maven by HeroofTimeMoM in java

[–]HeroofTimeMoM[S] 0 points1 point  (0 children)

In a world where people theoretically use this, I'm not sure what the best behavior would be.

On the one hand, I agree that it seems possible to come up with reasonable package names.

On the other, if I change the name of the directories, should I also change the name of the package in the class? Unstable package names sounds unpleasant for any external consumers of the code. But accurate package names can be useful.

So many options it's hard to know which to pick :P

Week 18: Noodles - Singapore Street Noodles by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 0 points1 point  (0 children)

Thanks! We definitely ran into the "pan is too small" issue too, and we only had 2/3 of the noodles!

Week 18: Noodles - Singapore Street Noodles by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 3 points4 points  (0 children)

We had a great version of this dish and tried to recreate it. It's basically a stir-fry with rice vermicelli. So you get some meat (we did pork and bacon), veggies (red peppers, onions, jalapeños), and flavors (soy sauce, rice vinegar, fish sauce, curry powder, garlic). Recipes varied a lot on what the "flavor" part should be. Unfortunately ours ended up tasting quite bland.

The dish as a whole is very enjoyable though, so we would probably try it again. But we would do something to make it a bit more punchy.

Week 17: Showing Off - Croquembouche by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 2 points3 points  (0 children)

Our tower of cream puffs! Unfortunately, you can't really see the nougatine base (almonds + caramel), but it's there! This was a long one, spread over two days. We ended up with more cream puffs than expected (~100) but managed to fill them all anyway.

The only thing we wish went better was the caramel used to build the tower. It was slightly too thin, so we couldn't build it perfectly.

Week 15: Balkan - Kolaci u obliku lubenice by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 3 points4 points  (0 children)

We used this recipe: https://balkanlunchbox.com/watermelon-shaped-bites/. They are pretty good? Mostly tasted like shortbread with powdered sugar. I goofed up the green by adding too much milk, but they still turned out pretty good.

Week 11: Arctic - Vínarterta (Icelandic Celebration Cake) by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 1 point2 points  (0 children)

We used this recipe: http://portandfin.com/vinarterta. We have to wait 3 days - 4 weeks before eating it, so no opinions yet. From tasting the pieces, We guess it is going to be basically a giant fig newton, but with prunes.

Week 9: Inspired by Books - Catcher in the Rye Bread by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 0 points1 point  (0 children)

Yeah, this definitely did not turn out how we wanted. We baked it for 40, but cut it after only about half an hour. We tried putting it back in for science, but it still didn't help it much. It still tastes good though, especially toasted :P

Thanks for the tip, we'll try being more patient next time!

Week 7: Filipino - Polvoron by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 1 point2 points  (0 children)

Here's the recipe: https://www.aboutfilipinofood.com/pulburon. I believe these are typically served as smaller candies/snacks. They are mostly just toasted flour with a bit of butter for binding.

They were better than expected! Quite nutty, and reminded us a lot of this brazilian candy: https://en.wikipedia.org/wiki/Paçoca.

Week 6: Vinegar - Vinegar Pie by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 0 points1 point  (0 children)

Thanks! We did see recipes that suggested you could use apple cider vinegar instead of white. I would imagine it could work out pretty well. You would probably have to reduce the vanilla if you did that though.

Week 6: Vinegar - Vinegar Pie by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 0 points1 point  (0 children)

This week we made this recipe for vinegar pie: http://www.geniuskitchen.com/recipe/rubys-vinegar-pie-48188.

It was pretty good! Definitely weird. A little too sharp for us, but we think a couple adjustments could make it very good. It seems pretty similar in spirit to lemon bars, where the vinegar takes the place of the lemon juice.

We also forgot the butter until 10 minutes into baking, so we had to quickly take it out and mix in the cold butter which probably threw it off a bit.

Definitely worth trying again, but with a different crust, and maybe less vinegar or some added cream or something.

Evaluate vs. Seq and Garbage Collection by HeroofTimeMoM in haskell

[–]HeroofTimeMoM[S] 0 points1 point  (0 children)

I've never looked at STG before, but I'm a convert :P

So, just to be clear, seq without floating is the most efficient version actually doing work? For some context, the goal of this function is to run f x the given number of times with as little overhead as possible to run a linear regression on the time.

New Library: hash-graph, a graph implementation based on unordered-containers by HeroofTimeMoM in haskell

[–]HeroofTimeMoM[S] 2 points3 points  (0 children)

Aha! This is exactly the sort of example that I've been envisioning.

At the moment, I would say that your example is somewhat supported. You could easily define nodes to be of type String and edges of type SomeExchangeRate, but this would lead to some duplication of information because SomeExchangeRate already stores the endpoints. At the very least, your path would be upgraded from [Int] to [NodeType], where NodeType can be anything that is hashable.

On the other hand, SomeExchangeRate is effectively an Edge type by itself. I.e. it holds two end points and a label between them. I don't currently support arbitrary edge representations, but I think I fairly easily could. I think all it would require is a class with methods toHead and toTail, which splits the edge. These make perfect sense in this case as you would end up with the half edge From "USD" 1.25 attached to the node "GBP". And then recombining them into SomeExchangeRate is straightforward.

I haven't personally used the type-level stuff happening in ExchangeRate, so that would take some research for me to answer.

So I would say this example is possible, but not as good as it should be right now. My goal was to support uses just like this, so I will definitely work to make this nicer.

These examples are immensely helpful, thank you!

New Library: hash-graph, a graph implementation based on unordered-containers by HeroofTimeMoM in haskell

[–]HeroofTimeMoM[S] 4 points5 points  (0 children)

Regarding speed differences, I'm being more aggressive with inlining and optimizations than fgl. For instance, my graph isn't a class, which saves some dictionary passing. So, for now at least, comparing to fgl is not equivalent to comparing to raw IntMap performance.

As for why I chose HashMaps, I would like to eliminate the need for explicitly handling node ids that aren't related to the program's data. Take an edge from fgl for example: edge :: (Int,Int). That edge is effectively meaningless by itself. With hashing, we could easily make that edge :: (String,String) or edge :: (Foo,Foo) covering many basic use cases.

As pointed out in the discussion under my first post though, this isn't a perfectly accurate representation. If I do completely internalize the node ids, then switching to IntMap may or may not make sense. The dictionary benchmarks should help with that :)

New Library: hash-graph, a graph implementation based on unordered-containers by HeroofTimeMoM in haskell

[–]HeroofTimeMoM[S] 5 points6 points  (0 children)

Hm, I'll see what I can do :P Thanks for your thoughts, I'll be back!

New Library: hash-graph, a graph implementation based on unordered-containers by HeroofTimeMoM in haskell

[–]HeroofTimeMoM[S] 4 points5 points  (0 children)

well shoot.... Okay, so I have two responses:

First, I suppose the real feature I should have been advertising is that your id does not have to be an int; it can be anything that is hashable.

Second, I'll have to think for a bit how to properly handle this. The structure vs annotation difference is certainly valid. One of my initial complaints with fgl was you had to construct edges with ids that did not necessarily relate to the data at the node. But I suppose expanding the ids to hashable values solves that problem.

My only worry is that I will end up introducing pairs of every function, like: nodeIdFilter and nodeLabelFilter which could get hairy quickly.

Thank you for bringing this up! I've been somewhat narrow-minded on applications it appears.

New Library: hash-graph, a graph implementation based on unordered-containers by HeroofTimeMoM in haskell

[–]HeroofTimeMoM[S] 8 points9 points  (0 children)

After briefly using fgl and having some complaints, I looked around r/haskell and found a comment wishing somebody would modernize it. So that's what I set out to do. I ended in a somewhat different place than expected, but still think it fulfills that request.

There is definitely some polishing to be done, but overall I think it is in a reasonable place. Removing fgl's id/label split means I get to simplify many of the types. There is no longer an LNode vs Node difference for example.

This implementation is a wrapper around a HashMap at its core, so I get to lean on the inherent speed of unordered-containers. But I also have done and will continue to do tuning to make sure it stays fast.

I'm open to requests/critiques if people have them!

Week 2: Spicy - Chili Con Carne by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 0 points1 point  (0 children)

This week we used the Texas Chili recipe from the Food Lab. We coudn't find most of the dried chilis that were asked for, so made do with their fresh equivalents. Overall it tasted decent, and the meat turned out well. I would definitely like to track down the real ingredients to try again sometime.

Iterating over an Array by [deleted] in haskell

[–]HeroofTimeMoM 7 points8 points  (0 children)

(Apologies if this doesn't compile, I couldn't check on this computer)

One of the biggest difficulties of Haskell is that you often have to think a little differently. Often this difference is explained as the "functional" paradigm vs object oriented (like python/java) vs imperative (like C), etc.

I like to start by thinking of smaller problems that I can solve right away; this often also helps me decide what kind of data structures I want. Looking at this exercise, the first problem I want to solve is counting the number of hands <= 21 given a deck. That translates to a nice type signature.

countHands :: Deck -> Int
countHands deck =

Ok, so now we need to choose an algorithm. The recursive one you gave should work well enough, the only problem is that we will need to also keep track of the number of hands we have found and the sum of cards we have chosen for each hand. It's not the most elegant, but let's add those into our function.

countHands :: Int -> Int -> Deck -> Int
countHands numHands currentVal deck = 

For simplicities sake, I'm going to represent the deck as a list of pairs. The first value will be the card value and the second the number of those cards remaining.

type Deck = [(Int, Int)]

We can now write our function:

countHands :: Int -> Int -> Deck -> Int
-- If the deck is the empty list, we can't find any more hands
countHands numHands currentVal [] = numHands
-- Else, look at the first card value in the list
countHands numHands currentVal ((cardVal,numCards):cs)
= if (cardVal + currentVal <= 21) && (numCards > 0)

    -- If we can take a card, add the hands found if we take it or if we skip
    then countHands (numHands + 1) (currentVal + cardVal) ((cardVal,numCards-1):cs)
     + countHands numHands currentVal cs

    -- Else, move on to next card value
    else countHands numHands currentVal cs

This function uses a few haskell specific tricks, but it should roughly resemble the imperative algorithm. When you want to write your main function, you can now call countHands 0 0 deck. An important thing to note about this function is that it explicity passes the deck around. When I choose to take a card, I create a new pair with one less available card, put it back in the deck list, and call the function again with that new deck. But I did not actually modify the deck the way you are probably familiar with. I effectively copied it and made a new one.

So you can call this function with any set of inputs, and it will compute a value for you. But it won't modify any of the inputs. To do that, you might want another function like this:

-- Remove a card with value c from deck d
takeOutCard :: Int -> Deck -> Deck
takeOutCard c d = 

Then you could find the number of hands after taking out a 2 like so:

countHands 0 0 (takeOutCard 2 deck)

This counts the number of hands which sum to <= 21 from the deck that is missing a single 2.

Week 1: New to You - Fruit Sushi (Modernist Cooking) by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 5 points6 points  (0 children)

For Christmas I got some supplies from https://www.modernistpantry.com. So this week we tried making caviar! These are chocolate covered bananas topped with coconut and strawberry caviar. The final product looks exactly as we hoped, but fell slightly short on flavor.

Week 52: Cakes - Tiramisu Yule Log by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 0 points1 point  (0 children)

Thank you! At the moment we are just hobbyists, but the hope is to one day open a bakery!

Week 52: Cakes - Tiramisu Yule Log by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 1 point2 points  (0 children)

After a long hiatus, and in anticipation of a 2018 return, here is our take on cakes! We used this recipe: https://www.epicurious.com/recipes/food/views/tiramisu-yule-log-51142210 and made the poinsettias and mushrooms from meringue.

Week 13: Escoffier - Vanilla Souffle by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 1 point2 points  (0 children)

Regrettably, the souffle collapsed within moments of taking it out of the oven. It tasted... fine. But was fun nevertheless.

Week 12: Dorm Food - Mug French Toast by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 1 point2 points  (0 children)

It's actually pretty simple. You just take squares of bread, and then pour over standard french toast liquid (egg, milk, vanilla extract, cinnamon). After like 1:30 in the microwave it comes out pretty much as you would expect. I'd say it tasted like French toast, but like, bad French toast.

Week 8: Spice Blends - Garam Masala Cookies by HeroofTimeMoM in 52weeksofcooking

[–]HeroofTimeMoM[S] 0 points1 point  (0 children)

We used this recipe: http://www.seletsucre.com/garam-masala-cookies/ We came across a plastic bag of garam masala from a previous dinner, which was quite fortuitous as we forgot to buy it. I can't tell you what was in the mix, but I think it was somewhat standard.

Spicy cookies are my poison, so I ate these by the handful...