« first day (1801 days earlier)      last day (1691 days later) » 
07:00 - 11:0011:00 - 21:00

11:00 AM
(It's not actually random, it's the lowest control point in the UTF-8 list, but still)
 
In my opinion almost all function should return an error, push() odesn't because "???" and this is why sometime std of rust sucks
push should return a Result
but as always people would say to me "it's annoying to use"
well no
 
@Stargateur I would. This looks excessive as you don't fall into problems with correct data
you push garbage, you get garbage. That's OK
 
@DenysSéguret meh!
so I want a push_stargateur_version()
 
We have checked functions for this kind of purpose
imho the simplest would be to chuck out unchecked typecasts from u8 to char
 
A panic maybe, if there's no runtime cost, but not a result.
 
11:03 AM
since that's where it happens
u32 to char is fair game
this allows people who still want the world to burn to typecast u8 to u32 and then char that
 
@SébastienRenauld there should be a checked way to do the cast, yes. I guess there is one and I didn't see it
 
There isn't, checked
the way you can do this the "safe" way is from_utf8() into append
 
String::push doesn't produce invalid UTF8 so I think it's fine
 
I think it's fine too
 
garbage input, garbage output. But no UB
 
11:06 AM
But I also think we're lacking utilities to deal with mono-byte chars. Probably because that would be abused so much...
 
in this day and age monobyte chars make very little sense
 
You mean a constrained u8?
 
people will just switch back to u8 for this
 
I know I'm annoyed when I want to check the first char of a string after I've already checked it's one byte
 
and do the checks themselves if they want strict ASCII
 
11:07 AM
pub struct Ascii(u8); ....
 
Wasn't there a brilliant article about this last week?
 
@SébastienRenauld link?
 
My frequent use case: I've made a check somewhere my string starts with, for example, \d. Now, later on in the algorithm, I want to test whether it's a 7. It's painful
 
trying to find it back
Found it
Enjoy the brainfuck: hsivonen.fi/string-length
 
Oh, I saw that
 
11:09 AM
I'll look at it later... I must work sometimes
 
realizing this is on the same level as all the datetime untruths developers take for granted until they run into them
 
@SébastienRenauld I ran into leap-seconds issues last week
 
Which version of leap-seconds
that's the real question
 
Well... it was more from the perspective of what do we want to happen
 
I've gotten my ass handed to me on production systems by all three versions of it (the "skip a second" the version, the "make some seconds shorter" version and the "go back one second" version)
the second one is the worst
 
11:11 AM
@SébastienRenauld dates are much simpler than unicode too. If you go deep into Unicode, there's absolutely no way to have anything correct ^^
 
Basically, we present trade summary data that can be used to draw a candlestick chart. A candle can be for various time periods: 1m, 3m, 5m,..
 
24:12:34 is a invalid time.
 
@SébastienRenauld all this is simple.
 
that can be valid time
 
11:12 AM
THe problem with dates is there's administration to do. For example to ensure you have up to date Olson tables (which no browser does)
 
The question is: do we want all 1m candles to be exactly 60 seconds in duration. Or... do we want each candle to start on an exact minute (0 seconds)
 
Been bitten by that one @PeterHall
 
Or.. do we want each candle to start on an exact 60 second multiple from the epoch
 
For optimization purposes I bucketed by 5s increments
and then took 12 buckets
 
calendar, in short, creation of 10000 years of completely differente civilizations merge together.
 
11:13 AM
it's easy to justify to a client, it's easy to justify for performance reasons, it allows pre-computing - everybody wins
 
The problem with dates is mostly the users. Who think they know what a date is and who don't understand we need precision about their timezones in order to give them the list of products of the day
 
The best is when they tell you CEST as a timezone
 
My approach was to work out which is the least likely for a user to evaluate the data themselves and tell us something is wrong.
 
as if that shit is constant
 
DST dates occasionally change
 
11:15 AM
Exactly
 
@SébastienRenauld ahhhhhhhhhhhh* this should be illegal
 
And central european time and DST don't mix
some countries swap DST earlier than others in that TZ
 
I had to make a library to try guess the timezone of the user in the browser
 
UTC or UTC or UTC
 
