« first day (2463 days earlier)      last day (2485 days later) » 

4:00 PM
If this wasn't so far away from my house I'd be in real trouble: Peterson's Donut Corner
 
cbg
 
cbg
 
DSM
4:01 PM
cbg
 
Cro
what does cbs mean?
 
Phew! So... there's actually a fancy-ish donut place in the inner city, we visited it once with the missus, with high hopes. But the donuts were horribly sweet and drenched in flavouring...it just wasn't good :(
 
The Central Broadcasting Service?
 
well this conversation about food took a sudden vegan turn.
 
Cro
cbg
not cbs
typing mistake
 
Common Brassica Group
 
@Cro you destroyed the cabbage train! :(
 
Is this a safe/OK way to remove all files in my_path all my googles turn up more verbose code,wondering if i'm missing something
[os.remove(os.path.join(my_path,f)) for f in os.listdir(my_path)]
 
@AndrasDeak that is, wow
 
@clickhere Do not use a list comp for its side effects.
 
4:03 PM
@JonClements someone was going to have to so the conversation could continue. We should be thankful
 
It's incredibly unreadable. Just use a for loop.
 
for f in os.listdir(my_path): os.remove(os.path.join(my_path,f))
see? one line :P
but that's still hard to read
just put...put a newline in it
 
bah... why is no one using pathlib ?
 
@MorganThrapp is readability the only side effect?
 
I only learned about its magic the other day, after having heard some regular praise its magic here.
 
4:04 PM
@clickhere the side effect is the files get removed
 
@clickhere I mean, that and getting yelled at by whoever has to maintain the code.
 
@LangeHaare you're building a list of Nones...
 
if I ever have to do Things™ with files I'll be sure to check out pathlib
 
Not to pile on, but it's common for many newcomers to python to think that python allows tons of expressiveness, so it's therefore good to make things as short and one-line-y as possible. But that's not quite "the python way". Simplicity is best, here
 
@JonClements so instead one should do any(os.remove(os.path.join(my_path,f)) for f in os.listdir(my_path)), correct? ;)
 
4:06 PM
Also, explicit is better than implicit.
 
@AndrasDeak sure... just evil though
 
DSM
@JonClements: how've things been? We haven't been keeping the same hours for a while.
 
v.v. busy
all for the good though
just beep in the mean time
 
Anyone have the link to the meta post that responds to the "decline of Stack Overflow" rant?
 
there's plenty - which one specifically? :(
 
4:09 PM
@JonClements I know, and meanwhile as a side effect, the files get removed, which is the goal, but as Morgan points out, it's not nice to use a list comprehension when your goal is the side effects
 
@AndrasDeak - or use collections.deque(maxlen=0).extend(...)
 
No, but I could link to the very first comment reddit ever had, which was "wow, reddit is going downhill"
 
@PaulMcG that's the consume pattern, right?
 
@JonClements the rant was linked in the latest "should SO be more nice" post that's getting downvoted right now. I seem to remember a response from a mod or employee pointing out that all the examples were old or fixed.
 
4:10 PM
unless that's a needlessly fancy way to call that trick
 
@AndrasDeak - yes
 
The "consume pattern" as in, if you do this you will be consumed
 
Cthulhu approves
 
oh I didn't realize you were saying that the removing of the files is what is a side effect of the list comprehension I had wrote
 
@PaulMcG or remarkably just use a for loop
 
4:12 PM
Everything about iterating I learned from Raymond Hettinger
 
haven't seen that Q&A yet
 
anyone here going to run for mod ?
 
that was posted on meta one week after I joined
 
I keep waffling back and forth. It might be fun to see how it goes, but I already have a ton of community responsibilities to juggle.
 
4:16 PM
Cabbage!
 
cbg, PM! Long time no see:)
how are you?
 
I've been busy moving house. And then I came down with a cold or something. I guess the stress of moving may have been a contributing factor...
 
Objective C is the weirdest language I have seen
 
@PM2Ring aww...I hope you're feeling better by now
 
@davidism join the club?
 
