« first day (2980 days earlier)      last day (1969 days later) » 

12:00 AM
is Queue the way to go if you want to keep some state between multiple threads? Or is more for a producer-consumer pattern? If so, what can be used to keep state between multiple threads that is thread-safe like queue?
*or is it more of a ..
 
you can edit/delete messages for 2 minutes in chat
 
12:27 AM
cbg
 
wim
@Aran-Fey I was more saying that the import wouldn't have worked in the first place without implicit namespace "feature"
 
Stupid question here, but is a stack overflow caused by excessive recursion in python physically harmful for my computer? I came up with a recursive function for AoC 8.1 and, much to my surprise, it passes the test case. But I hit max recursion depth with actual data. Did some searching and discovered increasing this is simple. But how far should I go?
Welp, set it to 3000 and my computer did not explode… just not sure why that limit is there in the first place unless the consequences are severe.
 
12:43 AM
And probably more definitively stackoverflow.com/questions/26873627/… . These are just coming from "python why recursion limit" in Google and there's plenty more answers
 
Yeah, I saw that. That’s where I learned how to increase the recursion depth. I’ll go back and read it again but I didn’t see anything about what that does to my machine. If it won't hurt my machine (which is normally impossible) I’m going to max it out just to see what can do with recursion on this laptop.
 
I'm not sure "damage" can occur in any physical way, but you could just end up crashing other processes by consuming all the system resources
 
Cool cool, and that's what I thought. It's a stupid question but worth asking
Thanks, I actually did not yet see that second link you shared, seems fairly informative
 
<mourns hopefully-temporary loss of abarnert>
 
wim
1:08 AM
physically harmful for the computer? LOL
 
I'm not making guarantees that a computer won't spontaneously combust. It involves electricity and I've electrocuted myself 3 times so that stuff is tricksy :P
Granted only once with a computer, which was the dumbest of the lot.
 
2:08 AM
cabbage
What happened to abarnet?
 
 
4 hours later…
wim
6:08 AM
damn @AnttiHaapala you beat me by 9 seconds
 
6:51 AM
oh -:P
where do you see that?
 
wim
7:24 AM
put the leaderboard to "stars" ordering display mode, and then hover event on the score
 
day 13 part 2 is killing me :D
it takes 8 minutes to run my code every time and I've rewritten it many times to fix bugs
 
wim
8:10 AM
day 13 complex numbers make a comeback!
My part B was 1 pixel away from my part A. weird!
@Unihedron you must be doing something crazy. should finish in under a second.
>>> time run(data, part_b=True)
CPU times: user 738 ms, sys: 2.95 ms, total: 741 ms
Wall time: 742 ms
perhaps you are iterating through the whole grid instead of iterating through the carts??
 
8:52 AM
recbg
@Unihedron your code is wrong then
@Unihedron ./runner.py 13 0.23s user 0.02s system 99% cpu 0.257 total
 
wim
SparseComplexMap(d.lines) lol
 
@wim I am lmao
 
wim
@AnttiHaapala view spoiler
 
9:19 AM
@wim it doesn't happen :D
 
wim
yep, also the problem doesn't really specify what to do there
 
no, I mean it does specify that it doesn't happen if you read carefully
 
wim
also interesting, this gonna crash ---->>----- but this not gonna be a crash ----<<---- because of which cart moves first!
 
wim
yep, I'm convinced.
I originally had a dumb assertion in to detect the case, fortunately it never happened so I didn't need to do anything else anyway..
 
9:37 AM
@Arne the problem is that there may be more than one context active at any time, both from nesting and concurrency. Nesting could be done with a stack (similar to the cache), but concurrency adds some scary stuff such as moving from one coroutine/thread to another.
 
In that case I've got to fold
I solve my threading problems in python by working single-thread only
 
hey guys how can we check how much quantity of each product under a particular id has been sold in a month using ARIMA
 
 
2 hours later…
11:39 AM
I want to run functions inside class when the class will be initialised. Can Python do that?
 
class Foo:
    function()
Or maybe you meant when an instance is initialized:
class Foo:
    def __init__(self):
        function()
 
yes when an instance is initialised, OK, thanks!
 
11:55 AM
> (On your initial map, the track under each cart is a straight path matching the direction the cart is facing.)
I wish I had read that line
 
