Thursday, December 24, 2009

How to rename multiple files at once on Windows 7?

Today, I accidentally discovered a simple way of renaming multiple files/directories at once on Windows 7. It is probably valid for all latest Windows versions, but I cannot verify it since I only have Windows 7.


  1. Select all the files/directories you want to rename
  2. Right click on one of them and select "Rename"
  3. Enter the new name, for instance, "eurotrip_picture"
  4. Hit "Enter" and you will all the selected files renamed as "eurotrip_picture (number)": eurotrip_picture (2), eurotrip_picture (3), ...

Wednesday, December 16, 2009

Ebabil bir kustur (Ababil is a bird)

Today, without any apparent reason, I started murmuring an old song from a -- now not-existing -- Turkish band called "Grup Vitamin". The song's name is "Ebabil bir kustur" (Ababil is a bird).

http://www.youtube.com/watch?v=DaIJv02R4-s

Then, I realized that I have no idea what kind of bird "ababil" is. I searched google and found out that it is a swift, and in Turkish it is "dag kirlangici": http://en.wikipedia.org/wiki/Swift

Then, the question was how this word got into this song. More google search revealed that it is an Arabic word, and it has a famous story among Muslims. According to the story, an evil king tried to destroy Kabah in Makkah. God sent many gigantic flocks of swifts on the army of this king. Each bird was carrying chickpea-size baked-clay stones. They dropped these stones on the army and all army was killed.

OK, now how can a stone at that size kill a human? It has to be very fast when it reaches the ground, almost as fast as a bullet. How fast is a bullet?

http://hypertextbook.com/facts/1999/MariaPereyra.shtml

The speed of bullet, of course, depends on the gun and some other factors, but it looks like a bullet can be as slow as 200 m/s and can be as fast as 1500 m/s or more. Probably, 200 m/s is fast enough to cause fatal damage to a human.

If we get back to the stone story: Swifts can fly as fast as 60 m/s according to Wikipedia. Let's assume that just before leaving the stones, they flew vertically towards ground, giving  the stones an initial vertical velocity of 60 m/s. If they dropped stones from 200 m elevation, it would take about 14.7 seconds to reach ground level (according to basic free fall assumptions). In 14.7 seconds, the stone would gain about 147 m/s speed. If we add the initial speed of 60m/s, the final speed is 207 m/s. This is fast enough to be considered as "like a bullet".

Conclusion: Birds are dangerous.

Tuesday, December 15, 2009

Converting Decimal/Hex/Octal to Binary in C++

I needed to code a hex to binary converter in C++. It was needed for a Verilog parser. There are lots of examples that one can find on google. I decided to code mine, and I also added decimal and octal numbers. The aim is to convert a Verilog constant (hex/octal/decimal) to a std::string of 1,0,X,Z values.

Let's start with decimal to binary:


The function will return the number of bits asked by the user. Of course, this function cannot handle X or Z values supported by Verilog. It worked for me.

For hex to binary and octal to binary conversions, I decided to use simple macros because it turned out to be the fastest code I tried. It does not look elegant, but that is not a concern for me.

First define the macros:

In these macros, HEX and OCT are characters, and STRING is an std::string. I used these macros in the following way:







Sunday, December 13, 2009

How to cook a simple baklava?

I occasionally cook baklava for friends and family. Although it looks complicated, it is quite simple and anybody can cook it easily, mostly because it is a simplified version of the real baklava recipe cooked in Turkey. Here is my "simple baklava" recipe...






Ingredients:
  • 1 lbs pistachios or walnuts (without shells)
  • # 7 thickness fillo-dough, size 12”x17”
  • 3 cups of sugar
  • 2.5 cups of water
  • 2 sticks of butter
  • Juice of half a lemon







  1. Mix sugar and water in a pan and boil on high heat for about 12 minutes. Add lemon juice and boil half a minute more, than put the pan aside for cooling. This mixture is called serbet.



  2. Finely grind the pistachios (or walnuts). You can use a small chopper for this purpose.



  3. Put the ground pistachios aside.


  4. Turn on your oven and set the temperature to 350F (convection, if available). The oven should be ready before you start placing fillo-dough layers in the tray.
  5. Melt the butter (you can use your microwave), it should be totally liquid.


  6. Use a baking tray of the same size of your fillo-dough for easy cooking. For this recipe, you can use a 12” x 17” tray.


  7. If the tray is made of metal, cover the tray with aluminum foil. If you have glass tray, no need for covering.


  8. Take fillo-dough sheets out of its package.



  9. Place 12 fillo-dough sheets one-by-one on the bottom of the tray. If the sheets are larger than the tray, cut the extra pieces with a sharp knife. We will use these pieces later. Then, add about half of the ground pistachios on it, creating a thin, homogeneous layer.




  10. If you have some extra pieces of fillo-dough sheets left from the previous step, you can use them now to cover the layer of pistachios.


  11. Place 4 fillo-dough sheets one-by-one on it. Then, add the reamining half of the ground pistachios on it, creating a thin, homogeneous layer. Be sure to leave a small amount of ground pistachios for final decoration.



  12. Place the remaining fillo-dough sheets on it.


  13. Using a sharp knife, cut the fillo-dough layers horizontal and perpendicular, creating small squares of size about 2.5” x 2.5”. You can actually give any rectangular shape you want at this stage. Make sure than all the layers are cut until the bottom of the tray.


  14. Evenly pour the liquid butter on it, and be sure that no dry area left on the surface.


  15. Immediately place the tray in the oven. Bake about 35-40 minutes. Check regularly after 30 minutes to be sure that your baklava is not burned.


  16. The baklava should have a light brown, golden color when ready. Some parts of it may be darker brown, which is OK.


  17. Remove the tray from the oven and using a sharp knife go over the borders of baklava squares to make sure that they are not connected to each other.


  18. Immediately pour the sugar & water mix (serbet) on it. Pour most of the mix between the squares.


  19. Sprinkle the remaining ground pistachios on and between the squares.


  20. Let it cool down. Wait about at least 12 hours before eating.



Afiyet olsun!