« first day (3849 days earlier)      last day (1324 days later) » 
00:00 - 14:0014:00 - 00:00

14:00
I'm curious what your as based approach would have looked like, if it had been (x=y)%5
?
I wasn't attempting anything
i was just figuring which came first
@Kevin Body is limited to 30000 characters; you entered 41194.
What can i do about?
Is this related to the Qt/database problem we were discussing the other day? I wasn't aware Qt text boxes had character limits.
No it's a so restriction
*Stack overflow
nice, I have so little ram my clion crashed
14:03
Interesting, I didn't know SO posts had a limit. I can get a little wordy myself, but I guess I've never exceeded 30,000
@ChrisP Enter 30000 characters or less.
Try using shorter words ;-) and if you're posting a lot of code, do your best to cut it down to an MCVE
Short (but still complete and verifiable) code makes for happy readers
I upload the code in my google drive.
I like a long CVE over a short non-CVE myself, but I think the guys on the main site are more picky
M and C and V and E all at once, or bust
If you edit in a link to Google Drive, they'll probably just say "please include your code in the question itself. If it's too long to submit, make an MCVE"
Anyone know, how to exit keyboard.wait()?
It is like a while loop. But I need to know how to use break.
14:09
If you had a stellar A-plus grade MCVE, I bet you'd get an answer in under thirty minutes. But sadly, it's harder to make an A-plus MCVE when databases are involved.
External dependencies, like tables saved in a file, are an automatic demotion to B grade
@CoolCloud what's keyboard?
editing also pings.... wtf
# Blocks until you press esc.
keyboard.wait('esc')
something like this?
That's what he's got already, yes. Now he wants to be able to have his other thread say "actually, stop waiting for esc, just exit instead"
14:12
But I dont want to press esc. I want a condition to stop it.
@Kevin Its related to the previous code, I think you got that figured already :P
That's what I was assuming, I went out on a limb a little there
raise an error but catch it
I was waiting for you to say "uh, that's not what I want at all...?"
@12944qwerty As in, raise an error in the other thread, and catch it in the waiting thread? It's kind of hard to get exceptions to cross over threads like that
I'm not sure what the context is behind his project....
I'm just picking out ideas that I can get for stopping the loop
class _Event(_UninterruptibleEvent):
    def wait(self):
        while True:
            if _UninterruptibleEvent.wait(self, 0.5):
                break
Context: it's a screen snipping tool that stays open until you press esc.
3 hours ago, by Cool Cloud
Would appreciate if anyone could trial run this -> Windows only
14:16
I'm not sure how _UninterruptibleEvent works... but you could use something from that
since keyboard.wait uses _Event
@Kevin Yea and my root also uses 'esc' as a bind and that would trigger the entire script to exit.
wait... i don't think it's meant to be interrupted :/
I don't know much about this _Event thing, but the general pattern of "do uninterruptible work for a little while, then check to see if anything wants us to quit, then repeat until done" is one idiomatic solution
bring it up with the devs
kek
Hmmmm what if I use keyboard.wait('CTRL+A+B+C+Q+D+F'), now no key can purposely exit the app. Unless they hit their head in the keyboard
14:18
Unfortunately it doesn't look like wait has a timeout argument or anything that would let you say "wait for esc to be pressed, or for 50 ms, whichever comes first"
I'm not 100% sure what the ultimate goal here is, but this may be useful information: if you want the main thread to stay alive until its child thread finishes working, do the_child_thread.join()
@Kevin Are there separate threads here? I haven't created anything manually, don't know what is happening implicitly though.
@CoolCloud you can use suppress
I assumed keyboard used a bit of threading, but now that you mention it, conceptualizing the problem as a threading problem isn't useful unless you're using threading manually.
Hmmmm Ill try around and see what happens. Anyway I have to restructure the entire app to work with multiple keys and not create more than one Tk() too.
@Kevin I see
I think you should be able to use suppress or raising and catching an error to break the loop
but I'm not 100% sure if you can break the loop... since it's supposed to be Uninterruptible
14:26
Hmmm I guess too, giving a weird key would work too.
Half baked solution:
#not shown: a bunch of code

    def close(): #or whichever function is bound to esc
        global window_already_handled_escape_press
        window_already_handled_escape_press = True
        root.withdraw()

