<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: James Middleton</title>
    <description>The latest articles on DEV Community by James Middleton (@midzdotdev).</description>
    <link>https://dev.to/midzdotdev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F589160%2F2bcf4a1b-5967-4db7-8b9f-d34682ad7e68.jpeg</url>
      <title>DEV Community: James Middleton</title>
      <link>https://dev.to/midzdotdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/midzdotdev"/>
    <language>en</language>
    <item>
      <title>Responsive &lt;video /&gt;: finally, a solution!</title>
      <dc:creator>James Middleton</dc:creator>
      <pubDate>Fri, 10 Feb 2023 18:53:58 +0000</pubDate>
      <link>https://dev.to/midzdotdev/responsive-finally-a-solution-ad4</link>
      <guid>https://dev.to/midzdotdev/responsive-finally-a-solution-ad4</guid>
      <description>&lt;p&gt;On a fine winter's evening, much pain was felt undertaking a treacherous endeavour of fitting a video element inside its parent.&lt;/p&gt;

&lt;p&gt;After failed ventures seeking answers from the World Wide Web, and sounding many explicatives to the browser, good old blindly-led trial-and-error saves the day once again.&lt;/p&gt;

&lt;h3&gt;
  
  
  ENTER, THE CODE...
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;This works for a parent with dynamic or explicit sizing, I'm using it within a CSS grid cell.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Style your &lt;code&gt;&amp;lt;video /&amp;gt;&lt;/code&gt; with this CSS and smile 😄&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;video&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/james2mid/embed/PoBMZLj?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;I was amazed that none of the answers I found out there solved this seemingly trivial challenge. I didn't want anybody else to experience such meaningless pain, so here you go.&lt;/p&gt;

&lt;p&gt;You're welcome 🙇‍♂️&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>webdev</category>
    </item>
    <item>
      <title>EdgeDB on a VPS: Don't do what I did</title>
      <dc:creator>James Middleton</dc:creator>
      <pubDate>Sun, 08 Jan 2023 21:02:45 +0000</pubDate>
      <link>https://dev.to/midzdotdev/edgedb-on-a-vps-my-experience-1njk</link>
      <guid>https://dev.to/midzdotdev/edgedb-on-a-vps-my-experience-1njk</guid>
      <description>&lt;p&gt;So I've spent all day trying to have my Docker container connect to EdgeDB today and I think I've cracked it. I'm sure some other people have been just as confused as me so I thought I'd share my findings so far.&lt;/p&gt;

&lt;p&gt;My goal was to setup my VPS with a scraper running in a Docker container which writes data to my EdgeDB database.&lt;/p&gt;

&lt;h2&gt;
  
  
  edgedb driving me mad 😤
&lt;/h2&gt;

&lt;p&gt;Through SSH, I created my EdgeDB instance on a non-root user with &lt;code&gt;edgedb instance create&lt;/code&gt;, performed my migrations and I thought everything was fine.&lt;/p&gt;

&lt;p&gt;Coming back to the scraper later, I came to find that for the whole time I was away my scraper couldn't connect to EdgeDB.&lt;/p&gt;

&lt;p&gt;I was receiving a &lt;code&gt;ClientConnectionFailedError&lt;/code&gt; saying &lt;code&gt;cannot establish connection: Connection refused&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So I whipped open the server's &lt;code&gt;edgedb&lt;/code&gt; cli and tried to connect. It worked fine. I look back at my scraper container's logs and it's able to connect again.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I was absolutely befuddled.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Tried playing around with the server's CLI to replicate the error I'd seen in my scraper, nothing.&lt;/p&gt;

&lt;p&gt;Hmm, maybe it's an issue with docker. I found the &lt;code&gt;edgedb/edgedb&lt;/code&gt; Docker image with a built-in &lt;code&gt;edgedb&lt;/code&gt; CLI. Could replicate the issue with that either.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Everything was working while I was logged in, but as soon as I logged out the client would fail to connect.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I felt like I was going crazy (Life as a Developer™️).&lt;/p&gt;

&lt;p&gt;I was scouring through the docs once again, and the problem suddenly clicked in my mind.&lt;/p&gt;

&lt;h2&gt;
  
  
  feeling both 😞 and 🤩
&lt;/h2&gt;

