<?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>Forem: Willem van den Ende</title>
    <description>The latest articles on Forem by Willem van den Ende (@mostalive).</description>
    <link>https://forem.com/mostalive</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%2F392656%2F09cebaa0-8ba9-4fb6-bd5c-a8148b40bd8e.png</url>
      <title>Forem: Willem van den Ende</title>
      <link>https://forem.com/mostalive</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mostalive"/>
    <language>en</language>
    <item>
      <title>How to replace an org-mode link by its description</title>
      <dc:creator>Willem van den Ende</dc:creator>
      <pubDate>Tue, 23 Feb 2021 10:24:02 +0000</pubDate>
      <link>https://forem.com/mostalive/how-to-replace-an-org-mode-link-by-its-description-c70</link>
      <guid>https://forem.com/mostalive/how-to-replace-an-org-mode-link-by-its-description-c70</guid>
      <description>&lt;h1&gt;
  
  
  Table of Contents
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt; Problem
&lt;/li&gt;
&lt;li&gt; Solution
&lt;/li&gt;
&lt;li&gt; Epilogue
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a id="org3835595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Problem
&lt;/h1&gt;

&lt;p&gt;Before turning a note into a blog post, I want to remove some of the org-mode links that are internal to my notes. There did not appear to be a way to do this out of the box. The answers I found &lt;a href="https://emacs.stackexchange.com/questions/10707/in-org-mode-how-to-remove-a-link"&gt;on emacs stackexchange&lt;/a&gt; used regular expressions or deleted a space after the link.&lt;/p&gt;

&lt;p&gt;I used a fair number of tabs to cobble up a solution, so I thought it would be worth sharing.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;org-delete-link&lt;/code&gt; by a throw-away account almost worked, and uses org-modes’ Abstract Syntax Three through the org-element api. &lt;a href="https://emacs.stackexchange.com/users/12336/timm"&gt;User Timm&lt;/a&gt; correctly pointed out a space after the link would also be deleted.&lt;/p&gt;

&lt;p&gt;&lt;a id="orgd509c76"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Solution
&lt;/h1&gt;

&lt;p&gt;I prefer &lt;a href="https://emacs.stackexchange.com/users/2710/andrew-swann"&gt;Andrew Swann&lt;/a&gt;’s name for the function, so here is my fixed mashup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;defun&lt;/span&gt; &lt;span class="nv"&gt;org-replace-link-by-link-description&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt;
      &lt;span class="s"&gt;"Remove the link part of an org-mode link at point and keep
    only the description"&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;interactive&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nv"&gt;elem&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;org-element-context&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;eq&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;car&lt;/span&gt; &lt;span class="nv"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ss"&gt;'link&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;let*&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nv"&gt;content-begin&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;org-element-property&lt;/span&gt; &lt;span class="ss"&gt;:contents-begin&lt;/span&gt; &lt;span class="nv"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                   &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;content-end&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;org-element-property&lt;/span&gt; &lt;span class="ss"&gt;:contents-end&lt;/span&gt; &lt;span class="nv"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                   &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;link-begin&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;org-element-property&lt;/span&gt; &lt;span class="ss"&gt;:begin&lt;/span&gt; &lt;span class="nv"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                   &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;link-end&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;org-element-property&lt;/span&gt; &lt;span class="ss"&gt;:end&lt;/span&gt; &lt;span class="nv"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
              &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;and&lt;/span&gt; &lt;span class="nv"&gt;content-begin&lt;/span&gt; &lt;span class="nv"&gt;content-end&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nv"&gt;content&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;buffer-substring-no-properties&lt;/span&gt; &lt;span class="nv"&gt;content-begin&lt;/span&gt; &lt;span class="nv"&gt;content-end&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
                    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;delete-region&lt;/span&gt; &lt;span class="nv"&gt;link-begin&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;link-end&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;insert&lt;/span&gt; &lt;span class="nv"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)))))))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Subtract one from link-end and it works. This is the fixed line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;delete-region&lt;/span&gt; &lt;span class="nv"&gt;link-begin&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;link-end&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Original question on emacs stackexchange: &lt;a href="https://emacs.stackexchange.com/questions/10707/in-org-mode-how-to-remove-a-link"&gt;in org-mode, how to remove a link?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a id="org265a8a6"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Epilogue
