« first day (4035 days earlier)      last day (1137 days later) » 

00:14
I fell foul of this issue earlier today, trying to debug a colleague's code, and it wasn't fun to track down. What I don't get from this answer (or the general setup) is the statement "but NULL (or a string literal 'foo') could be anything". How can a string literal be anything here for Postgres?
I think I'm curious for a counter-example where taking a string literal as text/varchar as an implicit cast will just explode something, but string encoding is a weak point for me
 
2 hours later…
02:03
@AnttiHaapala does this mean multrprocessing or ProcessPoolExecutor would no longer be needed? If the nogil version makes it to main python
 
7 hours later…
09:06
Style question: Option 1 or option 2?
try:
    some_function()
except Exception:
    self.running = False
    self.crashed()
else:
    self.running = False
    self.done()
try:
    try:
        some_function()
    finally:
        self.running = False
except Exception:
    self.crashed()
else:
    self.done()
09:31
@Aran-Fey I'd go with 1
Both flatter and seems less spaghetti at a glance
Simple is better than complex, huh. Alright
 
1 hour later…
10:40
Asyncio question: I need to loop over an async iterator, but simultaneously check if I have been paused and/or cancelled. Pausing is easy, I just make an asyncio.Event and throw a await self._unpaused_event.wait() into my async for loop, like so:
async for chunk in self._iter_data_chunks():
    # If paused, wait
    await self._unpaused_event.wait()

    file.write(chunk)
The problem is cancelling. If I'm cancelled, I don't want to wait for my async for to yield the next element, I want to cancel immediately. Is there an easy way to do that? The only solution I can come up with is to manually simulate an async for, which resulted in this (untested) monstrosity
10:54
@python_user yes pretty much
or it would be of much more limited utility
@Aran-Fey use trio
Hmm, how would that work? Having trouble finding something relevant in the trio docs
11:20
Hello there, How can I separate a column of pandas dataframe into multiple columns based on the size of each text length ?
ah that doesn't say either that it will cancel at the current point
How can I separate a column of pandas dataframe into multiple columns based on the size of each text length ?
id body
1 abcdefgh
2 xyzk

For this case, I would like to get:
id body1 body2
1 abcd efgh
2 xy zk
@AnttiHaapala any suggestion ?
@ozturkib no, use google :D
I was searching about more than one hour.
No success so far. That's way I asked here. If I ask it as a question, it will be downvoted as usual :)
So scared :)
11:40
I asked as a question here: stackoverflow.com/q/69809791/1953250
Could you please support me on the question if I am making any mistake once I prepare the question ? Thanks
Someone at google will be wondering why I'm searching for exploding pandas...
12:01
Could be worse, you could be trying to melt them
cabbage, long time no see
hi guys, anyone know the best way to model reaction time of some sort? or model something like a confounding variable
im kinda new, but im currently doing a masters project on HVAC control systems, I want to use outdoor weather and indoor temp, which is recorded at 30 min time intervals to model the relationship between them.
like the end goal would be to feed in an outdoor temp, feed in an indoor temp, and the algorithm would figure out how long it would take to heat up the building within that period of time, if that makes sense?
@roganjosh yeah... probably best to stick with proding and squeezeing 'em :p
@ReblochonMasque cbg
im trash at coding but feeling like imma fail my course soon if i dont figure this out
ideas on an approach would be very much appreciated if anyone has the time :(
Heat flux is a relatively simple equation, so you'd probably want to make use of that in some way. It's a case of fitting UAdT from en.wikipedia.org/wiki/Heat_transfer
12:16
@LoaiAlnouri perhaps PID control
@ReblochonMasque cbg, but you were here yesterday :P
<flashbacks to Laplace transforms>
okay thank you, Ill have a look into that. But they both require thermal conductivity (k) of material right? is that what my algorithm would be modelling?
@AndrasDeak but hey, they still didn't technically see you, now did they :P
morning cabbages folks
@LoaiAlnouri PID is a very general concept where you estimate the modulation on your system (in your case, heating power) from three terms: one is proportional to the signal (temperature difference, perhaps), one proportional to the time derivative of the signal, and one to its time integral
12:24
cbg!
You could approximate the thermal conductivity from that, but there will be other factors like convection (radiative transfer is probably not relevant). Keep in mind that I don't really know what your course is, so it's not clear how sophisticated this needs to be
the hard part is calibrating the three parameters to get optimal behaviour for your system
cbg @JonClements, @AndrasDeak
ahh okay thank you guys! well im just doing a 1 year conversion course from architecture so thought id pick a topic which bridges my past with my degree which is data science with AI
so im not very experienced as ive only been coding for less than a year and no real world experience
basically shot myself in the foot now im tryna walk to the finish line with my injury
12:29
heh, good luck
for what it's worth this doesn't sound like a problem where programming is your main concern
yeah well i have yet to get to the programming bit really just trying to figure out an approach so i know what data i need
but my deadlines approaching very soon so ive left things a little late
classic move
Deadlines can be quite stimulating. Just remember not to ask questions on the main site with "URGENT" in the title :P
yeah for sure hahahaha, might have to tho 👀
12:35
Make sure you ask here what you want first, because you need 20 rep for chat.
okay no problem, this is the chat right? I think i already have 20 rep
Yes, but if you ask a question on the main site with "URGENT" you won't have 20 rep for long
oh right, yeah i was joking was not gonna do that ahahah thanks for the heads up tho
no worries :)
(vague design questions aren't really great for the main site anyway)
@LoaiAlnouri sounds like most students I know of :)
12:39
hahah cant lie im lostttt, gotta just power through
12:53
key/value pairs might just be your savior (and before you melt from more non-understanding, I'm making a pun on "map" to "find" yourself because you're "lost")
hahaha i think i actually understood the pun
im getting somewhere
@AndrasDeak I think you're right im reading up and watching videos it seems like a PID problem to solve
thank you
no problem
13:42
Today I'm working with selenium and I have about three layers of asynchronocity going at once, and I have no idea what I'm doing
Hey,

