« first day (1476 days earlier)      last day (3466 days later) » 

8:22 PM
Jul 24 at 15:30, by vaultah
Sheesh, my grammar is still horrendous
Still horrendous :D
 
Cabbage all. Been a while.
 
Cabbage
 
o/
(The terrorists won, by the way - if anyone was keeping track.)
 
Sounds like we need to update all those old programming shirts
Instead of saying "Im not lazy, im waiting for my code to compile", they should say, "wating for my query to finish"
 
Martijn hammered it, so I was right
Or maybe "I was right, so Martijn hammered it" :)
 
8:38 PM
I think the later sounds better :p
 
Hi
Anybody there? I have a question what I try to solve
It tooks me 4 hours without any result and I don't understand why isn't working
This code:
 
Please see our rules: “You do not need to ask if it’s okay to ask a question.”
 
for byte in self.byte_array:
if((byte != ord('"')) or (byte != ord(' '))):
lst.append(chr(byte));
 
And use CTRL+K to format your message as code
 
for byte in self.byte_array:
        if((byte != ord('"')) or (byte != ord(' '))):
            lst.append(chr(byte));
appends me " and space to the char array
sorry byte_array
but in my condition I specify not to append that
I have made a modem class
 
8:47 PM
well, your check is doing this: if byte is not a " OR if byte is not a space
 
and I try to filter some receive comands
 
You mean, appends them to lst?
 
One of these is always true.
You want to use an and there.
 
^ that.
 
no
to not append '"' and ' '
but appends me too
this is the method
def filter(self):
    lst = []
    for byte in self.byte_array:
        if((byte != ord('"')) or (byte != ord(' '))):
            lst.append(chr(byte));
    return lst
 
8:48 PM
Same answer.
 
@LXSoft There is no character c such that c != ord('"') or c != ord(' ') will be false.
 
I solve it
Thanks alot
I replace or with and
 
2 mins ago, by poke
You want to use an and there.
 
Thanks poke and AirThomas
 
Sure, you’re welcome
 
8:50 PM
I wonder if there's a canonical question for "does not equal A or does not equal B"
 
Not everythign has (or needs) a canoncial question.
 
This is the result:)
[Byte string]
b'\r\n+CLIP: "+40356442557",145,,,,0\r\n'
Bytes receieved from start: 197

Informatii apel:
[Parameters]
['\r', '\n', '+', 'C', 'L', 'I', 'P', ':', '+', '4', '0', '3', '5', '6', '4', '4', '2', '5', '5', '7', ',', '1', '4', '5', ',', ',', ',', ',', '0', '\r', '\n']
 
@poke True, but I've seen this logic error a lot.
Anyway, not suggesting creating one - just wondering, idly.
 
You have?
 
Yeah. With beginners, but yeah.
 
8:52 PM
I only keep seeing a == b or c or d
 
Mmm, that too. I should clarify - I mean that I see it a lot in general, not specifically on SO.
 
Ah, okay
 
@AirThomas i used to work at a survey software company where customers could put boolean logic into their surveys. Understanding the difference between "and" and "or" is a very difficult problem, mostly because it is the opposite of our typical vernacular.
 
But well, logic can be hard.
 
I understand logic
 
8:55 PM
@Humdinger I would say, communicating it can be a difficult problem - understanding it, though? Once you get it, you get it, no?
 
I answered more customer tickets/support calls about and/or than anything else
 
thruth table
 
@Humdinger Opposite of what? :D
 
but when comes multiple logic I make mistakes
 
@AirThomas, ok yes. Once you get it, you get it. Good point
 
8:55 PM
@LXSoft Don’t worry, you will get used to it :)
 
@poke For example, in normal english you would say, if and " or a space, ommit it
 
@LXSoft Very common. Practice makes perfect.
 
@AirThomas @poke Practice I love
 
I think C is still the best language to learn boolean logic in, because it helps you understand that it is really just math
 
Now I'm trying to think what my most common Python mistake is. Possibly starting a line with def when I mean class.
 
