Gender rules can be tricky to sort out. As was mentioned already, Greek borrowings tend to be masculine. If a word ends in -ma, -pa, or -ta, and the word sounds scientific or nearly identical to English, you can safely assume it is masculine. For example, programa (i.e. program), mapa (i.e. map), and planeta (i.e. planet) are all fairly technical words and all nearly identical to English. Cama, on the other hand, is neither technical nor at all similar to the English word "bed," so it follows the standard rule of words ending in a being feminine.
Another tricky concept is feminine words that use "el" instead of "la." This happens whenever you have a feminine word that begins with an accented "a" sound. For example, "the cold water" is "el agua fría."
The important thing is that the first sound is an accented "a" - so you also get "el haba deliciosa" (the delicious fava bean). Since the first syllable must be accented for this rule to apply, you still get the standard "la" in words like "la arena calurosa" (the hot sand) and "la harina blanca" (the white flour).
Because of this rule, it can be hard to tell sometimes if a word that starts with an accented "a" sound is masculine or feminine unless you have an adjective to give you a clue. This has led to an odd conundrum with the word arte. In the singular, it is generally accepted to be masculine: el arte moderno (Modern art). However, in the plural, artes is generally accepted to be feminine: las artes (the arts).