<?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: Nick F</title>
    <description>The latest articles on DEV Community by Nick F (@nickfun).</description>
    <link>https://dev.to/nickfun</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%2F360325%2Fc9bbce05-8db7-497e-8334-7bdc1659228e.png</url>
      <title>DEV Community: Nick F</title>
      <link>https://dev.to/nickfun</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nickfun"/>
    <language>en</language>
    <item>
      <title>Postgesql - create a user for a database</title>
      <dc:creator>Nick F</dc:creator>
      <pubDate>Wed, 22 Nov 2023 22:23:31 +0000</pubDate>
      <link>https://dev.to/nickfun/postgesql-create-a-user-for-a-database-ng5</link>
      <guid>https://dev.to/nickfun/postgesql-create-a-user-for-a-database-ng5</guid>
      <description>&lt;p&gt;How to setup a new user and give that user permission over a database? I found this a hard question to answer, so I'm writing down my soltuion.&lt;/p&gt;

&lt;p&gt;This worked for me on Postresql 15.&lt;/p&gt;

&lt;p&gt;You need a superuser account, to create the database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;database&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;database&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;user&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;user&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="k"&gt;encrypted&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;password&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;alter&lt;/span&gt; &lt;span class="k"&gt;database&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;database&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;owner&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;user&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At that point, the user you created can login and create/edit/delete tables as you would expect within that one database.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>sql</category>
    </item>
    <item>
      <title>Using "git diff" and "git apply" to share small changes.</title>
      <dc:creator>Nick F</dc:creator>
      <pubDate>Fri, 09 Sep 2022 17:45:57 +0000</pubDate>
      <link>https://dev.to/nickfun/using-git-diff-and-git-apply-to-share-small-changes-3c0e</link>
      <guid>https://dev.to/nickfun/using-git-diff-and-git-apply-to-share-small-changes-3c0e</guid>
      <description>&lt;p&gt;Sometimes in a Pull Request Review you want to tell someone about a little change to make. You make your change locally, maybe a few lines different, and note that it works locally. Your &lt;code&gt;git diff&lt;/code&gt; output will show your change. How can you share this little snippit? Just copy the output of &lt;code&gt;git diff&lt;/code&gt; and sent that to your team mate. Here is a small change I've made locally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gh"&gt;diff --git a/conf/local.rb b/conf/local.rb
index 57672691..28fd024c 100644
&lt;/span&gt;&lt;span class="gd"&gt;--- a/conf/local.rb
&lt;/span&gt;&lt;span class="gi"&gt;+++ b/conf/local.rb
&lt;/span&gt;&lt;span class="p"&gt;@@ -1,6 +1,6 @@&lt;/span&gt;
&lt;span class="gd"&gt;-@whitePagesCacheTtl = "60s"
-
-@executionEnvironment = "local"
&lt;/span&gt;&lt;span class="gi"&gt;+@whitePagesCacheTtl = "120s"
+@considerEnv = "false"
+@executionEnvironment = "external"
&lt;/span&gt;
 @lightstep_collector_host = "HO123"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's say I copied all that. On a mac, we have the cool &lt;code&gt;pbcopy&lt;/code&gt; command to capture stdout and put it on the clipboard. So &lt;code&gt;git diff | pbcopy&lt;/code&gt; will copy it for us. Now you can put it in a pull request comment or send it to someone on chat.&lt;/p&gt;

&lt;p&gt;Ok so a team mate sent you that. You can read it as a human and see it changes a few lines. You could edit the file to make it match, but git can do it for you. Pipe the output to &lt;code&gt;git apply&lt;/code&gt;. Again on mac we have the nice &lt;code&gt;pbpaste&lt;/code&gt; command to send our clipboard to stdout. So one option is to copy the text from the pull request comment and pipe it to git apply.&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;$ &lt;/span&gt;pbpaste | git apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another option is to put the contents into a file and point git apply to that. Say you paste the diff into &lt;code&gt;new.patch&lt;/code&gt;, you can apply the changes with:&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;$ &lt;/span&gt;git apply new.patch &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;rm &lt;/span&gt;new.patch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I delete the patch since we are done with it and don't want to commit it to git. &lt;/p&gt;