4:18 PM
there aren't nearly enough mods in room 6 :)
 
Yeah, I know it's not like you guys just have a ton of free time. I just don't know if I can handle it yet.
 
@AndrasDeak Sort of. I have a bit more energy today, but I'm still feeling rather blah.
 
hope you get back to 100% then
 
Speaking of list comps with side-effects, I just inspired someone to add a non-side-effects version to their answer stackoverflow.com/a/45106014/4014959 And I wrote a case-insensitive set class.
 
@davidism if you're not sure - just don't then...
 
4:20 PM
@davidism Shog did say that mods are just sitting on their...laurels :P
some of them, I mean
 
Who the heck is laurel
 
@AndrasDeak welcome to real life
 
I heard of it; it sounds bad
 
does this actually work with iloc? stackoverflow.com/a/44311454/8131703
 
DSM
TBH being a site mod sounds like a thankless task, and not nearly as much fun as writing code as a way of helping the community.
 
4:21 PM
@AndrasDeak some have kids on the way.. some have really tricky business situtations
 
@LangeHaare what did you find when you tried?
 
Before I got sick I started playing with threading for the first time. Here's a version of sleepsort:
from queue import Queue
from threading import Timer
def sleepsort(seq, m=0.01):
    q = Queue()
    for u in seq:
        Timer(u * m, lambda u=u: q.put(u)).start()
    for _ in range(len(seq)):
        yield q.get()

print(*sleepsort([3, 1, 4, 5, 9, 2, 6, 8, 7]))
# output
1 2 3 4 5 6 7 8 9
 
@JonClements I feel like I'm disappointing you. :-( I'll run for mod in 6-8 weeks, don't worry.
 
@JonClements my point is not that mods should bend over backwards in clearing up our poo. My point is that there probably shouldn't be any mods who I only see during elections or on the mod user list:)
 
@AndrasDeak I did a little test and found it worked with loc but not iloc, but the answer says it can work with both - I wondered if the answer is wrong and needs editing or if I just don't know the conditions for when it should work with iloc
 
4:23 PM
@LangeHaare the answerer was online an hour ago, you should ping them and see what they think
 
@AndrasDeak the thing is, you might be biased against who could be a good mod or not...
 
if you're right, I'd probably suggest asking them to edit it themselves first
 
DSM
The answer doesn't say it works with both. It says that ix has been replaced by .loc/.iloc.
 
@LangeHaare editing the answers of active users is a controversial issue if you look around meta
@JonClements that's more than likely. And I have no perspective. But I have a few mods who I dislike because of their past actions. Now, my snarky comments regarding inactive mods is not directed towards them. Mods taking mod action in a way I disagree with is perfectly fine :)
 
@AndrasDeak mod stats are based on flags
 
4:25 PM
It's also possible that the invisible mods are doing stuff despite me not seeing them in chat or main or meta. Cognitive bias is a thing
 
> responses... written by a dog wearing a tinfoil hat
 
one flag can take a mod 12-15 minutes of investigation
 
thanks for the feedback, I posted a comment
 
@AndrasDeak yeah...
 
@JonClements I'm not trying to belittle the amount of (highly altruistic) work being done by mods
And we love you guys for all that shovelling you do :)
 
4:28 PM
yeah so... where's my snacks?
 
@idjaw has them
you know...for safe keeping
 
safe keeping? The pup knows exactly where I hide them all the time
his sense of smell is unbeatable
 
safe from harm inside the puppy's stomach
 
