Monday, June 11, 2012

Hinze Dam, Gold Coast, Australia

The Hinze Dam on the Gold Coast was designed to be built in three stages. Each stage made the dam bigger and increased capacity. Stage 3 has been completed late last year. 

This is the view from the top of the dam towards spillway - the only part of the dam made of concrete: 

The rest of the dam is made from rocks and clay:

The artificial Advancetown Lake:


The spillway seen from the bottom:

Countries of Southeast Asia - Part 3

The last group of countries by population consists of three small states. The smallest is also the most populous of them.

Singapore. Population: 5 million.
Area: 710 km2.
Capital: Singapore.
Official languages: English, Malay, Chinese, Tamil.
Religion: 33% Buddhist, 18% Christian, 17% atheist, 15% Muslim, 11% Taoist, 5% Hindu.
GDP per capita in PPP: 59,700 USD.
Currency: Singapore dollar.
Democratic? Yes.
Singapore was part of Malaysia for two years, when Malaysia was formed, but it proved to be irreconcilably different and it was expelled from the Malaysian federation. Singapore's armed forces have been created with help from Israel. Singapore's military is based on Swiss and Israeli models.
The territory of Singapore is so small that Singapore Air Force has training bases in USA, France, and Australia.
Singapore is one of the most business friendly countries in the world.


East Timor. Population: 1 million.
Area: 15,000 km2.
Capital: Dili.
Official languages: Tetum, Portuguese. English and Indonesian have a status of "working languages". 15 local languages are used.
Religion: 97% Christian.
GDP per capita in PPP: 8,700 USD.
Currency: US dollar.
Democratic? Yes.
East Timor became a state in 2002 after decades of occupation by Indonesia. 50% of the population was illiterate in 2010.


Brunei. Population: 0.4 million.
Area: 6,000 km2.
Capital: Bandar Seri Begawan.
Official language: Malay. 8 other languages are used.
Religion: 66% Muslim, 13% Buddhist, 10% Christian.
GDP per capita in PPP: 49,400 USD.
Currency: Brunei dollar.
Democratic? No.

Saturday, June 9, 2012

Countries of Southeast Asia - Part 2

This group of middle to small population countries of Southeast Asia contains three countries scarred by war and lack of freedoms. Malaysia stands out as the only democratic country, although it has laws discriminating some of its minorities. Interestingly, Malaysia is also the only country in this group with a Muslim majority and the only one with GDP per capita bigger than some European Union countries. The rest are predominantly Buddhist and very poor.

Burma (Myanmar). Population: 60 million.
Area: 680,000 km2.
Capital: Naypyidaw.
Official language: Burmese. 111 languages spoken.
Religion: 89% Buddhist, 5% Christian, 3% Muslim.
GDP per capita in PPP: 1,300 USD.
Currency: kyat.
Democratic? Not yet.
Myanmar has been in a state of civil war since gaining independence in 1948.


Malaysia. Population: 28 million.
Area: 330,000 km2.
Capital: Kuala Lumpur.
Official language: Malaysian. 137 languages spoken.
Religion: 61% Muslim, 20% Buddhist, 9% Christian, 6% Hindu.
GDP per capita in PPP: 15,600 USD.
Currency: ringgit.
Democratic? Yes.
The Malaysian king is elected for a 5 year term from the 9 hereditary rulers of Malay states.


Cambodia. Population: 14 million.
Area: 180,000 km2.
Capital: Phnom Penh.
Official language: Khmer. 23 languages spoken.
Religion: 96% Buddhist, 2% Muslim, 1% Christian.
GDP per capita in PPP: 2,500 USD.
Currency: riel.
Democratic? No.
Cambodia is infamous for the Khmer Rouge terror led by Pol Pot, which killed 1/5 of the population.


Laos. Population: 6 million.
Area: 240,000 km2.
Capital: Vientiane.
Official language: Lao. 84 languages spoken.
Religion: 67% Buddhist.
GDP per capita in PPP: 2,700 USD.
Currency: kip.
Democratic? No.
According to this shocking article in The Guardian, between 1964 and 1973 US bombers dropped more ordnance on Laos than was dropped during the whole of the second world war.

Sunday, June 3, 2012

Countries of Southeast Asia - Part 1

