Skip to content

Instantly share code, notes, and snippets.

Avatar

Hero Bird Robbepop

View GitHub Profile
@Robbepop
Robbepop / print_counted.cpp
Created Jun 10, 2015
Variadic Templates playground
View print_counted.cpp
#include <iostream>
template<typename T>
void print_counted_acc(size_t acc, T head) {
std::cout << acc << ' ' << head << '\n';
}
template<typename T, typename... Args>
void print_counted_acc(size_t acc, T head, Args... tail) {
std::cout << acc << ' ' << head << '\n';
@Robbepop
Robbepop / explicit_types.cpp
Created Jun 17, 2015
Some helper user defined literals in order to improve syntax with an extensive use of uniform initialization.
View explicit_types.cpp
#include <cstdint>
#include <cstddef>
namespace explicit_types {
//====================================================================================
// Operator definitions for signed int types
//====================================================================================
constexpr auto operator"" _i8 (unsigned long long value) noexcept -> int8_t { return value; }
constexpr auto operator"" _i16(unsigned long long value) noexcept -> int16_t { return value; }
View index_range_sequence.rs
use std::rc::Rc;
use std::cell::Cell;
use std::cell::RefCell;
use std::ops::Add;
use std::ops::Sub;
use std::ops::Range;
use std::fmt;
@Robbepop
Robbepop / mult_replace.rs
Created Oct 24, 2017
How to replace multiplication by a constant with shift and add operations.
View mult_replace.rs
// Multiplication by a constant can be replaced by multiple shift and addition operations:
// The following table shows that for constants from 1 to 36.
//
// ============================================================================
// N | Factorized | # Ops | Ops with x as input
// ----------------------------------------------------------------------------
// 1 | 1 | 0 | x
// 2 | 2 | 1 | x << 1
// 3 | 2 + 1 | 2 | x << 1 + x
// 4 | 4 | 1 | x << 2
View simplification_bool_lowering.rs
use ast2::prelude::*;
use simplifier::prelude::*;
pub mod prelude {
pub use super::BoolReducer;
}
/// This simplification procedure dissolves symbolic tautologies or contradictions
/// for boolean expressions.
///
View keybase.md

Keybase proof

I hereby claim:

  • I am robbepop on github.
  • I am herobird (https://keybase.io/herobird) on keybase.
  • I have a public key ASAqEVoi9VO42oPAQHmY21kujCqXIk70xe2RkiwyyGAXhAo

To claim this, I am signing this object:

@Robbepop
Robbepop / ink-3.0-and-canvas-node-setup.md
Created Oct 14, 2020
Hot to setup ink! 3.0 and Canvas Node
View ink-3.0-and-canvas-node-setup.md

How to setup ink! 3.0 and Canvas Node

@Robbepop
Robbepop / ink-3.0-and-canvas-node-setup.md
Created Oct 14, 2020
Hot to setup ink! 3.0 and Canvas Node
View ink-3.0-and-canvas-node-setup.md

Hot to setup ink! 3.0 and Canvas Node

@Robbepop
Robbepop / const_eval_for_next_power_of_two.rs
Created Oct 25, 2020
Constant evulator for next_power_of_two in proc. macros.
View const_eval_for_next_power_of_two.rs
fn const_next_power_of_two(ty: TokenStream2, value: TokenStream2) -> TokenStream2 {
quote! {{
if (#value) <= 1 {
0
} else {
let p = (#value) - 1;
let z = p.leading_zeros();
<#ty>::MAX as usize >> z
}
}}
@Robbepop
Robbepop / 0: System
Last active Oct 26, 2020
Benchmarks of the modular_bitfield crate.
View 0: System
# System Specs
- Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
- 64-bit
- 16 GB Ram
- commit: 6f11920cc3c4936baf2581de17c02a843c069beb