@idjaw yeah... sorry about the single malt :(
 
4:33 PM
That was out of character. But, it's OK. Next time just bark and I'll join you for a drink.
 
@user1993 If it's not true ASCII (i.e. it has chars > ord(127)) you may have success decoding the bytes as latin-1. You can see what it does with this snippet: bytes(range(256)).decode('latin1')
 
I'm still hurt that they left us out of latin1 only because of ő and ű
 
@PM2Ring where should I run this snippet?
 
there's a squigly õ where our glorious ő should be
@user1993 if you had to guess what would it be?
 
in the python console?
 
4:38 PM
That could be a good guess. Perhaps you should try and see what happens?
 
@AndrasDeak i work in the Spyder environment (Windows). I ran the snippet in its console and got-
  File "<stdin>", line 1
    bytes(range(256)).decode('latin1')
    ^
IndentationError: unexpected indent
 
@AndrasDeak Count yourselves lucky. By not being in Latin-1 you've escaped from the mess that we can thank Microsoft for when they decided to do their slightly modified version of ISO-8859-1 aka Windows-1252. See en.wikipedia.org/wiki/ISO/IEC_8859-1 for the sordid details.
 
Does that mean the same didn't happen to ISO-8859-2?
@user1993 and what does that tell you?
 
@user1993 Maybe try running it without indentation...
 
Wow, they had a lot of releases betwen Windows 10 and Windows 1995
 
4:41 PM
@KevinMGranger 1985?
 
@AndrasDeak silly me! yes did that. the output was -
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0¡¢£¤¥¦§¨©ª«¬\xad®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
 
no need to paste that ^
 
@AndrasDeak yeah it's a good song. What a throwback
 
my interpreter does the same thing, I can assure you
 
:)
 
4:43 PM
the question is what you make of that output, but at this point I defer to the kind gentlepeople of the room who are not me
apparently it's been a long week for me
 
ok, so that means my compiler can decode latin-1 properly
 
@AndrasDeak Well, no. I guess it's even worse. :) Wiki says "Windows-1250 is similar to ISO-8859-2 and has all the printable characters it has and more. However a few of them are rearranged (unlike Windows-1252, which keeps all printable characters from ISO-8859-1 in the same place)."
 
awesome :D
 
But the big problem with Latin-1 is that there were so many Web pages that claimed they were ISO-8859-1 when they were actually Windows-1250 that the major browsers assume that if a page says that it's ISO-8859-1 they attempt to decode it as Windows-1250. :(
 
cbg
 
4:50 PM
So if you have a Web page properly encoded as Latin-1 / ISO-8859-1, with the <meta> tag saying it's ISO-8859-1, and the yamming server giving the ISO-8859-1 header, and the browsers will treat it as Windows-1250. As you can imagine, this has led to much needless consternation.
 
@PM2Ring sounds like typical Microsoft shenanigans
 
@PM2Ring Clever sort method, haha
 
@AndrasDeak Yep. Create a slightly altered version of the standard and use your market dominance to make it look like everyone else is non-compliant.
@Marcus It's an oldie but a goodie.
 
I can hardly wait when they start to do that to ubuntu
 
ok, so the following worked -
for file in files:
        read_f1 = open(os.path.join(path,file),'r', encoding="latin-1")
        output1 = open(os.path.join('F:\chahat\MTech\series_imp_info_2', file + 'imp_info.txt'),'w', encoding="utf-8");
        for line in read_f1:
it was able to open all files and do the required stuff
but I wanted to understand what is going on
so is it like latin-1 is some kind of superset encoding that can read characters that utf-8 cant?
 
4:57 PM
No, it's just a different encoding. You can just as easily make a file that's valid utf8 but not valid latin1.
 
the interesting part is that when I used the method described here, it said the encoding is ANSI. And when I used this site - nlp.fi.muni.cz/projects/chared, it told me that the file is encoded in UTF-8 !!
 
So in other words, two methods that were not described in the link I posted hours ago?
 
sorry sorry! Just that in my google-fu for the last 2 hours, I had found them
 
just started delving into the linux / server stuff more, what a rabbit hole
 
@Marcus it never ends
 
5:00 PM
i guess both methods are fallible
 
I would guess that too, given that they both failed.
also lazy answer
 
so does this mean that the files I am dealing with are latin-1 encoded, given that they are being read without any error??
 
It means that Latin1 can decode them without error, that's it. Whether it decodes them in a meaningful way is a different question.
 
oh, ok
 
@user1993 Well, technically speaking, ANSI isn't an encoding. See the last paragraph here for details.
 