Coming from Europe, via Florida, I knew very little about the countries of Southeast Asia. I knew a bit about Vietnam - because of the wars, and because there is a Vietnamese community in Poland. In the U.S. I worked with a Vietnamese, and a Filipino, but still my knowledge of Southeast Asia was pitiful.

This has been changing since I moved to Australia. Countries of Southeast Asia (SEA) are Australia's neighbours to the north, and north-west. From the Australian viewpoint to the west there is the Indian Ocean and then far far away Africa, to the south - Antartica, to the east: New Zealand, New Caledonia, Fiji, and lots of smaller islands, and then far away South America. SEA countries are Australia's closest big neighbours. They are a varied and interesting bunch. Let's start with the four biggest by population size:

Indonesia.  Population: 237 million.
Area: 1,900,000 km2 on over 17,000 islands, the biggest of which are: Java, Sumatra, Borneo, New Guinea.
Capital: Jakarta.
Official language: Indonesian (form of Malay). Over 700 local languages.
Religion: 86% Muslim, 9% Christian.

GDP per capita in purchasing power parity (PPP): 4700 USD.
Currency: rupiah.
Democratic? Yes, since very recently.
Indonesian island of Bali, where 88 Australians died in 2002 bombings, is a popular holiday destination. The almost 4 mln inhabitants of Bali are very different from the rest of Indonesia in terms of religion: 92% are Hindu.


Philippines. Population: 92 million.
Area: 300,000 km2 over 7000 islands. Capital: Manila.
Official languages: Filipino (Tagalog) and English. 170 local languages.
Religion: 90% Christian, 5% Muslim.

GDP per capita in PPP: 4000 USD.
Currency: piso/peso.
Democratic? Yes.
Philippines is famous for exporting nurses, doctors, and even priests, mainly to the U.S.


Vietnam. Population: 91 million.
Area: 330,000 km2.
Capital: Hanoi.
Official language: Vietnamese.
GDP per capita in PPP: 3400 USD.
Currency: dong.
Religion: officially 81% atheist, but traditionally Buddhist with 6% Christian minority. See Religion of the Vietnamese.

Democratic? No.
Communist Vietnam is famous for fighting first the French and then the Americans for a total period of 31 years after end of WW II.



Thailand. Population: 67 million.
Area: 513,000 km2.
Capital: Bangkok.
Official language: Thai.
Religion: 95% Buddhist, 5% Muslim.
GDP per capita PPP: 9400 USD.
Currency: baht.
Democratic? Yes.
What is Thailand famous for? The only thing that comes to my mind are Thai ladyboys.

Friday, May 4, 2012

Polish Proverbs - Part Two

Part two of the proverbs and sayings that I heard while growing up in Poland, and which I still remember. A much longer list, in Polish only, can be found on wikiquote.org.

1. Nie ma róży bez kolców. There is no rose without thorns. Even the best outcomes have some undesired effects.

2. Gdzie dwóch się bije, tam trzeci korzysta. Where two fight, the third benefits. I remember that as a call not to fight.

3. Gdzie drwa rąbią, tam wióry lecą. Where wood is chopped, the chips fly. I think this means that if something big is going on, than it has known properties that may hurt you. It is an obvious, normal thing. Stay away from trouble.

4. Człowiek uczy się na błędach. A man learns by his mistakes.

5. Mierz siły na zamiary. Measure strengths for plans. Analyse the situation, and plan properly.

6. Nie porywaj się z motyką na słońce. Don't attack the sun with a hoe. Don't attempt the impossible.

7. Jak trwoga to do Boga. When in fear then to God. Used perhaps with contempt to describe a situation when people turn to religion only when they are afraid.

8. Nie ma tego złego, co by na dobre nie wyszło. Every bad outcome turns out to be good in some way. Can you think of something good that came out from the calamity you experienced? At minimum you learn something, gain experience.

9. W zdrowym ciele, zdrowy duch. In a healthy body, a healthy spirit.

10. Strzeżonego, Pan Bóg strzeże. What is protected, is protected by God. A call to protect your things, guard your affairs, be prepared for worst.

11. Najlepszą obroną jest atak. The best defence is to attack.

