shitposting 3.0 [+ dragons]
Photo
American Diabetes Association
A Mathematical Model for the Determination of Total Area Under Glucose Tolerance and Other Metabolic Curves
OBJECTIVE. To develop a mathematical model for the determination of total areas under curves from various metabolic studies.RESEARCH DESIGN AND METHODS. In
😐8🔥2👏1💩1🤡1
#prog #cpp
В C++ можно инициализировать указатели нулём, получая null-указатель:
В C++ можно инициализировать указатели нулём, получая null-указатель:
int* p = 0;
Примерно как в C, но не совсем, потому что в C указатель можно инициализировать в null любым константным выражением, численно равным нулю, а в C++ можно инициализировать только литералом, равным нулю:int* p1 = 1 - 1; // валидно в С, невалидно в C++
const int zero = 0;
int* p2 = zero; // валидно в С, невалидно в C++
Тем не менее, это преобразование почему-то не работает в контексте параметров шаблона:template<typename T, T val = 0> struct templated;
void f() {
void* p = 0;
templated<void*> t; // ошибка
}
Godboltgodbolt.org
Compiler Explorer
Compiler Explorer is an interactive online compiler which shows the assembly output of compiled C++, Rust, Go (and many more) code.
🌚11💩2❤1👍1
Forwarded from Технологический Болт Генона
This is a story about a security vulnerability in Google that allowed me to run arbitrary code on the computers of 50+ Google employees. Although Google initially considered my finding a serious security incident, later on, it changed its mind and stated that my finding is not, in fact, a vulnerability, but the intended behavior of their software.
Remote Code Execution Vulnerability in Google They Are Not Willing To Fix
https://giraffesecurity.dev/posts/google-remote-code-execution/
🤡20😁1💩1
Технологический Болт Генона
This is a story about a security vulnerability in Google that allowed me to run arbitrary code on the computers of 50+ Google employees. Although Google initially considered my finding a serious security incident, later on, it changed its mind and stated that…
#prog #itsec #article
Алсо:
Now, there are several options why Google did not think this is a problem and decided not to pursue fixing it:
<...>
* There is no actual risk associated with downloading these packages. Since I have not worked at Google, I do not know what are their security practices. It is possible that they run everything in isolated environments where the risk associated is extremely low. Nevertheless, the affected environments should still contain some information because they are not just plain OS installations with no data. There must be something there, like proprietary source code or proprietary inverted binary trees.
Алсо:
Now, there are several options why Google did not think this is a problem and decided not to pursue fixing it:
<...>
* There is no actual risk associated with downloading these packages. Since I have not worked at Google, I do not know what are their security practices. It is possible that they run everything in isolated environments where the risk associated is extremely low. Nevertheless, the affected environments should still contain some information because they are not just plain OS installations with no data. There must be something there, like proprietary source code or proprietary inverted binary trees.
👍8💩2
#prog #rust
github.com/rust-lang/rust/pull/106281
TL;DR: при активации фичей
github.com/rust-lang/rust/pull/106281
TL;DR: при активации фичей
#![feature(
generic_const_exprs,
transmute_generic_consts
)]
теперь можно вызывать transmute
между, например, следующими парами типов (где W
, H
и D
— обобщённые константные параметры типа usize
):[[u32; H]; W] <-> [[u32; W]; H]
[[u32; H]; W] <-> [u32; W * H]
[[[u32; D]; H]; W] <-> [u32; D * W * H]
[[[u32; D]; H]; W] <-> [[u32; D * W]; H]
[u16; L] <-> [u8; L * 2]
[u8; L] <-> [[u8; 1]; L]
[[u32; 2 * H]; W + W] <-> [[u32; W + W]; 2 * H]
GitHub
Add ability to transmute (somewhat) with generic consts in arrays by JulianKnodt · Pull Request #106281 · rust-lang/rust
Previously if the expression contained generic consts and did not have a directly equivalent type, transmuting the type in this way was forbidden, despite the two sizes being identical. Instead, we...
🔥8💩2❤🔥1
#prog #rust
На URLO Alice Ryhl подробно и при этом довольно коротко и ясно расписывает, для чего, собственно говоря, нужен Pin.
На URLO Alice Ryhl подробно и при этом довольно коротко и ясно расписывает, для чего, собственно говоря, нужен Pin.
The Rust Programming Language Forum
Pin tutorial are confusing me
From what I've gathered reading tutorials, an often repeated statement is Pin prevents an object from being moved. Just ctrl+f "move" at these turorials 1 2 3 4 and in the async book where it says Pinning makes it possible to guarantee that an object implementing…
❤3💩2
Блог*
#prog #rust #rustlib #article Kani — bit-precise model checker for Rust. Верификатор, который исполняет код символически и потому эффективно проверяет код на всех возможных входах. Если код (без внесения ограничений на работу kani) проходит проверку, то его…
#prog #rust #article
How Kani helped find bugs in Hifitime
Hifitime is a scientifically accurate time management library that provides nanosecond precision of durations and time computations for 65 thousand centuries in most time scales (also called time systems). It is useful wherever a monotonic clock is needed, even in the presence of leap second or remote time corrections (like for Network Time Protocol or Precise Time Protocol). It is suitable for desktop applications and for embedded systems without a floating point unit (FPU). It also supports the typical features of date time management libraries, like the formatting and parsing of date times in a
The purpose of this blog post is to show how Kani helped solve a number of important non-trivial bugs in hifitime.
How Kani helped find bugs in Hifitime
Hifitime is a scientifically accurate time management library that provides nanosecond precision of durations and time computations for 65 thousand centuries in most time scales (also called time systems). It is useful wherever a monotonic clock is needed, even in the presence of leap second or remote time corrections (like for Network Time Protocol or Precise Time Protocol). It is suitable for desktop applications and for embedded systems without a floating point unit (FPU). It also supports the typical features of date time management libraries, like the formatting and parsing of date times in a
no_std
environment using the typical C89 tokens, or a human friendly approximation of the difference between dates. For scientific and engineering applications, it is mostly tailored to astronomy (with the inclusion of the UT1 time scale), astrodynamics (with the ET and TDB time scales), and global navigation satellite systems (with the GPS, Galileo, and BeiDou time scales).The purpose of this blog post is to show how Kani helped solve a number of important non-trivial bugs in hifitime.
Kani Rust Verifier Blog
How Kani helped find bugs in Hifitime
Kani is a verification tool that can help you systematically test properties about your Rust code. To learn more about Kani, check out the Kani tutorial and our previous blog posts.
🔥2💩2
#prog #rust #article
Modular Errors in Rust
...If there’s one thing I wish for you to take away, it’s that error handling is hard, but it’s worth it to learn. Because I’m tired of having to deal with lazy kitchen-sink-type errors.
Modular Errors in Rust
...If there’s one thing I wish for you to take away, it’s that error handling is hard, but it’s worth it to learn. Because I’m tired of having to deal with lazy kitchen-sink-type errors.
Sabrina Jewson
Modular Errors in Rust
It is thankfully common wisdom nowadays that documentation must be placed as near as possible to the code it documents, and should be fine-grained to a minimal unit of describability (the thing being documented). The practice provides numerous benefits to…
💩4👍2
#prog #rust #article
Control flow patterns in Rust
Не слишком информативный пост для опытных Rust-программистов, но увидел любопытный паттерн для обхода отсутствия let-chains.
Именно, вместо
Control flow patterns in Rust
Не слишком информативный пост для опытных Rust-программистов, но увидел любопытный паттерн для обхода отсутствия let-chains.
Именно, вместо
let deadline = if let Some(settings) = self.settings {
if let Some(deadline) = settings.deadline {
if settings.deadline_override && deadline > 0 {
deadline
} else {
self.default_deadline
}
} else {
self.default_deadline
}
} else {
self.default_deadline
};
можно воспользоваться labeled block break и написатьlet deadline = 'done: {
if let Some(settings) = self.settings {
if let Some(deadline) = settings.deadline {
if settings.deadline_override && deadline > 0 {
break 'done deadline;
}
}
}
self.default_deadline
};
symbolica.io
Symbolica – Control flow patterns in Rust
👍8💩6🤯2😍1
Блог*
#prog #rust #article Control flow patterns in Rust Не слишком информативный пост для опытных Rust-программистов, но увидел любопытный паттерн для обхода отсутствия let-chains. Именно, вместо let deadline = if let Some(settings) = self.settings { if…
А ещё там есть пример для эмуляции for-else из Python, но этот пример лишь лишний раз укрепил меня во мнении, что эта языковая конструкция попросту не требуется в языке с достаточно продвинутыми итераторами.
К примеру, оригинал на Python:
К примеру, оригинал на Python:
items = [3,5,7,11,13,17]
item = 19
location = None
for i, x in enumerate(items):
if x == item:
location = i
break
else:
# break was not triggered
location = len(items)
items.append(item)
и его переделка на Rust, предложенная автором:let mut items = vec![3,5,7,11,13,17];
let item = 19;
let location = 'find_item: {
for (i, x) in items.iter().enumerate() {
if *x == item {
break 'find_item i;
}
}
// only reached when not breaking
items.push(item);
items.len() - 1
};
На мой взгляд, с использованием итераторов Rust это можно записать более кратко без потери выразительности:let location = match items
.iter()
.position(|&x| x == item)
{
Some(idx) => idx,
None => {
let idx = items.len();
items.push(item);
idx
}
};
👍8💩3❤🔥1🔥1
Fun fact: std::derived_from из C++ не имеет никакого отношения к derive-макросам из Rust
💩6🥴3
Forwarded from Ебучий случай
В последние 2 года регулярно слышу "ой, ну я не верующий, я не могу есть куличи".
Да ну вы чего!! Вас забуллила бабка у церкви или в твиттере кто-то предъявил? Раньше не было такой ерунды.
Не позволяйте никому встать между вами и вкусной сдобой с цукатами! Мы живем в прекрасное время, когда от любого праздника, традиции или обряда можно брать только ту часть, которая вам нравится, и не погружаться в детали, если не хочется. Единственная уместная куличиковая полиция - это та, которая ходит и раздает всем куличи, а не запрещает их есть.
Всем вкусных булок и нарядных яиц!
Да ну вы чего!! Вас забуллила бабка у церкви или в твиттере кто-то предъявил? Раньше не было такой ерунды.
Не позволяйте никому встать между вами и вкусной сдобой с цукатами! Мы живем в прекрасное время, когда от любого праздника, традиции или обряда можно брать только ту часть, которая вам нравится, и не погружаться в детали, если не хочется. Единственная уместная куличиковая полиция - это та, которая ходит и раздает всем куличи, а не запрещает их есть.
Всем вкусных булок и нарядных яиц!
👍24🤡4❤2💩1
Это, конечно, нужно быть большим оригиналом, чтобы инсценировать свои смерть, воскрешение и вознесение на небо только ради того, чтобы избежать призыва.
😁8💩3🤡2
#prog #rust #article
Writing a Fast C# Code-Search Tool in Rust
Экскурс в использование зависимостей в Rust /hj
В итоге, впрочем, инструмент вышел на порядок быстрее Roslyn.
Writing a Fast C# Code-Search Tool in Rust
Экскурс в использование зависимостей в Rust /hj
В итоге, впрочем, инструмент вышел на порядок быстрее Roslyn.
John Austin
Writing a Fast C# Code-Search Tool in Rust — John Austin
When I began learning Rust, I had several expectations. I figured that I would be a little less productive writing code, in exchange for memory safety and C-like performance. What I did not expect, was that I would actually be more productive writing…
💩1
А вы тоже постоянно покупаете новые резинки и заколки для волос, которыми потом не пользуетесь, или вы нормальные?
🥴13😁5💩2🤡1