« first day (2987 days earlier)      last day (2186 days later) » 

00:15
for filename in os.listdir(directory):
    path = directory+"/"+filename
    outpath = outdir+"/"+filename
    img = Image.open(path)
    print(directory+filename)
    #save cropped image
    img.crop((100,30,110,50)).save(outpath)
This is going painfully slow as I have to crop 800 images, any way to speed it up?
yes, but it'll probably finish before you're done speeding it up, so it's not worth it
It crops 3 images every second
But, I need to crop 70 parts out of each image and I have 800 images
Well, look into multiprocessing
According to my calculations it will take two days
How much can I gain from multiprocessing?
Does that depend on my core count?
not sure
00:23
It also doesn't help that I have no idea how to do multiprocessing
From what I read, seems like the benefits of multiprocessing are limited by core count
It seems like people usually end up finding they're limited by data movement costs.
It's hard drive speed? Really?
I'm creating 696 byte jpegs lol
They are cut from 3mb images though, that could be the problem
I'm wondering if it will be faster cutting 70 different spots out of the same image than cutting 1 spot of 70 different images
@user2357112 Thoughts?
No, not hard drive speed. The cost of shipping data across pipes from one process to another.
The multiprocessing module involves a lot more of that than people usually expect.
Although it looks like you're dumping data to disk, so you might end up limited by disk writing.
I'm more likely to be limited by disk reading
I'm writing bytes and reading megabytes
Ah, yeah, you're reading too.
Also chat briefly died for me. Did anyone else see that?
00:32
nop
I'm going to see what happens if I cut out 70 different sections of each image and see if that slows it down as much as I previously predicted
00:45
Thankfully it must be limited by disk read speed. I'm doing 70 crops per images at exactly the same speed as 1 crop per image
 
6 hours later…
07:04
Proud of my Day20 spoiler
 
1 hour later…
08:14
users are nice enough to keep upvoting my 0 vote accepted answers and so as a result I'm unable to get the Explorer badge. Any ideas @AnttiHaapala?
what are the requisite conditions?
I think your answer has to remain +0 for 24 hours.
i really appreciate the offer tho
reason why I won't do hats is because I can't help but delve down into the pits of awful shenanigans in order to get me my hats. I had the most hats of anyone else on SO circa 2016 (not SE). My worst offense was creating my own tag and tagging 50 of my own questions with it in order to get a silver badge adn the associated hat. I remember relaying this story here before as a testament to my debauchery. JC said something like "You know I can see that, right?"
08:37
hehe...
you're right. But it's just so much fun. Minus the debauchery of course
I guess I'm just not old enough to be grumpy at all the young whippersnappers doing their thing :D
hmm I thought nothing is more fun than D
@coldspeed damn, which hat did you get now?
ah handle
necromancer
yup
the only "easy" ones left are freehand circle and explorer
I don't have handle either
08:41
"moderate" for me would be merlin and hard would be guru. Impossible would be anything requiring me to contribute to another site
I haven't even posted anything to meta yet
I've got the guru hat so
I'll catch you :P
oof, you old contributors with your old posts :P
it was actually a new post
@coldspeed question is from Dec 2 stackoverflow.com/q/53577739/918959
Ah, HNQs to the rescue
most of my hnq posts (much like my current post there right now) are all pandas posts and those only get a fraction of the traction
current board leader has the red baron
08:49
find a -3, edit it to be good and pray
I shudder to even think of answering downvoted questions these days. Backlash is real
all about the hats
@piRSquared in +3 is bad
-3 is utterly awful.
I'm not proposing this but this is where my mind goes. We can identify a question currently sitting at zero. all three of us downvote, then answer, then remove downvotes, then upvote and hope to get plus 5 on the answer
hypothetically... if all 3 people dv'd, then answered the question, then uv'd, would all 3 get the badge? Or perhaps the hat has a way of discounting your vote so you cannot influence things?
08:54
My guess is all three get the hat
@piRSquared that's crazy impressive, respect!
but you need to let the down vote sit for a bit so that it registers
Thx @Arne
09:13
@piRSquared How long did it take to complete?
About an hour total
      --------Part 1--------   --------Part 2--------
