Skip to content

Instantly share code, notes, and snippets.

View niltonheck's full-sized avatar
I may be slow to respond.

Nilton Heck niltonheck

I may be slow to respond.
View GitHub Profile
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/metatx/ERC2771Context.sol";
contract OnChainLRU is ERC2771Context {
constructor(
address trustedForwarder_
) ERC2771Context(trustedForwarder_){}
address public lastCaller;
import { ChainEngineSdk } from "chainengine-sdk";
import fs from "fs";
(async () => {
const GAME_ID = '2fd5f2de-2c8c-4d2e-9139-211175244cb6';
const API_URL = 'http://localhost:3000'
const API_KEY = 'testApiKey';
const API_SECRET = 'testApiSecret';
const NETWORK = 'testnet';
I am attesting that this GitHub handle niltonheck is linked to the Tezos account tz1LyzQz9Vr8jw8w15kN4zzszGbpAJuoHF4h for tzprofiles
sig:edsigtZjPbiSGeuqjFuDegNpirYgBEt646Xin3errXuyJL3wqz8apQ9xaLJF4MbmmNFM1gFKpd5cVj1hW9PsJLABM2HCUNWVRNA
@niltonheck
niltonheck / running-trie.kts
Last active June 4, 2021 18:59
Execução da Árvore
Trie trie = new Trie();
Node root = new Node();
foreach (var key in conversions.Keys)
{
trie.insertIntoTrie(root, (key as String).ToArray(), 0);
}
// For de exemplo para validar performance.
for (int i = 0; i < 1000000; i++) {
@niltonheck
niltonheck / formatName.kts
Last active June 4, 2021 17:54
Hashtable e Função para Formatação do Nome
Hashtable conversions = new Hashtable();
conversions.Add("C Manut ", "Centro Manutenção");
conversions.Add("Centro Manut ", "Centro Manutenção");
conversions.Add("C M ", "Centro Manutenção");
...
String formatName(Trie trie, String record, Hashtable conversions) {
ClosestMatch close = trie.Search(record.name, root);
if ( close != null ) {
return conversions[close.Match] + record.name.Substring(close.Index);
@niltonheck
niltonheck / trie-correcao-grafia.kts
Last active June 4, 2021 17:33
Trie - Correção de Grafia
data class ClosestMatch (
val match: String,
val index: Int
)
data class Node(
var value: Char? = null,
var word: String? = null,
val children: MutableList<Node> = emptyList<Node>().toMutableList()
)
using System.Collections;
class ClosestMatch {
public String Match;
public Int32 Index;
public ClosestMatch(String incomingMatch, Int32 incomingIndex) {
Match = incomingMatch;
Index = incomingIndex;
}
@niltonheck
niltonheck / trie-correcao-nomes.kts
Last active May 21, 2021 14:29
Trie: Tratamento para Correção de Nomes
import kotlin.system.measureTimeMillis
data class ClosestMatch (
val match: String,
val index: Int
)
data class Node(
var value: Char? = null,
var word: String? = null,
cd ~
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install unzip zip
wget https://dl.google.com/android/repository/commandlinetools-linux-6514223_latest.zip
unzip commandlinetools-linux-6514223_latest.zip -d cmdline-tools
mkdir Android
mv cmdline-tools ./Android/
rm commandlinetools-linux-6514223_latest.zip
sudo apt-get install -y lib32z1 openjdk-8-jdk
class Node {
constructor(info) {
this.info = info;
this.leftNode = null;
this.rightNode = null;
}
insert(value) {
if(value <= this.info) {
if(this.leftNode == null) {