« first day (2925 days earlier)      last day (2248 days later) » 
01:00 - 18:0018:00 - 00:00

wim
wim
18:00
@PaulMcG 2nd answer is good.
TL:DR:
virtualenv: **avoid**
pyenv: **avoid**
pyenv-virtualenv: **avoid**
virtualenvwrapper: **avoid**
pyenv-virtualenvwrapper: **avoid**
pipenv: **avoid**
pyvenv: **avoid**
py2venv: **avoid**
venv: useful.
very succinct tl;dr
wim
wim
don't know why my bold didn't work
the chat markdown is a mysterious and fickle beast
A good chunk of markdown simply fails to work on multiline messages
1st answer recommends virtualenv
ಠ_ಠ
Like, it can still make urls clickable, and do quote blocks, and that's pretty much it
18:07
I've noticed that too. my backticks sometimes fail
@wim I think its due to multiple lines:
I believe only URLs work in multiline, but not formatted URLs
I use backticks in multiline messages even though I know they won't render properly because I have faith that the recipient will mentally add the monospace font in their brain
@Kevin also you should optimize for the starboard where formatting would work
cabbage guys
18:10
If I feel a starworthy message coming down the pipe, I try to make it fit in 150 characters on one line anyway, so formatting isn't a big deal there
wim
wim
@malan yes. I will add it to "the list". :)
I've been lurking only for long time, but now I came with something that totally confuses me.
Can anybody explain the result of the last of these three expressions to me?
>>> True == (False in [True,False])
True
>>> (True == False) in [True,False]
True
>>> True == False in [True,False]
False
wim
wim
@Jerry101, the introduction of venv is in part a response to that mess. If you want to help improve the situation, I suggest you use venv and encourage others to do the same. — Magnus Lind Oxlund May 14 '17 at 18:35
^ good comment
@ByteCommander ninja operator chaining
18:11
Observation: the quality of virtual environment software is inversely proportional to the length of its name. I'm going to write one named "ænv".
>>> (True == False) and (False in [True,False])
False
148
Q: Why does (1 in [1,0] == True) evaluate to False?

Peter WoodWhen I was looking at answers to this question, I found I didn't understand my own answer. I don't really understand how this is being parsed. Why does the second example return False? >>> 1 in [1,0] # This is expected True >>> 1 in [1,0] == True # This is strange False >>> (1 i...

one of the rare "please don't ever make this become a real use case" corner cases
Okay, gonna read this.
>>> (False in [True,False])
True
>>> #False is present in [True,False]
>>> True == True
True
>>>
18:13
Thank you!
@BlackThunder the question was why the third differed from both of the first two
without chaining it would be equal to either based on precedence
>>> (True == False)
False
>>> #True is not equal to False
>>> False in [True,False]
True
>>>
you're getting there
Wow! I am stuck at third.
Ah, I understand.
18:16
that's (also) why you should never test bools with testing equality
also,
>>> True == (False is False)
True
>>> (True == False) is False
True
>>> True == False is False
False
So "in" counts as comparison operator like <. Because we can do maths-like comparison operator chaining like "2 < x <= 42", which translates to "2 < x and x <= 42", that same applies (without practical sense) to "in".
Good to know, thanks again ^_^
no worries :)
I don't think many would shed a tear for not being able to chain in and probably is
But I don't understand how True == False in [True,False] is equal to False
@BlackThunder the answer was given twice, perhaps you have to pay more attention
Because of operator chaining, True == False in [True,False] is equivalent to True == False and False in [True,False], which is equivalent to (True == False) and (False in [True,False]), which is equivalent to False and True, which is equivalent to False
18:20
and now thrice
True dat
@Kevin You forgot: ∎
QED
Hold on
	def search(cls, expression, page, per_page):
		ids, total = query_index(cls.__tablename__, expression, page, per_page)
		...
		when = []
		for i in range(len(ids)):
			when.append((ids[i], i))
		return cls.query.filter(cls.id.in_(ids)).order_by(
				db.case(when, value=cls.id)), total