I answered a question on this for chrono a short while back
UTC means nothing
UT0 or UT1
 
11:16 AM
@Stargateur ÚTÇ
 
@SébastienRenauld they're near enough for most my users
 
The CEST example isn't though
 
I have stood on the Greenwhich meridian a few times and checked GPS. It is in accurate by about 50 metres
on either side
 
11:17 AM
@Stargateur short version, UT0 is what you know as UTC, sort of
UT1 is sidereal time
by convention they stay within 1s of each other
 
@SébastienRenauld I think you wrong
> The compromise that emerged was UTC,[9] which conforms to the pattern for the abbreviations of the variants of Universal Time (UT0, UT1, UT2, UT1R, etc.).[10]
 
That's the first time I see UT1R...
 
Holy shit that correction for UT1R
So UT1R is universal time based on angular velocity of the earth
 
OK... this doesn't apply to my applications...
 
It applied to one of mine
Well, it still applies but the project is mothballed because "we don't sell solutions"
the best I've ever had was people justifying that ISO8601 with microseconds was enough to be able to calculate microsecond differences between timestamps generated on different systems
convincing people that it was possible but not accurate was an actual splitting headache
(The application that required those timestamps required that level of precision)
Since there was no way to guarantee what hardware people were using as well, there were interesting cases with people using gpsd to sync time
 
11:23 AM
you mean you take the microsecond timestamp given by different systems and you compare them ?
 
and you'd randomly get 100ms skews once in a while thanks to a gps correction taking place
That's a very big simplification but you're not far off the mark
RF multilateration
i.e. I get different, supposedly highly correlated timestamps of reception of a radio signal and work out a position of the emitter from them
 
I have a rule "never trust any timestamp except monotonic clock"
 
Never trust a timestamp if you do not know exactly what fucks with the time source
if you have full control over the entire stack it's a different story
and by stack I really mean the entire machine - see the gpsd behind the hood "I'm going to skew you by 100ms" example
 
@SébastienRenauld this never happen ^^
 
Depends what kind of project you're on
but yeah, the moment your project uses commodity devices you're essentially fucked
 
11:37 AM
I don't even understand the question. It is done exactly the same way as in python
 
I vote to close this question until OP actually tries something.
 
It doesn't even need regex: play.rust-lang.org/…Peter Hall 54 secs ago
haha, you are trolling ?
 
@PeterHall with the quality trolls
What in the hell is happening
rust 1.32 only supports crypto 0.0.2
getting sha1 hashes for websocket handshakes will be fun
 
@SébastienRenauld wut ? I don't think rust claim to support anything from crypto
 
11:47 AM
I know, I'm just really surprised it went this far back
 
I don't understand
provide a link please !
 
A regex isn't really needed, itertools can do the job: docs.rs/itertools/0.8.0/itertools/…
 
Is that new user also trolling?
Ah, new user found this via not .
 
@FrenchBoiethios or a simple loop on chars()...
 
@DenysSéguret I'm lazy, don't u?
 
11:52 AM
I don't even see why someone would want to parse "42by4"
if letter doesn't matter it's make no sense to me
look like a homework
 
The OP has done an effort now
 
Yeah. I don't want to answer, it's really not interesting, but I wouldn't mind if somebody tries to be "welcoming"
 
He added an attempt
 
12:17 PM
@SébastienRenauld It's not a great effort. But I answered anyway
I was feeling some remorse about trolling
 
Holy shit the space outside of crypto is dark and full of terrors
crate #1: https://crates.io/crates/sha1
crate #2: https://crates.io/crates/sha-1
but wait, sha-1 before 0.6 was sha_1 as an extern, after it was sha1, thus colliding with the other one
different signatures
and one of them does not compute sha1 hashes properly
 
Is there a mean to have the same code for &'_ i32 and i32 as implementor when i32 is refered as self? I tried (&self).deref() but it does not work. Any other trait?
 
@FrenchBoiethios I don't quite follow what you're asking
 
@PeterHall I'll ask a real question, wait for it
 
You want a function that can take either a i32 or a &i32 as argument?
 
