Skip to content

Instantly share code, notes, and snippets.

function prepareWordListWithSuggestions(phrase = '', suggestions = []) {
const result = [];
let phraseAux = phrase;
let phrasePointer = 0;
suggestions.forEach((suggestion) => {
const start = suggestion.start - phrasePointer;
const end = suggestion.offset - phrasePointer;
const firstPart = phraseAux.slice(0, start);
if (firstPart !== '') {
result.push({ phrase: firstPart });
<template>
<div class="input--field">
<p class="input--field-label box--spelling-label" :class="{ active: isActive }">
{{ label }}
<span v-if="obligatory" class="text--color-red">*</span>
</p>
<template v-if="!hasFocus && value === ''">
<p class="placeholder">{{ placeholder }}</p>
</template>
<div
function parseHtmlToText(html) {
const element = html.cloneNode(true);
const spans = element.getElementsByClassName('suggestions');
while (spans.length > 0) {
spans[0].parentNode.removeChild(spans[0]);
}
let text = element.textContent.split('\n').join('');
text = text.trimStart();
text = text.replace(/ +/g, ' ');
return text;
<template>
<div class="input--field">
<p class="input--field-label" :class="{ active: isActive }">
{{ label }}
</p>
<template v-if="!hasFocus && value === ''">
<p class="placeholder">{{ placeholder }}</p>
</template>
<div
ref="editable"
<template>
<span class="suggestions--block">
<ul v-if="showSuggestions" class="suggestions" contentEditable="false">
<li class="suggestions--close" @click="handleClose">
<icon-close />
</li>
<li v-for="suggestion in suggestions"
:key="suggestion.value">
<p @click="handleSelectSuggestion(word, suggestion.value)">
{{ suggestion.value }}
<template>
<div class="input--field">
<p class="input--field-label">
{{ label }}
</p>
<template v-if="!hasFocus && value === ''">
<p class="placeholder">{{ placeholder }}</p>
</template>
<div>
{{value}}
@agusnavce
agusnavce / ml.ipynb
Last active November 13, 2019 18:28
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"> </script>
version: "3.5"
services:
postgres:
image: library/postgres:10.7
container_name: db
restart: always
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
@agusnavce
agusnavce / flask.Dockerfile
Created May 14, 2019 18:48
Docker file to contenarize flask app
FROM ubuntu:latest
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD ["app.py"]