Skip to content

Instantly share code, notes, and snippets.

@markusait
markusait / fuzzymatch.js
Created June 28, 2023 23:17
Gist to compare different fuzzymatch name matching algorithms
import bag from "talisman/metrics/bag.js";
import damerauLevenshtein from "talisman/metrics/damerau-levenshtein.js";
import jaroWinkler from "talisman/metrics/jaro-winkler.js";
import lcs from "talisman/metrics/lcs.js";
import mlipns from "talisman/metrics/mlipns.js";
import identity from "talisman/metrics/identity.js";
import mongeElkan from "talisman/metrics/monge-elkan.js";
import mra from "talisman/metrics/mra.js";
import overlap from "talisman/metrics/overlap.js";
import stringSimilarity from "string-similarity";
@markusait
markusait / StablyWebView.dart
Last active April 13, 2023 19:56
Open up Stably Ramp Trade page in a WebView and continue checkout in user's mobile browser when proceed is clicked
import 'package:url_launcher/url_launcher.dart';
class _WebViewExampleState extends State<WebViewExample> {
final String url = 'https://ramp.stably.io/?address=GDXLL7ERK46AL2ISBAA2N3YZOF4RNA3L75MYRYHRJL62BFOXN3Z53RDG&network=stellar&asset=USDC&lock=true&_blank=1';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Webview Example'),
@markusait
markusait / solequa.py
Last active October 1, 2021 05:53
solequa
import math
def isPosInt(x):
return x >= 0 and x.is_integer()
def findABs(n):
start = 2 if isPosInt(n / 2) else 1
limit = int(math.sqrt(n)) + 1
solutions = []
step = 2
@markusait
markusait / errorHandling.ts
Created May 20, 2020 03:05
Approach to do error handling in typescript
// Usually one wowuld import these declerations like such
// import { ok, err, Result } from './util'
export declare type Result<T, E>
= Ok<T, E> // contains a success value of type T
| Err<T, E> // contains a failure value of type E
// utility functions to build Ok and Err instances
export declare const ok: <T, E>(value: T) => Ok<T, E>
export declare const err: <T, E>(err: E) => Err<T, E>
export declare class Ok<T, E> {
/*
* Complete the 'getEventsOrder' function below.
*
* The function is expected to return a STRING_ARRAY.
* The function accepts following parameters:
* 1. STRING team1
* 2. STRING team2
* 3. STRING_ARRAY events1
* 4. STRING_ARRAY events2
*/
// https://www.youtube.com/watch?v=wyu6VRmtCmE&t=916s
const InsensitiveDistanceCompare = (str1, str2) => {
let index1 = 0
let index2 = 0
let different = 0
while(index1 < str1.length && index2 < str2.length) {
char1 = str1[index1]
char2 = str2[index2]
if(char1.toLowerCase() === char2.toLowerCase()) {
index1++
@markusait
markusait / addLiquidity.js
Created October 16, 2019 20:21
Uniswap adding liquidity
let Web3 = require("web3");
const Tx = require('ethereumjs-tx')
var abi = '[{"name": "TokenPurchase", "inputs": [{"type": "address", "name": "buyer", "indexed": true}, {"type": "uint256", "name": "eth_sold", "indexed": true}, {"type": "uint256", "name": "tokens_bought", "indexed": true}], "anonymous": false, "type": "event"}, {"name": "EthPurchase", "inputs": [{"type": "address", "name": "buyer", "indexed": true}, {"type": "uint256", "name": "tokens_sold", "indexed": true}, {"type": "uint256", "name": "eth_bought", "indexed": true}], "anonymous": false, "type": "event"}, {"name": "AddLiquidity", "inputs": [{"type": "address", "name": "provider", "indexed": true}, {"type": "uint256", "name": "eth_amount", "indexed": true}, {"type": "uint256", "name": "token_amount", "indexed": true}], "anonymous": false, "type": "event"}, {"name": "RemoveLiquidity", "inputs": [{"type": "address", "name": "provider", "indexed": true}, {"type": "uint256", "name": "eth_amount", "indexed": true}, {"type": "uint256", "name": "tok
@markusait
markusait / usds.svg
Created July 16, 2019 00:49
USDS Token SVG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"user_id" : "5",
"name" : "michael"
}
{
"type":"auth/StdTx",
"value":{
"msgs":[
{
"type":"tokens/FreezeMsg",
"value":{
"from":"tbnb1kzhvu454j2edyalutzpmq4z3m09dwrexym2zkn",
"symbol":"BNB",
"amount":"2"