I have to write a function for the Linear Congruential Number Generator to generate random integers and to find how many values it generates before it reaches the same seed value.
https://codeshare.io/8pq0We

This is the code
When I run this code, I get "NameError: name 'r' is not defined"
Does anyone know what the problem is with the loop? I'm using it to break when it breaches the seed value (r=10)
while r != 10 can't locate a variable named r, because no assignment statements have executed before that line, giving r a value
So I should incoperate the while statement in the def function because r is defined there?
I'm going to make a new r = formula as opposed to the return statement.
heres my question: are you mis-assuming that defining a function makes the function body run? because it doesnt.
Incorporating the while is one way of doing it, sure. If r = something executes before the while and in the same scope, then the NameError should go away.
13:51
and variables inside a function have their own scope. those variables dont exist outside the function
@ParitoshSingh Oops, I should call on the function for that right? Yea I did mis-assume
@Kevin Right, thank you so much!
Incidentally print(pseudorandom_formula) won't call the function, it will just print its name. Perhaps you wanted print(pseudorandom_formula())
@AmnesiaSmith yep yep, you have to call a function to run it. it still wont fix the issue with variables and scopes, which you'll still have to deal with. either make the function return every variable you need from it, and assign it, or put all logic together inside the function if thats more appropriate, including the loop itself
Thanks everyone!
woop woop, importlb.resources in 3.9 has concept of directories
could this be the end of zip_safe=False!!!!
14:02
In Selenium, driver.current_window_handle usually returns the handle of the window that is currently active and visible. But if the user manually switches tabs during the session, current_window_handle still refers to the original tab. Is there a way to find the real current window?
@AnttiHaapala using that module was quite awkward, felt like technical details of the implementation bled through super hard. glad to hear it gets more usable, now to pull my code to 3.9..
basically jars and java loaders have done this forever
like from the time of the applets
@Arne yeah works but it is still awful
>>> import importlib.resources
>>> import sys
>>> sys.path.append('x.zip')
>>> importlib.resources.files('x')
Path('x.zip', 'x/')
so you can navigate around but that path object does not have glob.
because it is zipfile.Path
no globbing :D
14:27
that's gonna be fun, refactoring code to make it more readable and then have my zipapps crash
just one month after I started using them
14:41
in plain asgi how do I do websocket that has separate "threads" receiving and sending from ws?
guess
just usng asyncio
    reader_task = asyncio.create_task(reader(), name='reader')
    writer_task = asyncio.create_task(writer(), name='writer')

    await asyncio.gather([
        reader_task, writer_task
    ])