12:33 PM
@FrenchBoiethios There's a common pattern of adding a blanket implementation of a trait for all &T where T: Trait.
If applicable, of course.
 
@E_net4 I'll see
@E_net4 But it prevents downstream to provide one's own implementation for a T and &T
I'd prefer not to do that
Eh, it works with borrow :)
 
Does it work with other numeric types, like nonnull?
And what about the orphan rules?
People cannot add ones own implementation after that, can they?
 
12:50 PM
This is such a fucking newbie trap
Is there a way to flag a crate as garbage?
I literally spent an hour going "WTF is going on?" only to realize the crate had a false implementation of sha1
1M downloads BTW
 
@SébastienRenauld Does it return false values ? Are there no test units ?
 
You mean the result of hashing a slice of bytes isn't the right one ? How can this go unnoticed ?
 
@PeterHall Thank you so much, that's clever! I should ask a question, so that you can earn some merited sweet points
 
12:53 PM
this is what I mean
 
But the test units...
 
hashing foobar yields ODg0M2Q3ZjkyNDE2MjExZGU5ZWJiOTYzZmY0Y2UyODEyNTkzMjg3OA== with that lib
 
@FrenchBoiethios haha ok
 
should yield iEPX+SQWIR3p67lj/0zigSWTKHg=
A drop-in replacement (sha-1) works with signature changes
so evidently it's not the wrong bytes going in
Could be because I'm on an odd processor but I doubt that
 
@SébastienRenauld it looks good to me
(I mean I asked the first sha1 hasher I found online)
 
12:59 PM
Yeah, which is why I'm legitimately puzzled
 
With such characters I don't think there's a char encoding problem...
@SébastienRenauld How exactly are you determining this one ?
 
obviously won't run on the sandbox
 
.digest().to_string() ?
 
Are you sure you should base64 the .digest().to_string() and not the digest() ?
I mean the digest().bytes(), probably, but I haven't tried anything, not at my rust computer
 
1:12 PM
The pointer question
"I need to put a memory address in a register" - no shit, that's kinda what you do with memory addresses, huh
 
@SébastienRenauld well, technically you could also not use them in which case they are not going to be put in a register :D :D :D
 
@PeterHall you need to tell that person properly about mem::forget()
otherwise they're going to shoot themselves in the foot and take the remaining limbs off with it
Really puzzled what they're doing though
 
They are probably integrating with hardware that provides some data in a register
@SébastienRenauld I thought I'd cover myself by making my example Copy and telling them to read the book :)
 
1:47 PM
@SébastienRenauld hashing imply randomness
you mean encrypt
 
Welp, at least my websocket upgrade path now works
 
2:01 PM
Fuck... I've spent half an hour staring at the log trying to see where the bug was... Turns out there's no more bug since I added a log
 
@DenysSéguret Problem solved!
 
not really, the bug comes back when I launch without the log. But it's too complicated and boring to explain (bottom line the console is smaller in debug mode and the whole algorithm is dependant on the console height).
I was staring at half the screen without noticying the other half was running without bug...
 
2:31 PM
@DenysSéguret haha
@DenysSéguret C, java, rust ?
 
sounds like xterm-related
 
@SébastienRenauld yes... and it's rust... but the language isn't relevant here, I'm just stupid
 
@DenysSéguret I KNEW IT, no wait...
 
@PeterVaro looks like the feedback for the heap question was positive
:-)
 
woop woop :raised_hands:
 
2:48 PM
now, to find where the default heap page count is
 
@SébastienRenauld the OP accepted your answer and then comment
@Stargateur It seems that this isn't due to stdin, stdout, stderr and argv as the same program gives a different output on different computers. I think it's highly unlikely that that would consume 16MB of memory as well. As for why bother, the goal was to write a program that consumes little memory but still has good performance, i.e. if the target machine has a very small amount of memory (say an old phone, or an Arduino), memory is a precious resource and can't be wasted! Hence the importance of checking memory usage. I believe the response below provides a good answer! — RedRain 37 mins ago
so I think he doesn't understand
 
I've left another comment to try to explain further
 
 
5 hours later…
07:00 - 11:0011:00 - 21:00

« first day (1801 days earlier)      last day (1691 days later) »