12:15 PM
@Arne didn't read that either but assumed anyway
 
I need some fast async help
I have this: paste.ubuntu.com/p/fc7yc7Qxv5 For some reason after every msg recieve, it closes the socket connection :/
And rejoins
When the sevrer sends a message history, this causes only one of the messages to appear (as it seems to rejoin after getting it, restarting the process)
 
@RandoHinn tempted to say "we only specialise in slow-medium aysnc - as that's how a proper async should be cooked" :p
 
Also, the websocket library in question is websockets.readthedocs.io
 
you still need to tie it into the main event loop no?
 
12:30 PM
if __name__ == '__main__':
    asyncio.get_event_loop().run_until_complete(run())
 
ahh... that wasn't in your paste :)
 
So, that gets us running.. The problem still exists..
I'm thinking its the with ... ?
 
I'm trying to find the next train that's going to turn up - so a bit occupied right now
 
Just assume you'll miss it anyway :D
 
starting to think I imagined such things as a transport service right now
 
12:41 PM
As far as I can tell, your code is a loop that creates a connection, then receives a message, and then sends a message. Maybe you want to create the connection outside of the loop?
 
async def run():
    async with websockets.connect('ws://chat.randohinn.com:8080') as websocket:
        while True:
            await msg(websocket)

async def msg(websocket):
    global message_out
    msg = await websocket.recv()
    print(msg)
    if isinstance(message_out,dict):
        print("asun saatma")
        await websocket.send(str(message_out))
        print("saadetud, loodetavasti")
        message_out = ""
    await asyncio.sleep(1)
Tried this
now message_out is not sent
 
... is message_out a dict?
 
yes
at least it becomes a dict, the moment i click the send button in the gui
 
I don't trust your global variable to update as expected
 
It does
Seems like msg = await websocket.recv() is blocking now
As we only contine if the server is sending anything...
So we can't send our message
How to fix this, though?
 
1:19 PM
Okay
 
await is supposed to block the current coroutine
that's how coroutines work
if you want to send separately from receiving, you need at least two coroutines
 
1:34 PM
Is there a cleaner way to uninstall Python3.x while there still is Python2.x installed (which i want to keep) ?
In some forums, removing with an uninstall screwed up the setup for them !! hence asking here.
 
I also have message_history = db.entries.find().sort('timestamp', -1).limit(20); this pymongo code piece
It works fine and gets the latest 20
but how do i flip them around to show as oldest-first ?
currently it is newest first
 
humm, @wim is it possible that my input with your part2 code is an infinite loop?
part 1 works fine
 
Tried ` message_history = db.entries.find().sort([('timestamp', -1),('_id', ASCENDING)]).limit(20)`
no luck
still newest-first
 
I want to time our longer runs but your part 2 seems stuck in an infinite loop
 
Any ideas?
ELI5: I want to reverse a pymongo cursor
got it
cast to list
and reverse that
 
1:59 PM
@WayneWerner you've got another Finnish fan :D
 
Still got async issues
async def run():
    websocket = await websockets.connect('ws://chat.randohinn.com:8080')
    while True:
        await msg(websocket)

async def actually_send(websocket):
    global message_out
    print(type(message_out))
    if isinstance(message_out,dict):
        await websocket.send(str(message_out))
        message_out = ""
        print("snet")

async def recieve(websocket):
    global all_messages
    while True:
        try:
            msg = await websocket.recv()
            print(msg)
nevermind
 
 
1 hour later…
3:07 PM
Anyone here?
I now have a thread related q
t will not start until the window closes. why?
And how to make this work?
I could run the window in a separated thread, as that works, but than it fails on macos
 
3:20 PM
Aand solved it
accidental mainloop in the constructor
 
3:49 PM
haha
 
4:16 PM
I finally get to do some AoC today. test case passed, my submission failed /-:
Don't bother me, I'm hunting edge cases.
 
I stayed up until midnight to see today's AOC, but I took one look at it and thought "... Maybe I'll go to bed now". If I hadn't sprained my wrist putting up drywall that evening, then I might have soldiered on
 
Funny, I told my wife "Let me see what the problem is. If I think I can do it quickly, I will. Otherwise, we can watch something on NetFlix" At 9:01 PM PST I told my wife "Ok, let's watch something"
 