Anyone mind helping me understand this little bit of code
Specifically, the order_by in the return statement. I'm not understanding what db.case is doing.
The ids, total is returned from an elasticsearch query (I assume in order of hit strength/relevance)
I think I'm seeing it.
No I don't think I am
18:32
You're doing better than me since I don't even know what database library we're using
sqlalchemy
sorry
Each item in when is a tuple of an item id and it's order in the original list, but how will it ever be the case when that item id and its order are equal?
I see so many db questions on the main site that don't mention what db they're using, I can only assume that there's something wrong with me that I can't figure it out from context. Maybe it's because I've used databases in Python for a grand total of thirty minutes, ever
so... this new project's name is a three words expression that result in the excellent GIN acronym. 10/10 will enjoy wanting to drink gin all the time.
Maybe to the informed reader, it's as obvious as np.array being from numpy. "Well he's using order_by right there, so of course it's sqlalchemy. Context clues."
I've only ever used sqlalchemy, so ¯_(ツ)_/¯
I was just forgetful
18:36
@malan That looks a bit like the idiom for returning stuff in the order they are in ids, but I'm not entirely sure.
@IljaEverilä That's what it is, I just don't understand the idiom
docs.sqlalchemy.org/en/latest/core/… says that the first argument of case should be a list of tuples, with each tuple containing a sql expression and a value. Which is confusing, because your when list contains tuples composed of and item id and the id's index, both of which I assume are integers, and so there are no sql expressions in sight.
The combination of the (value_to_compare_to, result_if_true) tuples and using value=cls.id shorthand result in something along the lines of case([(ids[0] == cls.id, 0), (ids[1] == cls.id, 1), ...]).
So the first id in the ids list gets 0 as order expression, next 1, and so on.
Or the first argument can be a dictionary, which when is not.
@IljaEverilä Interesting, so it's not doing what I thought it was doing (i.e., looking for equality between the two items in each tuple)
18:43
In [4]: print(case([(1,0),(2,1),(3,2)], value=1))
CASE :param_1 WHEN :param_2 THEN :param_3 WHEN :param_4 THEN :param_5 WHEN :param_6 THEN :param_7 END
@Kevin Seems like it does accept a list of 2-tuples in addition to dict.
@malan Nope, it is looking for equality between the first items in the tuples and the given value.
So it is using the CASE expr WHEN value THEN result ... END variant of a CASE expression. Tbh did not even know that was a thing :)
So I thought I needed an indexing service like elasticsearch to do a simple autocomplete ajax feature and just discovered that a simple SQLAlchemy query like Tag.query.filter(Tag.tag.startswith("<letters>")).all() works and elasticsearch does not
/new to programming
I am writing a script in which I have to accept root password of Linux system.
right now I am accepting it with getpass() method, How should I validate that user is entered the correct password?
Use the password and if the command doesn't work because of insufficient privileges, you know it's wrong.
I am going to use that passwprd in the middle of scriipt and I am accepting it at the biggining
and don't to make user wait till that time
19:11
Use it sooner, then.
I don't suppose it's possible to run some entirely innocuous program with super-elevated privileges, just to see if you have super-elevated privileges?
Like, sudo cat or something. idk, I am not a Linux person
Should be nothing to test as soon as you get it
I think it's definitely a valid use-case to want to verify a password ten seconds into a fifteen minute long script and not fourteen minutes and thirty seconds in
import os, subprocess

def prompt_sudo():
    ret = 0
    if os.geteuid() != 0:
        msg = "[sudo] password for %u:"
        ret = subprocess.check_call("sudo -v -p '%s'" % msg, shell=True)
    return ret

if prompt_sudo() != 0:
    # the user wasn't authenticated as a sudoer, exit?
