<?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: Sabrina Pereira</title>
    <description>The latest articles on DEV Community by Sabrina Pereira (@sfpear).</description>
    <link>https://dev.to/sfpear</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%2F261584%2Fc2f73416-0312-4fa0-9c87-690868b7afec.jpg</url>
      <title>DEV Community: Sabrina Pereira</title>
      <link>https://dev.to/sfpear</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sfpear"/>
    <language>en</language>
    <item>
      <title>Plot FiftyOne visualisations with Seaborn</title>
      <dc:creator>Sabrina Pereira</dc:creator>
      <pubDate>Mon, 01 May 2023 09:58:48 +0000</pubDate>
      <link>https://dev.to/sfpear/plot-fiftyone-visualisations-with-seaborn-2ock</link>
      <guid>https://dev.to/sfpear/plot-fiftyone-visualisations-with-seaborn-2ock</guid>
      <description>&lt;h2&gt;
  
  
  Why
&lt;/h2&gt;

&lt;p&gt;I wanted more customisation options to draw figures for my thesis paper. It took me a while to figure this out, so I thought I'd share.&lt;/p&gt;

&lt;h2&gt;
  
  
  How
&lt;/h2&gt;

&lt;p&gt;I'm assuming you already have a FiftyOne dataset with computed embeddings and visualization. If not, you'll need to &lt;a href="https://docs.voxel51.com/user_guide/dataset_creation/index.html" rel="noopener noreferrer"&gt;create a dataset&lt;/a&gt; and &lt;a href="https://voxel51.com/blog/fiftyone-computer-vision-embeddings-tips-and-tricks-mar-31-2023/" rel="noopener noreferrer"&gt;compute the embeddings and visualization&lt;/a&gt; before proceeding.&lt;/p&gt;

&lt;p&gt;I already have everything saved, so I load my dataset and the &lt;code&gt;compute_visualization&lt;/code&gt; results before plotting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;fiftyone&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;fo&lt;/span&gt;

&lt;span class="c1"&gt;# load dataset
&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load_dataset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dataset_name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# load computed visualisation
&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load_brain_results&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;vis_name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I have a sample field called "vehicle_type" that I want to use as the &lt;code&gt;hue&lt;/code&gt; in my seaborn plot. To obtain this information for each sample, I wrote a simple function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_vehicle_type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample_id&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;sample_id&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;vehicle_type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, I convert &lt;code&gt;results.points&lt;/code&gt; into a pandas DataFrame and fetch the "vehicle_type" information from the FiftyOne dataset.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;seaborn&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;sns&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;

&lt;span class="c1"&gt;# turn results.points into dataframe
&lt;/span&gt;&lt;span class="n"&gt;df_viz&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;points&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;y&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="c1"&gt;# get sample ids for each sample
&lt;/span&gt;&lt;span class="n"&gt;df_viz&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sample_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample_ids&lt;/span&gt;

&lt;span class="c1"&gt;# use sample id to get the sample field info I need
&lt;/span&gt;&lt;span class="n"&gt;df_viz&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;vehicle_type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df_viz&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sample_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;get_vehicle_type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, I plot the results using seaborn:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scatterplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;df_viz&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;x&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;y&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
&lt;span class="n"&gt;hue&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;vehicle_type&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;palette&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;mako_r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
&lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;edgecolor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;none&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Image Uniqueness&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;axis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;off&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Seaborn allows for greater control over the appearance of the plot. Since I don't need the plot to be interactive, this is the perfect solution for creating uniform plots for my paper.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final result
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fznk8324oof02heilca7r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fznk8324oof02heilca7r.png" alt="A scatter plot showing different clusters of similar images" width="515" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Extra: compute embeddings and visualisation
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;fiftyone.zoo&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;foz&lt;/span&gt;

&lt;span class="c1"&gt;# compute embeddings
&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;foz&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load_zoo_model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mobilenet-v2-imagenet-torch&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;embeddings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compute_embeddings&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# pickle embeddings for later use, this the computation takes a while
&lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;embeddings.pkl&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;wb&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;pickle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;embeddings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Compute visualization
&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compute_visualization&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;embeddings&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;embeddings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;brain_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;vis_name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>computervision</category>
      <category>python</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Install and use Postgres in WSL</title>
      <dc:creator>Sabrina Pereira</dc:creator>
      <pubDate>Fri, 24 Feb 2023 23:42:52 +0000</pubDate>
      <link>https://dev.to/sfpear/install-and-use-postgres-in-wsl-423d</link>
      <guid>https://dev.to/sfpear/install-and-use-postgres-in-wsl-423d</guid>
      <description>&lt;p&gt;To keep this short and sweet, I'll assume you know your way around bash, Postgres and already have WSL installed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Postgres
