<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Guide - Things I Keep Having to Google</title>
    <link href="../../../style.css" rel="stylesheet" type="text/css" media="all">
    <style type="text/css">
      /*h1 {
        background-image: url('wireguard_logo.png');
      }
      summary > * {
        margin-bottom: 0;
        display: inline-block;
      }
      details[open] > summary h6 {
        display: none;
      }*/
      td {
        padding: .2rem;
      }
      td h4 {
        margin: 0;
      }
    </style>
  </head>
  <body>
    <h1>guide:</h1>
    <h2 id="caption">Things I Keep Having to Google</h2>
    <nav>
      <a href="../../../">home</a>
      <a href="../../">blog</a>
    </nav>
    <p>This isn't really a guide to anything in particular, I just wanted an easily accessible reference for all the things I'm sick of wading through google results for, or otherwise seem to need help remembering. I've put it here in case someone else might find this helpful. I'll likely be adding to this as I find myself repeatedly googling things.</p>
    <h2>Binding things to just the Super key in KDE</h2>
    <ol>
      <li>Bind it to some other keyboard shortcut using KDE's typical GUI methods. Any shortcut will do.</li>
      <li>Find the entry for it in <code>~/.config/khotkeysrc</code>. There should be a line that looks like: <code>Uuid=<u>{77575b17-36d6-4b4e-b01f-2f1156e38583}</u></code>. Copy the contents of that line, specifically everything I have underlined there.</li>
      <li>Run the following commands:</li>
    </ol>
    <code>$ kwriteconfig5 --file ~/.config/kwinrc --group ModifierOnlyShortcuts --key Meta "org.kde.kglobalaccel,/component/khotkeys,org.kde.kglobalaccel.Component,invokeShortcut,&lt;YOUR UUID HERE&gt;"<br>$ qdbus org.kde.KWin /KWin reconfigure</code>
    <h2>Linux command line/Bash stuff</h2>
    <table>
      <tr><td colspan="2"><h4>pipeline</h4></td></tr>
      <tr><td><code>command | command2</code></td><td>uses the output of one command as the input to the next</td></tr>
      <tr><td><code>command > file</code></td><td>saves the output of a command to a file</td></tr>
      <tr><td><code>command < file</code></td><td>uses a file as the input to a command</td></tr>
      <tr><td><code>command < fileA > fileB</code></td><td>will therefore run <code>command</code> with the contents of <code>fileA</code> as the input, and save the output to <code>fileB</code></td></tr>
      <tr><td nowrap><code>command <<< "string or $variable"</code></td><td>will use the string or variable as the input to a command, the same as <code>&nbsp;< file</code></td></tr>
      <tr><td colspan="2"><h4>variables</h4></td></tr>
      <tr><td><code>variable=value</code></td><td>assigns a variable</td></tr>
      <tr><td><code>$variable</code></td><td>references it</td></tr>
      <tr><td><code>$(command)</code></td><td>lets you treat the output of a command like a variable reference</td></tr>
      <tr><td><code>$((number+variable))</code></td><td>does the same thing for integer math expressions.</td></tr>
      <tr><td><code>$((&nbsp;$(command)&nbsp;))<br>$((&nbsp;variable&nbsp;))</code></td><td>This can also just convert strings into integers.</td></tr>
      <tr><td><code>"te$(command)xt"<br>"as$((math))df"</code></td><td>Both can be inserted into strings.</td></tr>
      <tr><td><code>"some&nbsp;$variable&nbsp;text"<br>"more${variable}text"</code></td><td>Both of these are valid ways to insert a variable into a string.</td></tr>
      <tr><td colspan="2"><h4>grep</h4></td></tr>
      <tr><td><code>-v</code></td><td>inverts it, so matches are excluded</td></tr>
      <tr><td><code>-E "/regex/"</code></td><td>lets you use regex</td></tr>
      <tr><td colspan="2"><h4>cut</h4></td></tr>
      <tr><td><code>-d 'string'</code></td><td>determines the delimiter string</td></tr>
      <tr><td><code>-f n</code></td><td>specifies a field to output, delimited by <code>-d</code></td></tr>
      <tr><td><code>sed 's/  */ /g' | cut -d ' '</code></td><td>Piping your thing through this <span title="It's not foolproof, though. Make sure you understand what this is doing so you can adapt it if it breaks.">helps</span> with parsing a lot of Linux commands that output tabular data</td></tr>
      <tr><td colspan="2"><h4>misc</h4></td></tr>
      <tr><td><code>xrandr --output &lt;display name&gt; --brightness &lt;brightness&gt;</code></td><td title="It would definitely for sure be better to change this via the monitor's built-in menus, but that requires navigating both of my monitors' built-in menus.">Janky software-side display brightness setting with xrandr</td></tr>
      <tr><td><code>wget "https://example.com/file.zip" -O temp.zip; unzip temp.zip; rm temp.zip</code></td><td>Bash one-liner to unzip a file from the internet to the current directory</td></tr>
    </table>
    <h2>Webdev stuff</h2>
    <h4>Tables</h4>
    <ul>
      <li>Force a <code>&lt;td&gt;</code> element not to wrap by adding the <code>nowrap</code> attribute to it.</li>
      <li>Set the <code>table-layout</code> CSS property to <code>fixed</code> to force the the columns to be equal widths.</li>
    </ul>
    <h4>PHP</h4>
    <ul>
      <li>The <code>date()</code> function in PHP returns date information. The first argument is a format string and the second is an optional integer for a Unix timestamp. The valid format characters as of PHP 8 can be found <a href="https://www.php.net/manual/en/datetime.format.php">here</a>, and examples are listed in this table:</p>
      <details>
        <summary>Show table</summary><br>
        It is currently <?php echo date('l, F j, Y \a\t g:i:s A T');?><br><br>
        <table class="highlightrows" style="table-layout: fixed; width: 100%;">
          <tr style="font-weight: bold;"><td>Character</td><td>Output</td><td>Character</td><td>Output</td></tr>
          <tr><td>Y</td><td><?php echo date("Y");?></td><td>y</td><td><?php echo date("y");?></td></tr>
          <tr><td>o</td><td><?php echo date("o");?></td><td>L</td><td><?php echo date("L");?></td></tr>
          <tr><td>F</td><td><?php echo date("F");?></td><td>M</td><td><?php echo date("M");?></td></tr>
          <tr><td>m</td><td><?php echo date("m");?></td><td>n</td><td><?php echo date("n");?></td></tr>
          <tr><td>t</td><td><?php echo date("t");?></td><td>W</td><td><?php echo date("W");?></td></tr>
          <tr><td>l</td><td><?php echo date("l");?></td><td>D</td><td><?php echo date("D");?></td></tr>
          <tr><td>d</td><td><?php echo date("d");?></td><td>j</td><td><?php echo date("j");?></td></tr>
          <tr><td>S</td><td><?php echo date("S");?></td><td>z</td><td><?php echo date("z");?></td></tr>
          <tr><td>N</td><td><?php echo date("N");?></td><td>w</td><td><?php echo date("w");?></td></tr>
          <tr><td>A</td><td><?php echo date("A");?></td><td>a</td><td><?php echo date("a");?></td></tr>
          <tr><td>g</td><td><?php echo date("g");?></td><td>G</td><td><?php echo date("G");?></td></tr>
          <tr><td>h</td><td><?php echo date("h");?></td><td>H</td><td><?php echo date("H");?></td></tr>
          <tr><td>i</td><td><?php echo date("i");?></td><td>s</td><td><?php echo date("s");?></td></tr>
          <tr title="These are milliseconds and microseconds respectively. They will both return 0 when used with date() as it takes the Unix timestamp as an integer in seconds, but there are other functions that take this formatting and will return these accurately."><td>v</td><td><?php echo date("v");?></td><td>u</td><td><?php echo date("u");?></td></tr>
          <tr><td title="This one is so funny to me. This is Swatch Internet Time, a time system created in 1998 by the Swatch corporation to promote their &quot;Beat&quot; watches. It divides the day into 1000 equal chunks 86.4 seconds long. I encourage you to go read the Wikipedia page for this thing. It's great. Why PHP has a function for it I have no idea.">B</td><td><?php echo date("B");?></td><td>I</td><td><?php echo date("I");?></td></tr>
          <tr><td>e</td><td><?php echo date("e");?></td><td>O</td><td><?php echo date("O");?></td></tr>
          <tr><td>P</td><td><?php echo date("P");?><td>Z</td><td><?php echo date("Z");?></td></tr>
          <tr><td title="You can also use the function time() for this.">U</td><td colspan="3"><?php echo date("U");?></td></tr>
          <tr><td>c</td><td colspan="3"><?php echo date("c");?></td></tr>
          <tr><td>r</td><td colspan="3"><?php echo date("r");?></td></tr>
        </table>
      </details><br>
      The <code>strtotime()</code> function does the reverse operation, converting date strings to Unix timestamps. Storing dates as Unix timestamps and converting when needed is recommended.</li>
    </ul>
    <h2>Song Lyrics</h2>
    <p>I don't actually have a solution for this one, I just wish there was a resource for looking up the lyrics to songs and looking up songs by their lyrics that wasn't an SEO leech site.</p>
  </body>
</html>