12. Co dwie głowy, to nie jedna. Two heads are better than one. When you have a problem to solve, ask for advice.

13. Co komu pisane, to go nie minie. You will get, what is written for you. God has a plan for you.

14. Gdzie dwóch Polaków, tam trzy opinie. Where you have two Poles, there you have three opinions. National stereotype: not agreeing with one another.

15. Co ma piernik do wiatraka? What is the connection between ginger bread and the wind mill? The Polish version is very short, easy to utter quickly, and it was asked when speaker was talking about something not obviously connected to the previous subject. Something that required explanation.

16. Było, minęło. It was, it passed. No need to bring back the past, good or bad.

17. Co się stało, to się nie odstanie. What happened, cannot be undone.

18. Co kraj, to obyczaj. Different country, different customs.

19. Co za dużo, to nie zdrowo. Too much is not healthy. Mainly about keeping moderation in eating - don't overeat, but also in anything else. When kids are misbehaving, and the parent finally has had enough, he or she may say that. My grandma loved this one. She kept the good food locked away at all times, so wouldn't gobble it up at once. :-)

20. Co się źle zaczyna, to się dobrze kończy. What starts badly, ends well. A strange one, but often true. The point is that even if you start a relationship on a wrong foot, you can mend it. Your enemy can become your best friend.

See also: Polish Proverbs - Part OnePolish Proverbs - Part Three


Tuesday, April 24, 2012

Displaying special characters the hard way


