Skip to content

Instantly share code, notes, and snippets.

@ObiajuluM
ObiajuluM / fp.go
Created June 25, 2022 11:29
Handy snippets for generating common list comprehension function implementaions for your type(s) in golang
// Replace "X" and "Y" with your desired types
func mapXtoY(collection []X, fn func(elem X) Y) []Y {
var result []Y
for _, item := range collection {
result = append(result, fn(item))
}
return result
}
@ObiajuluM
ObiajuluM / main.py
Last active April 17, 2022 08:53 — forked from dangell7/main.py
XRPL (Bytes -> Hex <- Bytes)
def symbol_to_hex(symbol: str = None) -> str:
"""symbol_to_hex."""
if len(symbol) > 3:
bytes_string = bytes(str(symbol).encode('utf-8'))
return bytes_string.hex().upper().ljust(40, '0')
return symbol
def hex_to_symbol(hex: str = None) -> str:
"""hex_to_symbol."""