View build-static-rust.sh
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
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-unknown-linux-gnu |
View equalizer.rs
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
/// Tower equaliser: givern list of tower heights return the minimum number | |
/// of moves required to obtain tower of the same height or return "No solution" | |
fn towers(t: &[u32]) -> Option<u32> { | |
let mut moves: u32 = 0; | |
let mut n = t.to_vec(); | |
let max_moves: u32 = n.iter().sum(); | |
loop { | |
let imax = match n.iter().enumerate().max_by(|&(_, x), &(_, y)| x.cmp(&y)) { | |
Some((m, _)) => m, | |
_ => usize::MIN, |
View 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
[package] | |
name = "rocket_reqw" | |
version = "0.1.0" | |
edition = "2021" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
rocket = "0.4" | |
serde = {version = "1", features = ["derive"]} |
View Task-based executor.cpp
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
// Author: Ugo Varetto | |
// Implementation of task-based concurrency (similar to Java's Executor) | |
// and wrapper for concurrent access | |
// g++ task-based-executor-concurrent-generic.cpp -std=c++11 -pthread | |
#include <algorithm> | |
#include <chrono> | |
#include <condition_variable> | |
#include <cstdlib> //EXIT_* |
View rust-reqwest-stream-example.rs
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
let offset = 20000; | |
let chunk_size = 10000; | |
// File handle: | |
let mut handle = BufReader::new(File::open("data.bin").await?); | |
// Set cursor to needed chunk: | |
let mut chunk_stream = handle | |
.bytes() | |
.skip(offset) |
View barrier.cpp
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
#include <chrono> | |
#include <condition_variable> | |
#include <iostream> | |
#include <thread> | |
class Barrier { | |
public: | |
Barrier(uint32_t count) : threadCount(count), counter(0), waiting(0) {} | |
void wait() { |
View vector_allocation.cpp
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
// Author: Ugo Varetto | |
// buffer allocation performance tests: vector, vector+pod allocator (same as | |
// vector), raw aligned buffer (faster) | |
#include <sys/mman.h> | |
#include <unistd.h> | |
#include <cstdlib> | |
#include <ctime> | |
#include <iostream> |
View pwcpp_mm.cpp
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
/******************************************************************************* | |
* BSD 3-Clause License | |
* | |
* Copyright (c) 2020, Ugo Varetto | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are met: | |
* | |
* 1. Redistributions inputFile source code must retain the above copyright |
View pwcp.cpp
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
/******************************************************************************* | |
* BSD 3-Clause License | |
* | |
* Copyright (c) 2020, Ugo Varetto | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are met: | |
* | |
* 1. Redistributions inputFile source code must retain the above copyright |