morning cabbage
 
midning cabbage
 
Sam
4:36 PM
could someone explain how they'd go about debugging an issue such as this? pastebin.com/Vx4xrdgx <- reproducible error example
 
4:59 PM
@Sam thanks for the code example. What exactly is the problem? What happens when you run the code and what do you expect the result to be instead?
 
Sam
Sorry i should have provided an update. I've realised the code isn't running because my pipeline assumes there is data with a dtype of category (which isn't the case).. But, I didn't obtain that info from debugging I just happened to add in an additional category column! The resulting data_transformed should be the same shape as df but with the relevant transformations depending on its dtype
 
5:23 PM
I want to add one-hundred, 50-digit numbers. I have done a problem similar to this one. That was to add all digits of a big number. I have taken that number as a string and then used list(map(int, num)), and then used sum method. But here how can I use same method here? Is there any better method?
 
morning cabbage
What is stopping you from just summing those numbers? @taritgoswami Are they int/floats or strings? Put them all in a list, typecast, and sum. your method is fine.
 
wim
5:45 PM
@AndrasDeak not unless i have a bug... what your input? try uncommenting the "dump" line and put in an input(), clear screen char, so you can watch it like an animation?
 
Day13: From problem "They do this based on their current location". view spoiler
 
wim
6:04 PM
i would be surprised if you could get a correct answer ignoring that. seems it would almost surely cause off-by-one error for part a
 
Oh wow, i never knew about AoC.
I was wondering through, how do i pass authentication if i try to access the inputs using python requests?
r = requests.get("https://adventofcode.com/2018/day/2/input" )
print(r.text) #Puzzle inputs differ by user. Please log in to get your puzzle input.
it seems like there is an auth parameter in requests thati can use, but i am not sure how my google account fits in.
 
Getting input via requests is not one of the puzzles you need to solve. Why not log in as per normal?
 
@wim OK, it works now. No idea what was wrong in my first session
no wait, that was part 1, argh
they just keep going and going in part 2
 
i was just feeling lazy having to save all inputs to a file and then read it :P i was hoping it would be as simple as just setting up a requests url. Turns out the authentication is a bummer
 
6:19 PM
@wim if I add prints it goes down to 1 cart left but it doesn't stop. Then again in the dumpy animation I saw more than one cart; but that may have been due to massive slowdown due to terminal IO
I'll put up my input in a gist so you can try to repro
 
@AndrasDeak 1) I see that you already have Day13 gold 2) view spoiler
 
@piRSquared I'm talking about wim's code
 
Today's a bad day for good questions :C
 
ooooh nevermind
I copied your code from the github window rather than downloading raw, and I put the return on the wrong indentation level *facepalm*
sorry, unsurprising false alarm
 
wim
6:23 PM
:D
 
for some reason pasting from github into vim kills the indentation on the last line, and I only added one level out of habit
 
wim
you don't use curl or wget?
copy-pasting from github UI is dicey, they change some unicode characters sometimes and futz with whitespace
 
I could but I don't. Takes longer to click on the raw link button or edit the URL than to select all and copy-paste. I guess this one was educational
I usually use curl or wget for web pages or full repo zips
 
wim
for freeze-frame trick, maybe can help others:
    dump(a0, carts)
    input("press enter to continue...")
    print('\33c')
 
7:08 PM
TIL ice fog
 
7:51 PM
hmpf
there is this hat:
> delete 6 comments after owner edits post
one would think it is easy to attain!
 
no, 6 is a lot
 
just delete 6 [mcve] please
 
OPs very rarely edit after nudging
 
bin-go. especially in
so I went through 4 pages of my comments
and I got like 3...
 
try deleting your own comments on your own posts
 
wim
8:00 PM
stupid hats
now we get people posting 6 comments so that they can try to get a hat...?
or, like, trying to make a question that nobody will answer but won't get closed? :D
 
yup
 
I'm jaded by hats. I got caught up once. #Don'tForget #NeverAgain
 
do y'all hate hats?!
 
D:|>
 
8:11 PM
ô/
 
ő/
 
\Ōō/
 
ổ/
@piRSquared Zaphod Beeeeeeeeeeeeblebrox
or would it be \Ō|ō/
 
