<?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: Hahnbee Lee</title>
    <description>The latest articles on DEV Community by Hahnbee Lee (@hahnbeelee).</description>
    <link>https://dev.to/hahnbeelee</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%2F696329%2F065acc55-6e55-4306-838e-a3d4236a1e13.jpeg</url>
      <title>DEV Community: Hahnbee Lee</title>
      <link>https://dev.to/hahnbeelee</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hahnbeelee"/>
    <language>en</language>
    <item>
      <title>VS Code Extension that Generates Documentation Using AI</title>
      <dc:creator>Hahnbee Lee</dc:creator>
      <pubDate>Sun, 23 Jan 2022 00:18:01 +0000</pubDate>
      <link>https://dev.to/hahnbeelee/vs-code-extension-that-generates-documentation-using-ai-1cc3</link>
      <guid>https://dev.to/hahnbeelee/vs-code-extension-that-generates-documentation-using-ai-1cc3</guid>
      <description>&lt;p&gt;There's this fairly new extension on the VS Code marketplace called &lt;a href="https://marketplace.visualstudio.com/items?itemName=mintlify.document" rel="noopener noreferrer"&gt;AI Doc Writer for JavaScript, TypeScript, and Python&lt;/a&gt;. Here's what the README says:&lt;/p&gt;

&lt;p&gt;Step 1 Highlight code &lt;br&gt;
Step 2 Click on the Write Docs button (or hit ⌘ + .)&lt;/p&gt;

&lt;p&gt;So, I put it to the test to see how good it really is.&lt;/p&gt;

&lt;p&gt;Here's how it fared on some JS code:&lt;br&gt;
&lt;a href="https://media.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%2F1vohg3i7uha1bwji3cls.gif" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1vohg3i7uha1bwji3cls.gif" alt="Image description" width="800" height="444"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
 * return a set of all the subjects in the fullCoursesArray.
 * @returns A set of all the subjects.
 */
function getAllSubjects(): ReadonlySet&amp;lt;string&amp;gt; {
  const set = new Set&amp;lt;string&amp;gt;();
  fullCoursesArray.forEach(it =&amp;gt; set.add(it.subject));
  return set;
}

/**
 * For each subject, if it has a color, do nothing. Otherwise, give it a random color from the color
set.
 * @param subjectColors - The subject colors that are currently in use.
 * @returns A new object with the same keys as the original object, but with new values.
 */
export function allocateAllSubjectColor(
  subjectColors: Record&amp;lt;string, string&amp;gt;
): Record&amp;lt;string, string&amp;gt; {
  const subjectsColorsCopy = { ...subjectColors };
  getAllSubjects().forEach(subject =&amp;gt; {
    if (subjectsColorsCopy[subject]) return;
    subjectsColorsCopy[subject] = coursesColorSet[
      Math.floor(Math.random() * coursesColorSet.length)
    ].hex.substring(1);
  });
  return subjectsColorsCopy;
}

/**
 * Update the subjectColors object with the new color for the given subject.
 * @param subjectColors - The current subject colors.
 * @param {string} color - The color to be applied to the subject.
 * @param {string} code - The subject code of the subject to update.
 * @returns A new object with the updated color.
 */
export function updateSubjectColor(
  subjectColors: Record&amp;lt;string, string&amp;gt;,
  color: string,
  code: string
): Record&amp;lt;string, string&amp;gt; {
  const subjectsColorsCopy = { ...subjectColors };
  getAllSubjects().forEach(subject =&amp;gt; {
    if (subject === code) {
      subjectsColorsCopy[subject] = color;
    }
  });
  return subjectsColorsCopy;
}

/**
 * When the user clicks outside of the element, the `clickOutside` event handler is called.
 */
export const clickOutside = {
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  beforeMount(el: any, binding: any): void {
    el.clickOutsideEvent = (event: Event) =&amp;gt; {
      if (!(el === event.target || el.contains(event.target))) {
        binding.value(event, el);
      }
    };
    document.body.addEventListener('click', el.clickOutsideEvent);
  },
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  unmounted(el: any): void {
    document.body.removeEventListener('click', el.clickOutsideEvent);
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also tried it on some Python code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def collect_dataset():
    '''
    The function is used to collect the data from the github repository.


    :return: A matrix of the dataset.
    '''
    response = requests.get(
        "https://raw.githubusercontent.com/yashLadha/"
        + "The_Math_of_Intelligence/master/Week1/ADRvs"
        + "Rating.csv"
    )
    lines = response.text.splitlines()
    data = []
    for item in lines:
        item = item.split(",")
        data.append(item)
    data.pop(0)  # This is for removing the labels from the list
    dataset = np.matrix(data)
    return dataset


def run_steep_gradient_descent(data_x, data_y, len_data, alpha, theta):
    '''
    This function runs the gradient descent algorithm.

    :param data_x: the data matrix
    :param data_y: the actual y values
    :param len_data: the number of data points
    :param alpha: learning rate
    :param theta: The initial value of theta
    :return: Theta
    '''
    n = len_data

    prod = np.dot(theta, data_x.transpose())
    prod -= data_y.transpose()
    sum_grad = np.dot(prod, data_x)
    theta = theta - (alpha / n) * sum_grad
    return theta


def sum_of_square_error(data_x, data_y, len_data, theta):
    '''
    It calculates the sum of squared error for the given data and the given theta.

    :param data_x: the data matrix
    :param data_y: the y values of the data
    :param len_data: the number of data points
    :param theta: theta vector
    :return: The sum of the squares of the errors.
    '''
    prod = np.dot(theta, data_x.transpose())
    prod -= data_y.transpose()
    sum_elem = np.sum(np.square(prod))
    error = sum_elem / (2 * len_data)
    return error


def run_linear_regression(data_x, data_y):
    '''
    Runs gradient descent on the data and returns the final theta vector.

    :param data_x: The training data
    :param data_y: The dependent variable
    :return: Theta
    '''
    iterations = 100000
    alpha = 0.0001550

    no_features = data_x.shape[1]
    len_data = data_x.shape[0] - 1

    theta = np.zeros((1, no_features))

    for i in range(0, iterations):
        theta = run_steep_gradient_descent(
            data_x, data_y, len_data, alpha, theta)
        error = sum_of_square_error(data_x, data_y, len_data, theta)
        print("At Iteration %d - Error is %.5f " % (i + 1, error))

    return theta
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What do you guys think?&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>python</category>
      <category>productivity</category>
      <category>vscode</category>
    </item>
  </channel>
</rss>
