#!/bin/bash
# Generate some test certificates which are used by the regression test suite:
#
# tests/tls/ca.{crt,key} Self signed CA certificate.
# tests/tls/redis.{crt,key} A certificate with no key usage/policy restrictions.
# tests/tls/client.{crt,key} A certificate restricted for SSL client usage.
# tests/tls/server.{crt,key} A certificate restricted for SSL server usage.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dict | |
let mut dict_file = | |
std::fs::File::open("dictionaryFile").unwrap(); | |
let mut dict = Vec::new(); | |
dict_file.read_to_end(&mut dict).unwrap(); | |
// compress | |
let mut enc_buf = [0; 1_000_000]; | |
let encoder_dict = zstd::dict::EncoderDictionary::copy(&dict, 0); | |
let mut compressor = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// See https://w3c.github.io/trace-context-binary/#de-serialization-of-traceparent | |
fn parse_traceparent(bytes: &[u8]) -> Result<SpanContext, &'static str> { | |
if bytes.len() != 29 { | |
return Err("Invalid traceparent length. Must be 29 bytes."); | |
} | |
if bytes[0] != 0 { | |
return Err("Unsupported traceparent version."); | |
} | |
if bytes[1] != 0 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn amain() { | |
use std::{ | |
future::poll_fn, | |
pin::Pin, | |
task::{Context, Poll}, | |
}; | |
use tokio::sync::mpsc; | |
let (tx, mut rx) = mpsc::channel(100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Subscribe to any acount changes to Pyth SOL/USDC account (H6AR...QJEG): | |
This requires websocat - `brew install websocat` | |
```bash | |
echo '{"id":1,"jsonrpc":"2.0","method":"accountSubscribe","params":["H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG",{"encoding": "jsonParsed"}]}' | websocat --no-close "wss://internal.ny.mainnet.rpc.jito.wtf/?access-token=XYZ" | |
``` | |
Output | |
``` | |
{"jsonrpc":"2.0","method":"accountNotification","params":{"result":{"context":{"slot":240142003},"value":{"lamports":23942400,"data":["1MOyoQIAAAADAAAA8AwAAAEAAAD4////GgAAABcAAAC0RlAOAAAAALNGUA4AAAAAGAudTAIAAAB/ZvSRAAAAAJ08zJMAAAAAFUKKAAAAAAAc++qFAAAAAJ08zJMAAAAAUNSYZQAAAAADAAAAAAAAAIqwPP8YRKuXXc3RaDAgwFmfxTkrby4S1d1hW8wsLm0IAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACzRlAOAAAAAHT4GUsCAAAA6daTAAAAAABP1JhlAAAAAHT4GUsCAAAA6C6NAAAAAAABAAAAAAAAALRGUA4AAAAAB/LLOf2wKdxReE0o7xeRHZfBppyFcjobYlWzQlNDrXUNzhRLAgAAAKBnWgMAAAAAAQAAAAAAAACeRlAOAAAAAA3OFEsCAAAAoGdaAwAAAAABAAAAAAAAAJ5GUA4AAAAAnz6le9QJugDEDZKuVxNBwn48L37frOHCSlGxoVwxsregsyJLAgAAAAJjkgMAAAAAAQAAA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local keys = redis.call('KEYS', ARGV[1]); | |
if next(keys) == nil then return keys end; | |
local chunk_size = 4096; -- must be under 8k, see https://github.com/nhibernate/NHibernate-Caches/issues/62 | |
local n = #keys; | |
local out = {}; | |
for i=1,n,chunk_size do | |
local unpack_start = i; | |
local unpack_end = math.min(n, i + chunk_size - 1); | |
local vals = redis.call('MGET', unpack(keys, unpack_start, unpack_end)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::thread::sleep; | |
use std::time::{Duration, Instant}; | |
use redis::{AsyncCommands, ConnectionLike, RedisResult}; | |
use tokio::time::timeout; | |
use futures::StreamExt; | |
use futures_util::Stream; | |
/* Cargo.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat file.csv | sqlite3 demo.db ".import --csv '|cat -' mytable"; sqlite3 demo.db |
import "array"
array.from(rows: [
{_time: 2021-01-01T00:00:00Z, _value: "foo"},
{_time: 2020-01-02T00:00:00Z, _value: "bar"}
])
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use rustls; | |
let roots = rustls::RootCertStore::empty(); | |
let mut tls = rustls::ClientConfig::builder() | |
.with_safe_defaults() | |
.with_root_certificates(roots) | |
.with_no_client_auth(); | |
tls.key_log = Arc::new(rustls::KeyLogFile::new()); | |
let client = Arc::new( |
NewerOlder