8:20 PM
Yam! I choked on my coke zero a little bit.
 
8:37 PM
today's wheel to reinvent: home made dependency injection container!
 
8:48 PM
dependency syringe
 
@AnttiHaapala I'm slightly confused, lol.
 
@AndrasDeak slow clap
 
cbg
 
afternoon cabbage
 
Hacked my way through the Flask issues, head a little less fried tonight :P
 
9:00 PM
so a coworker and I started this project over a month ago and I'm already disgusted by some of the code I wrote...
okay, "disgusted" is a little too strong..."ashamed" might be better...
one function is 150+ lines of code.
 
I genuinely thought I was gonna beat that but it seems I managed to split it into two 6 months or so ago. Bet it would have been worth a hat, too
 
@Code-Apprentice The definition of bad code is anything you wrote more than a week ago
16
 
@WayneWerner s/a week/a day/
 
If it makes you feel any better, nobody has crashed the function(s) that I had in mind for the last 6 months. It applies 10s of filters on a dataframe to end up with an interactive plot. I kinda dread to think how I'd go about modifying it if they asked me to, but it does what it was supposed to, and is stable
So, just start praying you never have to revisit the function and everything is probably fine :P
 
wim
9:12 PM
@FélixGagnon-Grenier elaborate?
 
Hmm, my code comments are making me re-live that mess
# Data is logged at the end of the hour. This has become a confusing
# issue across the board and handling has changed multiple times. Here
# we knock everything back an hour to correctly align with any shift
# filters.
Followed 50 lines later by
# The hour shifting issue is back! For the time-being it's decided that
 
🎶 Let's do the time warp again 🎶
 
:)
The code is kinda like the Cha-Cha-Slide on a broken CD where everything just goes back and forth by one hour on repeat
 
9:28 PM
@wim I have problems adapting to the (possibly only existing in my head) python framework's paradigm of decorator based routing and general magic, so I try to reuse patterns I'm used to in the development of web app. The container I envision and like working with is a configurable object that generates and shares existing instances of types used in the handling of http requests. Once a route is matched, the container is tasked with instantiating the handler.
the api is mostly def make(desired_type) and def share(instance_or_type)
with a def define_param(name, value) for constructor arguments that are scalars. With that, managing object's instantiation is mostly automated and resolved automatically, and I feel right at home
 
Can I delete a question I asked that is marked as a duplicate but received comments or is that not appropriate ?
 
I have a feeling that at some point I'll go back to just import stuff at the top of the files, but at least I'll now why then
 
Am I right to be outraged by this? stackoverflow.com/questions/53770415/sorting-drop-down How can someone come and delete code from the OP's post?
Hmmm, some wonky editing race condition
 
Yes, you were right. Thankfully it was a mistake, but if that were really what had happened, it would be completely inappropriate
some cleaning could be done
 
If someone intentionally did it, then yes, outrage of some form or fashion is a good choice :)
 
9:43 PM
I have deleted code from people's posts if it's totally not relevant but that edit was the single line that didn't work. <waving angry fists>. Sometimes the way editing is reconciled in those conditions is really confusing to me
@petruz you are free to delete it but I'm curious as to why you want to? A duplicate is not, in itself, a bad thing
 
@petruz comments are ephemeral. You only get repercussions for deleting a question with answers
 
wim
@roganjosh that sounds kinda like a wedding I went to recently
 
