1.84K subscribers
3.4K photos
134 videos
15 files
3.65K links
Блог со звёздочкой.

Много репостов, немножко программирования.

Небольшое прикольное комьюнити: @decltype_chat_ptr_t
Автор: @insert_reference_here
Download Telegram
Forwarded from Кіт ✙ без шляпи🇺🇦
> how to trim string in go

You do not cut strings in hurry, just stop and trim them
👍71
> how to trim string in java

Just like in every other country, I guess. I mean, I didn't hear that cutting strings there is prohibited by law
👍81
> how to trim string in haskell

Firstly, they are called tendons, not strings. Secondly, leave messing with body to professional surgeons
👍51😁1
> how to trim string in c#

Put on glasses
5😁2
Forwarded from TechSparks
Гугл приготовил не очень приятный сюрприз для всяких быстро обученных аналитиков, которых выпускают курсы и буткемпы. Основное умение такого аналитика, как правило, состоит в том, что он(а) может покрутить данные в разных опенсорсных моделях и выявить, например, аномалии или сформулировать простейшие предсказания. Без минимальных навыков программирования это невозможно, и именно эти навыки и продаются.
Но вот Гугл начал интегрировать возможности своего TensorFlow прямо в Sheets, называется это очень адекватно SimpleML. Теперь имея таблицу данных, можно безо всякого программирования напустить на данные машинное обучение, и простейшие его результаты получить не покидая Sheets.
Everything runs completely on the user browser. Your data doesn’t leave Google Sheets and models are saved to your Google Drive so you can use them again later.
И, похоже, это только начало: наверняка и более сложные сценарии тоже в итоге в таблицы интегрируют. Очень впечатляющая и реально полезная реализация no code подхода. https://venturebeat.com/ai/google-brings-machine-learning-to-online-spreadsheets-with-simple-ml-for-sheets/
#prog #rust

Посмотрим вот на этот код:

async fn fail<'a, 'b, 'c>(_: &'static str)
where
'a: 'c, 'b: 'c,
{}

async fn pass<'a, 'c, 'b>(_: &'static str)
where
'a: 'c, 'b: 'c,
{}


Отличаются эти две функции, помимо названия, лишь порядком лайфтаймов в определении. Тем не менее, проверка показывает, что вторая функция компилируется, а первая — нет.

Это — баг компилятора. К счастью, фикс есть, надеюсь, скоро смержат.
👍8🤔3🔥1🤯1
#prog #rust #article

Self-referential types for fun and profit

<...>Contrary to usual answers, this will show how to create self-referential types manually. A very important subset of such types are straightforward to reason about and, most importantly, can be manipulated through a safe interface. We will not rewrite the borrow checker, we will not use std::pin, but we will use a bit of unsafe. You’ve been warned.
1
#prog #parsing #rust #article

Parsing numbers into base-10 decimals with SIMD

When parsing number-dense JSON, much of the overhead is parsing numbers instead of parsing the JSON itself. For the typical case, most of the overhead within number parsing is converting into a form mantissa * 10^-exponent, not transforming into a proper floating point value.

Looking through high-quality number parsers such as rust_decimal’s or simd_json’s, they tend to avoid SIMD or only use it after ensuring there’s a long enough series of decimal characters. They also don’t support parsing in batches and concern themselves with problems like

* How do I avoid reading off the end of the number?
* How can I give precise error messages?
* How do I handle extremely long decimals?
* How do I handle separators?

In realistic parses, most of the above never apply! Invalid data is rare, long numbers are rare, weird separators are rare, and most numbers aren’t at the end of a buffer (with padding, none are). We can relax the above constraints and get something friendlier to a SIMD implementation. First, we assume:

1. All inputs have an extra 16 bytes of data off the end
2. Precise error reporting is not required
3. Inputs are not longer than 16 bytes
4. Inputs only contain digits and potentially 1 ‘.’
5. The sign is already processed (it’s just a simple check and pointer adjustment)
6. Optionally, we can parse many numbers at once

While these restrictions appear limiting, they’ll handle almost all actual cases, and a fallback can take the rest. With these considerations, we can go about writing a vectorized parser.

<...>

The elephant in the room is figuring out if this optimized parser is faster in real-world settings. It’s one thing to be faster in a very tight microbenchmark loop; replicating performance improvements in production is more challenging. Microbenchmarks can exacerbate coincidental interactions with microarchitecture that wouldn’t be relevant in the real world. Especially in parsing, there’s lots of complex, branchy, unpredictable surrounding code that complicates an otherwise clean sequence of instructions.

I’m experimenting with adding this to the rust port of simd-json, and adding unsafe fast-path parsers to rust_decimal. Hopefully we’ll see the desired real-world gains!
🔥1
Forwarded from dev optozorax
Онигири придумал и сделал волновую симуляцию света на основе клеточных автоматов. В итоге получаются очень красивые и графонистые картинки распространения света. Настолько простых и качественных симуляций света я раньше не видел.

https://www.youtube.com/watch?v=noUpBKY2rIg

Там же там есть связанное видео про радугу от Макара Светлого, тоже рекомендую заценить.

А ещё он опубликовал код, который прямо в браузере рисует это на шейдерах через видеокарту, можете зайти с компа или телефона: onigiriScience/71.
2❤‍🔥1
Forwarded from Код, коты и карандаш
— Почему из хаскелистов получаются хорошие супруги?
— Они не умеют изменять.
🔥25😁9
#rust #video

The Death and Rebirth of Docs.rs

Fun fact: ввиду особых потребностей docs.rs пришлось в какой-то момент использовать кастомный форк rustdoc — и так как это, по сути, часть компилятора, фактически кастомный форк компилятора — и за промежуток больше года, в течение которого использовался этот форк, изменения подтягивались из апстрима всего семь раз (включая финальный, когда нужные изменения приняли в апстрим и содержать кастомный форк более не было необходимости)
🤔1
Не, ну это шикарно, ящитаю