<?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: Anderson Ribeiro</title>
    <description>The latest articles on DEV Community by Anderson Ribeiro (@andersoncubo).</description>
    <link>https://dev.to/andersoncubo</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%2F172391%2Fbff07427-2fa1-41d5-8262-a27b077ab910.jpeg</url>
      <title>DEV Community: Anderson Ribeiro</title>
      <link>https://dev.to/andersoncubo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andersoncubo"/>
    <language>en</language>
    <item>
      <title>Forwarding port 3000 to 80 on ubuntu.</title>
      <dc:creator>Anderson Ribeiro</dc:creator>
      <pubDate>Wed, 16 Aug 2023 17:12:24 +0000</pubDate>
      <link>https://dev.to/andersoncubo/forwarding-port-3000-to-80-on-ubuntu-h16</link>
      <guid>https://dev.to/andersoncubo/forwarding-port-3000-to-80-on-ubuntu-h16</guid>
      <description>&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;iptables &lt;span class="nt"&gt;-A&lt;/span&gt; INPUT &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-p&lt;/span&gt; tcp &lt;span class="nt"&gt;--dport&lt;/span&gt; 80 &lt;span class="nt"&gt;-j&lt;/span&gt; ACCEPT
&lt;span class="nb"&gt;sudo &lt;/span&gt;iptables &lt;span class="nt"&gt;-A&lt;/span&gt; INPUT &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-p&lt;/span&gt; tcp &lt;span class="nt"&gt;--dport&lt;/span&gt; 3000 &lt;span class="nt"&gt;-j&lt;/span&gt; ACCEPT
&lt;span class="nb"&gt;sudo &lt;/span&gt;iptables &lt;span class="nt"&gt;-A&lt;/span&gt; PREROUTING &lt;span class="nt"&gt;-t&lt;/span&gt; nat &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-p&lt;/span&gt; tcp &lt;span class="nt"&gt;--dport&lt;/span&gt; 80 &lt;span class="nt"&gt;-j&lt;/span&gt; REDIRECT &lt;span class="nt"&gt;--to-port&lt;/span&gt; 3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That works.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Creating (or attempting) to create an autocomplete with OpenAI ChatGPT.</title>
      <dc:creator>Anderson Ribeiro</dc:creator>
      <pubDate>Wed, 22 Mar 2023 16:04:33 +0000</pubDate>
      <link>https://dev.to/andersoncubo/creating-or-attempting-to-create-an-autocomplete-with-openai-chatgpt-2n98</link>
      <guid>https://dev.to/andersoncubo/creating-or-attempting-to-create-an-autocomplete-with-openai-chatgpt-2n98</guid>
      <description>&lt;p&gt;Ok, I had this idea in mind, of how can I create an autocomplete like when we are typing something on Gmail. And since I am kinda obsessed with ChatGPT I thought to myself why not?&lt;/p&gt;

