<commit_before>#!/usr/bin/env bash

FIND_CMD='find . -type f ! -path "*.git*" ! -path "*node_modules*" | fzf --height 100% --border -m  --ansi'

if [ $# -eq 0 ]; then
  CONTENT_FILE=$(eval "$FIND_CMD")
  ABSOLUTE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
  echo "$ABSOLUTE_PATH "'`# _ to search again`'" $CONTENT_FILE"
  exit 0
else
  if [ $1 == '_' ]; then
    CONTENT_FILE=$(eval "$FIND_CMD")
  else
    CONTENT_FILE="$1"
  fi
fi

if [ -z "$TOOLBOX_SCRIPTS_GRAMMARLY_FILE" ]; then
  GENERATED_FILE="/tmp/grammarly.html"
else
  GENERATED_FILE="$TOOLBOX_SCRIPTS_GRAMMARLY_FILE"
fi

NEW_UUID=$(uuidgen)

cat > "$GENERATED_FILE" <<"EOF"
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
        <title>Grammarly</title>
    /head>
    <body>
        <textarea style="height: 500px; width: 100%; font-size: 20px";>
EOF
if [ -z "$TOOLBOX_SCRIPTS_GRAMMARLY_FILE" ]; then
  GENERATED_FILE="/tmp/grammarly.html"
else
  GENERATED_FILE="$TOOLBOX_SCRIPTS_GRAMMARLY_FILE"
fi

cat > "$GENERATED_FILE" <<"EOF"
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
        <title>Grammarly</title>
    </head>
    <body>
        <textarea id="textarea" style="height: 500px; width: 100%; font-size: 20px";>
EOF
cat "$CONTENT_FILE" >> "$GENERATED_FILE"
cat >> "$GENERATED_FILE" <<"EOF"
        </textarea>
        <script>
EOF
echo "const uuid = '$NEW_UUID';" >> $GENERATED_FILE
cat >> "$GENERATED_FILE" <<"EOF"
const el = document.getElementById('textarea')

// remove last empty line
const lines = el.value.split('\n')
el.value = lines.slice(0, lines.length - 1).join('\n')<commit_msg>Remove duplicated code<commit_after>#!/usr/bin/env bash

FIND_CMD='find . -type f ! -path "*.git*" ! -path "*node_modules*" | fzf --height 100% --border -m  --ansi'

if [ $# -eq 0 ]; then
  CONTENT_FILE=$(eval "$FIND_CMD")
  ABSOLUTE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
  echo "$ABSOLUTE_PATH "'`# _ to search again`'" $CONTENT_FILE"
  exit 0
else
  if [ $1 == '_' ]; then
    CONTENT_FILE=$(eval "$FIND_CMD")
  else
    CONTENT_FILE="$1"
  fi
fi

if [ -z "$TOOLBOX_SCRIPTS_GRAMMARLY_FILE" ]; then
  GENERATED_FILE="/tmp/grammarly.html"
else
  GENERATED_FILE="$TOOLBOX_SCRIPTS_GRAMMARLY_FILE"
fi

NEW_UUID=$(uuidgen)

cat > "$GENERATED_FILE" <<"EOF"
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
        <title>Grammarly</title>
    </head>
    <body>
        <textarea id="textarea" style="height: 500px; width: 100%; font-size: 20px";>
EOF
cat "$CONTENT_FILE" >> "$GENERATED_FILE"
cat >> "$GENERATED_FILE" <<"EOF"
        </textarea>
        <script>
EOF
echo "const uuid = '$NEW_UUID';" >> $GENERATED_FILE
cat >> "$GENERATED_FILE" <<"EOF"
const el = document.getElementById('textarea')

// remove last empty line
const lines = el.value.split('\n')
el.value = lines.slice(0, lines.length - 1).join('\n')
{'fraction_non_alphanumeric': 0.1905988409529942, 'fraction_numerical': 0.015775917578879587, 'mean_word_length': 3.8622848200312987, 'pattern_counts': {'":': 0, '<': 50, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '513679', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1170, 'n_words': 248}