Skip to content

Instantly share code, notes, and snippets.

import com.datastax.driver.core.exceptions.NoHostAvailableException;
import io.lettuce.core.RedisCommandExecutionException;
import org.slf4j.Logger;
import java.util.concurrent.Callable;
public class ExponentialBackoff {
private final long delay;
private final long maxAttempts;
private final Logger logger;
@DoumanAsh
DoumanAsh / CassandraHealthImpl.java
Last active December 2, 2020 03:20
Simple cassandra health monitoring using v4 driver
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
import com.datastax.oss.driver.api.core.config.DriverConfigLoader;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@DoumanAsh
DoumanAsh / keys
Last active May 23, 2022 09:26
Optimal keys for Squares RNG v1
0xc58efd154ce32f6d,
0xfcbd65e54bf53ed9,
0xea3742c76bf95d47,
0xfb9e125878fa6cb3,
0x1ebd294ba7fe8b31,
0xf29ba87dc5f1a98d,
0x815a7e4ed4e3b7f9,
0x63acbfe213f5d867,
0x67e2d1b542f9e6d3,
0x682ec13872ecf651,
///Describes Executor configuration
pub trait ExecutorConfig {
///Function to call when exectur goes to sleep.
fn on_sleep(&mut self) {
#[cfg(not(feature = "std"))]
core::sync::atomic::spin_loop_hint();
#[cfg(feature = "std")]
std::thread::yield_now();
}
error: internal compiler error: src\librustc_mir\transform\generator.rs:532: Broken MIR: generator contains type std::option::Option<http::header::HeaderValue> in MIR, but typeck only knows about for<'r> {&'r client::Client<C>, client::request::Request, usize, http::Method, http::Uri, http::HeaderMap, std::option::Option<bytes::Bytes>, hyper::client::ResponseFuture, futures_util::future::map::Map<futures_util::compat::compat01as03::Compat01As03<hyper::client::ResponseFuture>, [closure@src\client\mod.rs:233:80: 233:131]>, fn(std::result::Result<client::response::Response, hyper::Error>) -> std::result::Result<<std::result::Result<client::response::Response, hyper::Error> as std::ops::Try>::Ok, <std::result::Result<client::response::Response, hyper::Error> as std::ops::Try>::Error> {<std::result::Result<client::response::Response, hyper::Error> as std::ops::Try>::into_result}, ()}
--> src\client\mod.rs:217:86
|
217 | pub async fn redirect_request(&self, mut req: request::Request) -> RequestResult {
@DoumanAsh
DoumanAsh / config
Created May 14, 2019 08:47
ssh config for multiple keys to the same host (e.g. github)
# Personal GitHub account
Host github.com
HostName github.com
User git
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
# Work GitHub account
Host github.com-work
HostName github.com
error[E0282]: type annotations needed
--> src\multi.rs:158:5
|
158 | / fn spawn(self) where Self: 'static + Future<Item=(), Error=()> + Send {
159 | | spawn(self);
160 | | }
| |_____^ cannot infer type
impl<F: Send + 'static + Future<Item=I, Error=E>, I: Send + 'static, E: Send + 'static> AutoRuntime for F {
#[inline]
fn finish(self) -> Result<Self::Item, Self::Error> {
block_on(self)
}
#[inline]
fn spawn(self) where Self: 'static + Future<Item=(), Error=()> + Send {
spawn(self);
}
///Trait to bootstrap your futures.
pub trait AutoRuntime: futures::Future {
///Runs futures to completion.
///
///## Note
///
///It must not be used from within async context
#[cfg(not(feature = "multi"))]
fn finish(self) -> Result<Self::Item, Self::Error>;
#[cfg(feature = "multi")]
pub trait UnaryPredicate<T> {
#[doc(hidden)]
fn call(&self, val: &T) -> bool;
}
impl<T: PartialEq> UnaryPredicate<T> for T {
#[inline(always)]
fn call(&self, val: &T) -> bool {
self == val
}