« first day (2957 days earlier)      last day (2216 days later) » 

00:38
so why did my comment on this not work stackoverflow.com/questions/53384189/…
@AndrasDeak ... yeah i know how to do it in markdown in general ... i thought maybe they had an alternate markdown in the comments (or maybe its just not allowed... although i swear i see it all the time)
ahh the space :
:P
lol whoops
obvious now
 
3 hours later…
04:05
recbg
cbg @JoranBeasley
04:30
>>> import sys
>>> sys.stdin, open(0), open('/dev/stdin')
(<_io.TextIOWrapper name='<stdin>' mode='r' encoding='UTF-8'>, <_io.TextIOWrapper name=0 mode='r' encoding='UTF-8'>, <_io.TextIOWrapper name='/dev/stdin' mode='r' encoding='UTF-8'>)
If I do each of those separately on a different line each in my Python 3.7.0 interpreter, my Python shell exits as if did a Ctrl-D.
No traceback, no nothing...
I wonder if one/any of them does EOF on __del__ when GC'd...
Actually, two open(0)'s are all it takes...
 
2 hours later…
 
2 hours later…
07:45
cbg
Anyone are from Melbourne?
08:16
cbg
 
1 hour later…
09:26
How would I properly implement consumer threads that can be shut down on demand? Currently I'm doing something like while True: task = queue.get() in each thread, but I need a way to do somehow abort the queue.get if the thread was asked to shut down
The ugly solution would be to use a global stop_threads flag and poll for new tasks like while not stop_threads: try: task = queue.get_nowait()
 
1 hour later…
10:54
@Aran-Fey there's a suggestion to put a kill token onto the queue they are waiting for. Is that applicable?
11:09
Oh, smart. Sure, that works
11:58
I've used that in practice when distributing tasks to a thread pool. Pushing a None onto the queue for each worker (they stop reading the queue at the first None input) shuts things down in a pretty orderly fashion.
 
