If you do an end-run around the normal open source publishing you can get in trouble- up to and including termination- but my guess is there is more context around the firing than just "posted open source code to work with standard Google APIs". For example, you can get punished at google (up to and including termination) for raising your voice in a meeting.
Calling an idea nonsense is fine, calling it not profitable is great, and saying its a waste of time is a Monday. Attacking someone as a fucking moron is pointless, just fire them, deprioritize them, or move on.