8:58 PM
True is 1, false is 0. And is a multiply, or is an add.
Just do the math and test it out :)
 
@Humdinger That works in Python too.
>>> True + True * False + True
2
 
I actually never noticed you could use '1' and '0' int literals as replacement for True, False in python until now >.<
 
>>> issubclass(bool, int)
True
 
@Humdinger More generally, 0 and nonzero integers, but yeah.
Just like elsewhere.
 
True and False are just singletons for the two instances of bool which is a subtype of int. True is 1, False is 0.
 
9:02 PM
How did I miss this.... I feel like my life was a lie...
I blame java
 
:)
Oh Java and its stupid primitive types
 
@poke What isn't a subclass of bool? Other than old-style objects?
hmm. str.
 
@AirThomas I think you are thinking of object, not bool?
 
I made some changes to my method
def filter(self):
    for index, byte in enumerate(self.byte_array):
        if((byte == ord('"')) or (byte == ord(' '))):
            self.byte_array.pop(index)
instead of using a local array
 
because nothing is a subtype of bool. And issubclass(A, B) checks if A is a subclass of B (not the other way around)
 
9:05 PM
but seems to not work so well when ' ' and '"' are close to each other
 
@LXSoft That’s not a good idea. You should mutate something while you are iterating through it.
 
only remove one of them
 
I think I'm needlessly confusing class inheritance with the inherent truthiness of objects in a language where everything is an object.
 
and that is because I think pop will change index
and index will be +1
after list is re-indexed
 
And I did have the arguments reversed.
 
9:07 PM
@poke Thanks, so I need to push in a new temp list
 
See also this question.
 
I think creating a new list was a better idea. Editing in place always gets tricky
 
Also note, that filter is already a built-in function, so you might want to choose a different name.
 
@poke shouldn't
(you meant)
 
@AirThomas Oops, yes, you shouldn’t. Of course. Huh.
 
9:10 PM
So, in reference to "use '1' and '0' int literals as replacement for True, False in python"
Here's what I'm getting at: Can't you evaluate anything that way in Python?
 
@Humdinger Thanks, I think is the best option
@poke Thanks for that question
 
@AirThomas Not sure what you mean
 
@AirThomas Well if you assume that None type is actually version of every object, yes
but otherwise, yes
 
@Humdinger What do you mean by that?
 
@poke He means in python, every primitive type has a true/false representation. For example, empty lists are false, full lists are true
 
9:14 PM
And objects are true by default
 
Well yes, object provides a default __bool__ special method (which every type inherits), so everything can be converted to bool.
 
@AirThomas Meaning, if I have an object type I define, it always evaluates true unless its a none-type. So it depends on if you consider a none-type a version of my object or not. (Completely theoretical answer)
 
@poke old-style objects don't inherit that but are also true (by default)
 
@Humdinger Since Python is a dynamically typed language, types only belong to a value (not a variable). So when I change something to None, I change that variable’s type to type(None).
@AirThomas Well, the same thing is built into old style objects though.
But I’m usually only talking about Python 3 anyways :P
 
You could however, build an object which would throw an exception if used like a boolean.
 
9:17 PM
Anyway, no real point here, except that I would have thought it obvious that you could use 1 and 0 this way
 
@AirThomas Ya, it should have been obvious, but for whatever reason it just never clicked for me.
 
@Humdinger Now I'm trying to do this...
 
>>> class DontBoolMe:
        def __bool__ (self):
            raise NotImplementedError()

>>> a = DontBoolMe()
>>> if a:
        print('foo')

Traceback (most recent call last):
  File "<pyshell#16>", line 1, in <module>
    if a:
  File "<pyshell#12>", line 3, in __bool__
    raise NotImplementedError()
NotImplementedError
 
Oh, forgot __bool__ was __nonzero__. Glerbghl.
@poke You forgot "Bro"
 
lol :P
 
9:20 PM
Mine was NoBoolForYou, btw
My department has a Python 2-only policy because there are no programmers, per se, and the managers are scared.
 
