Skip to content

Instantly share code, notes, and snippets.

/// @author raffy.eth
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
contract DNSDecoder {
function decode(bytes memory dns) external pure returns (string memory s) {
unchecked {
require(dns.length != 0);
bytes memory v = new bytes(dns.length - 1); // [5] 3abc0 => [3] abc, but "abc." so -1
pragma solidity ^0.8.23;
import {IERC165} from "@openzeppelin/contracts@4.8.2/utils/introspection/IERC165.sol";
import {ENS} from "https://github.com/ensdomains/ens-contracts/blob/master/contracts/registry/ENS.sol";
import {IExtendedResolver} from "https://github.com/ensdomains/ens-contracts/blob/master/contracts/resolvers/profiles/IExtendedResolver.sol";
import {IMulticallable} from "https://github.com/ensdomains/ens-contracts/blob/master/contracts/resolvers/IMulticallable.sol";
import {BytesUtils} from "https://github.com/ensdomains/ens-contracts/blob/master/contracts/wrapper/BytesUtils.sol";
contract MultiResolver is IERC165, IExtendedResolver {
using BytesUtils for bytes;
import {keccak} from '@adraffy/keccak';
function namehash(name) {
let buf = new Uint8Array(64);
if (name.length > 0) {
for (let label of name.split('.').reverse()) {
buf.set(keccak().update(label).bytes, 32);
buf.set(keccak().update(buf).bytes, 0);
}
}
import os
import sys
import struct
# chia stuff
from chia.wallet.derive_keys import master_sk_to_local_sk
from chia.plotting.util import parse_plot_info
from chia.types.blockchain_format.proof_of_space import ProofOfSpace
# see: chiapos/src/plotter_disk.hpp WriteHeader()
// Copyright 2018 Chia Network Inc
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@adraffy
adraffy / gist:0a1a27e23ad48c0a80bb
Created November 5, 2014 00:01
Example of How to dump Items to JSON
package wktest;
import com.antistupid.warbase.data.ArmorCurve;
import com.antistupid.warbase.ids.ItemClass;
import com.antistupid.warbase.types.ArmorT;
import com.antistupid.warbase.types.ClassT;
import com.antistupid.warbase.types.EquipT;
import com.antistupid.warbase.types.QualityT;
import com.antistupid.warbase.types.RaceT;
import com.antistupid.warkit.WarKit;
static void dumpIds() {
WarKit wk = WarKit.load();
JSONObject root = new JSONObject();
root.put("items", wk.wearableMap.values().stream().map(x -> x.itemId).collect(Collectors.toCollection(JSONArray::new)));
root.put("gems", wk.gemMap.values().stream().map(x -> x.itemId).collect(Collectors.toCollection(JSONArray::new)));
// not all enchants have a corresponding item
root.put("enchants", wk.enchantMap.values().stream().filter(x -> x.itemId > 0).map(x -> x.itemId).collect(Collectors.toCollection(JSONArray::new)));
root.put("foods", wk.consumeMap.values().stream().filter(x -> x.type == ConsumeT.FOOD).map(x -> x.itemId).collect(Collectors.toCollection(JSONArray::new)));
root.put("potions", wk.consumeMap.values().stream().filter(x -> x.type == ConsumeT.POTION).map(x -> x.itemId).collect(Collectors.toCollection(JSONArray::new)));
// includes elixirs, flasks, scrolls
package warkit;
import warbase.types.SpecT;
import warbase.types.ProfT;
import warkit.player.Player;
public class Main {
public static void main(String[] args) {
package warbase;
import warbase.data.ArmorCurve;
import warbase.types.ArmorT;
import warbase.types.ClassT;
import warbase.types.EquipT;
import warbase.types.GemT;
import warbase.types.QualityT;
import warbase.types.RaceT;
import warbase.types.SocketT;
package wardbc;
import java.nio.file.Paths;
import wardbc.lazy.LazyDBC;
import wardbc.lazy.rows.*;
public class Main {
static public void main(String[] args) {