&lt;/h1&gt;

&lt;p&gt;Why do I want this? I want to publish only some of my org-roam notes. Org-roam notes are like private wiki-pages. It also allows (with a bookmarklet) to clip webpages to their own org-roam note. At the top of the note, there is a roamkey that then contains the url of the page. I want to export my org-roam notes to markdown. Links should be to orignal webpages, instead of my private clippings with notes.&lt;/p&gt;

&lt;p&gt;This is a baby step in the right direction.&lt;/p&gt;

&lt;p&gt;FYI  macs is perfectly usable without writing any code, using a distribution like Doom Emacs (my current) or Spacemacs (my previous). This is the first time in six years of regular emacs use that I’m writing a non-trivial amount of code for it.&lt;/p&gt;

</description>
      <category>emacs</category>
      <category>orgmode</category>
      <category>lisp</category>
    </item>
    <item>
      <title>How to 'fix' nodemon giving EADDRINUSE when changing a file</title>
      <dc:creator>Willem van den Ende</dc:creator>
      <pubDate>Tue, 04 Aug 2020 10:08:21 +0000</pubDate>
      <link>https://forem.com/mostalive/how-to-fix-nodemon-giving-eaddrinuse-when-changing-a-file-49a</link>
      <guid>https://forem.com/mostalive/how-to-fix-nodemon-giving-eaddrinuse-when-changing-a-file-49a</guid>
      <description>&lt;p&gt;TLDR: upgrade to &lt;a href="https://github.com/remy/nodemon#nodemon"&gt;nodemon&lt;/a&gt; 2.0.4 or higher.&lt;/p&gt;

&lt;h1&gt;
  
  
  Background
&lt;/h1&gt;

&lt;p&gt;This was a '4 tabs problem' yesterday, posting this here to save you the trouble. I found quite a few solutions, including a recent one that were not as simple as just upgrading. What happened? I installed a starter kid for node.js, from someone else. It would serve my tiny experimental API just fine, but I'd get "Port already in use" after each server restart. Nodemon reloaded my server.js just fine, but it seemed the application port wasn't shut down soon enough.&lt;/p&gt;

&lt;h1&gt;
  
  
  Solution
&lt;/h1&gt;

&lt;p&gt;Set &lt;code&gt;"nodemon": "2.0.4"&lt;/code&gt; in package.json and you should be good to go.&lt;/p&gt;

&lt;h1&gt;
  
  
  Bonus - I learnt about 'fuser'
&lt;/h1&gt;

&lt;p&gt;One of the &lt;a href="https://github.com/standard-things/esm/issues/676#issuecomment-653371336"&gt;incomplete solutions&lt;/a&gt; mentioned &lt;a href="https://www.digitalocean.com/community/tutorials/how-to-use-the-linux-fuser-command"&gt;fuser&lt;/a&gt;, a handy linux command to work with open ports and files. &lt;code&gt;fuser -k &amp;lt;YOURPORT&amp;gt;/tcp&lt;/code&gt; will kill the process using &lt;code&gt;YOURPORT&lt;/code&gt; (adjust number to taste). It can do similar things for open files, as well as list them.&lt;/p&gt;

&lt;p&gt;It does happen some times that I have development servers open, and can't use a port, but forgot which app is using that port, &lt;code&gt;fuser&lt;/code&gt; is a quick way to find out which program it is, and if necessary kill it.&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>debugging</category>
      <category>nodemon</category>
    </item>
    <item>
      <title>How to visualize a PostgreSQL schema as SVG with SchemaSpy</title>
      <dc:creator>Willem van den Ende</dc:creator>
      <pubDate>Wed, 22 Jul 2020 16:15:05 +0000</pubDate>
      <link>https://forem.com/mostalive/how-to-visualize-a-postgresql-schema-as-svg-with-schemaspy-516g</link>
      <guid>https://forem.com/mostalive/how-to-visualize-a-postgresql-schema-as-svg-with-schemaspy-516g</guid>
      <description>&lt;p&gt;TLDR: Use the option &lt;code&gt;-imageformat svg&lt;/code&gt; to generate an ER diagram in SVG format&lt;br&gt;
