Skip to content

Instantly share code, notes, and snippets.

@andelf
andelf / doh.rs
Last active September 24, 2023 16:44
Rust DoH DNS over HTTP Resolver for reqwest
//! A DoH client for the sync crate
//!
//! To be used in ClientBuilder.dns_resolver
use once_cell::sync::Lazy;
use std::{
cell::RefCell,
collections::HashMap,
net::SocketAddr,
time::{Duration, Instant},
@andelf
andelf / hsl_to_rgb.rs
Last active June 28, 2023 15:23
HSL color to RGB color conversion for embedded Rust
//! color conversion
//!
//! via https://github.com/emgyrz/colorsys.rs which is not friendly to embedded devices
pub const RGB_UNIT_MAX: f32 = 255.0;
pub const HUE_MAX: f32 = 360.0;
pub const PERCENT_MAX: f32 = 100.0;
pub const RATIO_MAX: f32 = 1.0;
pub const ALL_MIN: f32 = 0.0;
@andelf
andelf / rm-yiyan-eb-watermark.js
Last active March 18, 2023 05:29
Remove eb-watermark, copy and paste to dev-console
(function () {
function removeWatermark() {
const watermark = document.getElementById('eb-watermark');
if (watermark) {
watermark.remove();
console.log('eb-watermark removed!');
}
}
function observeDOM(targetNode, callback) {
@andelf
andelf / logseq-cla.md
Last active November 10, 2022 11:17
Logseq, Ltd. Contributor License Agreement

Logseq, Inc. Contributor License Agreement

Thank you for your interest in the open source project(s) managed by Logseq, Inc. (“Logseq”). In order to clarify the intellectual property license granted with Contributions from any person or entity, Logseq must have a Contributor License Agreement (“CLA”) on file that has been signed by each contributor, indicating agreement to the license terms below. This license is for your protection as a contributor as well as the protection of Logseq and its other contributors and users; it does not change your rights to use your own Contributions for any other purpose.

By clicking “Accept” on this page You accept and agree to these terms and conditions for Your past, present and future Contributions submitted to Logseq. In return, Logseq shall consider Your Contributions for addition to the official Logseq open source project(s) for which they were submitted. Except for the license granted herein to Logseq and recipients of software distributed by Logseq, You reserve al

@andelf
andelf / wch-isp.py
Last active May 5, 2022 18:36
WCHISPTool in python
#!/usr/bin/env python3
import usb.core
import usb.util
import struct
import random
def random_byte():
return random.randbytes(1)
@andelf
andelf / deepl.rs
Last active February 19, 2023 12:56
DeepL Rust command line
// https://zu1k.com/posts/thinking/deception-tactics-in-deepl-api-design/
@andelf
andelf / common.gypi
Created April 3, 2022 15:24
openssl_fips fix
{
'variables': {
'configuring_node%': 0,
'asan%': 0,
'werror': '', # Turn off -Werror in V8 build.
'visibility%': 'hidden', # V8's visibility setting
'target_arch%': 'ia32', # set v8's target architecture
'host_arch%': 'ia32', # set v8's host architecture
'want_separate_host_toolset%': 0, # V8 should not build target and host
'library%': 'static_library', # allow override to 'shared_library' for DLL/.so builds
@andelf
andelf / estimate_energy.py
Last active August 19, 2023 03:01
TRON estimate energy
#!/bin/env python3
import collections
import statistics
import sys
import requests
import base58
@andelf
andelf / parse_event.py
Created February 23, 2021 11:12
Parse TVM event
from tronpy import Tron
from tronpy.keys import keccak256
from pprint import pprint
client = Tron()
txn_id = 'e010654f48b5f94a4ea0305273bac3310b273979e1df61c8fd2334c52686ba6e'
txn_info = client.get_transaction_info(txn_id)
@andelf
andelf / README.md
Last active February 22, 2021 10:19
2-Step Random number for TRON(TVM)

Output

function currentRequestId() view returns (uint256 )
function fulfillRandomRequest(uint256 reqId) returns (uint256 )
function isRequestIdFulfilled(uint256 ) view returns (bool )
function randomResult(uint256 ) view returns (uint256 )
function requestRandom() returns (uint256 requestId)
Current reqId: 10
req_id: 11 rand: 2