Back in 1991 a programming language called Clipper (version Summer'87) was a popular choice for making simple business applications for IBM PC computers. Clipper was a specialised language designed to easily create business forms of 25 rows by 80 columns of characters. It was also very simple to read and write data using dBase IV format dbf files.

It had one tiny problem back then - it did not handle special Polish characters: ĄĆĘŁŃÓŚŹŻ, which at that time were encoded typically in the Mazovia code page.

Luckily, Clipper was extensible through the assembly language, so somebody wrote this little 8086 library to write and read characters using processor interrupts. I don't know who wrote it, because there was no author in the file, and every Clipper programmer had the source, so I assume it was, and is, in the public domain. The version presented here has been slightly updated by me, mainly by adding comments.

Please note: this program is very fragile and dangerous: inputs are not validated, which makes buffer overrun a possibility.

Clipper commands:
SCREENSTR read characters from SCREEN to Clipper STRing.
STRSCREEN write characters from Clipper STRing to SCREEN.

Assembly functions:
__RETNI, __PARNI, _RETC, __PARC allow passing of data to/from Clipper.
__PARNI, for example, allows passing of a Clipper numeric value to the assembly language, see Nantucket's Guide to Clipper here.
__PARC places the address of a Clipper character string in DX:AX.

16 bit registers like DX can can be accessed as DH and DL - higher and lower byte. Read the guide to 8086 registers, by Thomas Scarff, and the guide to Input and Output (I/O) in 8086 by Joe Carthy for more information.

And here is the assembly code:


PUBLIC   SCREENSTR
PUBLIC   STRSCREEN

EXTRN    __RETNI:FAR
EXTRN    __PARNI:FAR
EXTRN    __RETC :FAR
EXTRN    __PARC :FAR

DGROUP   GROUP   DATASG

DATASG   SEGMENT 'DATA'
; string to return to Clipper
         RETSTR DW 80 DUP (0)  
DATASG   ENDS

_PROG    SEGMENT 'CODE'
; cs -> code, ds -> data
         ASSUME cs:_PROG,ds:DGROUP 

SCREENSTR PROC   FAR


; save registers
          push bp         
          mov bp,sp
          push ds
          push es
          push si
          push di


; get param. #1: row into dh
          mov ax,1        
          push ax
          call __PARNI
          add sp,2
          mov dh, al
          push dx


; get param. #2: col into dl
          mov ax,2        
          push ax
          call __PARNI
          add sp,2
          pop dx
          mov dl, al      


; get video page in bh
          mov ah,0fh
          int 10h         


; set cursor
          mov ah,02h
          int 10h         


; get param. #3: count into cl
          mov ax,3        
          push ax
          call __PARNI
          add sp,2
          mov cl, al
          mov ch, 0        


; di is an index for RETSTR
          mov di, 0        
          push di


; start loop1
; bh: video page, read char
loop1:    mov ah,08h        
          int 10h           


; write to RETSTR
          pop di
          mov RETSTR[di],ax 


inc. offset  
          inc di             
          inc di
          push di


; inc column
          inc dl           


; set cursor
          mov ah,02h       
          int 10h         
; loop: dec cx 
          loop  loop1      


; restore registers
          pop di           
          pop di
          pop si
          pop es
          pop ds
          pop bp


; return string
          mov dx, seg RETSTR       
          mov ax, offset RETSTR
          push dx
          push ax
          call __RETC
          add sp,4

          ret

SCREENSTR ENDP

STRSCREEN PROC   FAR

          push bp
          mov bp,sp
          push ds
          push es
          push si
          push di


; get param. #2: row
          mov ax,2         
          push ax
          call __PARNI
          add sp,2
          mov dh, al
          push dx


; get param. #3: col
          mov ax,3         
          push ax
          call __PARNI
          add sp,2
          pop dx
          mov dl, al
          push dx


; get param. #4: count
          mov ax,4         
          push ax
          call __PARNI
          add sp,2
          mov ch,0
          mov cl, al
          push cx


; get param. #1: string
          mov ax,1         
          push ax
          call __PARC  
          add sp,2
          mov es,dx
          mov bp,ax


; get video page (in bh)         
          mov ah,0Fh
          int 10h          
          mov bl,0


; write to screen
          mov ah,13h
          mov al,2
          pop cx
          pop dx
          int 10h          

          pop di
          pop si
          pop es
          pop ds
          pop bp

          ret

STRSCREEN ENDP

_prog    ENDS
         END



Friday, April 13, 2012

Silence before the Storm


I'm scared. As a civilisation, we are moving very quickly towards our total destruction.

No, I am not talking about global warming. We can deal with that. Even if we do nothing to control the amounts of greenhouse gases in the atmosphere, and it becomes unbearably hot in some places, and sea levels rise 80 meters making countries like the Netherlands and Bangladesh disappear under water, we will survive. We will relocate to higher, cooler places. We will ban combustion engines, or more likely we will get CO2 out of the air and store it underground. Climate change will be disruptive, it will be unpleasant, but we will adjust. Countries will help each other, or will fight each other, or mayhem will rein, but our civilisation will survive. We may even be better off: we may develop technologies that allow us to control the climate globally whatever the cause, and we may embark on ambitious projects like making deserts habitable by changing local climate. All good stuff.

I am talking about something much more sinister, namely: robots and AI. We blindly keep developing technologies that are a mortal danger to us. Our latest "achievement" is Boston Dynamics' newest robot: PETMAN, or as it should be called, the Terminator, because it is ghastly similar to the original killing robot.

PETMAN's development started at least a year ago under a ruse of testing soldier uniforms. It is however the first serious example of a dangerous new weapon category: a humanoid robot. These robots will be able to use anything that was designed to be used by humans, anything that has a human interface. They will walk the stairs, open doors, move things, turn on and off switches, valves, operate heavy machinery, drive tanks, fly planes. They won't need machine guns for arms. They will be able to pick up any gun and use it. This is what makes them a new weapon category. There was no such thing in the past. We were making specialised military robots: flying drones, scouting, guarding, and combat vehicles, and now we created a robot that can control them.

Can we control it? Can we control the person who will send millions of these robots on a mission? As a civilisation we have a poor track record of stopping those in power from committing crimes against humanity. We actually have laws in place that give those in power immunity and the right to secrecy.

Combined with the latest advancements in sensory input processing and AI, examples of which are Google's self-driving cars, IBM's Watson supercomputer, and Apple's Siri, we are making a weapon much more dangerous than nuclear, chemical, or biological weapons. Those weapons were dumb. We would use them once or twice, see how terrible they were, and put them away. It may not be possible to put away a million highly intelligent PETMANs that can build, repair, and recharge themselves, know exactly were they are, access any map, and all human knowledge in milliseconds. Once let out, they may not come back.

Behind many of these technologies is DARPA, and their newest robotic challenge is probably one step too far. We could ban robotic and AI development on international level before singularity happens, but will we do it?

Post scriptum: PETMAN climbing stairs...