Outils pour utilisateurs

Outils du site


pele_mele:stack_exchange

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
pele_mele:stack_exchange [2020/11/18 03:22] alexispele_mele:stack_exchange [2024/11/23 03:59] (Version actuelle) alexis
Ligne 1: Ligne 1:
 ====== Stack Exchange ====== ====== Stack Exchange ======
-<WRAP todo> 
-Ajouter toutes les questions 
-</WRAP> 
- 
 Cette page contient les réponses à toutes les questions que j'ai posé sur l'ensemble des sites de [[https://stackexchange.com/|Stack Exchange]]. Cette page contient les réponses à toutes les questions que j'ai posé sur l'ensemble des sites de [[https://stackexchange.com/|Stack Exchange]].
 En tout cas, toutes celles des questions qui méritent d'être conservées si le site venait à disparaître. En tout cas, toutes celles des questions qui méritent d'être conservées si le site venait à disparaître.
  
-===== Seasoned Advice ===== +<catlist pele_mele:stack_exchange -sortByTitle -noHead>
-  - [[pele_mele:stack_exchange:cooking-78840|How to modify a bread recipe to accomodate longer proofing times?]] +
-  - [[pele_mele:stack_exchange:cooking-79458|Why is eating pretzels safe when they are bathed in lye?]] +
-  - [[pele_mele:stack_exchange:cooking-79461|How to bake croissant?]] +
-  - [[pele_mele:stack_exchange:cooking-82283|Does beating hot oil into eggs before cooking an omelette make a difference?]] +
-  - [[pele_mele:stack_exchange:cooking-84099|Looking for a Finnish bread name and recipe]] +
-  - [[pele_mele:stack_exchange:cooking-91741|What pepper is used in Sriracha sauce?]] +
-  - [[pele_mele:stack_exchange:cooking-102288|Can I ferment blanched cabbage?]] +
-  - [[pele_mele:stack_exchange:cooking-110527|Are dried elderberries safe to eat?]] +
- +
-<WRAP group> +
-<WRAP half column> +
-==== How to modify a bread recipe to accomodate longer proofing times? ==== +
-I used to bake a lot but since I've switch jobs, I do not have enough time in the evening anymore. But I work really close from home so I can go home for lunch if needed. +
- +
-My idea is to start the bread in the morning before work, then return for the second kneading during lunch, then I can bake it at night. I know that I need to lower the temperature during the proofing, so I though of putting the dough in the refrigerator. +
- +
-Will this work? Is there other ways to achieve what I'd like? +
- +
-<WRAP help> +
-Aside from (or even instead of) lowering the temperature, you can drastically reduce the yeast; it will take time for the smaller initial yeast population to multiply to a similar population as the larger amount of yeast to start with, and this will reduce the activity of the dough. +
- +
-As a generally salt-avoiding person, I hesitate to say, but will, that additional salt also slows things down, ferment-wise. It will impact flavor, of course, and at some point become effectively inedible, so don't overdo that. +
- +
-If your recipe uses any sugar, you can reduce or remove it...but that will also affect browning and flavor. +
- +
-You may find that the refrigerator slows things down too much to get a loaf risen in the course of a day - or you may need to go the opposite direction on the various yeast-retarding things I just mentioned to overcome the refrigerator temperature on your timescale. Or you can extend your timescale to suit, as needed. +
-</WRAP> +
-<WRAP help> +
-I suggest checking out the bread books by Francois and Hertzberg starting with Artisan Breads in 5 Minutes a Day. Their techniques are designed to do things like over the weekend mix up several loafs worth of dough and proof it. Then, when ready to use, take part of it out for a final rise of about 20 minutes and bake which seems to be what you are after. +
- +
-ETA: I suggest this because they have already done the experimenting. I am notoriously bad with bread that if I do one thing slightly wrong I get a brick instead of a loaf. All other cooking I treat recipes as a good starting point. But bread, I want someone else to get it right first, then I try to duplicate what they did. +
-</WRAP> +
-<WRAP help> +
-Yes. You could buy a used refrigerator for the purpose of bread proofing, ferments, preferment's, sponges, sourdoughs etc. +
- +
-keep the temp between 50f and 60f and adjust your formulas, timing or temps to accommodate your schedule. Once you establish a routine you will find it very efficient. +
-</WRAP> +
-<WRAP info> +
-[[https://cooking.stackexchange.com/questions/78840/how-to-modify-a-bread-recipe-to-accomodate-longer-proofing-times|baking - How to modify a bread recipe to accomodate longer proofing times? - Seasoned Advice]] +
-</WRAP> +
-</WRAP> +
- +
-<WRAP half column> +
-==== Why is eating pretzels safe when they are bathed in lye? ==== +
-I read many recipes of pretzels and they required to dip the raw dough in a bath of lye. As anyone should know for their own safety, lye is caustic and shouldn't be ingested. +
- +
-What is the process involved that make them edible? +
- +
-**Edit**: I am aware of the action of the lye. I wonder how the non-edible lye on the dough is transformed into something that is safe to eat. +
-<WRAP help> +
- +
- +
-Basically, the lye reacts with the CO₂ and moisture present during baking to form a non-toxic carbonate. This makes it safe to eat. +
- +
-The reaction: +
- +
-CO₂ (g) + H₂O (l) ­⇄ H₂CO₃ (aq) +
- +
-H₂CO₃ (aq) + 2 NaOH (aq) → Na₂CO₃ (aq) + 2 H₂O (l) +
- +
-[[http://www.chem.indiana.edu/faculty-research/faculty-resources/chemistry-demos/demos/17-3%20Sodium%20Hydroxide%20and%20Carbon%20Dioxide.doc|From here (MS doc)]] +
- +
-[EDIT] +
- +
-Spurred by the comments, I have searched further. +
- +
-tl;dr There is much going on wrt the lye dip. As far as safety goes, the lye is consumed in many reactions, including the above. +
- +
-  - (Firstly: The equation source was not the basis of my answer; rather it was to refresh my memory of the reaction about which I was told/read several years ago was the reason why lye is safe to use on leavened breads, which was its combining with carbonic acid. (I apologize for not checking the balance adequately.) +
-  - My recent search only found one [[http://www.thekitchn.com/expert-bagel-maker-confirms-you-dont-need-lye-to-make-a-good-bagel-maker-tour-203288|reference at The Kitchn]] +
- to the reaction of lye with carbonic acid as the reason for its safe use. It is also unsourced. +
-  - Simultaneously, I found a [[https://www.researchgate.net/profile/Richard_Owusu-Apenten/publication/229953267_Effect_of_Alkali_Dipping_on_Dough_and_Final_Product_Quality/links/5562f80408ae8c0cab3345a2/Effect-of-Alkali-Dipping-on-Dough-and-Final-Product-Quality.pdf?origin=publication_detail|research paper]] and a [[http://foodchemblog.com/2014/07/read-to-the-tune-of-the-boxer/|Food Chem Blog entry]] which referenced it, both of which discussed the behavior of the lye bath on pretzels. There is a lot there, so I shall only quote the paper abstract: +
- +
-> The effects of alkali dipping on starch, protein, and color changes in hard pretzel products have never been researched. Experiments were conducted to mimic reactions occurring on the pretzel dough surface. Dough was dipped in water or 1% sodium hydroxide solution at different temperatures between 50°C and 80°C. Protein and starch profile after dipping were analyzed. Color development on pretzel surface following the extraction of pigments from flour was investigated. Whole dough and pretzel samples were also made at pilot plant and the properties were analyzed. Only starch granules on the dough surface were gelatinized following dipping. Amylose-lipid complex dissociated at a lower temperature with alkali treatment but were not dissociated, even at high-temperature dipping in water. Treating the dough at 80°C in alkali solution resulted in the hydrolysis of proteins into smaller peptides that could be not precipitated by trichloroacetic acid (TCA). Dough surface color was different following pigment extraction from flour but not significantly different following baking. The results suggest that the color that developed on pretzel surface was not due to pigments present in the flour but was contributed by the reaction within or between the starch and protein hydrolysis derivatives during baking. +
- +
-and what I think is the pertinent quote from the blog: +
- +
-> The protein results (2 in the list above [reproduced following]) indicate that the lye dip provides the smaller proteins needed for Maillard reactions, whereas the water dip does not. This seemed like perhaps the most important point to me. +
-+
-> The dip resulted in the hydrolysis of protein into smaller peptides. This happened a little bit in 25°C water or lye dip, more in 80°C water, and a lot more in 80°C lye dip. Also, the smaller peptides in the hot lye dip had the smallest molecular weights; most of them “walked off” the electrophoresis gel, leaving no bands. The authors explain that the alkaline conditions of the lye dip result in like charges along the proteins, which repel and cause the proteins to unfold; this makes them more susceptible to hydrolysis. +
- +
-Both the blog and the paper are worth reading. +
- +
-My conclusion: the lye is consumed by the various reactions and therefore poses no safety concerns. +
- +
-</WRAP> +
-<WRAP help> +
-The purpose of dipping in lye (or other basic solution, like baking soda...or even [[http://www.nytimes.com/2010/09/15/dining/15curious.html|baked, baking soda]]) is that it promotes coloring, as the solution reacts with the surface of the dough. It also promotes the Maillard reactions when the dough cooks. The result is even browning and that typical alkali flavor. If choosing lye, food grade is important, as commercial grades may include other, heavy metal, impurities. Lye is extremely caustic. So it must be used carefully! In pretzel and bagel making the solution is generally quite dilute...maybe around 3% lye in water. In both pretzel and bagel making, the product is typically given a brief bath in boiling water, after a dip in the lye solution. The boil and/or subsequent baking neutralized the alkali rendering it safe to eat. +
-</WRAP> +
-<WRAP help> +
-The reason it is safe is three-fold. +
- +
-First, the concentration is only 1% NaOH and the pretzels are only dipped for 10 seconds (see Snack Food Technology pages 180-182) which limits the amount of hydroxide per pretzel. +
- +
-Second, the dough itself, for example protein of the dough, has [[http://homepage.smc.edu/kline_peggy/Organic/Amino_Acid_pKa.pdf|acidic groups]], such as amino acid side chains of lysine and tyrosine, which neutralize the hydroxide. +
- +
-Finally, as explained in [[http://onlinelibrary.wiley.com/doi/10.1111/j.1365-2621.2006.tb15619.x/abstract|Effect of Alkali Dipping on Dough and Final Product Quality]] Journal of Food Science vol. 71, pages C209-C215, protein in the dough is partially hydrolyzed under the alkaline conditions. This exposes more terminal amino acid groups which also participate in neutralization. +
- +
-The [[https://books.google.com/books?id=qdnuCAAAQBAJ&pg=PA180&dq=lye%20dip%20pretzels%20seconds&hl=en&sa=X&ved=0ahUKEwj4iaTDiIHTAhXBPCYKHXKqBQcQ6AEIOzAG#v=onepage&q=lye%20dip%20pretzels%20seconds&f=false|Snack Food Technology]] book cited above also explains: +
- +
-> If the caustic concentration becomes too high, there is not a complete conversion to sodium bicarbonate in the baking and drying cycles and the pretzels will be hot to the taste due to the residual sodium hydroxide +
-</WRAP> +
-<WRAP help> +
-Lye will readily react with either [[https://en.wikipedia.org/wiki/Amino_acid|amino-acids]] (producing respective sodium salts) or with [[https://en.wikipedia.org/wiki/Fatty_acid|fats]] (producing soaps), both reactants being readily present in dough. You don't need CO2 to neutralize it. +
- +
-Ingesting small amounts of those end-products is indeed safe, and normally only a small quantity of lye is used in the process. +
-</WRAP> +
-<WRAP help> +
-The references noted above have mostly looked at the specific chemical changes to the constituents of the dough and the species in solution. A few point to the Maillard reactions as a contributor to what is going on. +
- +
-It is worth noting that the Maillard reactions are quite complex and involve a lot of intermediate products. However, in many cases the rate limiting factor is the pH of the constituents. It is possible to accelerate the reactions by raising the pH, and more Maillard products are produced if you let the process run for an extended period of time or raise the temperature which further increases the reaction rate. Some people don't believe that you can get the reaction to go at all at temperatures below 300°F, yet adding a little baking soda to a batch of onion soup and pressure cooking it (265°F) for 40 minutes will yield the same browning that much longer cooking of the onions produces in the classic technique. +
- +
-So increasing the pH by using lye (pH 13) vs sodium carbonate (pH 10) vs sodium bicarbonate (pH 8) will facilitate a dramatic speed up the Maillard reaction rate, and subjecting the pretzel to high temperature in the oven will carry it out. What happens to the NaOH to detoxify it is most likely a combination of neutralization, dilution, and chemical conversion through interaction with other available species. I would not recommend eating dough dipped in lye without baking the dough first. +
- +
-I am intrigued by the notion that the high pH breaks down the proteins into shorter amino acid sequences which facilitates the Maillard reactions but does not affect the rate constants. +
-</WRAP> +
-<WRAP info> +
-[[https://cooking.stackexchange.com/questions/79458/why-is-eating-pretzels-safe-when-they-are-bathed-in-lye|food safety - Why is eating pretzels safe when they are bathed in lye? - Seasoned Advice]] +
-</WRAP> +
-</WRAP> +
-</WRAP> +
- +
-===== Stack Overflow ===== +
-  - [[pele_mele:stack_exchange:stackoverflow-27801219|How to unit test a Symfony2 form when it uses a transformer linked to a database]] +
-  [[pele_mele:stack_exchange:stackoverflow-27972741|Is there a better way to handle the Doctrine proxy object]] +
-  - [[pele_mele:stack_exchange:stackoverflow-28071372|How to test a concrete method calling an abstract method with phpunit]] +
-  - [[pele_mele:stack_exchange:stackoverflow-29131903|How to revert a chunk of a file in the staging area?]] +
-  - [[pele_mele:stack_exchange:stackoverflow-29661578|How to handle a POST method that generate multiple resource with REST?]] +
-  - [[pele_mele:stack_exchange:stackoverflow-29779716|Symfony form validation of integer field]] +
-  - [[pele_mele:stack_exchange:stackoverflow-29987139|Symfony2 - Collection type is displayed twice in my view]] +
-  - [[pele_mele:stack_exchange:stackoverflow-35478874|How to choose the driver to serialize/deserialize with jmsserializer]] +
-  - [[pele_mele:stack_exchange:stackoverflow-44944603|Talend warning and error messages are black]] +
-  - [[pele_mele:stack_exchange:stackoverflow-47312136|How to use a variable as user name in a SF memory provider?]] +
-  - [[pele_mele:stack_exchange:stackoverflow-50909507|List available workflows in Symfony]] +
-  - [[pele_mele:stack_exchange:stackoverflow-62270358|How to define a macro to interpret a unicode character with Mathjax]] +
- +
-<WRAP group> +
-<WRAP half column> +
-==== How to unit test a Symfony2 form when it uses a transformer linked to a database ==== +
- +
-TLDR: I am new to unit tests and I have few questions: +
- +
-  - Are my transformer tests well written? +
-  - Is there a way to decoupled my transformer tests from the database? +
-  - How to test my form with the transformer using the database? +
-  - Should I decouple my form from my transformer? +
- +
-------- +
-I don't know if my classes are too coupled, if my design is flawed or if my understanding of the unit tests is bad. +
- +
-Here is some background.   +
-I have a form object with different widgets. One of them is used within a model transformer.   +
-This model transformer uses a connection to the database to retrieve the proper object. +
- +
-Here is my code: +
- +
-<code php> +
-class BookToStringTransformer implements DataTransformerInterface { +
-    private $om; +
- +
-    public function __construct(ObjectManager $om) { +
-        $this->om = $om; +
-    } +
- +
-    public function transform($book) { +
-        if (!$book instanceof Book) { +
-            return ""; +
-        } +
- +
-        return $book->getName(); +
-    } +
- +
-    public function reverseTransform($string) { +
-        if (!is_string($string) || !$string) { +
-            return null; +
-        } +
- +
-        $book = $this->om +
-                ->getRepository('MyBundle:Book'+
-                ->findOneBy(array('name' => $string)) +
-        ; +
- +
-        if (null === $book) { +
-            throw new TransformationFailedException(sprintf( +
-                    'The book "%s" does not exist!', $string +
-            )); +
-        } +
- +
-        return $book; +
-    } +
-+
- +
-class ItemType extends AbstractType { +
-    private $om; +
- +
-    public function __construct(ObjectManager $om) { +
-        $this->om = $om; +
-    } +
- +
-    public function buildForm(FormBuilderInterface $builder, array $options) { +
-        $bookTransformer = new BookToStringTransformer($this->om); +
-        $builder->add($builder->create('book', 'text', array( +
-                    'required' => false, +
-                ))->addModelTransformer($bookTransformer)); +
-    } +
- +
-    public function setDefaultOptions(OptionsResolverInterface $resolver) { +
-        $resolver->setDefaults(array( +
-            'data_class' => 'MyBundle\Entity\Item', +
-        )); +
-    } +
- +
-    public function getName() { +
-        return 'mybundle_item'; +
-    } +
-+
-</code> +
- +
-I wrote unit tests for the transformer using the KernelTestCase +
- +
-<code php> +
-class BookToStringTransformerTest extends KernelTestCase { +
-    private $name = 'existing name'; +
-    private $em; +
- +
-    public function setUp() { +
-        static::$kernel = static::createKernel(); +
-        static::$kernel->boot(); +
-        $this->em = static::$kernel->getContainer() +
-                ->get('doctrine'+
-                ->getManager(); +
-    } +
- +
-    public function testReverseTransform_whenNameExists_returnsBookObject() { +
-        $transformer = new BookToStringTransformer($this->em); +
-        $book = $transformer->reverseTransform($this->name); +
-        $this->assertInstanceOf('MyBundle\Entity\Book', $book, 'Should return a Book object'); +
-        $this->assertEquals($this->name, $book->getName(), 'Should return a Book object with the selected name'); +
-    } +
- +
-    /** +
-     * @expectedException Symfony\Component\Form\Exception\TransformationFailedException +
-     */ +
-    public function testReverseTransform_whenNameDoesNotExist_throwsException() { +
-        $transformer = new BookToStringTransformer($this->em); +
-        $transformer->reverseTransform('unknown name'); +
-    } +
- +
-    /** +
-     * @param mixed $invalid_parameter +
-     * @dataProvider provideInvalidParameter +
-     */ +
-    public function testReverseTransform_whenParameterIsInvalid_returnsNull($invalid_parameter) { +
-        $om = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock(); +
-        $transformer = new BookToStringTransformer($om); +
-        $this->assertNull($transformer->reverseTransform($invalid_parameter), 'Should return a NULL value'); +
-    } +
- +
-    /** +
-     * @return array +
-     */ +
-    public function provideInvalidParameter() { +
-        return [ +
-            [null], +
-            [false], +
-            [true], +
-            [''], +
-            [[]], +
-            [new \stdClass()], +
-        ]; +
-    } +
- +
-    public function testTransform_whenParameterIsBookObject_returnsName() { +
-        $book = $this->em->getRepository('MyBundle:Book'+
-                ->findOneBy(array('name' => $this->name)); +
-        $om = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock(); +
-        $transformer = new BookToStringTransformer($om); +
-        $this->assertEquals($this->name, $transformer->transform($book), 'Should return a string containing the name'); +
-    } +
- +
-    /** +
-     * @param mixed $not_book +
-     * @dataProvider provideInvalidBookObject +
-     */ +
-    public function testTransform_whenParameterIsNotBookObject_returnsEmptyString($not_book) { +
-        $om = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock(); +
-        $transformer = new BookToStringTransformer($om); +
-        $this->assertEquals("", $transformer->transform($not_book), 'Should return an empty string to be chained'); +
-    } +
- +
-    /** +
-     * @return array +
-     */ +
-    public function provideInvalidBookObject() { +
-        return [ +
-            [null], +
-            [123], +
-            ['123'], +
-            [[]], +
-            [true], +
-            [new \stdClass()], +
-        ]; +
-    } +
-+
-</code> +
- +
-As I am new to unit tests, I don't even know if it is the proper way to test that transformer.   +
-I start writing tests for the form object. I am using the TypeTestCase but there is no simple way to get the connection to the database and I can't use the KernelTestCase. +
- +
-<code php> +
-class ItemTypeTest extends TypeTestCase { +
-    /** +
-     * @expectedException \PHPUnit_Framework_Error +
-     */ +
-    public function test_whenCreatedWithNoParameters_raiseException() { +
-        new ItemType(); +
-    } +
- +
-    /** +
-     * @expectedException \PHPUnit_Framework_Error +
-     */ +
-    public function test_whenCreatedWithBadParameters_raiseException() { +
-        new ItemType(123); +
-    } +
- +
-    public function test_whenCreatedWithGoodParameters_createsFormObject() { +
-        $om = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock(); +
-        $type = new ItemType($om); +
-        $form = $this->factory->create($type); +
-        $this->assertInstanceOf('Symfony\Component\Form\Form', $form); +
-    } +
- +
-    public function test_whenSubmittedWithGoodData() { +
-        $formData = array( +
-            'name' => 'existing name', +
-        ); +
- +
-        $om = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock(); +
-        $type = new ItemType($om); +
-        $form = $this->factory->create($type); +
- +
-        $form->submit($formData); +
-    } +
-+
-</code> +
- +
-The last test fails because the transformer does get access to the database since I am passing a mock to the form. So should I get a real object (meaning classes are too coupled) or should I find an other way. +
- +
-Thank you +
-<WRAP help> +
-The approach is good, in the last method you must mock the repo object and the repo response. In example try this code: +
-<code php> +
-public function test_whenSubmittedWithGoodData() { +
-    $formData = array( +
-        'name' => 'existing name', +
-    ); +
- +
-    $om = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock(); +
- +
-    $repoMock= $this->getMock('Doctrine\ORM\EntityRepository', array(), array(), '', false); +
- +
-    $om +
-        ->expects($this->atLeastOnce()) +
-        ->method('getRepository'+
-        ->withAnyParameters() +
-        ->will($this->returnValue($repoMock)); +
- +
- +
-    $repoMock +
-        ->expects($this->atLeastOnce()) +
-        ->method('findOneBy'+
-        ->withAnyParameters() +
-        ->will($this->returnValue($mockedBook)); +
- +
-    $type = new ItemType($om); +
-    $form = $this->factory->create($type); +
- +
-    $form->submit($formData); +
-+
-</code> +
-</WRAP> +
-<WRAP info> +
-[[https://stackoverflow.com/questions/27801219/how-to-unit-test-a-symfony2-form-when-it-uses-a-transformer-linked-to-a-database|How to unit test a Symfony2 form when it uses a transformer linked to a database - Stack Overflow]] +
-</WRAP> +
-</WRAP> +
- +
-<WRAP half column> +
-==== Is there a better way to handle the Doctrine proxy object ==== +
-</WRAP> +
-</WRAP> +
-===== Super User ===== +
-  - [[pele_mele:stack_exchange:superuser-1225022-|Send notification from systemd]] +
- +
-===== TeX - LaTeX ===== +
-  - [[pele_mele:stack_exchange:tex-367891|Is there a better way for drawing my table]] +
-  - [[pele_mele:stack_exchange:tex-370684|Is there a better way to repeat the content of a page?]] +
-  - [[pele_mele:stack_exchange:tex-374734|Why is there a padding only on the first row of a repeating pattern?]] +
-  - [[pele_mele:stack_exchange:tex-377681|How to keep cell border with a column background color?]] +
-  - [[pele_mele:stack_exchange:tex-391286|Apostrophe is not showing as an apostrophe [closed]]] +
-  - [[pele_mele:stack_exchange:tex-391569|Why the first tikz element is a bit off?]] +
-  - [[pele_mele:stack_exchange:tex-392900|How positioning works with tikz]] +
- +
  
pele_mele/stack_exchange.1605698544.txt.gz · Dernière modification : 2020/11/18 03:22 de alexis