Skip to content

Instantly share code, notes, and snippets.

View Tsugami's full-sized avatar

Yslan Ramos Tsugami

  • Brazil
  • 05:55 (UTC -03:00)
View GitHub Profile
import * as React from "react";
import { useState, useEffect } from "react";
import { render } from "react-dom";
const FULL_TEXT =
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum";
function App() {
const [currentText, setCurrentText] = useState(0);
const [acc, setAcc] = useState(FULL_TEXT);
const isUpper = (str) => str === str.toUpperCase();
const cloneArray = (arr) => [...arr];
const cloneAndUpdateArray = (arr, value, index) => {
const newArr = cloneArray(arr);
newArr.splice(index, 1, value);
return newArr;
};
def char_to_hex(char):
return char.encode('utf-8').hex()
def string_to_hex(string):
chars = list(string)
hex_chars = map(char_to_hex, chars)
return "".join(hex_chars)
print(string_to_hex("char"))
# 63686172
defmodule AliasesRegistry do
@moduledoc false
def init do
Registry.start_link(keys: :unique, name: __MODULE__)
end
def via do
{:via, Registry, {__MODULE__, :aliases_registry}}
end
@Tsugami
Tsugami / levenshtein_distance.exs
Last active December 14, 2021 22:42
Levenshtein Distance in Elixir
defmodule LevenShteinDistance do
def compare_distance(str, ""), do: String.length(str)
def compare_distance("", str), do: String.length(str)
def compare_distance(str, str), do: 0
def compare_distance(str1, str2) do
[first1, rest1] = pattern_str(str1)
[first2, rest2] = pattern_str(str2)