« first day (4235 days earlier)      last day (696 days later) » 

12:32 AM
hey, does that make sense ?
class box(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(), nullable=False)
    obj = db.relationship("objects", backref='box')

class objects(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(),nullable=False)
    box_id = db.Column(db.Integer, db.ForeignKey('box.id'), nullable=True)


def createBoxAndObj():
    newBox = box(name ="box1")
    db.session.add(newBox)
    newObj = objects(name ="obj1",box_id=newBox.id)  # that is the aim, add the box Id
or maybe i have to fire "db.session.commit()" twice to allow the system to generate Id for box in the first time, then the second time to create items so i can use it on the "newObj.box_id"
 
 
7 hours later…
7:45 AM
@LoopingDev you can use .flush() if you require the id of something to be generated before you move on
Separately, please consider getting rid of the camel case and instead following PEP8
 
can I ask post a question related not to code, but about tweepy and twitter here?
 
I'm going to go with "yes" because tweepy is a python library
 
 
2 hours later…
9:44 AM
Just got the Python golden badge 😀
 
Nice!
 
Thanks
I already had tons of golden badges but a programming one is more shiny :D
 
10:12 AM
Today's crazy thing I might have to program: A script that starts the driver for my new gaming mouse and then immediately kills it. Because if you close it the normal way, it resets all the settings.
 
Nice. I had a classmate who said his USB flash drive only worked if he tore it out of the computer, "safely remove" would mess up the contents.
 
Wow, how does that happen?!
 
My guess was that something was a bit broken on his filesystem, and Windows would helpfully "repair" it by screwing up the rest too.
It's also possible that something went wrong once with "repairing" and he wouldn't risk it again.
I know I've been careful not to let windows "repair" my linux-created NTFS usb sticks...
 
Yeaaah. And to this day, I still haven't figured out how to turn a bootable USB stick back to "normal" with Windows...
 
 
2 hours later…
12:22 PM
@Aran-Fey is this about a Logitech mouse and G Hub?
 
12:53 PM
Nope, Mars Gaming. Good to know this isn't the only company with terrible software though
 
1:05 PM
@Aran-Fey Hmm, would simply formatting it do the trick?
 
As far as I know, Windoze can only format partitions, but not the whole device
So I end up with 1GB of storage and 31GB of wasted space
 
@Aran-Fey I think almost all of the gaming company have terrible software too. I use something from Razer and the software really is a turn off
@Aran-Fey ah classic windoze
 
Rufus can do that? I'll need to try that
 
Never used it, but I'm told that's the go-to tool for creating live USBs
Would seem reasonable for it to work in reverse
 
1:44 PM
I use Ventoy
It's different, but more convenient. Especially if you have multiple ISOs
 
Interesting
 
@Aran-Fey can you delete partitions?
 
If yes, I don't know how ¯\_(ツ)_/¯
 