&lt;/h2&gt;

&lt;p&gt;To install Postgres and run it in WSL, all you have to do is the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your WSL terminal&lt;/li&gt;
&lt;li&gt;Update your Ubuntu packages: &lt;code&gt;sudo apt update&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Once the packages have updated, install PostgreSQL (and the -contrib package which has some helpful utilities) with: &lt;code&gt;sudo apt install postgresql postgresql-contrib&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Confirm installation and get the version number: &lt;code&gt;psql --version&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Set a password
&lt;/h2&gt;

&lt;p&gt;The default admin user, &lt;code&gt;postgres&lt;/code&gt;, needs a password assigned in order to connect to a database. To set a password:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter the command: &lt;code&gt;sudo passwd postgres&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;You will get a prompt to enter your new password.&lt;/li&gt;
&lt;li&gt;Close and reopen your terminal.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can access &lt;a href="https://www.postgresql.org/docs/current/app-psql.html" rel="noopener noreferrer"&gt;psql&lt;/a&gt; directly using &lt;code&gt;sudo -u postgres psql&lt;/code&gt;. You should see your prompt change to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;postgres=#
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To change databases just use &lt;code&gt;\c mydb&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can also use &lt;code&gt;su - postgres&lt;/code&gt; to go into the postgres user. Here you use the password you set up above. Your prompt should change to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;postgres@mycomputername:~$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From here, you can use psql to login into any database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a database
&lt;/h2&gt;

&lt;p&gt;To create a database, just use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;createdb mydb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can change &lt;code&gt;mydb&lt;/code&gt; to whatever name you want to give your database. To access it, just enter &lt;code&gt;psql mydb&lt;/code&gt; in the command line. Now your prompt should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mydb=#
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create tables in a database from a file, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;psql -U postgres -q mydb &amp;lt; &amp;lt;file-path/file.sql&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Useful commands
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;\l&lt;/code&gt; lists all databases. Works from any database.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\dt&lt;/code&gt; lists all tables in the current database.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\c &amp;lt;db name&amp;gt;&lt;/code&gt; switch to a different database.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use &lt;code&gt;psql&lt;/code&gt; without sudo
&lt;/h2&gt;

&lt;p&gt;Create a Postgres user with the same name as your Ubuntu username using the following command. And when it asks, make the new role a superuser.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo -u postgres createuser --interactive
Enter name of role to add: sabrina
Shall the new role be a superuser? (y/n) y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you have to change the &lt;code&gt;pg_hba.conf&lt;/code&gt; file. It will be under &lt;code&gt;/etc/postgresql/&amp;lt;postgres-version&amp;gt;/main&lt;/code&gt;. You will need sudo to edit this file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo vi pg_hba.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Scroll to the bottom of the files, now change where it says &lt;code&gt;peer&lt;/code&gt;, to &lt;code&gt;trust&lt;/code&gt;, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Database administrative login by Unix domain socket
local   all             postgres                                trust

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Accessing your database from Windows
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;You have to change the file &lt;code&gt;postgresql.conf&lt;/code&gt;. Just uncomment the line for &lt;code&gt;listen_address&lt;/code&gt; and change it to &lt;code&gt;listen_address = '*'&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Set up a password for postgres admin user &lt;code&gt;sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"&lt;/code&gt;. This will change the password to postgres and this is what you use when connecting to a database. The password you set during install is for the postgres Ubuntu user.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now you should be able to connect to your database from Windows using software such as &lt;a href="https://tableplus.com/windows" rel="noopener noreferrer"&gt;TablePlus&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Need more?
&lt;/h2&gt;