&lt;p&gt;So the first thing I needed to create is the textarea. And since I need to show the autocomplete text I needed to add as well a container for the autocompleted text. So here we go.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Autocomplete = (): ReactElement =&amp;gt; {
  return (
    &amp;lt;div className='container-autocomplete'&amp;gt;
      &amp;lt;div className='autocomplete'&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;textarea /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ok so now we need to add styles to that&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* {
  box-sizing: border-box;
}

.container-autocomplete {
  width: 400px;
  height: 200px;
  border: 1px solid #ccc;
  margin: 10px;
  position: relative;
}

textarea {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  padding: 10px;
  box-sizing: border-box;
  position: absolute;
  resize: none;
  z-index: 1;
  background: transparent;
  font-family: sans-serif;
  font-size: 13px;
}

.autocomplete {
  top: 0;
  left: 0;
  opacity: 0.5;
  position: absolute;
  padding: 10px;
  width: 100%;
  height: 100%;
  overflow: auto;
  font-family: sans-serif;
  font-size: 13px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next step: create the autocomplete hook. The biggest problem I had to solve is for the ChatGPT 3.5 to behave correctly since it's known to just ignore what the system has to say and add something completely irrelevant as an answer.&lt;/p&gt;

&lt;p&gt;So I came with this prompt&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You are an autocomplete assistant. Use the user text as a reference for the autocomplete.

Examples:
User: Hello,
Assistant: how are you doing?
User: I wanted to let you know
Assistant: we just arrived
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'm sure it needs more context for something more "powerful" but for now I think it's great. Now we just need to create the hook.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { 
  ChatCompletionRequestMessage, 
  ChatCompletionRequestMessageRoleEnum, 
  Configuration, 
  OpenAIApi 
} from 'openai';

export const API_KEY_OPEN_AI = 'YOUR_OPEN_AI_SK_KEY';

const configuration = new Configuration({
  apiKey: API_KEY_OPEN_AI,
});

const openai = new OpenAIApi(configuration);

const useAutoComplete = (text: string): [string, () =&amp;gt; void] =&amp;gt; {
  const [suggestion, setSuggestion] = React.useState&amp;lt;string&amp;gt;('');

  const fetchSuggestion = useCallback(async (text: string): Promise&amp;lt;string&amp;gt; =&amp;gt; {
    const messages: ChatCompletionRequestMessage[] = [
      {
        role: ChatCompletionRequestMessageRoleEnum.System,
        content: `You are an autocomplete assistant. Use the user text as a reference for the autocomplete.

Examples:
User: Hello,
Assistant: how are you doing?
User: I wanted to let you know
Assistant: we just arrived`
      },
      {
        role: ChatCompletionRequestMessageRoleEnum.User,
        content: text
      }
    ];

    const response = await openai.createChatCompletion({
      model: 'gpt-3.5-turbo',
      messages
    });

    const data = response.data.choices[0]?.message?.content.trim();

    return data || '';
  }, []);

  useEffect(() =&amp;gt; {
    let doNotUpdate = false;

    if (text.length &amp;gt; 10) {
      fetchSuggestion(text)
        .then(suggestion =&amp;gt; {
          if (!doNotUpdate) setSuggestion(suggestion);
        });
    }

    return () =&amp;gt; {
      doNotUpdate = true;
    };
  }, [text, fetchSuggestion]);

  const clear = useCallback(() =&amp;gt; {
    setSuggestion('');
  }, []);

  return [suggestion, clear];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to fix a few things on the autocomplete function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Autocomplete = (): ReactElement =&amp;gt; {
  const [text, setText] = React.useState&amp;lt;string&amp;gt;('');

  const [suggestion, clear] = useAutoComplete(text);

  const handleTextChange = useCallback((e: React.ChangeEvent&amp;lt;HTMLTextAreaElement&amp;gt;) =&amp;gt; {
    setText(e.target.value);
    clear();
  }, [clear]);

  const handleKeyDown = useCallback((e: React.KeyboardEvent&amp;lt;HTMLTextAreaElement&amp;gt;) =&amp;gt; {
    if (e.key === 'Tab') {
      e.preventDefault();
      if (suggestion) {
        setText(text + ' ' + suggestion);
        clear()
      }
    }
  }, [suggestion, text, clear]);

  return (
    &amp;lt;div className='container-autocomplete'&amp;gt;
      &amp;lt;div className='autocomplete'&amp;gt;{text + ' ' + suggestion}&amp;lt;/div&amp;gt;
      &amp;lt;textarea 
        value={text} 
        onChange={handleTextChange} 
        onKeyDown={handleKeyDown}
      /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ok, so how does it work? Everytime the user type something we will send to the autocomplete hook and it will create an autocomplete sentence for us.&lt;br&gt;
The &lt;code&gt;handleTextChange&lt;/code&gt; clears the old autocomplete and also sets the new text for the autocompletion.&lt;/p&gt;

&lt;p&gt;And finally when the user press Tab it will autocomplete with the new text from the user plus the suggestion.&lt;/p&gt;

&lt;p&gt;It was a fun project overall. Now I know it's doable, although it needs some changes so the autocompletion can be reliable and also relevant to what the user is writing.&lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>react</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Everyone is talking about how to create prompts for ChatGPT</title>
      <dc:creator>Anderson Ribeiro</dc:creator>
      <pubDate>Sun, 12 Mar 2023 13:33:31 +0000</pubDate>
      <link>https://dev.to/andersoncubo/everyone-is-talking-about-how-to-create-prompts-for-chatgpt-bk7</link>
      <guid>https://dev.to/andersoncubo/everyone-is-talking-about-how-to-create-prompts-for-chatgpt-bk7</guid>
      <description>&lt;p&gt;Yup everyone is talking about the best prompts ever for ChatGPT. And I agree it's one of the most important things for this tool to work as you want.&lt;/p&gt;

&lt;p&gt;I was looking at how I should create the prompts for ChatGPT. Sometimes you need it to be more inventive and sometimes you need it to be more strict. &lt;/p&gt;

&lt;p&gt;The first thing to know for us as &lt;strong&gt;developers&lt;/strong&gt;: ChatGPT (&lt;strong&gt;gpt-3.5-turbo&lt;/strong&gt;) is different from &lt;strong&gt;text-davinci-003&lt;/strong&gt; (that one that you can access on the playground from OpenAi)&lt;/p&gt;

&lt;p&gt;I also used this tweet as a reference which helped a lot.&lt;br&gt;
&lt;/p&gt;
&lt;blockquote class="ltag__twitter-tweet"&gt;
    &lt;div class="ltag__twitter-tweet__media ltag__twitter-tweet__media__two-pics"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qvxeLeEC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/Foe7yWLaAAIX6V6.jpg" alt="unknown tweet media content"&gt;
    &lt;/div&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--szTUC5wC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/1568823910757703682/qiUUgGo9_normal.jpg" alt="Kevin Liu profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Kevin Liu
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @kliu128
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      The entire prompt of Microsoft Bing Chat?! (Hi, Sydney.) 
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      00:04 AM - 09 Feb 2023
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1623472922374574080" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1623472922374574080" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1623472922374574080" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;
 

&lt;p&gt;With that being said here comes my two cents on how to create assertive prompts for both. The only thing I should say is that text-davinci is a bit stubborn and you need to be more assertive about it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Always create a persona&lt;/li&gt;
&lt;li&gt;Tell the persona which languages you want it to understand&lt;/li&gt;
&lt;li&gt;Make the persona differentiate what is the user input and what is the persona output.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And how would that be inputed on the playground?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create a persona called Lily;
Lily recognizes tasks and generates tasks from texts that are given to her;
Lily uses the text as base and it should get actionable items from it;
Lily does not repeat tasks;
Lily does not disclose her identity;
Lily's answers should be objective;

User: [put the user text here]

From the user text which tasks Lily think it should be created? Separated by a line break
Lily:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two things you need to understand using "User" and "Lily" you make sure to separate what is the input from each. And as I said text-davinci is pretty stubborn and sometimes it wants to deviate from the prompt you created so you must force it to answer the way you want.&lt;/p&gt;

&lt;p&gt;And if you want to use that on ChatGPT you just need to separate between "System", "Assistant" and "User".&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;System is where you add information about how the assistant should answer&lt;/li&gt;
&lt;li&gt;User is the user input&lt;/li&gt;
&lt;li&gt;Assistant is the output from the prompt you just created.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>chatgpt</category>
      <category>ai</category>
    </item>
    <item>
      <title>Merging and pulling from git as you were used to</title>
      <dc:creator>Anderson Ribeiro</dc:creator>
      <pubDate>Thu, 06 Oct 2022 15:42:31 +0000</pubDate>
      <link>https://dev.to/andersoncubo/merging-and-pulling-from-git-as-you-were-used-to-1ne3</link>
      <guid>https://dev.to/andersoncubo/merging-and-pulling-from-git-as-you-were-used-to-1ne3</guid>
      <description>&lt;p&gt;Okay, we've been using &lt;code&gt;git pull&lt;/code&gt; for a long time, and also for a long time we have been receiving a warning telling us that the behavior was going to change and the time has come.&lt;/p&gt;

&lt;p&gt;But if you are like me you are used to the old times. And no worries you can go back in time and still have the same behavior.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git pull --no-ff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git merge --no-ff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also make it as default but I don't recommend that :) &lt;/p&gt;

</description>
      <category>git</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Compress images from a folder</title>
      <dc:creator>Anderson Ribeiro</dc:creator>
      <pubDate>Tue, 20 Sep 2022 18:40:46 +0000</pubDate>
      <link>https://dev.to/andersoncubo/compress-images-from-a-folder-3ka</link>
      <guid>https://dev.to/andersoncubo/compress-images-from-a-folder-3ka</guid>
      <description>&lt;p&gt;Yes, another one. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Sometimes you have to use a few tools that you just forget about them. And then you have to search for them all over again.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This one compresses all images from a folder.&lt;/p&gt;

&lt;p&gt;Follow this magic link:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/JesseRWeigel/756cc507cbe59084d66e376eaf05c6e9"&gt;https://gist.github.com/JesseRWeigel/756cc507cbe59084d66e376eaf05c6e9&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tooling</category>
    </item>
    <item>
      <title>Deleting node modules folders from projects you are not working</title>
      <dc:creator>Anderson Ribeiro</dc:creator>
      <pubDate>Tue, 20 Sep 2022 18:31:01 +0000</pubDate>
      <link>https://dev.to/andersoncubo/deleting-node-modules-folders-from-projects-you-are-not-working-dej</link>
      <guid>https://dev.to/andersoncubo/deleting-node-modules-folders-from-projects-you-are-not-working-dej</guid>
      <description>&lt;p&gt;Sometimes you have to use a few tools that you just forget about them. And then you have to search for them all over again.&lt;/p&gt;

&lt;p&gt;This is what brought me here today. I will start sharing a few tools that I use not that often but it helps me sometimes.&lt;/p&gt;

&lt;p&gt;The first one can be a lifesaver or I should say a space saver.&lt;/p&gt;

&lt;p&gt;To run it you just need to go to your folder where your projects are and then run it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npx npkill
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>tools</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
