There is a growing interest in using pulsed high magnetic field as a controlling parameter of physical phenomena in various scientific disciplines, such as condensed matter physics, particle physics, plasma physics, chemistry, and biological studies. We devised a concise and portable pulsed magnetic field generator that produces a 40 T field with a pulse duration of 2 ms. It is assembled using only off-the-shelf components and a homemade coil that leverages small computers, Raspberry Pi, and Python codes. It allows for straightforward modification for general purposes. As working examples, we show representative applications in condensed matter experiments of magnetoresistance, magnetization, and magnetostriction measurements for graphite, NdNi2P2, and NdCo2P2, respectively, with the maximum magnetic field of 41 T and the lowest temperature of 4.2 K.