#not shown: a bunch of code

keyboard.add_hotkey('ctrl + shift + z', show, args=('s'))
keyboard.add_hotkey('ctrl + shift + x', show, args=('c'))
while True:
    window_already_handled_escape_press = False
    keyboard.wait('esc')
    if not window_already_handled_escape_press:
        break
Assuming the goal is "make escape quit the entire application, unless the snipping window is active, in which case just make it minimize/hide the window"
Hmmm interesting solution, ill try to implement it :D
you could recreate keyboard.wait
and break where you want to
A valid approach. The function is quite small, so I expect it would be easy to make your own. github.com/boppreh/keyboard/blob/master/keyboard/…
their documentation doesn't explain everything where it should unfortunately
they don't explain suppress and trigger_on_release (but they do in another method so that may be why)
14:33
Reading the code more, I'm going to revise "easy" to "possible"
You'd have to drill down to the gritty details of the threading that looks for key presses
I think I'd skip that and use a solution based on add_hotkey rather than wait
or
you can ask a question on SO
😂
How is everyone doing!
14:48
bad....
just finished a test
:(
What kind of test?
Isn't finishing a test the phase were you feel great :)
It is when you feel you did your best
AP World
DBQ
Practice Test but graded
I have never once done my best, because the peak of my abilities lies in the future when I transcend physical form and become an orb or pure reason
14:52
lol
kevin has yet to peak
In comparison, merely studying very hard and getting a 100% is the smallest fraction of my best
I rarely study
The docs say that they have a timeout for hotkeys....
Complex hotkey support (e.g. ctrl+shift+m, ctrl+space) with controllable timeout.
How silly. add_hotkey is asynchronous so giving it a timeout is not very useful. Compare to wait, which is synchronous and would benefit greatly from a timeout.
lol is everyone working on multiprocessing stuff right now, too?
Threading. Close enough.
14:56
multiprocessing is the library I am using currently. I believe threads are different than processes
could be wrong. I have yet to google that question
Indeed they are different.
This is honestly so cool....
import multiprocessing
import time

def mp_worker(filename):
time.sleep(1)
return filename * filename

def mp_handler():
p = multiprocessing.Pool(32)
filenames = [1, 2, 3, 4, 5, 6] * 32

start = time.time()

with open('results.txt', 'w') as f:
for result in p.imap(mp_worker, filenames):
f.write(f'{result}\n')

end = time.time()
print(f'Multiple Threads: {round(end - start, 2)} seconds')

f.close()
if __name__=='__main__':
mp_handler()
Consult tinyurl.com/urnzp7k if you want whitespace to not get removed in your code
Wasn't sure if you can use formatting in this chat
idk what I'm looking for
lol
15:02
It's a little different from the main site's markdown engine, but it has some common features. whitespace-respecting fixed font blocks is one such feature
@Jasonp If you want to display floats with a specific precision, you can directly use formatting for this. Compare f"This is enough pi: {math.pi:.2f}"
The .2 means two digits after the decimal point.
Why are you telling me this lol
I appreciate the tip though
Because it's easier than print(f'Multiple Threads: {round(end - start, 2)} seconds')
Oh I see. I appreciate the comments. Frankly, I can read the round() function better. Is there any incentive in terms of speed?
My gut says that Miyagi's approach is a tiny bit faster.
15:10
Tiny bit relative to computers or relative to humans ;)
welp i have another test rn
hopefully i don't have to show work
goodluck
which exam?
Hon Chemistry
YESS i don't have to show work
that turns a 50 min exam into 30 mins
Generally I/O is the slowest part of a program, so if you're printing anything to the console, that's going to overshadow any optimization you use when constructing the string
(within reason)
@MisterMiyagi what's this: {math.pi:.2f}
15:14
In other words, humans won't notice.
The part after the colon means "display the object using float-style formatting, with precision 2"
@Jasonp As Kevin said, code performance doesn't matter when doing I/O. However, since your intention is to format the code, using the appropriate format tool conveys this better.
It also avoids a few problems, such as round not necessarily producing a fixed number of digits.
anyone have any idea why a site would make the browser hang while using webdriver and work fine without? (we're using selenium to check status of some sites and most work, but a couple freeze the program without response so while checking with headless turned off, I noticed that in the "automated" chrome/firefox window, the site doesn't load at all, just sites there waiting for response; same site works fine in non-automated browser windows)
@Kevin so it converts the int to a string with 2 decimal points?
Yeah, except math.pi is not an int.
15:20
integers can only represent whole numbers, so it doesn't come close to properly representing 3.141592654(etc)
@Kevin Heresy! pi is exactly 3!
floats also can't represent pi exactly, but it's close enough for horseshoes and hand grenades.
There was this scientist on the telly...
@Kevin oops, i meant float/decimal number
The ratio of a circle's circumference to its diameter can be three, if you bend spacetime juuuust right
15:22
our highschool class whatsapp group is named pi=3 :D
@LFLFM My first suspicion for any web crawling problem is "the site can tell from your user agent string that you're a robot, and it's giving you junk as punishment"
that happens to me so many times
Hmm, reading further, it seems like selenium's web driver simply copies your normal browser's agent string, so there shouldn't be any bot indicators there.
@Kevin, that was my first thought; but I checked the automated window and all request headers match that of the non-automated window... in fact, the route that fails to return a response returns when requested directly; so weird
15:27
Half-serious suggestion: monitor your outgoing HTTP packets using Wireshark, and compare your program's packets against the regular browsers'
Is there anyone available right now and help me with a code? I have asked it 10 hours ago but got no reply?
the dev tools from chrome and from firefox seem to differ where they stop, (ie. chrome says it doesn't get a response on some json config file request; ff says it's in a websocket protocol switch) but both basically just freeze
@KomalpreetSingh where?
wow, I just pushed a weeks work to git, 40 changed files this was terrible also very satisfying
[donning my Room Owner hat] 10 hours is still within our solicitation limit, but I think I'll allow it this time.
15:28
this is a regular browser, my program sends its requests to the local (or remote) webdriver and the webdriver controls the browser window almost like a normal user
@KomalpreetSingh you also have to be patient... it takes time
@KomalpreetSingh I'll take a look when I have some free time
@LFLFM Makes sense, that's kind of what I thought it was doing. My wireshark suggestion was only half-serious because I can't think of a plausible reason that the packets would be different.
Thanks for considering my request.
15:30
But sometimes I like to take the time to formally eliminate a possibility that I'm already 99% sure is impossible, just to reassure my sanity
@Code-Apprentice cbg
hehehe yeah... it can be an option actually; both browsers are failing at different points; I'm quite sure it's a bug in the underlying chrome webdriver code or something similar but if I could find a difference in the packets maybe there could be something I could do about it
thanks for the suggestion @Kevin :)
Unpleasant theory: the website really hates bots, so it monitors your mouse cursor movement for overly precise bot-like strokes, and sends you junk if it thinks you're robotty
I believe Google does things like this when deciding how often to serve you captchas
can't be, hangs before first load
loads just a few resources, not enough to even render before it freezes
Hmm, "bug in the webdriver" is slowly looking more likely...
I don't like to lay blame on something as fundamental as the guts of a popular browser, but if you eliminate all other possibilities, there it is
15:38
yeah, me too... I was debugging this for ages, then I was blaming docker (where I was running my selenium servers) and now I switched it all to local to try and debug better and sure thing the automated window simply does not load the damn site
15:50
@KomalpreetSingh Please read our chat rules ~ sopython.com/chatroom
Everyone should read the rules yes, but this one time I gave him an exception for the solicitation grace period :-)
Weird, 3 people came in asking to look at their question with quite a lil interval between them
I am percolating the problem as we speak... It would be going faster if I had some sample data though.
I have a theory that help seekers release a pheromone that lets them converge on a room at the same time
Interesting theory ;)
Thank you for your support, you'll get a shoutout in my Nobel Prize in Biochemistry acceptance speech
15:56
@Kevin Hurray :p
"I don't know if Cool Cloud is truly a cloud, but when my work was in hot water, he was cool"
Damn, that hit deep :PP You sure are percolating
cbg
I finished my chem test... woohooo
🥳
I have error says 'TypeError: Object of type HTTPError is not JSON serializable`
but what is it exactly HTTPError object?
I'm assuming it's an exception
what's the code?
def get_location_by_ip(ip):
    url = f'{GEO_IP_SERVICE}/{ip}'

    response = requests.get(url)

    response.raise_for_status()

    return response.json()