1 hour later…
13:19
Yesterday I was mad that there isn't an easy way to automate interaction with simple print-and-prompt programs, but now I've decided that doing so would be a hard target to hit. It's a leaky abstraction. I was thinking of these kinds of programs as having certain properties, e.g. if stdout is non-empty, then that's a prompt and it's ready to accept something via stdin. But even very simple programs can't guarantee this.
track = input("Enter track name.")
print("Ok. Adding track to playlist...")
time.sleep(1)
artist = input("Enter artist name.")
Here's an example. If you read from stdout while time.sleep(1) is running, you'll see the "Ok" string in the buffer, and assume it's waiting for stdin. But actually it's doing I/O on the playlist.
The automation prototype I wrote yesterday is basically only useful when used on a program that only prints to stdout via input calls. That's rare even in Contrived Thought Experiment Land.
> In theory, there is no difference between theory and practice. But, in practice, there is.
Yeah, expect has its limitations. If the text dialogue isn't amenable to prompt recognition it becomes impossibly difficult.
I'm going to go out on a limb and guess that the average OS doesn't have a way of signaling that a process is waiting for input
I believe you are correct, Captain. That would seem logical.
you don't need two opens, a single one is enough
$ python3
>>> open(0)
<_io.TextIOWrapper name=0 mode='r' encoding='UTF-8'>
>>> 2
2
>>> # exits after printing this
13:39
Please sign my petition to make input() append chr(5) aka ENQ aka Enquiry to the end of all prompts, so automation programs can tell that they're prompts
Does one have to respond with chr(6), then?
Only in very polite contexts, like if it's a program written by a queen or emperor
Hmm. Concept: a programming language with honorifics
private/protected/public is already halfway there, really
for foo the printable in stuffy the iterable:
print thee (foo)
like that?
13:47
Mm hmm. And let's replace import with announcing
cbg!
Yo
"@Facebook employees, @Twitter employees don’t believe their company has crossed a line yet. They haven’t put down the tools. And by continuing to aid the companies making those decisions by selling them their labor, they’ve become complicit in their actions." https://twitter.com/m_ott/status/1064066806162296833
context?
I recall reading that Facebook did something bad involving privacy the other day. It must have been pretty bad to distinguish from the ordinary day-to-day badness they've been doing for years.
13:56
I'm told they hired a PR company that creates fake news or something
14:32
I haven't got the emotional bandwidth to be outraged about big scandals but I hope everyone else does because if nobody gets outraged then nothing gets fixed
> You are blocked from following this account and viewing their Tweets.
Interesting
On a totally unrelated note I watched the "Ballad of Buster Scruggs" movie by the Cohen brothers last night and it was outstanding. I don't have the attention span to watch movies normally but this an anthology. Worth watching for sure and it's now on Netflix.
I know that's way off topic but given the fact that it's a slow day and that some will have time off for Thanksgiving I figured I'd throw that out there :)
O Brother Where Art Thou has been on my to-watch list since it came out.
And it's probably going to stay on that list for a long time... I'm not actually sure how one is supposed to watch a movie if it isn't on Netflix or in one's local Redbox vending machine
If the answer is "identify the distributor of the film, subscribe to their proprietary streaming service, watch the movie, then unsubscribe", I think I'll just skip that and read a book instead.
14:51
Could someone here help me out with something on django?
Fire away, but be ready to be asked for an MCVE
pastebin.com/wcbw0nG3 // I'm trying to implement a functionality on the checkout screen where the user can type a new quantity and edit the existing quantity of the item ordered
My template has some extra functionality below which isn't a part of this, hence it seems abrupt but yeah. I'm trying to have the user change enter a value and click on modify, then the quantity gets updated
is this going to be about {% for order_detail, weight in order_details %}?
that bits fine. I added a form where I type a new quantity
and I want to update the previously added quantity
prntscr.com/lkqe8j // This is a view. I type the quantity and click on modify. The 12 gets updated to 5
\o cbg
15:03
But?
MultiValueDictKeyError I get this error
cabbage, Moo
That was for MooingRawr.
item_id = request.POST['{{order_detail.supplyID}}']
I may be missing something but what's happenning here?
I honestly didn't make the models and I don't like the way it was made. I'm trying to locate the item which was modified and replace the quantity
Could you suggest some way I can collect the value from the user and just edit the quantity of that particular order?
15:11
Two points:
- your POST form only sends the quantity, doesn't send the item id.
- POST['{{order_detail.supplyID}}'] is not how you retrieve that id from a dict
How do I send the name
NameError at /ASP/changeQuantity
name 'POST' is not defined
<input type="hidden" name="id_or_some_better_name" value="{{order_detail.supplyID.pk}}">