Day       Time   Rank  Score       Time   Rank  Score
 20   01:26:39    279      0   01:49:49    313      0
ok, was getting suspicious about my own runtime
wait, you mean to complete the problem or run the code?
complete the problem
wait, I'm not too sure about the difference
Are you talking about the time complexity / efficiency of the algorithm? Or how long did it take me to figure out how to make it work?
09:24
how long the code needs to run in order to give a solution
whole thing runs in less than 3 seconds
=/
seems i chose the wrong approach
09:38
probably because of these lines, where instead of passing indices I just copy parts of the string
:-) Just here to say Hi
hi =)
cabbage, in that case :-)))
 
1 hour later…
11:00
I agree with @Arne, @piRSquared solution to today's puzzle is impressive, hats off my master!
I get the tests correct, but my solution yields a path length that is too low - I'll have to revisit this.
11:25
@wim do don't sort, for starters. For the size of the numbers involved here, it is otherwise perfectly servicable. Rosetta Code has a few more options: rosettacode.org/wiki/Factors_of_an_integer#Python
@MartijnPieters Out of curiosity, how many times do you get @'d in a day?
I used a variant of the 3rd option, using set(chain.from_iterable((i, n // i) for ...)).
@coldspeed one more time just now... :-P
oops!
that's the majority, there are a few meta comments every week, and mod message responses perhaps (from people we contact and from the CM team).
That's weird, I get a Page Not Found
11:29
wait, not certain now that responses is public. I forget what mods can see extra sometimes.
@coldspeed there you go, mod powaz gone to my head. You can't see.
lot of powaz, indeed...
say you turn in for the day and wake up the next morning... how many notifications do you expect to see? 20? 50? (this excluding flag related stuff)
just trying to get an idea of what it's like to be the Popular Guy here
11:43
Adventous morning cbg
12:38
hello , i'm trying to add data to a table with sqlalchemy were 1 function will add half the column and another function will cover the rest for example x = {id=id , v=v } and in another function z = {id=id , b=b } the table look like this {id , b , v } whenever i try to insert z or x i get an error because i've not provided value for the 3rd item , how can i do this ?
13:15
cbg all
14:04
@coldspeed thanks
@piRSquared how about no
14:16
cabbage to all
hi! , could anyone check my thread if you can help me with SQLAlchemy with flask ?
@za001a I can't help you, but FYI the room rules frown on promoting Qs in here soon after posting
ok thank you for letting me know
@za001a Would be a tad easier to see what's happening if you clean up the code example (indentation does matter)
14:25
@PaulMcG i've just edited it and added upload2 function as well , is it more clear now ?
@za001a No - this kind of code is not valid
class Files(db.Model):
id = db.Column(db.String(255))
file1 = db.Column(db.String(255))
file2 = db.Column(db.String(255))
Likewise for all your method defs
is there a canonical way to set classes as "non-boolean"? Using __bool__ = None as for __hash__ produces a rather unhelpful TypeError: 'NoneType' object is not callable
@PaulMcG oh you are right , i actually have some renaming and saving destination codes which I've excluded them because it's not necessary but i've accidentally left out important stuff as well , I'll fix it.
i guess it's more clear now @PaulMcG
14:52
@MisterMiyagi what do you mean by "non-boolean"?
everything in python has to have a truthiness
(or raise an error, like boolean numpy arrays do)
@za001a I guess not - where do methods stop and start? If this really is how your code is indented then you have bigger problems. If it isn't then why are you posting this confusing mess of text.
@AndrasDeak well, not having truthiness ;)
same way that some things do not have a hash and the like
It looks like you are fairly new to SO, but please consider the people who you want to read your questions. If you won't take the time to carefully post your problem code, why do you expect them to take the time to sort it out?
@MisterMiyagi things that don't have a hash raise an error if you try to hash them. So whatever doesn't have truthiness should raise in their __bool__.
def __bool__(self):
    raise TypeError('I refuse to guess if I'm true or not')
@PaulMcG I'm fairly new to coding and that's how my code look like right now , not sure why you are saying this but i'm doing my best to make it as clear as possible
should I add the Javascript part . is that what you mean ? @PaulMcG i'm trying not to add too many noise stuff that might confuse others from zooming in on the real issue.
15:04
@AndrasDeak technically, it is hash (len, +, ...) raising the error
This code for example:
@app.route("/upload1" ,methods = ["POST"] )
def upload1():
importedFiles = request.files.to_dict();
for file in importedFiles:
    file1 = importedFiles[file].filename

file2 = ""
addFiles = Files(id=id ,file1=file1 ,file2=file2 )
db.session.add(addFiles)
db.session.commit()
but if there is no equivalent for bool, then a regular error it is
thanks
Please indent properly. Where does the method end? Where does the for loop end?
road to HNQ any possible dupe target for this?
I've never done things like this but if your class shouldn't do bool() then this is the only straightforward thing I believe
which is to say, this is just my educated guess
@PaulMcG it ends right before file2 in python space defines the end of the loop
ok
thanks, Paul, for your efforts :)
@AndrasDeak I think the numpy case you cited is a pretty strong indication there is no better way
Well, what else could there be? It can return True, or False, or...something else that is either truthy or not. You'll have to support things like if your_obj: ... where a truthy or non-truthy replacement would choose either way
which means that the only option is not returning anything, i.e. raising (also, in the face of ambiguity refuse the temptation to guess)
several operators allow "deletion" by setting their magic method to None
for example, __hash__ = None causes hash to raise a TypeError: unhashable type: 'Foo'
15:17
Ah, I see what you mean now. I'd guess truthiness is fundamental
I need to learn some more about teting and how to mock out stuff for tests, does anyone have any thoughts on pytest vs unittest, bearing in mind I haven't looked at pytests' fixtures yet?
Cabbage
Cbg, PM, how are you?
@MisterMiyagi That's what the docs recommend. But another option is to raise NotImplemented. But see the notes in the docs for NotImplementedError.
15:26
@PM2Ring not raise NotImplemented, right?
no sell
TypeError: __bool__ should return bool, returned NotImplementedType
Hi Andras. I'm ok, I guess. :) It's taken me a bit longer than usual this year to get over my usual winter depression, but my mood seems to be improving.
@PM2Ring I'm very glad to hear that! I'm always concerned when you disappear for a week or two :)
it seems Python does not allow to suppress the truth
kinda philosophical
15:30
object.__bool__(self)

    Called to implement truth value testing and the built-in operation bool(); should return False or True. When this method is not defined, __len__() is called, if it is defined, and the object is considered true if its result is nonzero. If a class defines neither __len__() nor __bool__(), all its instances are considered true.
Thanks.
the fact that python goes to great lengths to squeeze some kind of truthiness out of an object suggests that it's always intended to be defined
and when it isn't, well, it's an exception
an object without a meaningful boolean interpretation should probably always be considered truthy
just like it's the case for objects not implementing __bool__ at all
I presume MisterMiyagi has a good reason why they don't want to do that
@AndrasDeak Oops. :) Indeed, it's supposed to be returned, not raised. If I weren't on my phone, I would've tested it first...
15:33
not being able to use myobj or somethingelse or if myobj: seems pretty ugly :)
but now i'm curious what his usecase is
@PM2Ring well the doc links make up for that I think ;)
@ThiefMaster well it better be a good one, because "oh right, I could just leave it truthy" would imply a lot of wasted time :D
Oh, good. :) But anyway, if it's totally forbidden to call bool() on the object then IMHO an Exception of some kind ought to be raised. And I guess TypeError, or a subclass of it, is appropriate.
that's what I thought too
15:40
@ThiefMaster I am experimenting with creating awaitable events based on wrapped values
OTOH, I totally agree with ThiefMaster that such an object is non-Pythonic, so MisterMiyagi better have a yamming good reason for creating such a thing. ;)
so that it is possible to do something like await (value == 42)
but that makes it pretty easy to accidentally mix synchronous and asynchronous truthiness
what's "synchronous" vs "asynchronous" truthiness?
so the wrapped type should forbid direct truth tests
is value your object or is value == 42 your object?
15:44
value is the object that should not support bool
but what you use there is __eq__, right?
yep, that one is not restricted to boolean return values
I don't get it, but OK :P
and yes, I do have a necronomicon on my table right now
I'm starting to suspect an XY problem but I know nothing about async so I can't know for sure
15:50
@AndrasDeak let's say we have a threading.Event. synchronous is event.is_set() and asynchronous is event.wait()
in the one case, you want the truthiness right now
in the other case, you want the time when the truthiness is true
@MisterMiyagi So make your __eq__ return NotImplemented, like the linked docs say.
Hi
Somebody recommended me wing yesterday. I am trying to open a remote project but it somehow can't open folder it is looking for some project file on the remote, but I don't get how to create it, any ideas?
@Andras If your wife is into scifi, she should definitely check out the Mathematical Fiction database.
Dec 3 at 15:52, by PM 2Ring
A few days ago I discovered Alex Kasman's Mathematical Fiction database. "This database lists over one thousand short stories, plays, novels, films, and comic books containing math or mathematicians".
@PM2Ring __eq__ is working fine, it is __bool__ that seems to require explicitly raising an error
Rightio
15:56
@PM2Ring thanks, I'll pass it on
and that reminds me, we still owe you a crochet sphere testing ;)
@AndrasDeak Yes, you do! :)
cbg
@PM2Ring link is a dud
Can I do anything about a wrongly declined flag?
15:59
@timgeb yeah, complain on meta for instance
I have a feeling when I post this on meta that it will be instantly closed as a duplicate of "how to use the not an answer flag".
in that case show me the post first
(they might be right)
It's not Python, but I'd like to hear your opinion: stackoverflow.com/questions/12627443/jquery-click-vs-onclick/… - How is this attempting to answer which method to use when?
Yeah, that's not NAA, just pointless crap. Use 20k delvotes for that.
So any answer that contains random code is not NAA?
16:02
it could be seen as an attempt to answer, which makes the decline valid (sort of)
That database has some great stuff. But sadly, many stories written by non-mathematicians portray mathematicians as asocial, or socially inept, or downright evil. :( Alex (the maintainer) often complains about that. He's written a few stories himself that avoid that stereotype. I've only read one of his stories (so far), but I hope to read more of his work.
@timgeb you'll often see that yes
mods shouldn't have to use technical knowledge to handle flags, and a technical answer that's blatantly wrong falls in this category
Well, I know that now. I have always flagged random code as NAA and never got it declined up until now.
it also depends on the mod handling it
But there's probably no point in contesting decisions on posts like these. Just let the community delete it.
I think the decline comes from a review.
16:04
@PaulMcG Oops. Thanks.
@timgeb I think that should only dispute it
Hmm, I can't say that I agree handling any code as an answer, but at least I know how the game is played now.
it's not an answer, but flags will be a gamble
otherwise this is the go-to reference: meta.stackoverflow.com/questions/287563/…, see the infographic
this is somewhere between "rotten apple" and "granny smith among all the idareds"
It's orangest orange.
There's still on-going discussion to change the flag description text to make it a bit more obvious... but... 6-8 and all that...
16:08
I just won't use that flag anymore if the answers contains any code.
use it on link-only crap
Mods don't generally have to handle NAA/VLQ flags... (there's some cases where an NAA flag jumps straight to the mod queue instead of the community queue - accepted answers for instance) but generally the community reviews them (mods don't by default see anything in that queue that's less than an hour old) - mods just pick up any slack pending.
@timgeb If an answer looks so bad that it could've been posted by a bot, then you can flag it as a possible spam precursor, with a custom flag. But if it's merely technically wrong, then it should be handled by the community.
and by link-only I mean link-only where there's no useful information left if you strip the hyperlink
@PM2Ring the answer I'm talking about is not technically wrong. It's not an answer to the question asked by OP. :)
16:11
@timgeb Oh, ok. I guess that makes it VLQ. I'll take a look at it...
Whoever recommended me wing was ludicrous, the GUI is sooooooooo buggy
@timgeb yeah... however, it's still an "answer" - be it completely wrong or an answer to a different question... the NAA flag is used to indicate what's in the answer box is a comment/doesn't contain an answer otherwise kind of thing.
It's impossible for an answer to answer no other question.
@Hakaishin I don't know anyone who uses Wings IDE - let alone anyone that'd recommend it... think I've installed it and tried it once and just immediately got turned off...
16:13
Yeah. That's bad. Probably not a bot, but definitely clueless. ;) But it's deleted now.
yeah, like I cant stick the project window back into the window... Like no way
@timgeb so NAA is basically: "could you provide more information about what x is?" or "I'm having the same issue - did you ever solve this?" - should be a comment... "look at <some link here>" - no content in the answer itself even if the link does answer the question...
I think PyCharm is pretty much the go to IDE these days if one wants to use an IDE?
thanks
holdenweb recommend Wings IDE for its SSH capabilities.
He also conceded that it's an uncommon requirement
albeit pretty cool
16:18
umm... interesting... depending on the OS though, you can always mount a remote filesystem over ssh as a local directory and just work with that...
wow I think I was never this fast disappointed so hard by a product. Bye bye wing
@JonClements can't run it in the remote env that way though, and I think that's the real kicker
@JonClements Not really, I tried and it lags like hell and it is officially not supported
oh... so it goes to levels beyond what I was expecting then... (probably should have read a bit more on it before commenting :p) @Arne - sounds cool though... not something I'd use but cool none the less...
it's super useful when working on strange architectures that don't support IDEs
which is what I did actually, I wrote openstack drivers for IBM mainframes
I bet you'll be shocked to hear that I couldn't install pycharm on them directly
16:26
oh terribly shocked... my heart just can't take it :p
Mind you - I have mixed feelings about IDEs anyway... sometimes they're absolutely fantastic and other times they just seem to get in the way...
Yeah, I never want to go back to Eclipse
man anyone here work with AWS?
Why don't they update their UI
its so boring
been like that for years
there's a rolling update for the UI been happening the last few months
rds is on the new look, not that it's much to write home about
i'm less concerned with how it looks and more concerned with how slow it is
16:29
I wish wish they changed the color schema from that blue whit whatever it is
it's fast if 2 people use it
but for company wide stuff... omg
shrug I use everything with dark reader on anyway
@Arne when Eclipse originally came out - I was actually really quite hopeful about some kind of universal IDE... but then, spending a few hours with it (mostly waiting for it to do anything) and then trying to grok what it expected of me to do be able to do anything configuration wise etc... I left it be...
I used google cloud. Was even slower
I still find Eclipse more useful because people around me know Eclipse so it's easier to get help
nah, it's slow fullstop. There are only four or five users here and it's brutal at times. We obviously try to keep everything automated with terraform or whatever, but sometimes you can't help being in there, and ugh
Wasn't any slower or faster at OldCo, which had a couple of hundred on
it's uniformly mediocre, but hey, consistency.
I'm currently working on a cloudformation script. There has to be a better way to do this than messing around in sublime.
the only time I go into the console a lot is for S3 stuff and man is it slowww
16:36
@qaispak umm... never had many issues with "slowness" in gcloud...
@JonClements It's incredible how brave they were to ship something as slow as eclipse
I honestly spent more time waiting for it then programming back then
start pc -> get coffe, start eclipse -> get a cake, eat it, nap, maybe be able to start working
@Arne yeah... it seemed fairly monolithic - while what I was excited about was potentially for extending it and modularity for things... that err... didn't strike me as ever really happening...
I was expecting it to be a fairly light ide framework with plug and play stuff - not a behemoth that it ended up as...
 