@Kevin Could you clarify what you mean by "current window"? Selenium's (or HTML's) definition of "window" is a bit... complicated. Or maybe I should ask: What are you planning to do with the returned handle?
14:57
I guess I'll start by rewinding to the beginning of my XY chain. My ultimate goal is to automatically download a local copy of every image on every Wikipedia page that I visit.
(more details forthcoming)
Hmm. That might be tough. As far as I know, selenium isn't designed to support a user interacting with it
Is it necessary for the wikipedia tab to be focused? Perhaps you can just loop over all open pages using driver.window_handles
If the user vows to never open a second tab, this is quite easy -- I have a functioning prototype at pastebin.com/Ey9Kf9wy. Well, I haven't implemented download_all_images, but it just needs to do a little DOM navigation and maybe some curl. No problem there.
But if the user does open a new tab, then the script will twiddle its thumbs waiting for the "active" tab to change urls, and all the while the user may be navigating through any number of pages
driver.window_handles correctly shows the handles of all tabs in the session, but I don't think that gives me the power I need
I haven't rigorously checked, but I'm pretty sure there's no way to navigate the DOM of a non-active window, and there's no way to make a non-active window active without hiding the user's "real" active window and making the target the "real" active one
15:13
As far as I can tell you can activate a window with driver.switch_to.window(handle), but I have no idea about those side effects of hiding the current active window
I have to say, the python selenium docs are... not good
Yeah, my experience has not been seamless
driver.switch_to.window(handle) does indeed activate the window. Here is a little prototype that activates a different tab every 2 seconds: pastebin.com/vGnDt8YR
Does that only change which tab you're controlling or does it actually change the browser's active tab?
Let's define "driver focus" as what window the driver currently has access to, and "user focus" as the window that the human at the computer can see with their eyes. driver.switch_to.window(handle) changes both the driver focus and the user focus.
wow, what a mess
So, uh, can I interest you in writing a userscript instead? It seems you can download things with GM_download
I'm kicking around the idea of injecting custom HTML/JS into the active page. It will hijack all <a> tags and turn their href=whatever attributes into onclick = askSeleniumToNavigateTo(whatever). askSeleniumToNavigateTo sends an async request to my Python script*, which decides how the url should be handled -- opened in the active window, opened in a new window, saved for later, etc
(*I assume this is possible, but haven't tried)
15:33
Why not forget about selenium entirely and do all the work with JS?
@Aran-Fey Possibly sufficient for v1.0, but maybe not a good fit for some bells and whistles I had in mind for down the road. For example, if I want all images to be saved to the directory <project_root>/<name of page>, I don't think GM_download will let me specify that.
You can specifiy a destination path, but apparently it has to be relative to the Downloads folder :(
Comedy option: have tampermonkey send an AJAX request to my always-on web server, which downloads arbitrary files from the internet and puts them in arbitrary locations on my local system.
I don't have an always-on web server and I don't know how to make one, so, small hiccup there. Also it's a security nightmare
I believe there's no problem if you bind the server to localhost. But it's possible that I'm wrong and a bunch of web devs will appear shortly and lynch me.
Super extra hard mode: make it work even if the page to be downloaded has state-of-the-art bot detection and session authentication tokens etc etc. If I'm using Selenium, no additional work needs to be done in that respect, since the session is human-piloted and already has the image data in memory.
Perhaps Tampermonkey can do that to, if it can beam the image data to localhost as a b64 stream or something
I was going to say "it will double the bandwidth requirements of the download though" but I guess sending data from my computer to my computer isn't really a bandwidth-constrained action
15:48
@Kevin I put together my "twitter to RSS feed" thing complete with always-on web server in less than 6 hours the other day
you can bind it to localhost and nobody else (not even LAN) would see it
it's pretty much just docs.python.org/3/library/…
and I don't know yam about web stuff
Hmm, this web server approach is beginning to sound like a non-comedy option
the only problem is having to remember to run it...
True. But that is an acceptable restriction, even for all my roadmapped bells and whistles
and debugging is a bit of a nuisance because when you stop the server, the port keeps being bound for another minute or so
And you have to parse the request bytes manually, because that stdlib module is really barebones. But you'd be the one making the request in the first place.
Yeah, so I can make a specification that's easy for me personally to encode and decode
15:54
You can also forgo the web server and use websockets
I don't have any specific bell or whistle in mind that would need this, but it would be nice if I could keep open a persistent session between the page and the server
I think I'll leave that out of v1.0 though
For completeness, there's also the option of writing a browser addon
Now that I brought it up, we can continue to ignore it
True. That at least can determine the user-focused tab without fail. I know this for sure because Selenium IDE can tell when you switch tabs.
(confidence: 85%)
 
3 hours later…
18:48
@roganjosh Not yet: life is turbulent both personally and professionally and it's likely I'll be occupied. Also my disorganisation means I can't find the reg. details in my email.
heya @holdenweb
Long time. How's you?
@holdenweb No worries, sorry to hear things are turbulent. It's sold-out now so I was wondering if you'd managed to get a ticket before that
 
1 hour later…
20:21
Hello, I am using git solely for the purpose of version control. What I usually do is have a .txt file that has all the 'git add [file name]' that I just paste to the terminal each time. Then I do a 'git commit -m [comment]'. I used to always just do git push [remote] is it better to still do a git pull [remote]?
Those two are very different things, so what are you really asking?
If you're the only one touching the remote then pull should be a no-op. Anyway if you omit the pull and try to push and something's changed on the remote, you'll get an error anyway so you'll see something happened (that's when you DON'T force push).
Is the process also correct rather and if I should pull always
If you can successfully git push, then a git pull wouldn't have pulled any changes anyway
What he said. Right after push, pull should be a no-op.
In any case pull = fetch + merge. I'm very happy with only fetching, and doing any merges myself when I have to. Then there's no surprises.
Hmm, I was thinking of doing pull before push
20:25
Ah, I misunderstood, yeah. Then we just agree.
But either way it's unnecessary
Thanks that clears things up also one thing I noticed in my github
Is I have 3 branches but I only have 2 branches in my terminal
try doing a git fetch [remote]
that should give you all the [remote]/... branches
20:27
@Pherdindy what's that from?
@Pherdindy how about git branch -a?
The first one is from github it's my remote/origin
hmm, not sure what that -> origin/main means
In any case, you probably deleted your local simplify-extract-raw-output branch
Yeah been a while not sure what happened to it will review the branch and investigate
if you need it, just check it out
# probably just
git fetch upstream
git checkout -b origin/simplify...
I think
at worst fetch -> git checkout origin/simplify... -> git branch simplify... will work
if my original version works it will probably automatically set it to be a remote tracking branch
ah, OK, the -> origin/main was just HEAD
20:41
Somehow I just did git checkout simplfiy_extract_raw_output after doing git fetch origin
And did it work?
And it created a new branch following the remote branch's
Great! I didn't know that would work.
Yeah it seemed to work: Branch 'simplify-extract-raw-output' set up to track remote branch 'simplify-extract-raw-output' from 'origin'.
yeah, perfect
that might have actually been what I vaguely remembered happen earlier, and thought that the git checkout -b with the origin name would trigger
I don't have time to play with that to see if both work, what matters is that you're on track
The question remains what "stale" means in whatever tool gave you the first screenshot (you never answered my question)
20:43
Based on what I read stale means there has been no commits in 3 months I believe
ah, OK
Which makes sense since it's a missing/deleted branch
And I haven't really touched it in a while
Thanks I suppose that's all the issues so far with git lol
no problem
Have you played the learngitbranching tutorial?
It goes a long way in demystifying git learngitbranching.js.org
I remember you referring me to it a year or so back forgot about it but will make sure to take a look
Is there something I can use to keep setuptools.setup(version="0.2.0",) up to date with __version__ = '0.2.3'? I've dropped the ball on this one :/
I suppose PyPI would be a lot more unhappy about this than when we install from a private github repo
21:00
Well, there are various hacks to extract the __version__ (like importing, or regex), which may or may not work well enough for you. But if you're not married to setuptools, just switch to flit (or poetry? Not 100% sure it has this feature)
I don't think I'm married to setuptools depending on how the replacement might work with things like cython etc. in our internal environment. By your message are you suggesting that you know that flit has this feature, but not sure of poetry, or are you speculating on both? It's not a show-stopper but it looked really weird when I pip install git+<url>@v0.2.3 and then got it reported back that it installed 0.2.0
I know flit has it, not sure about poetry
Neat, thanks. I shall do some research :)
 
2 hours later…
22:49
Hi guys, trying to understand this code, is it valid in Python?
"amount": project.candidates_requested * 100
if project.candidates_requested
else 0,
23:12
@S.Code Maybe. ;) It's not valid in isolation, but inside a dict literal it's fine.
23:23
@Kevin There's a Wikimedia API. Granted, there's a bit of a learning curve, and the documentation is a bit of a rabbit warren. And things that you think ought to be easy with it may be a PITA. I last used it a few years ago, so I'm pretty rusty, but downloading all the images on a page should be fairly straightforward, IIRC. I might even have written some Python 2 code which does exactly that... mediawiki.org/wiki/API:Main_page
@S.Code You need to give the context. As a "ternary expression" it's valid, otherwise no
Then again, I'm pretty sure that just running it would tell you if it's valid or not. That's not exactly the most taxing thing to test

« first day (4035 days earlier)      last day (1137 days later) »