(not my screenshot, I won't get caught using Windows that easily)
 
I've definitely been in that menu before, but I think it was all greyed out for some reason
 
1:54 PM
Maybe it's mounted and therefore "in use"
 
Possible. Can windows "unmount" something? Do you just hit "eject" and then leave it plugged in?
 
Sure would be nice if this wasn't as difficult as rocket science
 
2:20 PM
I did it, I can finally order at the local KFC by saying "I'll have the usual"
Next step is to make sure everyone there knows that HSBC terminals don't accept my credit card
 
Two months from now, go in and say "I'll have the unusual". Keep 'em on their toes
 
I already order differently once every few days :P I try to look happier and when they ask "the usual?", I respond with "not today!" as if it's a special occasion or something
 
 
2 hours later…
5:01 PM
What up beautiful people
You all have a good day today?
 
 
2 hours later…
6:40 PM
How can I speed up this code?
for file in os.scandir(data_path):
    %7z e '$file.path'
 
note to most of the room: that's only valid syntax in a jupyter notebook or similar
 
yes, I was going to write a note, I used IPython, sorry for not writing sooner and thanks for the note
 
Is there a good reason why you're not using your shell for this?
 
The thousands files are on Google Drive
I'm using Google Colab to access them
 
I'm pretty sure you can run shell commands with a leading ! in google colab
 
6:52 PM
Yes, it's also possible
 
Well I'm saying that adding a python loop to a shell command makes little sense, even though the overall performance is hopefully similar.
And are you sure you want to extract all those files right next to the respective archives?
It seems weird to worry about performance when you have to do this only once, and it seems weird to want to extract right next to the archive in google drive if you do this more than once. It's perfectly plausible that this is what you want to do, I just want to make sure you're doing it on purpose.
 
What would the best alternate code be, using shell?
@AndrasDeak--СлаваУкраїні Yes
I do this for several folders, with different years
And there are many many files
 
@Marco if google colab uses bash then it's probably something like for file in *; do 7z e $file; done. No guarantees though because I don't have a complete understanding of your data.
 
year = 2000
while year <= 2022:
  year = str(year)
  data_path = 'somepath/'+year
  for file in os.scandir(data_path):
    !7z e '$file.path'
  year = int(year)
  year = year + 1
 
6:57 PM
More complete code
 
ah, I see
Won't that extract every file into the current working directory?
 
Yes, but it's ok
 
It's fine
 
for year in $(seq 2000 2022); do for file in "somepath/$year/*"; do 7z e $file; done; done  # _probably_, no warranty included
 
7:02 PM
It's faster? :P
 
Probably. Significantly? Depends on how much overhead it incurs for jupyter to call out to the shell.
 
Thanks in advance, I'll test it. Yeah, I really needed it to be significantly faster, it's taking hours and Colab disconnects without finishing the task. Could it be that if I use multithreading or numba, etc, it doesn't significantly increase speed?
What do "done" commands do? I did not know them...
 
do-done are the braces in bash for a for loop
 
ahh ok, thanks
does that last "done" really not have a semicolon after it?
 
7:20 PM
As I understand from your answer, there is also
 
 
1 hour later…
8:25 PM
https://stackoverflow.com/questions/72332633/reversing-a-list-in-python-using-recursion

Any better duplicates for this, or are we supposed to treat the confusion as if it were a typo?
 
actually yeah, that targets the problem rather than just hte misconception
see, I have the second one bookmarked, even, but that doesn't help me find it
 
8:57 PM
@roganjosh thanks, lol
 
https://meta.stackoverflow.com/questions/385343/can-a-reference-question-be-used-as-a-dupe-target

I stumbled upon support on meta for the kind of canonical-creation process I've contemplated before.
 
class box(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(), nullable=False)
    obj = db.relationship("objects", backref='box')

class objects(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(),nullable=False)
    box_id = db.Column(db.Integer, db.ForeignKey('box.id'), nullable=True)


def createBoxAndObj():
    newBox = box(name ="box1")
    db.session.add(newBox)
    newObj = objects(name ="obj1",box_id=newBox.id)  # that is the aim, add the box Id
 
can you actually display box.obj results this way in the first place?
 
@KarlKnechtel I'll try that
 
9:55 PM
@KarlKnechtel , sorry for the late response, i ran into few issues with the encryption, i had to untangle that first
# i ran this code as a test
print("TEST 1 >>  " + box.obj)

# that error has risen in response.
line 233, in reverse_operate
    raise NotImplementedError(str(op))
 
It's telling you that you can't add a string and a objects
 
ok so the line "print("TEST 1 >> " + box.obj)" is the problem lol
 
10:19 PM
print(f"TEST 1 >>{box.obj}")
 box.obj # that is how it looked like in the console
i thought it's going to return a list of objects , empty or not.
#when I tried
print ( len(box.obj))
# i received this error
TypeError: object of type 'InstrumentedAttribute' has no len()
nvm i think i got it.
the question still presented though, how do i query box based on the number of objects referred to

I wanna run something like that
# how to query the first box with items more than 3 for example.
firstBox = box.query.filter(len(box.obj) > 3).first()
if it's not possible, that's fine, i'll just make a column in the box class and just add 1 when object is added and subtract 1 when it's being removed.
but if there is a better way to do this, i'm down for it
 
10:34 PM
Any chance that filter() accepts a callable?
 
11:08 PM
@AndrasDeak--СлаваУкраїні I have no idea, but I guess i will just go with what is working right now which is adding a column until i figure out how to do it properly if that was even possible, im still not sure.
 

« first day (4235 days earlier)      last day (696 days later) »