1 hour later…
Neo
Neo
17:40
Hi, does anyone knows whats wrong with this regex:
vlans = re.findall(r'\bNO\s+\K\S+', output)
It works in regex101 site but not in python
It is supposed to grab next data after NO
VR-Default    10.10.40.9   16      NO  V10-Test-VLAN  50
It returns "V10-Test-VLAN" in regex101 but empty in my code
I am thinking I need to a escape character somewhere or something like that
Does \K need to be escaped?
Neo
Neo
I dont this so
\K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
Not in standard Python regex
Neo
Neo
hmmmm
I got rid of \K. now it is working but also grabbing NO
morning cabbage
17:47
@Neo you need to match NO without capturing
regex rather than re has \K I think
Neo
Neo
\K not seem to be working. I am using re
Even looking at my IDE color coding /K does not look same as /b and /s+
yes, that's what I said
Neo
Neo
yea sorry
I thought you meant the other way
in Android, 2 mins ago, by Dave S
why are pandas hanging out in python wtf
Neo
Neo
(?<=NO)\s+\S+
Thats a bit better but add extra space before
Guess I can do that after
vlans = [x.strip(' ') for x in vlans]
You could omit the argument to strip without harm, I imagine.
18:28
>>> re.findall(r'NO\s+(\S+)', 'VR-Default    10.10.40.9   16      NO  V10-Test-VLAN  50')
['V10-Test-VLAN']
Neo
Neo
ooohhh thanks
on regex tester it also shows match on NO
but when I run it in python, i only gives me VLAN name
Thanks!!
@holdenweb Wings IDE didn't work for Hakaishin chat.stackoverflow.com/transcript/message/44894906#44894906
@Neo re.findall is a little different to doing a basic re.search, which is (probably) what your regex tester does, but I haven't used any online regex testers in ages.
 
