I hereby claim:
- I am conectado on github.
- I am conectado (https://keybase.io/conectado) on keybase.
- I have a public key ASC5R3Z3vZ2IYXcMA4Zot4wq2n2_yxNSh-JjBsb8Gc-6dQo
To claim this, I am signing this object:
use anyhow::Context; | |
use bytecodec::{DecodeExt, EncodeExt as _}; | |
use futures::{Future, FutureExt}; | |
use std::{ | |
collections::VecDeque, | |
net::{SocketAddr, ToSocketAddrs}, | |
pin::Pin, | |
task::{ready, Poll, Waker}, | |
time::{Duration, Instant}, | |
}; |
To efficiently calculate a ^ b I found this algorithm https://en.wikipedia.org/wiki/Exponentiation_by_squaring | |
Luckily (for me) I don't think the reasoning behind the algorithm is very well explained so I had the chance to think it over and I think I came up with a good way to explain it. | |
The most important concept behind the algorithm is decomposing "b" in a sequence of multiplication by 2: | |
So, given the binary representation of a number we recognize 2 operations left-shift and "put a 1 in the lsb". For any binary representation the first can be done by multiplying by 2, the second can be done by summing 1. | |
With this operations, we proceed like in a calculator, we start with 1, this being your msb, then you shift it to the left and "enter 1" if there is one in the second msb or shift again, then you do it again for the third digit and so on until you get all the digits. |
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0 | |
#![allow(unused_parens)] | |
#![allow(unused_imports)] | |
use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight}; | |
pub struct WeightInfo; | |
impl pallet::WeightInfo for WeightInfo { | |
fn on_initialize_first(i: u32, ) -> Weight { |
I hereby claim:
To claim this, I am signing this object:
body { | |
background-color: rgb(29,30,40); | |
} | |
.item-up { | |
background-color: rgb(189,215,238); | |
} | |
.item-down { | |
background-color: rgb(248,203,173); |
<body> | |
<div class="grid-wrapper"> | |
<div class="sub-grid-wrapper"> | |
<div class="item-up"> | |
</div> | |
<div class="item-up"> | |
</div> | |
</div> | |
<div class="sub-grid-wrapper"> | |
<div class="item-up"> |
A Pen by Gabriel Alejandro Steinberg on CodePen.
body { | |
background-color: rgb(29,30,40); | |
} | |
.item { | |
background-color: #3f4d72; | |
color: #7c5c48; | |
font-size: xx-large; | |
text-align: center; | |
font-weight: bold; |
body { | |
background-color: rgb(29,30,40); | |
} | |
.item { | |
background-color: #3f4d72; | |
color: #7c5c48; | |
font-size: xx-large; | |
text-align: center; | |
font-weight: bold; |
<body> | |
<div class="grid-wrapper"> | |
<div class="sub-grid-wrapper"> | |
<div class="item"> | |
1 | |
</div> | |
<div class="item"> | |
2 | |
</div> | |
</div> |