(Something tells me you can't get repercussions, only face them)
 
9:59 PM
One can generally understand the concept of repercussions /nitty-picking
 
*knit-
 
wim
@FélixGagnon-Grenier It's not fair to call that "Python framework's paradigm".
 
oh right, I forgot to mention: I meant python's web frameworks (that I have seen)
 
wim
Even that not fair.
DRF uses a router class. Django uses a urls.py module.
 
10:02 PM
@wim It's a pity I didn't know in advance. If you ever find yourself in that kind of situation again, you can talk at the bar about how you have an internet acquaintance that accidentally happened to see DJ Casper live in Florida before anyone really knew who he was. Then you can drink yourself out of that nightmare with your new, super-impressed buddies.
 
I might have been heavy-handed...
 
wim
The decorator thing seems to have been popularized by joke frameworks like flask
Unfortunately people liked this bad design, so it caught on.
 
I see...
after realizing that the framework is mostly used (in our projects) to route http requests to domain handlers, I installed routes and wire gunicorn requests to handlers manually
along with routes matcher and said dependency injection container
 
I actually don't agree with that assessment at all, but I've had two days of issues that ultimately ended with me just registering an exception on Flask that takes the highest precedence and solved my context issue
 
but point taken @wim, I'll try to remove that association from my head.
 
10:06 PM
I see it as a bit of a hack, but it's in sopython and nobody has stepped up to try explain to me exactly how the context works
 
wim
Which part don't you understand about "how the context works"? Are you asking about how the request itself is magically available despite not being passed around as an argument?
 
is it magically dumped in the global scope somehow?
 
Everything I tried said I was working out of context. The docs suggest you can grab the context with with, but you have to use a proxy for blueprints, and that didn't work
Why is this necessary if you can grab the context of a blueprint in Flask?
That, as far as I can tell, is not documented at all. Then you have to attach a dictionary to g, an object passed around with the context, and retrieve from the dictionary later
I could have followed the sopython approach to the letter, but I actually needed an object from the session, which uses flask-session in my case. I just couldn't fit it all together
 
wim
10:23 PM
@FélixGagnon-Grenier thread-local context last I checked, and this design was fairly ingrained in flask from the beginning so I doubt they changed it in 1.0
but yes, it's similar to a global variable for all practical purposes
 
Turns out that I found a better solution for my purposes anyway. No need for decorators. On a view function:
@bp.route('/approve_new_user', methods=['POST', 'GET'])
@login_required
def approve_new_user():
    check_user_group(['Master'], current_user.username)

    req = request.form.to_dict()
    print(req)
    return redirect(url_for('auth.approve_new_user'))
And then the check_user_group function:
def check_user_group(required, username):

    with sqlite3.connect(DB_PATH) as conn:
        c = conn.cursor()
        c.execute("""
                  SELECT user_group FROM user_auth_groups
                  WHERE username = ?
                  """, (username,))
        authgroups = c.fetchall()
        if not authgroups:
            return redirect(url_for('auth.login_homepage'))
    authgroups = [item[0] for item in authgroups]
    if 'Master' in authgroups:
        return True
    if not any([item in required for item in authgroups]):
 
wim
Why are you following sopython as an example? I'm not sure that was ever intended to be used as an example of a good web design. Just intended to be a working website.
 
Just register the exception and call within the function, there are no context issues then
@wim because everything else has kinda acted as a showcase for Flask, and it's written solely by the maintainer of the library?
Sorry, the combined post ended up being a big block of code, I should have posted to pastebin
 
it would make sense for him to write it As It Should Be, but the site was here long before I came and I don't know how it was written
 
It is still modified. And it uses the blueprint model, which was a late addition to Flask
And the blueprint model, btw, is absolutely awesome, but it seems to have come with some really convoluted issues (IMO and I'm very much a learner)
 
11:28 PM
@roganjosh what kind of issues?
 
everything was saying I was out of the app context.
And no matter how I tried to catch the context in the blueprint, I failed. But the blueprint necessarily has more than one part that relies on the context, so maybe I just missed the perfect combo
Turns out, for me, that you can just throw an exception into the mix and register a handler on the blueprint to make a redirect. I'm usually pretty resilient to repeated errors but this one got the better of me and my ability to understand
But this works better for me; it's still one line and I can catch user groups within the function
 
I... am very confused by what your ultimate goal here is :)
 
I'm not developing a generic app like a blog from all the tutorials. It's a control panel for a factory-wide simulation. I'm now on a phone so I won't waste your time trying to illustrate
But it's worth noting that there are cases where it's actually useful for a user to actually modify the site on behalf of others, without my intervention. One user creates a new department; that department should now be available to all other users.
It's only the last two days that I've struggled in retro-fitting permissions for literally every action and thrown a full login system in. This was not in the original scope.
 
11:45 PM
Ah. Yes that sound fraught with scope creep!
 
But, it was also me that decided that it needed to be done, so I'm definitely not able to moan :P
Actually; I've framed that incorrectly, it's actually been quite a bit of fun in mental gymnastics :)
 

« first day (2980 days earlier)      last day (1969 days later) »