@app.route('/v1/api/checkCurrentWeather')
def check_current_weather():
    try:
        location = get_location_by_ip(IP)
        city = location['city']
        country_code = location['countryCode']
    except Exception as ex:
        return {'message': 'FAILURE', 'ex': ex}, 500

    return {"city": city, "country": country_code}, 200
Most likely an HTTPError is being raised by whatever library you're using to make web requests. It's happening because it didn't get a valid response from the server.
You may be able to get more detailed information by displaying the stack trace.
16:17
I'm using flask
try doing str(ex)
in the exception handler
Ok, I will try it
much clear now :)
{
  "ex": "401 Client Error: Unauthorized for url: api.openweathermap.org/data/2.5/…;,
  "message": "FAILURE"
}
yeah, ex was giving you an Exception object. JSON does not parse Exception object.
ok, tnx :)
so I have new issue
a str is a JSON object too
16:25
I'm exporting this env variable value
export WEATHER_SERVICE_API_KEY={my_value}
but still get the same issue
while locally it works
any idea why the container doesn't recognize it?
what issue?
it throws now 401
for apikey
but I set it in the env
and I know for sure it is right as I ran it locally and it works
I suggest making a question
that way we can see everything
Sure
I have this code:
i meant making an SO question
16:35
Yes sure
Yeah this might be a problem with the container and not necessarily Python, so posting it on SO will get some non-Python eyes on it
damn, keyboard doesn't work on repl
Why does this return None?
re.match('/boo/', 'abcbooabc')
But on regex101.com it shows that it's valid regex and it successfully matches the boo pattern
16:51
Try removing those slashes, Python doesn't use those to signify a regex
No luck
Oh, and use search, because match only checks the beginning of the string
it does work with how Kevin tells in regex 101
it does not match on regex101 (the slashes version)
I think you were attempting PHP's regex
Or perl, or any of its many imitators
16:53
I tried removing the slashes, the if still evaluates the expression as False
>>> import re
>>> re.search("boo", "abcbooabc")
<re.Match object; span=(3, 6), match='boo'>
if I do if re.match('boo', 'abcbooabc'): print("something")
it doesnt print something
1 min ago, by Kevin
Oh, and use search, because match only checks the beginning of the string
Yes, that is the correct behavior. match correctly identifies that "abcbooabc" does not start with "boo".
Ah
Thanks, I used .search and it worked.
So match only matches from the beginning of the string?
16:54
yes
thanks a bunch
think of match like == and search like in
except it's for regex
nah, think of match like .startswith
oh yeah.... that's a feature i didn't know existed until yesterday
so..
I'm six away from 400 🥳
omg
kevin
your emoji picker is awesome
😲
Thanks, it's one of my favorites
I did steal the idea though so I can't take credit for the concept, just the execution
17:07
there are two though?
Yes, there are at least two userscripts that do this, mine and rLemon's. I took the idea from him :-)
Are you unknowingly using rLemon's script and not mine? I won't take it personally :-)
@Kevin For container you need to use --env in the docker run command to pass env variables to the container. I tested and verified it's working
17:15
I'm the primary author of any script in a kms70847 repository, if that's not clear. That's my github username.
@12944qwerty Oh, ok, in that case there are three, and the two I wrote took the idea from rLemon's.
ok
@Kevin I realized yesterday lol
there are a couple emojis that are missing
unfortunately
It's pretty easy to change around which emoticons and unicode characters you want, just look for the <td> elements in the template and write in your preference. Of course, this still won't let you embed arbitrary images or platform-specific reactions, for example pogChamp.
yeah
nocie
i was thinking it should just load the image if it's by itself
but that takes space
I suppose you could insert a url to an existing imgur page. That should load the image properly when you send the message. Of course, it will just look like a url in the selector window.
Hi Guys, can I ask one question regards my code? :)
*one more
17:20
you can mess around with the logic though
maybe use a dictionary format
the keys are the selections and the values are the outputs
Exercise: refactor the script so that imgur links look like "noice(imgur)" in the selector window, but still paste in a url
Yes a dictionary may do the trick
@app.route('/driveStatus', methods=['POST', 'GET'])
def drive_status():
    if request.method == 'POST':
        try:
            data_json = request.json
            with open('input.json', 'w') as f:
                json.dump(data_json, f)
        except Exception as ex:
            return {"message": "failure", "ex": ex}, 500

        return {"message": "success"}, 200