&lt;p&gt;This is just a quick overview of what to do to get up and running, for a more in-depth tutorial see &lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04" rel="noopener noreferrer"&gt;this&lt;/a&gt; and the sources listed below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-database#install-postgresql" rel="noopener noreferrer"&gt;WSL Documentation: Install PostgreSQL&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.postgresql.org/docs/current/tutorial-createdb.html#id-1.4.3.4.10.4" rel="noopener noreferrer"&gt;Postgres documentation: 1.3. Creating a Database&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/a/73066114" rel="noopener noreferrer"&gt;StackOverflow: PostgreSQL: Why psql can't connect to server?&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dba.stackexchange.com/a/1288" rel="noopener noreferrer"&gt;StackExchange: How do I list all databases and tables using psql?&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/a/46143801" rel="noopener noreferrer"&gt;StackOverflow: fatal role "root" does not exist&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.cybertec-postgresql.com/en/postgresql-on-wsl2-for-windows-install-and-setup/" rel="noopener noreferrer"&gt;POSTGRESQL ON WSL2 FOR WINDOWS: INSTALL AND SETUP&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/a/13796578" rel="noopener noreferrer"&gt;StackOverflow: password authentication failed for user "postgres"&lt;/a&gt;&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>wsl</category>
      <category>tutorial</category>
      <category>database</category>
    </item>
    <item>
      <title>Vagrant and VirtualBox on Windows 11 and WSL</title>
      <dc:creator>Sabrina Pereira</dc:creator>
      <pubDate>Mon, 13 Feb 2023 15:01:06 +0000</pubDate>
      <link>https://dev.to/sfpear/vagrant-and-virtualbox-on-windows-11-and-wsl2-395p</link>
      <guid>https://dev.to/sfpear/vagrant-and-virtualbox-on-windows-11-and-wsl2-395p</guid>
      <description>&lt;p&gt;Download VirtualBox's latest version for Windows and its extension pack from &lt;a href="https://www.virtualbox.org/wiki/Downloads" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;After installing VirtualBox, install the pack by going into tools &amp;gt; extensions then clicking install:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0lckw70otflu14vr34ke.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0lckw70otflu14vr34ke.png" alt=" " width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install vagrant according to their &lt;a href="https://developer.hashicorp.com/vagrant/downloads" rel="noopener noreferrer"&gt;instructions for Linux&lt;/a&gt;. All you have to do is to runt he following command in WSL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update &amp;amp;&amp;amp; sudo apt install vagrant
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Export some global variables to be able to run vagrant (these need to be reset each time you open a new terminal):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
export PATH="$PATH:/mnt/c/Program Files/Oracle/VirtualBox"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You also have to add the folder where your project is located:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH="/mnt/c/&amp;lt;path-to-folder-where-Vagrantfile-is&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you have to ssh from PowerShell 🫠&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh vagrant@127.0.0.1 -p 2222
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add this line to your &lt;code&gt;Vagrantfile&lt;/code&gt; to be able to have a project in your ubuntu file system:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;config.vm.synced_folder '.', '/vagrant', disabled: true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more info on WSL installs, click &lt;a href="https://developer.hashicorp.com/vagrant/docs/other/wsl" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>cpp</category>
      <category>csharp</category>
      <category>embedded</category>
    </item>
    <item>
      <title>Miniconda in WSL</title>
      <dc:creator>Sabrina Pereira</dc:creator>
      <pubDate>Tue, 27 Sep 2022 16:16:10 +0000</pubDate>
      <link>https://dev.to/sfpear/miniconda-in-wsl-3642</link>
      <guid>https://dev.to/sfpear/miniconda-in-wsl-3642</guid>
      <description>&lt;h1&gt;
  
  
  Install
&lt;/h1&gt;

&lt;p&gt;Download the latest version of miniconda:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bash Miniconda3-latest-Linux-x86_64.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  After Installation
&lt;/h1&gt;

&lt;p&gt;To install conda's shell functions, first restart your shell, then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;conda init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you'd prefer that conda's base environment is not activated on startup, set the auto_activate_base parameter to false:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;conda config --set auto_activate_base false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remove the installation file from your directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm Miniconda3-latest-Linux-x86_64.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Using Miniconda
&lt;/h1&gt;

&lt;p&gt;To get into your conda environment&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;conda activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create a new environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;conda create --name &amp;lt;new-env-name&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To view all your environments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;conda env list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conda cheat sheet PDF &lt;a href="https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other useful things to know
&lt;/h2&gt;

&lt;p&gt;Open current directory in file explorer&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;explorer.exe .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>datascience</category>
      <category>anaconda</category>
      <category>linux</category>
      <category>wsl</category>
    </item>
  </channel>
</rss>