3 hours later…
wim
wim
21:09
    def f1(n):
        s = ""
        for c in string.ascii_letters * n:
            s += c
        return s

    def f2(n):
        s = []
        for c in string.ascii_letters * n:
            s += c
        return "".join(s)
guess which one is faster
f2 with really long string, and f1 with short strings ?
In CPython, I thought that an optimization was added for concatting strings, so for CPython, I vote f1
By long and short, I meant n obviously ;d
wim
wim
I tried n in 1, 100, 10000, 1000000 ..
21:18
The suspens is unbearable.
wim
wim
Hey is this cheating? AoC day 20 spoiler
suspiciously easy one. I feel like it's maybe cheating to use these libraries!
I was at a party last night, bummer I probably could have made a top spot on the global leaderboard :(
Was it f1 or f2 then ?
wim
wim
%timeit yourself ;)
wim
wim
21:48
@piRSquared this code is buggy
21:59
rbrb
wim
wim
@MartijnPieters yours is bugged too
>>> data = "^E(N|S)E$"
>>> rmap = RegularMap.from_regex(data)
>>> rmap.furthest_room()
(2, 0)
>>> print(rmap)
#######
###.###
###-###
#X|.|.#
###-###
###.###
#######
correct answer is 3, not 2.
ENE is not a valid regex on that map
or is that your point?
wim
wim
that's my point
Ah, yeah. That map is shaped like a fork with two prongs
wim
wim
>>> import re
>>> re.match(data, "ENE")
<re.Match object; span=(0, 3), match='ENE'>
22:05
yeah, I meant the drawing
wim
wim
that the second day in a row Martijn was able to get correct answer with a bogus algo, man that guy is lucky!
>>> data = "^E(N|S)E$"
>>> g = graph(data)
>>> render(g)
  #####
  #.|.#
###-###
#X|.#
###-###
  #.|.#
  #####
22:23
recbg
 
1 hour later…
23:49
@wim what’s a test string that I bug out on? Will check it later

« first day (2987 days earlier)      last day (2186 days later) »