and then get it with POST['id_or_some_better_name']
request.POST was implied sorry.
But the fact that you didn't pick up on it makes me want to refer you to the django documentation =|
Well I've literally been using django for the first time the past hour
so
What about python?
Don't mean to be rude, just want to gauge the recommended reading.
ValueError at /ASP/changeQuantity
15:27
your changeQuantity view does not save the changes it made to the object and does not provide any context for the template. Which means you need to read the tutorial at least, specifically the part about using the models API. Then you have the general reference. Be patient, it's worth investing time in the docs.
How can I go about saving the changes?
API reference for models. Again, reading through the tutorial will take less time than going on a wild chase after errors without understanding what you're doing.
Should we expect answerers to catch logical redundancies? stackoverflow.com/a/53395885/2336654
specifically:
(df.f >=50) | ((df.f<50) & (df.C<8))
I don't consider it downvote-worthy. I might count it as a demerit if I'm on the fence about upvoting.
I think I agree with you
15:41
Okay reading the docs help xD Thanks
16:08
if OrderDetail.object.filter(supplyID=cleaned_info['selected_supply']).exists() //What's the syntax error here?
An if must end with a colon
Other than that, there's no syntax error. Note: there are other kinds of errors besides syntax errors.
Yeah just realised lol
(Ok, //What's the syntax error here? is itself a syntax error because Python doesn't use double slash for comments. But I assume that's not in your real code)
yeah that isn't
just forgot the colon
@Kevin You aren't missing anything. I know it was popular, but I personally thought "Brother Where Art Thou" was crap.
@JerricoKyle You forgot the newline and indentation after the colon too, if that really was your code. Single-line compound statements damage readability.
16:21
To answer my own question from an hour ago, apparently I can watch movies via Youtube/Apple/Amazon for about three dollars. Whether this is possible without subscribing to something, is not something I could determine from the thirty seconds of research I did.
Ah, it wasn't a multi-line compound statement, just a long condition. Pardon my inattention.
wim
wim
17:05
@FrankAK I'm from Melbourne
17:49
cabage
18:04
cbg
@idjaw do you know about flask or wtforms?
I know about them yes. I've used them for my particular use cases. Less wtforms though.
btw, you don't have to ping people directly unless an ongoing discussion is happening and you want to address that particular person in response (and even then, don't over ping :) Chances are after the first ping they are aware). If we are around we will read the message and answer if we can.
i want set selected attribute to a option of a queryselectfield using a variable
Yep, definitely don't know. :)
jejejeje dont worry
18:11
I'm not a big wtforms user at all. I build APIs mostly. I barely do any UI work
im taking a course in pluralsight and say this "flask is only for APIs, is not for full stack web development" is that true?
90% of the Flask questions I see have nothing to do with APIs
i agreed, i use it for web development, is easy, flexible and powerfull
Anyone asserting that "X can only be used for Y" had better provide citations, or preferably a complete proof
^^
I think that statement is executing a very poor job at trying to explain a use case for flask as opposed to django without specifying django
thus making that statement really bad
18:19
yep
i understand that he want explain the difference because have some knowledge of flask, but if is new person in flask will get confused
18:33
I have a question off-Toppic
Can I ask it please
yes, i guess
I want to extract a video of my powerpoint presentation because i lost it.
How can I find the path of the video in the power point presentation.
PS: I'm using Microsoft Office 2010
in the presentation still play?
Yes
I found a video on Youtube where the guy can just save the video with right click button, but when i try to do the same thing, I don't find the option to save it as a video. I just have the option to save it as image file
The video is still in there and I can play it but there is no option to download it or copypaste it
18:55
seriously, 3 downvotes for an answer that explains about triangle numbers, but 2 other answers that do exactly the same get upvotes.
Gah, do I need to come down like a moderator ton of bricks on something here?
Behavioral interference. Sometimes, I get the impression that there is a certain time of day in which the participants resent me answering. This is probably in my mind but it speaks to the imperfectness of SO voting as a measure of goodness.
One downvote from each other answerer, plus one downvote from Martijn's Tyler-Durden-esque alter ego who's trying to get him to quit the site and start a fight club instead
wim
wim
@MartijnPieters I'm not sure 3 downvotes are warranted (probably not), but it looks like the OP is trying to learn basic programming, and not learn a mathematics trick
From a certain perspective, programming and math tricks are the same thing ;-) (but yes, I know what you mean)
wim
wim
That being said, the fact that a closed form solution exists should certainly be mentioned as an addendum in an answer
19:01
There was a question earlier today about Project Euler problem #1, which has a closed form solution. The asker wanted to know why his O(N) approach didn't work for N=10**9.
@MartijnPieters YES!!! IRON FIST OF MOD POWER
wim
wim
ton of bricks not very ninja style
Rather than answering, I told him to check the message board for the problem, which is only accessible to people that already solved it. I didn't want to contribute to the increasing spoilerification of that site
@idjaw i resolve it jejeje using replace from jinja template, changing value= to selected value=
@wim ton of bricks—but you never saw it coming
19:10
cool
do you know a way to pass values avoiding GET, for example to delete with a id, how pass this id? in flask
I don't understand
for example, you have this route
@person.route("/delete/<id>")
def delete(id):
 delete_function(id)
 return "yeah deleted"
