Skip to content

Instantly share code, notes, and snippets.

@staticgc
staticgc / update_sshkey_vmss.sh
Created December 1, 2022 17:31
Update ssh key to azure vm scale set
if [ $# -lt 2 ]; then
echo "$0: <resource group> <pub key file>"
echo "Optional: you can generate ssh key pair using:
'az sshkey create --name <key name> --resource-group <resource group name>'"
exit 1
fi
rg=$1
pubkey=$2
@staticgc
staticgc / error.rs
Last active February 26, 2021 03:53
Clonable Error in Rust
use std::sync::Arc;
#[derive(Clone, Debug)]
pub enum Error {
pub kind: Arc<ErrorKind>,
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match *self.kind {
@staticgc
staticgc / conn.rs
Created January 30, 2021 06:31
Bandwidth control in hyper
use std::task::{Context, Poll};
use std::pin::Pin;
use hyper::client::{connect::{Connection, Connected}};
use tokio::net::{TcpStream};
use tokio::io::{ReadBuf, AsyncWrite, AsyncRead};
use async_speed_limit::{limiter::{Limiter, Consume}, clock::{StandardClock}};
use futures_util::future::Future;
//use anyhow::Error;
use std::io::Error;