complete bitcoin script example

complete bitcoin script example

I am trying to learn how to write my own script from scratch. I have seen about a dozen examples by googling but non of them are complete. I am aware of btcdeb as well. Is there a tutorial that covers

1) what a complete script looks like in a modern day transaction
2)how to compile that script so it can be uploaded to the test net
3)what is required on the client side, including cryptographic
operations 
4)How to actually upload that with an rpc call to a node

Thank you in advance