&lt;p&gt;This is something I do often. I used git for a long time without knowing about &lt;code&gt;apply&lt;/code&gt; or that the output of &lt;code&gt;diff&lt;/code&gt; can be used as input. It has helped me a few times.&lt;/p&gt;

</description>
      <category>git</category>
    </item>
    <item>
      <title>Failed deploy to dokku</title>
      <dc:creator>Nick F</dc:creator>
      <pubDate>Mon, 12 Oct 2020 02:58:16 +0000</pubDate>
      <link>https://dev.to/nickfun/failed-deploy-to-dokku-ldh</link>
      <guid>https://dev.to/nickfun/failed-deploy-to-dokku-ldh</guid>
      <description>&lt;p&gt;I've got this Scala Play app that I develop on my laptop and deploy to a Dokku on a small Linode VPS.&lt;/p&gt;

&lt;p&gt;These days, when I deploy, I get these failures:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git push dokku master
Counting objects: 72, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (70/70), done.
Writing objects: 100% (72/72), 10.72 KiB | 731.00 KiB/s, done.
Total 72 (delta 45), reused 0 (delta 0)
-----&amp;gt; Cleaning up...
-----&amp;gt; Building yt from herokuish...
-----&amp;gt; Adding BUILD_ENV to build environment...
-----&amp;gt; Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
       Detected buildpacks: multi scala
-----&amp;gt; Multipack app detected
=====&amp;gt; Downloading Buildpack: https://github.com/heroku/heroku-buildpack-scala
=====&amp;gt; Detected Framework: Play 2.x - Scala
-----&amp;gt; Installing JDK 1.8... done
-----&amp;gt; Running: sbt compile stage
       [info] Loading global plugins from /tmp/scala_buildpack_build_dir/.sbt_home/plugins
       [info] Loading settings for project scala_buildpack_build_dir-build from plugins.sbt ...
       [info] Loading project definition from /tmp/scala_buildpack_build_dir/project
       [info] Loading settings for project root from build.sbt ...
       [info] Set current project to play-ytdl (in build file:/tmp/scala_buildpack_build_dir/)
       [info] Executing in batch mode. For better performance use sbt's shell
       [info] Compiling 21 Scala sources and 1 Java source to /tmp/scala_buildpack_build_dir/target/scala-2.13/classes ...
remote: .sbt_home/bin/sbt-extras: line 241:   480 Killed                  "$@" &amp;lt; /dev/null

       !     ERROR: Failed to run sbt!
       We're sorry this build is failing. If you can't find the issue in application
       code, please submit a ticket so we can help: https://help.heroku.com
       You can also try reverting to the previous version of the buildpack by running:
       $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-scala#previous-version

       Thanks,
       Heroku

To MYDOMAIN.com:yt
 ! [remote rejected] master -&amp;gt; master (pre-receive hook declined)
error: failed to push some refs to 'dokku@MYDOMAIN.com:yt'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;.sbt_home/bin/sbt-extras: line 241:   480 Killed&lt;/code&gt; is the important part. Searching the web about it, this is not a Dokku issue. I can reproduce by checking out my source code on the VPS directly and trying to &lt;code&gt;sbt stage&lt;/code&gt; to build the project myself. I get the same &lt;code&gt;Killed&lt;/code&gt; message eventually.&lt;/p&gt;

&lt;p&gt;The problem is I don't have enough RAM to build the project :-O&lt;/p&gt;

&lt;p&gt;My options are to get more RAM, or compile the project locally and deploy an artifact. I'll look into the second option, but I might get lazy and buy a larger VPS. It will depend on my free time.&lt;/p&gt;

&lt;p&gt;I make this post in case someone else is putting this error message into google and needs a hint on what is happening.&lt;/p&gt;

</description>
      <category>scala</category>
      <category>dokku</category>
      <category>heroku</category>
    </item>
  </channel>
</rss>