@Kevin yes right
19:19
If a good design principle turns out to produce a user-hostile system, it's not a good design principle
@W.Dodge it is checking for sudo password for user not root password, I want to check root password
You have a user who is going to use your script. They probably don't have root pass unless they are admin but they have their own password that grants root privileges. Just get their sudo pass and do what you need to do. The only reason you need root pass it to log in as root. But you just need to run as sudo
You can't even log in as root on some systems (e.g., Ubuntu)
19:26
actually my scrpt is going to install driver which required root previladge
@AmanJaiswal If a user is in the sudo group, he's totally able to install a driver
Whoops, sorry Antti (I seem to mess up the reply to a lot)
If you are a super user it does not matter
no it is matter, according to driver it should be installed by root
Otherwise just login as root to begin with and run the script without any fancy password checking
@AmanJaiswal Perhaps you're misunderstanding the instructions, or perhaps the instructions meant to say user with root privileges
I have never found there to be anything at all that I can't do on my system using sudo that I can with root
Except for easily redirecting stdout without tee and all that
19:32
ERROR: installer must be run as root
this the error I get when I try to install it with user who have root privaledge
Doesn't sudo make you root? That's how the linux privilege system works, isn't it? You just have to be logged in as a user who has the privilege to do whatever you're trying to do?
@Aran-Fey gives root privileges but does not make one root
ummm... well neither
@W.Dodge Are you sure? sudo whoami outputs root.
so, you cannot grant more capabilities to already running processes in general
19:34
sudo runs commands as another user (substitute user do)
sudo can launch new processes that inherit from sudo that will be running with effective user id distinct from that of the original user
The default, AFAIU, is 0
it does not affect "you" :D
But you can run like sudo <username> right?
sudo -u username
19:36
linux's stupid user-based privilege system makes me question if we're really living in the 21st century and not the stone age
@Aran-Fey hem, Linux does not have user-based privilege system.
or... well, it "does" but it doesn't.
@Aran-Fey Yes, I guess you are right in that sudo makes you root for that single action
group-based?
@Aran-Fey no.
no no and no.
19:37
What kind of system should AranOS have?
it is capability-based etc...
I've always thought of that as "granting root privileges" but, in many ways that's the same thing
it is just that the default is that the UID 0 is given all the capabilities. Doesn't have to be at all.
all the mechanisms are pluggable.
@AndrasDeak Basically the same kind of system that smartphones use for apps. The same way you can give an app the privilege to access your camera, you should be able to give users or programs privileges
however it turns out that there is a good reason why the default still gets used so much - it is yamming difficult to actually create a good SElinux policy set.
19:41
@AnttiHaapala I don't get why you say it doesn't. Permissions-based system? Is that what you're looking for?
I'll refrain from commenting on SElinux
@malan permissions-based system means as much as number-based math...
How would you describe Linux's security system though? rwxrwxrwx describes the permissions for a file and it seems everything is dependent on that
and file owner
"Everythign is a file"
and "Every file has permissions"
pretty much sums up all of the security in Linux
and you're pretty much totally clueless about everything then.
I guess so
19:44
the rwxrwxrwx is the least level of everything.
the UID does not matter, the capabilities do
and then the policies, and...
another thing is that the rwxrwxrwx applies only after you see that file - and if you don't see that file then it doesn't matter who you are...
As long as su and sudo make you a different user, that's only a technicality though. In practice, it's effectively user-based
@Aran-Fey aran-fey/UID 23421 can have a process with all the root privileges, so how it is user-based?
@AmanJaiswal that's only like 172740 seconds too early
Sorry I did not get you
@AmanJaiswal I don't get why do you want to have the root password?
guess what?!
I don't know the root password to any of my systems
how do you suppose I could use your script then?
@AnttiHaapala but the users who is going to use script will have root password
as this script is use to install some driver on servers
19:51
sigh
How do you know? If they're running it on Ubuntu you're pretty much screwed
@malan because we have only ubuntu
Ubuntu has no root
@AmanJaiswal what's wrong with asking to run the entire installation with root privs?
@malan ubuntu has root, but it randomizes the password by default
I see: >. It merely has been given a password which matches no possible encrypted value, therefore may not log in directly by itself.
19:53
because after installtion of driver script is going to run some tests as a normal user
Debian does that too if you don't give it a password
@AmanJaiswal then you can do that too :D
it is just a call to setuid, setgid to drop privs
@malan you can switch to root on ubuntu by the way, just need to know root pass. You can set root pass with sudo passwd root
then ` su - root` and enter pass
you can write sudo -Hu root -s
19:57
@AnttiHaapala But only if my user account has all the privileges that root has, right? There's no smaller entity than a user account, right? What if I want to run a program with more restricted privileges?
@Aran-Fey so argue about it now
@Aran-Fey I've tried to tell you that the accounts do not have intrinsic privileges.
but it didn't get to you yet...
> Starting with kernel 2.2, Linux divides the privileges traditionally
associated with superuser into distinct units, known as capabilities,
which can be independently enabled and disabled. Capabilities are a
per-thread attribute.
Linux 2.2 was released in .... 1999...
so no, this millennium linux hasn't been relying on mechanisms from last millennium
@AnttiHaapala That's from the programmer's manual, are there userspace tools to modify an individual user's capabilities?
Though IDK why I would want to
@malan "what programmer manual" that's manual section 7
20:05
Section seven is system calls and stuff you can use when writing c programs, or am I wrong?
I generally stick with section 1
I'm wrong
section 2 is system calls. section 7 is misc
yeah
@AnttiHaapala Okay, fine, the technology is there. But nobody except for linux kernel developers has any idea how to use it. Why do I have to be a linux expert if I want to make my PC more secure?
so how do you make your windows or mac secure?
Is that possible?
20:08
I can complain about Windows and Mac too if you want
idk...
it is hard
Does anyone know if urllib3 has a history of unexpected breaking changes? I've been noticing a couple influential libraries pinning it to "anything less than the next one" which isn't the pattern I'm used to seeing.
@Aran-Fey for example now on ubuntu you can install viruses like
requests and botocore specifically
semantic versioning
if major then that is expected
i.e. that's exactly how you're supposed to do
20:10
Yeah, right now they are on 1.24. I'd expect to see <2, just not <1.25
can any body upvote to reopen my question, some one marked it as duplicate but I don't think so thats correct
https://stackoverflow.com/questions/52899006/validated-root-password-in-python?noredirect=1#comment92710789_52899006
well then...
@Aran-Fey how about this:
Past and current implementation
A full implementation of capabilities requires that:
1. For all privileged operations, the kernel must check whether the thread has the required capability in its effective set.
2. The kernel must provide system calls allowing a thread's capability sets to be changed and retrieved.
3. The filesystem must support attaching capabilities to an executable file, so that a process gains those capabilities when the file is executed.
Before kernel 2.6.24, only the first two of these requirements are met; since kernel 2.6.24, all three requirements are met.
the part 3
@ThiefMaster haha found this question of yours: unix.stackexchange.com/questions/46919/…
wow, so one should think in terms of processes and capabilities rather than users and privileges
yes
it is just that by default the old semantics are emulated with setuid 0
@AnttiHaapala Okay, look, I don't want to argue about what's technically possible and what isn't. All I'm saying is that it's currently awfully user-unfriendly. We all use su and/or sudo all the damn time, and the fact that it logs you in as another user sucks. I've lost count how often that garbage has caused me problems.
20:21
so you want to have you yourself able to execute everything?
and it would be better? :)
I want to be able to execute everything after entering a password, yes.
but my point was: "using aran-fey"?!
If the "this user is an administrator" box is checked then yes
so let me get this straight: you're arguing that the system must be made more secure by making it less secure for the sake of convenience?
How does executing a process as a different user make the system less secure?
Status quo: Entering a password makes me someone else
Proposed change: Entering a password gives me additional privileges
20:41
it depends on the privilege set...
the surprising truth is that it is more secure to use another user account for the elevated privs...
becuase it doesn't read your .dotfiles say.
rbrb
21:07
I wrote some code in Python that can merge an arbitrary amount of JSON files into one massive JSON file
Oh no, it got a "UnicodeEncodeError"!
21:22
I've finally been disillusioned. I was pretending that SO was a knowledge repository, when in fact it's been a helpdesk for a long time. About 80% of my motivation just died. Probably permanently.
I always thought SO was like Quora for programmers
I'm not familiar with Quora, but it looks way less knowledge-base-y than SO
quora is one of the infamous "we're not like other sites" examples
quora usually comes up in the context of quality control on SO
21:39
Searching meta for "quora" is quite enlightening. Seems like the complete opposite of SO.
21:56
Help desk that produces a knowledge repository
lst = ['West', 'North', 'Central', '1', '0', '100', '90']
res = [' '.join(i for i in lst if not i.isdigit()),*(i for i in lst if i.isdigit())]
print(res)
here better to use to generator expressions or change them to list comprehension?
same results but performance question
wim
wim
list comprehension better
res = [' '.join([i for i in lst if not i.isdigit()]),*[i for i in lst if i.isdigit()]]
why so I brought this up last week i believe without an example but what happens thta makes list comprehension preferred ?
Inside the join, a list comprehension is faster. Dunno about the *(...) though
oh okay so the synergy with join
wim
wim
21:59
gencomp has extra overhead, and generator must be fully expanded in memory anyway, so it ends up that the list comp is better
there's an interesting question about this on main somewhere
ty
will look @wim ty @Aran-Fey as well
22:24
in Android, 1 hour ago, by AdamMc331
Had to been done ur welcome
@wim bold not supported in multiline messages?
wim
wim
22:38
@Code-Apprentice correct.
wim
wim
23:05
@user2357112 import tokenize.. very good!
do you think it's possible for two different input dict to render to the same line in output? I couldn't think of any example but couldn't easily disprove it either.
@wim: If the original dict only contains values supported by ast.literal_eval, and the keys are valid names, then I don't think it's possible.
With things like numpy ints or other types that create ambiguity in repr, it's definitely possible.
jpp
jpp
23:29
@vash_the_stampede, it's the same reason as list(...) is worse than [...] list comp. This answer has more detail.
makes sense
@jpp ty ty
01:00 - 18:0018:00 - 00:00

« first day (2925 days earlier)      last day (2248 days later) »