OK. What is the exact problem you are facing
wim
wim
the id comes from the url
19:14
i solved the first problem, the select with a selected value for a edit form, preselect based on database value
wim
wim
so the client would be HTTP DELETE to yourapi/delete/1234 for example
ujumm
how to avoid that
wim
wim
don't
that's how you write a REST API
what do you mean avoid that? What is your actual goal?
protect my app to someone that want delete person with id=4 and change to 12 in url
wim
wim
19:15
we don't need any more crappy APIs out there please
if some is facing the same problem, this is the solution. :)
I fixed out. I Just changed the file end name from test.pptx to test.zip and decompress it then I found the video in media file.
@VictorAlvarado It is up to you to protect and sanitize. So if someone tries to make a malicious call to your service via API, you need to make sure that you have the necessary logic to catch and reject
@wim because that i want sanitize jajaja
if you have an API call that is delete/<id> and you don't actually want that functionality, then remove that API call
wim
wim
google authorization / authentication
19:17
I almost accidentally deleted my google account the other day, speaking of which. I was sweating from panic.
i used a checking like this:

if person.id in the url is equal to que person.id in the edit form you can delete, either not, the original person.id is in a hiddenfield

the other way i thinking was do the redirect with a POST not a GET
but my interest is know if there exists more clean solution for that
something like passing the id encrypted or someone else
your ultimate goal is to make sure that work being done by a user is done only against their own id?
so if they provide another id in an attempt to be malicious against another user you want to catch that?
This sounds like you need to use proper authentication/authorization as hinted out by wim
yes, but... i do it that with the user configuration section
Don't do this yourself
It's all done for you already. Use what's available to you
is now in the autorization i use flask_login, and work properly
know want avoid the user delete "payment" record with putting any values in the url id parameter
19:22
I'm missing something, here. If you can get the id out of a hidden field, then why have a url parameter at all?
i want only can delete the payment that he clicked in a list that i generated, sorry for the english and for be a vampire of asking jajaja, the problem is that i from venezuela, and the spanish site is not too good in flask answer
because first i show a list with all of the id of the payments
later click in "DELETE" or "EDIT" , this is a <a href> with URL_FOR(url, id=id)
the id is generate from a loop
after that, a edit form appear and the url get id=2 or id=3
It really sounds like you need some authorization model to separate user groupings
you seem to be trying to implement too much of what can be given to you for free
i do that in PHP, using javascript
but in python is different
using post for every thing
This isn't a language constraint. Both would be solved with the same design mechanism. You authenticate, you check your authorization level, and you perform said action whether you are allowed to or not. Underneath it all, most of that code is the "same". Maybe you have different libraries you can use in that PHP/JS combo. But you're ultimately doing the same thing.
@wim: I must note that triangle numbers are taught, at least in then UK, in early high school, generally before programming is.
19:29
How much high school math do people usually retain? Percentages? Interest rates?
And for most coding challenges I’ve seen the point of an exercise like the one in that question is to remind people of the importance of remembering your basic high school math..
Anywho, it’s been a long, long day. I’m now in a pub being plied with beer by good friends. I’m off-ski!
enjoy @MartijnPieters
@AndrasDeak PYTHAGORAS!!!!!!!!!!! aaand we're done. There really wasn't anything else right?
integrals and derivatives are the hell
im system engineer and see more than 5 mathematics and calculus
19:36
I didn't learn any of that until college
well I'm from Quebec so it's a bit of a different system
We don't have Grade 12. We do two years after highschool and then go to university
in the high school i see only derivaties and limit
yeah I did calculus 1, 2 and linear algebra in "college"
let me traslate college and high school for a moment jajaja
in my state, college if for 12 year to 16 aprox
later university
college is like 2 or 3 years, this depends on the grade you want archieve
wim
wim
remembering your high school math is important so that you can do complete stupid coding challenges efficiently? got it :)
2 year = bachelor
3 year =
average technician
jajajaj, even with that i cant do challenge :( the algorithms freak me out
19:41
@wim What else is it used for? :P
even i see useless the algoritms in web develop or they are in other place?
wim
wim
tipping your server
I use a lot of trig and vector math for non-coding-challenge stuff.
Yeah but you're Kevin. You don't abide by the same rules as us mortals.
jajajajaja
wim
wim
19:43
In English we normally use h, like this:
jhjhjhjhjhjhjh
hue
sometime ago i found a web with a lot of challenge, i will paste the url
jhjhhj
Careful with the laughing. Kevin is known to turn people in to geometric shapes that he later uploads to imgur
the cemetery of gifs
is we laugh if jajajaja, if with laugh with "evilness" jejejeje
:O
19:44
lol
or he will transform me into a kevin script variable like
victor_alvarado = False
Be good or The Kevin will garbage collect you
he is good and will do this: idjaw.right_ear(enable=True)
how old are you boys? just curious, im 23 year old
I'm older than you by a lot. I'll just say that.
@Kevin Exception catched, syntax error: The Kevin garbage will collect you.
19:47
I'm older than you by seven years. You may need some high school math to solve this.
where seven might or might not actually be seven
I'm older than Kevin by one year.
stackoverflow
me: 23
kevin: 30aprox
idjaw: ∞
ahmyohlin: 31aprox
wim
wim
I got this invoice the other day
lucky I paid attention in basic math!!
Any waiter cunning enough to hack the receipt printer maybe deserves an extra buck forty
Trying to figure out where those numbers even came from. It's not just adding a flat fee to the balance due before calculating tip, because the numbers work out differently for each percentage. The balances for each one are $37.(7), $37.8, and $37.(18) respectively.
Might be a piecewise function. "For any balance above $29 and below $35, print this gratuity guide, which contains numbers I made up on the spot when I was hacking the printer"
20:05
lol
nice job doing the math
wim, you need to go back to that place and make several purchases in different cost ranges so we can get more data points
3
wim
wim
hmm. tempting, despite the sarcasm.
Ok I need help thinking of most efficient ways of doing a pandas task. I have huge csv files 10+gigs. Each main dataframe has a column called text I want to sort on this based on 500 keywords. So in the end I get 500 dataframes or 500 csv files with rows from the main dataframe
Now I only have 8gb of ram, so I have to probably go line by line
500 10gb files each sorted a different way?
No. let me give an example for clarity.
Main DF
date           text
10-10-2018     I like apple
10-10-2018     Bananas are my favorite fruit
10-10-2018     Kiwi and apple shakes are the best
10-10-2018     got some rotten fruit


keywords: apple, banana, kiwi

apple df
date           text
10-10-2018     I like apple
10-10-2018     Kiwi and apple shakes are the best

banana df
date           text
10-10-2018     Bananas are my favorite fruit

kiwi df
date           text
10-10-2018     Kiwi and apple shakes are the best
20:15
Hmm, there's a couple Maggiano's in my own neighborhood. Time to take science into my own hands.
U can call and ask?
:P
I don't think they'll give out their secret tip formula. They'll probably just apologize and say they fixed the problem. That's no fun.
What we really need is someone who works at Maggiano's
wim
wim
@Kevin ...and they'll send someone to bust your kneecaps later that evening
Just another Tuesday in Jersey. Bada bing!... That's a thing we say here, right?
wim
wim
20:22
Ooh wop de do wop de do
@wim hehe
catchy song
I'm having trouble loading an image in my Django template. Any pointers what docs to read to figure this out?
@Kevin Those all seem due to rounding...it should be $37.(81). If you take the $37.80 amount and calculate the tips, they all round to the given amounts...but why $37.80 when the total clearly states $29.99?
20:42
You're right. The mystery continues.
@ex080 This doesn't look like sorting so much as filtering, which is a much easier job. I would create a {keyword: outputfile} dict mapping each keyword to an open filehandle for that keyword's output. Then you can read the raw file line by line, and for each keyword, if the keyword is in the line, copy the line to that keyword's output file.
You don't even need a dict really, just a list of (keyword, outputfile) tuples, since all you are going to do is iterate over them for each line in your source file
I go it working like this so far, but I'm concerned about efficiency.
keyword_outfiles = [(kwd, open("{}.csv".format(kwd), w)) for kwd in "apple kiwi banana".split()]
for line in source:
    for kwd, outfile in keyword_outfiles:
        if kwd in line:
            outfile.write(line)
Ahh ok so the list comprehension will be better?
import pandas as pd

# Represents big data 6-10 gig dataframes
main_df = pd.DataFrame([
['10-10-2018','i like apple'],
['10-10-2018','bananas are my favorite fruit'],
['10-10-2018','kiwi and apple shakes are the best'],
['10-10-2018','got some rotten fruit']
],columns=['date','text'])

# Sanity check for read in
print(main_df.head())

# Keywords I am interested in sorting by
keywords =['apple','banana','kiwi']


def sort_by_keyword(keyword):
  # list to hold indexes of matches
  sortedIndex = []
The list comprehension is there to be shorter to type in chat, not necessarily better.
20:54
I figured it would be easier to filter and grab the index only then pull the rows I want by index save and free up memory.
If you have only 8GB, will pandas even be able to hold your original raw source data? The code I posted has a comparitively tiny memory footprint.
I have a 15 gb swap
Is this some kind of pandas homework assignment, where it is required that you use pandas?
If not, why are you using it?
21:10
No im just most familiar with it. Open to different way.
Never use things like .iterrows with pandas ;)
Or at least, try not to.
    import pandas as pd

    data = {
    	'A' : ['some_dates', 'some_dates', 'some_dates', 'some_dates', 'some_dates'],
    	'B' : ['i like apple', 'i like apple', 'i like bananas', 'i like apple', 'i like peach']
    }

    df = pd.DataFrame(data)
    print( df.loc[df['B'].str.contains('apple')] )
            A             B
