Does power from a resistor perform work or heat transfer? Let's say I have a cylindrical piston filled with air and fitted with an electrical resistor. The resistor has a current going across it and a voltage for a certain amount of time. My system would be the air inside the piston.
In the first law of thermodynamics: Q - W = E,
Would the power from the resistor for a designated amount of time perform a heat transfer or a work transfer on the air?
 A: The resistor will heat up the air (if assume 100% energy convert rate), then the total heat transferred from resistor to air will be given by
$Q = P\cdot t=I^2Rt=IUt$
Then from the first law of the thermodynamics, we know the total inner energy of air $E$ is 
$E=Q-W$
here $Q$ is the heat transferred into the system (if heat is transferred from out, then $Q>0$, if the system transfer heat out, then $Q<0$), and the $W$ is the work done by the air (if air do work i.e. air pushes the piston out, then $W>0$, if outside does work to the air, i.e. someone pushes the piston to compress the air, then $W<0$).
So from this, you know the power from the resistor generate heat, and this heat is transferred from resistor to air. If the piston cannot move, then no work will be done, so the increase of inner energy of air is just the heat transferred or generated by the resistor, that is
$\Delta E = Q$
If the piston can move, the increase in energy will result in the increase of air temperature, and therefore, the air pressure will increase and the air will push the piston out. In this process, air do work to the piston. So the inner energy of air will drop, but this work is done by air. 
A: The resistor always produces heat, because it emits thermal energy, but the heat can be converted into work using a heat engine, as in your example.
