This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Counter do | |
use GenServer | |
def start_link(_) do | |
GenServer.start_link(__MODULE__, 0, name: __MODULE__) | |
end | |
@impl true | |
def init(initial), do: {:ok, initial} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Base { | |
a: unknown; | |
b: unknown; | |
c: unknown; | |
foo(): unknown; | |
bar(): unknown; | |
} | |
type RemoveMethods<T> = { [P in keyof T as T[P] extends (...args: any) => any ? never : P]: T[P] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const hasBit = (bit, bitfield) => (bitfield & bit) === bit; | |
export const addBit = (bit, bitfield) => bitfield | bit; | |
export const removeBit = (bit, bitfield) => bitfield & ~bit; | |
export const addOrRemoveBit = (bit, bitfield) => addBit(bit, bitfield) ? removeBit(bit, bitfield) : addBit(bit, bitfield); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
branch="$(git rev-parse --abbrev-ref HEAD)" | |
if [ "$branch" = "main" ] || [ "$branch" = "dev" ]; then | |
echo "You can't commit directly to the \"$branch\" branch, please checkout to a new branch before committing" | |
exit 1 | |
f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const FIREBASE_API_KEY = process.env.FIREBASE_API_KEY; | |
const FIREBASE_EMAIL = process.env.FIREBASE_EMAIL; | |
const FIREBASE_PASSWORD = process.env.FIREBASE_PASSWORD; | |
const FIREBASE_AUTH_URL = `https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=${ FIREBASE_API_KEY }`; | |
const method = "POST" | |
const body = { | |
email: FIREBASE_EMAIL, | |
password: FIREBASE_PASSWORD, |
OlderNewer