A “Python 2-only policy”? That’s crazy.
 
I mean, literally, no programmers. I am not a programmer by training either.
And we have unknown mountains of unmaintained code years (or decades) old that nobody wants to deal with.
 
What are you doing there then
 
I complete the class with help from here
Thanks
class Modem:

def __init__(self, port):
self.serial_handler = serial.Serial(port-1)
self.byte_array = bytearray()
self.char_array = ''
self.bytes_received = 0

def send(self, byte_array):
self.serial_handler.write(bytes(byte_array, 'utf-8'));

def readBytes(self):
for byte in self.serial_handler.read(self.serial_handler.inWaiting()):
self.byte_array.append(byte)
self.bytes_received = self.bytes_received + 1

def printBytes(self):
for byte in self.byte_array: self.char_array += chr(byte)

def filter(self):
modem.send("ATI\r\n")
modem.send("AT^DDSETEX=2\r\n");
modem.send("AT+CLIP=1\r\n");
modem.receive()
modem.serial_handler.close()
 
Interviewer: "We need more people who know how to do database stuff and write programs that do stuff with databases. Could you learn to do that?"
Me: "Yeah, I don't have much formal education or experience, but I'm comfortable with code generally, I taught myself X, Y, Z, and I find it satisfying."
 
9:26 PM
uhuh
Sounds a bit frustrating.
 
Later on, after I was hired, Interviewer: "For some reason we have a hard time keeping smart people around here. I don't know why. We tried hiring people who already know how to do this stuff, but we won't pay them enough."
 
>_<
 
On the plus side, I get paid to teach myself things I want to learn anyway.
 
As long as you’re happy with it.. :)
 
So far, yeah. Long term, we'll see. Only been in this position 2 months.
 
9:28 PM
oh :D
 
That Pakistani murder-baby question is quite possibly the best thing to hit meta.SO all year.
 
...what?
 
33
Q: Trying to share a question with Facebook: Outcome quite unexpected

KrumiaSo I tried to share this innocent enough question with Facebook: Why is this program erroneously rejected by three C++ compilers? And this is what popped up: And indeed, the shared post directs me to a particularly disturbing article with the same title in gawker.com. I checked the meta tags...

 
So that's why my code isn't compiling. — ThisSuitIsBlackNot 2 hours ago
 
9:45 PM
lol
 
So there I was, processing a minor buttload of chronological data stored in tables manually partitioned by year, when suddenly I got to 2004 and the primary key magically was a char field with letters and shit.
JOB SECURITY, FOLKS.
 
?
I don't know enough about databases -- what's the implication of that?
 
Well, on a basic level, it's an inconsistency that means I had to special-case for this one year in my Python script which is not ideal.
But more importantly, the sorting gets buggered.
 
It doesn’t really matter what type the primary key is of
 
I just thought primary key = unique identifier
a sort of "row ID"
 
9:55 PM
yeah
 
It matters when it breaks the script you wrote that works for the other eleven years.
 
different type of primary key?
 
And the field isn't remotely atomic.
 
i.e. the tables aren't standardized?
or normalized, w/e
 
The explanation that was given to me for this, by the way, was "we lost that data somehow"
 
9:57 PM
My db lingo is weaksauce
 
@AureliusPhi Different column type. E.g. various sizes of integers, characters (which are integers), or strings, or even binary stuff
 
To illustrate: The unique identifier everywhere else is a "surrogate" key which means it has no inherent meaning - such as a row ID. And so it's easily to sort as 1, 2, 3, 4, etc.
 
lol
 
Primary keys don’t have to be that way though. And coming from database theory, they usually aren’t. Databases often use it because they are cheap, simple and effective.
 
I worked 6 month as DBA programmer
and I know nothing
 
10:00 PM
In this one table, the unique identifier has the pattern ^2004[AB]-[0-9]+$
 
only to create simple triggers procedures tables with primary and foreign keys
 
So instead of 1, 2, 3, 4, *if* you happen to be sorting on this key, you get, e.g.:
2004A-1, 2004A-10, 2004A-100, 2004A-101, 2004A-102, 2004A-1000
 