5:08 PM
ok..
 
@user1993 Possibly. Latin-1 is kind of a subset of Unicode, in the sense that Unicode code points 0–255 are identical to the Latin-1 values.
 
and the same is the case with UTF-8?
 
I thought code points 0-255 were identical in ASCII and Unicode so I'm already wrong
Oh, right, ascii is only defined up to 127. That's why. Totally knew that. Yep
 
@user1993 Not quite. The ASCII characters (chars in the range chr(0)-chr(127)) are a subset of UTF-8. You can read how UTF-8 encodes Unicode codepoints here. And here's some code I wrote a year ago that shows how to decode UTF-8 manually.
 
thanks, will go through them
 
5:19 PM
As I mention in that answer, there's no absolutely no need to decode or encode UTF-8 manually like that. The whole point of that code is simply to show how UTF-8 works.
 
got it
 
But speaking of Latin-1...
@SebastianNielsen Try this: os.urandom(8).decode('latin1')
 
I could weep!! finally got this thing working hours after I thought it would work
 
It's a good feeling.
 
5:36 PM
A few weeks ago, I stumbled across a bug in the PIL / Numpy interface: the PIL Image.fromarray method doesn't correctly decode packed bits to a mode '1' (B&W) image. Here's a program that illustrates the problem, with 2 alternative functions that work correctly, plus 3 functions that try to work around the bug.
I finally came to the conclusion that it's not possible to work around it in general, but all 3 of those functions give correct images when the scale is a multiple of 8.
 
any idea os about this paste.ubuntu.com/25090302 ? A numpy array with no shape?
 
@AbhishekBhatia it's called a numpy scalar
compare np.array([0]) and np.array(0)
 
@AndrasDeak the type says array though.
 
yes, because it's an array
there's some history there
it's an ndarray with 0 ndim and empty shape
contrasting with an ndarray with 1 ndim and (1,) shape
you can turn it into a python scalar or a 1-element 1d numpy array as you like
 
@AndrasDeak How I am unable to access it element by usual numpy indexing?
 
5:40 PM
because it can't be sliced
but there's only the one value inside, that's guaranteed
what do you want to do with that?
 
I want to plot it.
 
you can plot it as well as any other scalar, I think
one usually doesn't encounter numpy scalars in the wild, so you might have another problem
you can convert it to a usual kind of length-1 1d array like so: np.array(0)[None], or you can turn it into a python scalar as np.array(0).tolist()
you'll probably see that this doesn't affect your plotting problems
 
Thanks!
 
you're welcome
 
Seems like a weird type to have, what's a use-case of this? Storing scalars?
 
5:44 PM
I think there are historical reasons?
I read about this a while back, I don't remember
one can live a fulfilling and happy life without using them
 
haha..yeah :)
 
perhaps they're not called scalars after all, but 0d arrays
there's this post for instance
> The curious situation with Numpy scalar-types was bore out of the fact that there is no graceful and consistent way to degrade the 1x1 matrix to scalar types. Even though mathematically they are the same thing, they are handled by very different code.
see also DSM's answer mentioning np.atleast_1d
you can use that if you expect both 0d and 1d arrays and want to handle them as 1d arrays
it will convert np.array(0) to np.array([0]) and it will leave np.array([0]) alone
the rival answer of numpy guru hpaulj there is also instructive
 
@Marcus do you have a separate machine on the side to tinker with ?
 
6:11 PM
@MooingRawr hosting @ linode
 
@Marcus - have you looked over this page? Much sound advice
(no one-box?)
 
no, only for specific sites :(
 
@PaulMcG Yep, that's more or less what I'm doing now
learning more about security features
 
@PaulMcG incomplete list, doesn't contain xkcd for instance
 
not sure if moving the port away from 22 is worth it though
 
6:23 PM
Here's a cute thing from the HNQ: biology.stackexchange.com/questions/62641/…
 
Key-only auth should be good enough - but definitely disable root and password ssh
 
yeah, i am going key-only (+ encryption pass)
root disabled
 
I opened a server on Amazon last year and within minutes it was getting hammered with root/admin, root/root, etc. login attempts
 
Moving from 22 reduces botnet attempt spam from filling your logs :) but putting it on a non-privileged port opens you up to a new attack from other users if the daemon crashes. The alternative is using a different privileged port or setting up selinux
 