&lt;p&gt;I'd already looked at it sooo many times, but &lt;a href="https://www.edgedb.com/docs/guides/deployment/bare_metal" rel="noopener noreferrer"&gt;this&lt;/a&gt; wonderful piece of documentation had a critical piece that I'd missed.&lt;/p&gt;

&lt;p&gt;I thought that the DB instances ran globally, but it turns out that using &lt;code&gt;edgedb instance create&lt;/code&gt; makes instances that are scoped to the user executing the command.&lt;/p&gt;

&lt;p&gt;Following the guide more closely, I noticed that &lt;code&gt;edgedb instance create&lt;/code&gt; is never used!&lt;/p&gt;

&lt;p&gt;The key was to use the global &lt;code&gt;systemd&lt;/code&gt; daemon thing instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; &lt;span class="nt"&gt;--now&lt;/span&gt; edgedb-server-2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This serves a global instance on port &lt;code&gt;5656&lt;/code&gt;. It's independent of user and always runs in the background.&lt;/p&gt;

&lt;p&gt;Set a password for the &lt;code&gt;edgedb&lt;/code&gt; credentials:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"&amp;gt; "&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; PASSWORD

&lt;span class="nb"&gt;sudo &lt;/span&gt;edgedb &lt;span class="nt"&gt;--port&lt;/span&gt; 5656 &lt;span class="nt"&gt;--tls-security&lt;/span&gt; insecure &lt;span class="nt"&gt;--admin&lt;/span&gt; query &lt;span class="se"&gt;\&lt;/span&gt;
 &lt;span class="s2"&gt;"ALTER ROLE edgedb SET password := '&lt;/span&gt;&lt;span class="nv"&gt;$PASSWORD&lt;/span&gt;&lt;span class="s2"&gt;'"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can go ahead and link it to your CLI so it's easier to connect in future. If you've kept the default settings, the command is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;edgedb instance &lt;span class="nb"&gt;link&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--host&lt;/span&gt; localhost &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--port&lt;/span&gt; 5656 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--user&lt;/span&gt; edgedb &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--database&lt;/span&gt; edgedb &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--trust-tls-cert&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  my-instance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll be prompted to enter in that same password and bob's your uncle!&lt;/p&gt;

&lt;p&gt;You can now easily connect through the CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;edgedb &lt;span class="nt"&gt;-I&lt;/span&gt; my-instance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The DSN is a connection string of the format &lt;code&gt;edgedb://username:password@host/database&lt;/code&gt;. To get the DSN made during your linking, do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;edgedb instance credentials &lt;span class="nt"&gt;-I&lt;/span&gt; my-instance &lt;span class="nt"&gt;--insecure-dsn&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check it works through the CLI without requiring the link:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;edgedb &lt;span class="nt"&gt;--dsn&lt;/span&gt; my-dsn &lt;span class="nt"&gt;--tls-security&lt;/span&gt; insecure 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you can use that DSN as the connection config for your client as I did with my Docker container. Whether it's Docker or not, set the environment variable &lt;code&gt;EDGEDB_DSN&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;EDGEDB_DSN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"my-dsn?tls_security=insecure"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Make sure you have the &lt;code&gt;?tls_security=insecure&lt;/code&gt; param in the &lt;code&gt;EDGEDB_DSN&lt;/code&gt; environment variable for your runtime client. &lt;strong&gt;Notice the &lt;code&gt;_&lt;/code&gt; rather than the &lt;code&gt;-&lt;/code&gt; we used earlier.&lt;/strong&gt; Here's more about the DSN &lt;a href="https://www.edgedb.com/docs/intro/clients#using-edgedb-dsn" rel="noopener noreferrer"&gt;in the docs&lt;/a&gt;, although right now these aren't respected in the CLI.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Tada! 🥳&lt;/p&gt;

&lt;h2&gt;
  
  
  outro 🎶
&lt;/h2&gt;

&lt;p&gt;Thanks for reading through and I really hope this helped you so you're not banging your head against a metaphorical brick wall for as long as I was!&lt;/p&gt;

&lt;p&gt;Let me know if you have any issues with this, I'd be keen to learn more about it.&lt;/p&gt;

&lt;p&gt;On that note, I'll be getting rid of all that nasty &lt;code&gt;insecure&lt;/code&gt; stuff by setting up the TLS certificates properly at some point. If you'd like to hear about that then let me know!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>productivity</category>
      <category>tooling</category>
    </item>
  </channel>
</rss>