@AirThomas Why not make it a composite key [AB] + int then?
>_<
 
It's not my project and I'm not allowed.
But it's the source data for my project.
 
(not criticism directed at you, but more at the original designers)
 
10:03 PM
Yeah, I understand. Anyway, I did my best to code around it, and finally this afternoon figured out why I was missing seemingly random rows in the output table.
They're not random at all - when you sort like an asshole
I would kick that char field's butt if it had a butt
INSERT INTO tbl (pk) VALUES ('butt');
 
Are primary keys usually just numbers in sequence? (in practice)
 
@AureliusPhi Depends who's designing the DB. Not necessarily though.
Some people always use meaningless surrogate numeric primary keys.
There's a notorious user who used to post on SO who calls them idiot keys.
 
"used to"
 
That guy sounds like an asshole
I never understood why some people feel the need to browbeat the people they are supposedly trying to help
If your advice is good, it will speak for itself
 
10:11 PM
That's one of his more abrasive posts.
Lot of them are actually very high quality, though he's one of those "my way or the highway" folks.
 
Well, the way he says it is a bit unfriendly, but he is technically right.
 
In my experience, the trouble with that is that when they turn out to be wrong / inaccurate over something, they have a real hard time just owning up to it
 
If data already contains an actual key, use that as the primary key.
 
does it make sense to use "natural keys" if it's not standard across most of your tables in use?
i.e. one table with one primary key, another table with a different primary key, etc
 
10:16 PM
Well, each relation should have the appropriate keys for the data it stores.
 
@AureliusPhi It depends on the tables. In this case, they're "manually partitioned" which is to say they could actually all be the same table, but they've been physically split according to which year they belong to.
So whatever you use, these tables should all be defined in the same way.
 
@AirThomas facepalm
 
at the risk of sounding like an idiot, i've had to split tables by year before, too
At least, in MS Access
If a table / query exceeds 2 GB, everything chokes
 
Access is... special.
 
A proper database shouldn’t require something stupid like that
 
10:19 PM
Manual partitioning could conceivably be warranted in some context that I doubt I'll encounter any time soon.
And to be fair, this was something that started 15+ years ago.
 
Are you using SQL Server, etc?
 
I don't know when MySQL started to support partitioning syntax but my guess is Not Then
 
At work, one part involves processing copies of external .dbf files which update daily, so we have to copy over the .dbfs (so we aren't operating on live data) and then run a bunch of maketables, queries, etc
 
To be fair to the people involved, these horror stories are not exactly their fault. They don't have the training and can't be expected to just know the right way to do things.
And for all my griping, I have just as little training. I'd love to get a brutal review from a real professional, I'm sure they'd find all sorts of icky stuff.
And that, kids, is why I wake up in a cold sweat at night trying to run flake8 on my pillow.
@AureliusPhi I have no experience with dBase, but that doesn't sound like an ideal workflow. What kind of processing are you doing? Aggregation, reporting?
 
@AirThomas Not sure -- a bit of everything. A big part is using those queries to export Excel reports
But all the maketables, queries, etc do take time
 
10:40 PM
Sounds like the type of thing that could be automated, if not fully, then at least somewhat.
 
Yeah, currently it's all automated in Access
It's just unwieldy and I can't help but feel like something is hugely inefficient
 
@AureliusPhi Well, if you have the ability to copy the data to a separate development environment and recreate the system using some other tools, you could learn a lot and maybe come up with something more efficient.
 
11:05 PM
Well, Happy Halloween to those who celebrate it, and to the rest of you, mass quantities of delicious rhubarb.
 
rhubarb
and no, I’m not celebrating it. I’m actively ignoring it (by not opening the door for kids)
 
I bought candy, but I am the only one who's gonna eat it
 
We don’t have any sweets to give away anyway.
— We did have cookies, but you can’t really give a single cookie each, right?
 

« first day (1476 days earlier)      last day (3466 days later) »