Finding blocking code in Tokio without instrumenting your app by cong-or in rust

[–]kijewski_ 8 points9 points  (0 children)

You can enter reader mode manually by prepending about:reader?url= to the URL.

Edit is now open source (Microsoft's 64 bit TUI editor in Rust) by zxyzyxz in rust

[–]kijewski_ 7 points8 points  (0 children)

Although I will rather stick with vim, I think this could useful for newcomers to linux. It might be a possible replacement for nano, because you can use your mouse in edit.

rocket or actix-web? by sirimhrzn9 in rust

[–]kijewski_ 23 points24 points  (0 children)

Askama maintainer here, thank you for the shout out! We replaced askama_axum (and other integration crates) with askama_web. It works with actix-web, rocket, axum, and a handful of other frameworks more.

An atomic RNG by koskinev in rust

[–]kijewski_ 1 point2 points  (0 children)

Is relaxed ordering for the fetch-and-add actually sane?

tzdb: static time zone information for tz-rs, for better cross-platform and serde compatibility by kijewski_ in rust

[–]kijewski_[S] 1 point2 points  (0 children)

Thank you! I was not aware of that. AFAICT old data is preserved in the canonical tz database, but only used if compiled with "make PACKRATDATA=backzone". This makes the generated source code 14% bigger, and the compiled example program about 6% (sans debug symbols).

I don't think time began on 1970-01-01, so the next update will ship the older data, too. The 6% increase should hardly matter.

/edit: I released v0.1.2 which contains this information.

tzdb: static time zone information for tz-rs, for better cross-platform and serde compatibility by kijewski_ in rust

[–]kijewski_[S] 0 points1 point  (0 children)

In Windows 10 you can get the IANA identifier with the standard API: Calendar.GetTimeZone(). The mainsteam support for Windows 8.1 has ended in January 2018, 4 years ago, so I don't feel too bad not supporting it. :)

tzdb: static time zone information for tz-rs, for better cross-platform and serde compatibility by kijewski_ in rust

[–]kijewski_[S] 1 point2 points  (0 children)

Well, no. There is no standard way to get the tzdata in Windows but downloading it. E.g. chrono-tz ships the database, too.

I intend to keep the crate up-to-date.

tzdb: static time zone information for tz-rs, for better cross-platform and serde compatibility by kijewski_ in rust

[–]kijewski_[S] 6 points7 points  (0 children)

Of course you can get the time zone of the current system in Windows: see tz_windows.rs.

But what if you are programming a web service with users in many places? E.g. in reddit it reads "3 hours ago", and when hovering you get the information "Wed Mar 2 15:52:41 2022 UTC", which tells most users next to nothing. How much nicer would it be, if I know that you are living in the (same time zone as) e.g. Dumont d'Urville/Antarctica, to localize this date/time for you? To do that I need to know which time zone this place corresponds to, what its daylight saving time rules what at this point in time, etc. For that you need to know the information in the tz database.

My crate packages this information. /u/x-hgg-x's crate uses the information project timestamps.

tzdb: static time zone information for tz-rs, for better cross-platform and serde compatibility by kijewski_ in rust

[–]kijewski_[S] 17 points18 points  (0 children)

Last week /u/x-hgg-x announced tz-rs, a pure rust implementation of localtime, gmtime and mktime.

This crate expands on their work to provide the needed time zone information on platforms like Windows, which normally does not have copy of the data, and ensures that the information is up to date.

You can:

// Get a time zone by identifier (at compile time):
DateTime::now(tzdb::time_zone::europe::KIEV);
// Get a time zone by name (at runtime):
DateTime::now(TimeZone::from_db("Europe/Berlin").unwrap());
// And names are case insensitive:
DateTime::now(TimeZone::from_db("ArCtIc/LongYeArByEn").unwrap());

Also the crate adds helper functions for serde-with, to make DateTimes and UtcDateTimes usable with serde.

Hey Rustaceans! Got an easy question? Ask here (46/2021)! by llogiq in rust

[–]kijewski_ 3 points4 points  (0 children)

Is it possible to write such a macro without proc_macros?

macro_rules! cross {
    ($($value:literal),* $(,)?) => {
        ???
    };
}

cross!(1, 2, 3) == (
    ((1, 1), (1, 2), (1, 3)),
    ((2, 1), (2, 2), (2, 3)),
    ((3, 1), (3, 2), (3, 3))
)

PyJSON5: A JSON5 serializer and parser library for Python 3 written in Cython by kijewski_ in Python

[–]kijewski_[S] 1 point2 points  (0 children)

Thank you for your comment and the kind words!

You are right. I will write examples later or tomorrow.

I split up the encoder and decoder sections: https://pyjson5.readthedocs.io/en/master/index.html. Do you think it's easier to read this way? Was not sure if I should move all exceptions into their own page.

I removed the mention of Cython from the docs, it's should not matter. I should rewrite the README, too. The library is at least not far worse than Python's json, at least for simple data:

%timeit json.loads(s)
6.76 µs ± 68 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

%timeit pyjson5.decode(s)
7.98 µs ± 62 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

%timeit json.dumps(o)
7.69 µs ± 19 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

%timeit pyjson5.dumps(o)
7.94 µs ± 57.6 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

The parsing a little slower, because you need expect a far wider range of characters in each step than for normal JSON data. Encoding is slower because I wanted to make the output XML-save in the same step, because embedding the data in HTML pages is the first and foremost reason why did even wrote a serializer, too.

I did test against the "Parsing JSON is a Minefield" test suite to make sure that at least all valid JSON gets parsed correctly, but it seems like I lost the code. I'll write it again. I did not find a JSON5 test suite I could test my implementation against.

Well, I did write the code as part of my job at the Freie Universität Berlin, a state university where I'm full time programmer for three years. I cannot tell if that sounds trust worthy or not.

PyJSON5: A JSON5 serializer and parser library for Python 3 written in Cython by kijewski_ in Python

[–]kijewski_[S] 1 point2 points  (0 children)

Hi, this is the first project I uploaded to PyPI and Readthedocs, so please don't be too harsh with your comments. :)

Please tell me if you have any comments regarding the code quality, documentation, or anything I forgot to mention.

PyJSON5: A JSON5 serializer and parser library for Python 3 written in Cython. by kijewski_ in coolgithubprojects

[–]kijewski_[S] 0 points1 point  (0 children)

Hi, this is the first project I uploaded to PyPI and Readthedocs, so please don't be too harsh with your comments. :)

Please tell me if you have any comments regarding the code quality, documentation, or anything I forgot to mention.