0  some_dates  i like apple
1  some_dates  i like apple
3  some_dates  i like apple
@ex080 I'm sure if you posted the question on SO, you'd have a better answer than this one.
@ex080 - have you looked at the 5-liner I posted? Short of writing the headers on all of the output files, and closing them when you are done looping through the input data, it should do everything you want.
So, there is an actual SO question for what he asked ? I'm lost.
No, I posted a 5-line code snippet earlier in the chat.
21:26
Oh right, he uses pandas but it is not mandatory.
I never tried to read a 10Gb+ file using only python, shouldn't it be faster to use pandas to process the data inside ?
Sorry i was driving
@ex080 - you'll also want to handle issues in searching for keywords like case "bananas" in "Bananas are my favorite fruit." -> False. And embedded strings "apple" in "Peach Snapple is the worst!" -> True.
@PaulMcG you are right!
I plan on making everything lowercase
And that snapple case is interesting
I think you have enough to chew on now - I must rbrb for a bit
@IMCoins didn't know that shortcut i thought i would have to go row by row
Thanks
I will chew this cud.
-moo-
Cbg
21:35
As far as I understand how pandas works, you should either use internal functions, or apply/applymap and insert some lambds to them. ;)
By the way, pandas is awesome. ;)
@ex080 print( df.loc[df['B'].str.contains(r'\bapple\b')] )
This will match apple as entire words only.
you could use a regular expression to prevent things like snapple, or just split the words on spaces and match those
Yeah I was thinking regex too
21:51
The .str.contains() method in pandas already uses regex by default. Hence the r'\bapple\b' line just above.
i think IMCoins solution is most apt since I am already using pandas.
I could also do .str.lower().str.contains(r'\bapple\b')
If I wanted to match case.
The people who made pandas already thought about it.
df.loc[df['B'].str.contains(r'\bapple\b', case = False)]
will either match `apple` or `Apple` or `appLe` ...
22:25
Not sure why you'd bother using .str.contains without regex though. It's much slower than a regular list comprehension through the Series values.
Oh nevermind, it has some nice NaN handling.

« first day (2957 days earlier)      last day (2216 days later) »