with &lt;a href="https://github.com/schemaspy/schemaspy" rel="noopener noreferrer"&gt;SchemaSpy&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/schemaspy/schemaspy" rel="noopener noreferrer"&gt;SchemaSpy&lt;/a&gt; generates HTML documentation from your database schema, including&lt;br&gt;
Entity Relationship diagrams. I find visualization helpful as a database model&lt;br&gt;
grows.&lt;/p&gt;

&lt;p&gt;Out of the box it produces diagrams in png format, like this one in the &lt;a href="https://hasura.io/blog/building-customizable-ecommerce-backend-with-hasura-graphql-apis/" rel="noopener noreferrer"&gt;Hasura&lt;br&gt;
ecommerce example&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fhasura.io%2Fblog%2Fcontent%2Fimages%2F2020%2F04%2Fecommerce_schema.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fhasura.io%2Fblog%2Fcontent%2Fimages%2F2020%2F04%2Fecommerce_schema.png" alt="database schema with tables user, store, order, cart, product, inventory, and order item. the post linked above describes it in more detail."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I prefer &lt;a href="https://developer.mozilla.org/en-US/docs/Web/SVG" rel="noopener noreferrer"&gt;SVG&lt;/a&gt;, because it scales, is smaller, and it is all text.&lt;/p&gt;

&lt;p&gt;Using &lt;a href="https://github.com/schemaspy/schemaspy" rel="noopener noreferrer"&gt;SchemaSpy&lt;/a&gt; to see what the relations are like is not complicated, &lt;em&gt;once you&lt;br&gt;
have downloaded the dependencies and figured out the command line options&lt;/em&gt;. And&lt;br&gt;
there are quite a lot of command line parameters. I had to download the&lt;br&gt;
&lt;a href="https://jdbc.postgresql.org/download.html" rel="noopener noreferrer"&gt;postgresql jdbc driver&lt;/a&gt; by hand, and specify the path with the &lt;code&gt;-dp&lt;/code&gt; option:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;schemaspy-path&amp;gt;$ java -jar target/schemaspy-6.1.1-SNAPSHOT.jar \
  -t pgsql -host localhost -db postgres -o /tmp -u postgres -dp . -p postgres -imageformat svg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The -t  option is mandatory. Probably works for anything that has a &lt;a href="//20200707172959-jdbc.md"&gt;JDBC&lt;/a&gt;&lt;br&gt;
Driver. I use a local database inside a docker container that is only open to my&lt;br&gt;
machine, so I left the passwords and the port at the default settings the&lt;br&gt;
docker-compose configuration came with.&lt;/p&gt;

&lt;p&gt;See the comment by Jon Lauridsen below on how to do all of this with a docker one-liner.&lt;/p&gt;

&lt;p&gt;If you forget an option, Schema Spy will tell you what was missing. I stuck the&lt;br&gt;
above in a shell script inside my project, so I can easily generate it again. I&lt;br&gt;
left the output as &lt;code&gt;/tmp&lt;/code&gt;, so when I reboot (rarely), I am forced to create a&lt;br&gt;
fresh diagram. Next step: integrate it into the build script, so I get&lt;br&gt;
a fresh diagram whenever I add database migration files in the &lt;code&gt;migrations&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;SchemaSpy uses &lt;a href="//20200623081841-graphviz.md"&gt;graphviz&lt;/a&gt; to generate images, the .dot files it uses as input, and&lt;br&gt;
the generated images can be found in &lt;code&gt;&amp;lt;outputpath&amp;gt;/summary/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;At first I had a one liner for this, and then while writing the post, I found&lt;br&gt;
that SchemaSpy supports SVG natively. It is 'just' another output parameter:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-imageformat svg&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For more details, see the &lt;a href="https://schemaspy.readthedocs.io/en/latest/started.html" rel="noopener noreferrer"&gt;Get Started page in the SchemaSpy documentation&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;I hope you found this helpful. It took me a bit of searching to find SchemaSpy, and the svg option. I'd be interested to know better alternatives, if there are any.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>documentation</category>
      <category>visualization</category>
    </item>
  </channel>
</rss>
