First thing i came up is a NOR gate. If you put at least one of two items (A OR B), in the chest to the right, the output (Q) will change from 1 to 0. The other way around, if none of A and B is in the chest, the output is 1. Of course one single bit item (fish is usually good) has to be put into the gate's chest to keep it working.
![Image](https://forums.factorio.com/images/ext/13990dd52aa2661597e1a9f8f0df4de7.jpg)
The AND gate is derrived from the NOR gate by the following boolean formula: !( A or B ) = !A and !B
So i inverted the four inserters of the gate and negated the output. It turns 1 for the chest to the right holding both items, A AND B.
![Image](https://forums.factorio.com/images/ext/b8cfea58d3165b23fbb331b3c8e65289.jpg)
Of curse the gates are stackable and we can create things like: Only insert coal into the furnace, if there are no gears OR ammo AND more than 100 iron ore are avaiable. The two express belts could be replaced with fast inserters, which would make the gate a little faster. But it uses less energy this way and a nother electric pole would be needed.