You may also be able to limit SSH logins by user IP
 
6:25 PM
Keeping in mind that IPs can be spoofed, and if your limiting system is automated, someone can spoof your IP and get you locked out :P
 
what do you think about choosing some high port like 9000+?
 
@KevinMGranger - would fail2ban help reduce the botnet spam problem?
 
I'm currently reading auth.log (assuming it's the right file)
and holy crap it's full of attempts already
 
@PaulMcG kinda. It's still vulnerable to the problem I just mentioned, and botnets are pretty hydra-like. Now, it's important to remember what problem you're solving by doing this-- not getting your logs filled up. If the concern is disk space, set up logrotate / configure journald. If it's not being able to see (non-automated) login attempts of interest, then that's a more interesting issue, and fail2ban might help, as might blocklists
Keep in mind this isn't necessarily learned from personal experience, just from what I've learned from supposed experts
 
I keep forgetting where stuff is
these folder names take getting used to, esp. the crazy filenames
 
6:36 PM
@Marcus as long as it's literally anything but 22, you'll seriously reduce the amount of attempts. What else the port is probably doesn't matter. Just keep in mind the privileged/non-priv issue
 
Keep a journal.
 
That's not even up to date, heh. Missing /run and /usr/libexec
 
I guess that means I'm not up to date either, which is not news
 
@KevinMGranger Not yet familiar with the concept of priv/non-priv ports
Some ports are off-limits?
And what kind of other attack if the daemon (the ssh daemon?) crashes / what would cause this to crash in the first place?
 
Murphy?
 
6:41 PM
Only root can bind to ports 1-1024, anything above is bindable by regular users. So if your sshd daemon dies while on port 6000, another user can spin up one pretending to be yours, that actually steals your credentials. SELinux can be configured to allow more granular permission so they couldn't do that. But if you're the only user on that box, it doesn't matter
 
SELinux is the one supported by the NSA, right?
 
Err, define supported
 
SELinux is pretty secure, but you do need to spend a day actually grokking it
 
We sure are off-topic from python though :P
 
support as in "I support your using it" :D
> The key concepts underlying SELinux can be traced to several earlier projects by the United States National Security Agency (NSA).
> Original author(s) NSA and Red Hat
that's where I got this vague impression from ^
I mean wikipedia
 
6:45 PM
Well, when you put it that way...
 
@KevinMGranger What about picking another port that is <= 1024?
 
30 mins ago, by Kevin M Granger
Moving from 22 reduces botnet attempt spam from filling your logs :) but putting it on a non-privileged port opens you up to a new attack from other users if the daemon crashes. The alternative is using a different privileged port or setting up selinux
that's probably one of the best alternatives, based on that ^
 
Whoops, missed that part
 
This is a list of notable port numbers used by protocols of the transport layer of the Internet protocol suite for the establishment of host-to-host connectivity. Originally, port numbers were used by the Network Control Program (NCP) in the ARPANET for which two ports were required for half-duplex transmission. Later, the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP) needed only one port for full-duplex, bidirectional traffic. The even-numbered ports were not used, and this resulted in some even numbers in the well-known port number range being unassigned. The Stream...
 
CBG!
I've a question related to python modules.
 
6:59 PM
Port 666 is good...
 
I was going through the python official doc
 
Jun 9 at 16:52, by PM 2Ring
python -c "import telnetlib;print(telnetlib.Telnet('bofh.jeffballard.us', 666).read_all().decode())"
 
It says "A program doesn’t run any faster when it is read from a .pyc file than when it is read from a .py file; the only thing that’s faster about .pyc files is the speed with which they are loaded."
 

« first day (2463 days earlier)      last day (2485 days later) »