locally, it creates the file input.json when I trigger the POST request form postman
ok, so far so good
but when using container, it just prints ` "message": "success"` but the file wasn't created
someone here once told me to not use frozendict... use something else instead. Anyone know what the alternative is?
17:23
I guess it has something to do with json.dump command
I, too, remember hearing that I shouldn't use frozendict.
what's a frozendict
It's a dict that you can't change after you create it. Available only as a third party module(?)
Apr 8 at 14:59, by Aran-Fey
The worst part is that frozendict is unmaintained and throws a DeprecationWarning, so you have to use immutabledict instead, which doesn't sound quite as catchy
a frozendict is when you label many types of icecream sandwiches and stick them in your freezer </s>
I think this is the conversation. Is immutabledict on pypi?
17:24
immutabledict! thank you :D :D :D
@rel.foo.fighters Maybe you don't have file write permissions in the container. Try writing a simple ordinary file, and see if that works. Something like with open("output.txt", "w") as file: file.write("hello")
json is usually pretty good about crashing promptly with a descriptive error message if it can't produce the right output, so I don't think it's responsible for getting to "message: success" without creating the file
ignore @Kevin
my bad :) I forget to map
Ah, gotta watch out for those maps.
it does exists inside the container
Success! Even though I didn't do anything.
I removed a bunch of emojis i'll never use and added a couple
and combined all the tools that I use into one bookmarklet
Actually I like it better when I don't have to do anything. Help seekers finding their own solution is a lovely sight.
k, gtg eat
bye
@rel.foo.fighters You know that it will be lost when you re-start the container, right?
Or at least probably will be lost
17:44
I half-suspected that's what was happening. File writes successfully, then vanishes into the ether before rel can check.
If you're thinking "it's fine, I'll transfer the file to more permanent storage before the program ends", consider just writing it to that location to begin with. If said storage doesn't have a file-like interface that json.dump understands, remember that json.dumps also exists.
@12944qwerty can I please remind you that our rules ask that you "Wait to post until you've written a complete sentence. Avoid rapid, short "stream of conciousness" messages. Avoid using abbreviated "txt spk".". I'm going back through the transcript to try re-base my understanding of what's happened and it's mostly you just firing off short statements exactly against that rule
And by "what's happened", I don't want to suggest there's been any event (poor choice of words). I just need to also keep on top of what's happening :)
There has been some crude words recently or abbreviations ;)
Is there a particular example that you think is inappropriate other than "kek" which, IMO, fails only on the socially-acceptable scale?
I could search
17:57
and more I guess
@CoolCloud can you stop now?
Everyone tries to be annoying these days
@roganjosh Yes I know
@KomalpreetSingh I already pointed you to our rules today when you asked the first time. You make me sad.
@roganjosh roganjosh rebase --force
I have a mental checklist of things that I'll allow myself to do with git and --force is not in that list for the safety of all! :P
18:07
--force isn't really an option for git rebase anyway
I got the sentiment though :)
@Kevin There's actually types.MappingProxyType in the stdlib, but A) it sounds gross and B) it's not hashable (CC @inspectorG4dget)
Thanks. I need that hash :P
18:56
@roganjosh My rapid short messages is a habit i picked up on discord... I'll try to fix it though. Sorry
Thank you
And I can't seem to find what you mean by "whats happened"
I can't remember either...
I'm a room owner, so it's somewhat on me to at least try and keep up to date with discussions and users. I did actually immediately clarify that I chose the wrong wording, and you've also just posted two messages back-to-back
oh, oops. I thought "what's happened" was something I said earlier. Oops
hm weird... I had edited a question earlier (and it got accepted by community) but the OP rollbacked it. The question was childish which is why I edited it... should I ask on Meta about this or what?
"The question was childish" don't waste time trying to salvage what isn't worth salvaging.
19:04
By the way, as long as you can't make edits without them having to be approved by more high-rep users, you should try to avoid making small edits. People have better things to do than review an edit that only made minor changes like turning a "thx" into a "thanks"
Even users that can edit with no approval will occasionally get into a rollback war with OPs. I usually just let OP have their way, I got more fun things to do
At the moment, I question the reality of the "question was childish" assessment tbh
I can link it?
Morbid curiosity says yes, but I think it's best that you don't
19:32
Can anyone give a conclusive statement to the comments here
conclusion, waste of time
To keep arguing, yes it is a waste of time.
Anyway, thanks @MisterMiyagi
@Kevin the official stance is that you need two people for a rollback war. You can easily avoid one if you don't roll back/edit twice.
@12944qwerty no
20:01
How does one become room owner? How did you guys become room owner
@Kevin That is fun ;)
radioactive meteorite
That's hulk
Your point being? :P
@roganjosh I don't think it matters anymore
20:09
@CoolCloud There is no clear path and I hope I didn't come across as obtuse on the point by adding to the joke
@roganjosh Not really
@AndrasDeak Kays, got it
20:40
So in the morning I wrote some code... and now in the evening I'm drawing ASCII art in comments... is it weird that I feel like the ASCII art is much more productive?
I guess today my commenting skill leveled up for the first time in a while
Depends on whether you can sell it?
Well you might refactor all that code eventually but the ASCII art is there to stay
@roganjosh I'd say no, but I don't understand modern art, so... there's a chance
I've drawn things (sparse matrix patterns) in comments exactly once in my life so far. But that was pretty important.
@Aran-Fey just turn it into an NFT
I bet it's possible. I'm desperately searching for a Banksy pun, for full disclosure
20:42
That's pretty much what I'm drawing as well
[ascii rectangle] + [another ascii rectangle] = [third ascii rectangle]
Me drawing in comments is like me using a second colour for whatever I'm writing/drawing on paper.
I've switched to Damian Hirst, the biggest joke, and my pun engine still won't start :'(
I have to admit that most art puns would probably go over my head anyway. For all I know you could've already made a dozen of them
Let's say I did (if you're none-the-wiser)
I still think Damian Hirst is an interesting guy... If my day job was putting blobs of different coloured paint on a canvas, I might be a little less stressed. But, hey, what do I know?
20:58
I think once you've become a popular artist, it's indeed smooth sailing. But getting there is probably a lot like winning the lottery. But then again, I could be completely wrong
...today we proved beyond a shadow of a doubt that IT guys don't understand art
...except for ASCII art
ASCII art is just underrated. I think that's the real problem :P
 
1 hour later…
22:09
I finally figured out how to configure the testing/dev sandbox for one of my 3rd party services!
or rather I figured out how to configure it to work with my staging backend
 
2 hours later…
23:54
Folks, does this generate an array?
` [eval(x) for x in attr]`
If so, what is this kind of syntax called?
00:00 - 14:0014:00 - 00:00

« first day (3849 days earlier)      last day (1324 days later) »