Hysteresis and creep in powders and grains