• 0 Posts
  • 67 Comments
Joined 1 year ago
cake
Cake day: December 31st, 2023

help-circle

  • that is a little more complicated

    p.communicate() will take a string (or bytes) and send it to the stdin of the process, then wait for p to finish execution

    there are ways to stream input into a running process (without waiting for the process to finish), but I don’t remember how off the top of my head

    
    from shutil import which
    from subprocess import Popen, PIPE, run
    from pathlib import Path
    
    LS   = which('ls')
    REV  = which('rev')
    
    ls   = run([LS, Path.home()], stdout=PIPE)
    
    p = Popen([REV], stdin=PIPE, stdout=PIPE)
    stdout, stderr = p.communicate(ls.stdout)
    
    print(stdout.decode('utf-8'))
    


  • just use python instead.

    • wrap around subprocess.run(), to call to system utils
    • use pathlib.Path for file paths and reading/writing to files
    • use shutil.which() to resolve utilities from your Path env var

    Here’s an example of some python i use to launch vscode (and terminals, but that requires dbus)

    
    from pathlib import Path
    from shutil import which
    from subprocess import run
    
    def _run(cmds: list[str], cwd=None):
        p = run(cmds, cwd=cwd)
    
        # raises an error if return code is non-zero
        p.check_returncode()
    
        return p
    
    VSCODE = which('code')
    SUDO   = which('sudo')
    DOCKER = which('docker')
    
    proj_dir = Path('/path/to/repo')
    
    docker_compose = proj_dir / 'docker/'
    
    windows = [
      proj_dir / 'code',
      proj_dir / 'more_code',
      proj_dir / 'even_more_code/subfolder',
    ]
    for w in windows:
      _run([VSCODE, w])
    
    _run([SUDO, DOCKER, 'compose', 'up', '-d'], cwd=docker_compose)
    



  • See, I like to actually enjoy myself sometimes, instead of just hating the world

    And part of that enjoyment is good coffee. Fresh, locally roasted coffee, that I grind fresh each morning. I either take it black, or with a splash of milk, depending on my mood

    Drip brewers are perfectly fine, so long as you don’t use the hot plate. But the biggest impact on coffee flavor is the freshness of both the roast and the grind





  • Because it’s all an impulse decision

    “New Year’s Resolutions” are the exact opposite of setting good goals

    Good goals:

    • need to be definable
      • “I will start restricting calories and target a 1lb per week loss”
      • not “get in shape”
    • need to be actionable
      • “I will start making plans right now, and implementing them tonight”
      • not “I will wait till a specific time of the year”
    • need to be sustainable
      • “I will adjust my strategy to work around my daily habits and otherwise be flexible”
      • not “NO MORE SWEETS”


  • Coffee brewers that have a hot plate under the carafe will burn and ruin coffee. The best method of keeping coffee fresh is to keep it in a sealed container (like a double walled carafe with a lid)

    Microwaving coffee is actually a pretty decent way to re-heat it, but the taste will depend on how fresh it was kept prior



  • My guess is that there’s a capacitor in there somewhere. The capacitor stores enough charge to keep the time for short periods (like a power flicker). But it’s unreliable for longer periods of time (beyond a few minutes) and will cause clock drift.

    So, when the power goes out for a medium length of time, the microwave resets to 12:00 to indicate that you need to set the time again

    However, if the microwave is left unplugged for an extended period of time (a few days to weeks), the capacitor is fully drained. My guess is that this causes the time to be set to --:–

    Why it would be designed like that? No idea