« first day (2547 days earlier)      last day (2626 days later) » 
04:00 - 19:0019:00 - 00:00

19:00
if @Antti was here he'd say "look in python 3"
;)
brutal, yeah i havent found anyone willing to help me out in SO chat to-date, but wishful thinking
Posting on SO and providing a big fat bounty is the best bet
my question would likely get marked as a duplicate
it's a common error, none of the SO questions are shedding much light on it
wim
wim
@alex post it anyway
dupes are not necessarily bad
@alex then perhaps you're missing something
19:02
Going into hair-splitting detail exhaustively debunking every proposed solution for every proposed duplicate post is the best bet
if you keep seeing solutions to your problem and they don't work, you're probably missing something
yes andras perhaps i have been missing something for several months too
wim
wim
and if someone finds the right dupe, it helps you anyway
point taken but yet-another-python-2.7-import question is sort of my last resort. do you guys know of any other communities that i could reach out to?
I think this is the best community
19:06
(i probably will ask SO anyway)
I recommend expanding your search from websites to mailing lists and IRC servers
if it's simple enough you could ask here too instead of meta-discussing your question (easy for me to say: I won't be able to help)
I don't have any specific addresses on hand but I'm pretty sure both exist
true that i've tried a reddit irc server, no dice
thanks
@AndrasDeak does moral support count as helping ? :D
19:09
@MooingRawr I guess :P
I also don't object to seeing the question asked in here but I have a limited understanding of import mechanics, so I can't solve anything but the simplest of typos
an immoral solution to the actual problem would probably be better
Wow, my dumb question on gamedev.se got 10k views. Now everyone knows that basic 2D rendering confuses me.
[surreptitious profile click]
we can use this whenever fame goes to your head and we need to cut your wings to get you back on the ground
19:11
might be too localized to discuss here. tldr i have a heavily modular codebase i'm working on that works in pycharm but not on the terminal
4
Q: Basics of drawing in 2d with OpenGL 3 shaders

davidismI am new to OpenGL 3 and graphics programming, and want to create some basic 2d graphics. I have the following scenario of how I might go about drawing a basic (but general) 2d rectangle. I'm not sure if this is the correct way to think about it, or, if it is, how to implement it. In my head, ...

@davidism that question is pretty old, you even look younger in your avatar there
i appreciate it though
Back in my C++ days, when I wrestled with OpenGL just getting a triangle drawn on the screen was the hardest part.
So struggling with a rectangle is not so shameful, it's 33 to 100 percent harder than what I struggled with, depending on whether you're counting by vertices or area
I remember doing 2d work. You need an orthographic... something.
projection?
19:14
Probably yeah.
But only listen to my advice if you want to do it the way it was done fifteen years ago. Or really, how it was described fifteen years ago in tutorials that were already ten years old
geometry is several hundred years old, so we're cool
Hmm that doesn't square up with my understanding that Bob Ross invented perspective in the 70s
But realtalk the API for OpenGL has changed between versions and the way I remember is probably completely passe by now
Argh, I figured out why my frequency table wasn't working. isalpha excluded ASCII space character.
If I also recorded that, everything works without the non-printable heuristic.
Frequency table...... is there a benefit to doing it that way ?
What other way is there?
19:28
I just did a rolling calculation and kept whatever was the 'largest'
im assuming you are tlaking about 1.3
Yeah, 1.3. Calculation of what?
I just counted the number of A-z including space and the "sentence" that yielded the most was my winner
Lol, that works too. I was assuming things would get more ambiguous later.
Python has so much empty space with their recommended styling :|
spoilers to 1.3 this was my solution
19:31
@corvid But you don't have to write as much so it balances out. ;-)
right. I thought about making it more robust and what not but I got lazy and if I have to change it in the future I would have but eh....
yeah I miss using python now that I am mostly full time javascript, it feels like the most well-thought out language in terms of powerful expression imo
Like list comprehensions feel unmatched by javascript
Javascript... I was asked to look at it once at work. I told them if they were willing to pay me for a week of me looking at basic docs, or would they rather put me on something that I was actually hired for... :P
thank god I didn't need to look at javascript :\
I enjoy some things in modern JavaScript, but all the tooling around it makes me really angry.
Javascript works well for event-driven systems and interfaces, but it's extended out to do too much
19:33
I really don't like that imports can only be at the top though.
So you have to use require still if you want conditional imports. Which has different API than import.
i dont like the fact that $ are in javascripts :(
You could use functional imports in higher versions of javascript
async loadSomethingConditionally() {
  if (condition) {
    const conditionalModule = await import('whatever');
  }
}
cbg
19:50
cbg
the heuristics given for 1.6 are completely failing me
i.e. I just can't find my bug
i figured my thing out
i was using python -m to try to call a specific script
genius
good job
I mean finding it; not missing it for months
i solved the problem i was having for months with python -m
refactored a very large codebase to follow this modular design
i was invoking modules with python -m for a while and forgot to update my own readme
like, sometimes you dont want to invoke a module
well, packages are usually not run
19:57
no but in my case it made sense
yeah, there are a lot of examples for it
i wanted to test things on the module level
i ran into a little hiccup just now and then i had a lightning flash of python 2.7 imports-related PTSD
thank you guys for the moral support
dumb question since I've been out of the python game for a bit: is it considered bad practice to use callbacks like this?
like what?
21:01
anyone done cryptopals 13?
@Kevin (late reply for 1.6) did you ever fix the heuristic for the key size? I have the same problem as you: given the right keysize it works like a charm but there's no chance of finding the right keysize with the given heuristic
that part should be trivial yet I can't get it to work
@davidism the challenges are numbered starting from 1; 13 is 2.13
@AnttiHaapala yeah, just thought of that.
@AndrasDeak I got it right the first time
I'm on 1.6 right now.
21:04
doing what the description suggests?
what I did was correlate all blocks with each other, cross product.
well, yeah, that could work, but that's definitely not the heuristic given
so I'm probably doing it right
lol :D
it doesn't tell to do exactly as said, just some suggestions
I'm feeling lazy. "bin() string comparison hamming distance" lazy.
none of which give remotely correct naswers?
21:06
how's that lazy
@davidism you wouldn't be alone :P
I didn't even skip the 0b
bin(int.from_bytes(xor(a, b), 'big', signed=False))[2:].count('1')
no need to skip the prefix
I know, that's why I didn't skip it
Oh, duh.
21:12
and unsigned is the default
oh, you were replying to davidism
I just can't get a keysize larger than 5 :|
it's driving me nuts
almost always 2 wins
lo-ol
then there is something very wrong
@AndrasDeak ah now I remember
"don't divide by keysize, divide by keysize squared"
Normalize this result by dividing by KEYSIZE.
that's what I'm doing
21:22
so are you summing them together or what?
take the mean
taking the mean and summing them gives the same result if I'm using the same number of blocks in each case
same, the sizes I get are [5, 3, 2, 13, 11, 20, 18, 38, ...]
I think that heuristic is broken. The only fix I've heard so far is Antti's, and it has little to do with the suggested heuristic
ah also, remember that you're not to correlate them together :D
wonder what Kevin did
21:24
so how has mine little to do!?
@AnttiHaapala not sure what that means
sorry sleepy:D
remember to not self-correlate...
I didn't
I'm not a math person, so I still don't know what that means.
nblocks = len(msg)//trysize
avgdist = sum(hamming(msg[i0*trysize:(i0+1)*trysize],msg[j0*trysize:(j0+1)*trysize])
              for i0 in range(nblocks) for j0 in range(nblocks))/(nblocks*(nblocks-1)/2*trysize)
one of my many failed attempts, this one is the "check all the pairs" version ^
21:26
wow :D
Are you fighting the 1.6?
Just to confirm, 5 isn't actually the right key size? I haven't finished coding yet.
@davidism it's not
@IljaEverilä yup, if I arbitrarily use the right keysize it all works fine. The proper heuristic to get the keysize is eluding me
the correct keysize is >10
I took the "try 2 first blocks" way too literally first, which also resulted in 5 for the longest time.
21:27
I also tried 3 and 5 and 50 and "all"
no, not "all"; that was just for Antti's suggestion
Moved to combinations of first 4 -> got the correct len.
you're also not a) dividig the hamming by try size and calculating mean.
def probable_key_lengths(ciphertext):
    keysizes = []
    for ksize in range(2, 41):
        hammingtotals = []
        hammings = 0
        chunklist = list(chunks(ciphertext, ksize))
        for c1 in chunklist:
            for c2 in chunklist:
                if c1 is c2:
                    continue
                hammingtotals.append(hamming(c1, c2) / ksize)

        keysizes.append((sum(hammingtotals) / len(hammingtotals), ksize))

    keysizes.sort()
    return keysizes
just to recap: for n=3 (hamm1/x + hamm2/x + hamm3/x)/3 == (hamm1+hamm2+hamm3)/(3*x)
3 is for the mean, x is actually trysize
21:31
true dat :D
going home, will pick up later, rbrb
rbrb
@Antti you're also doing double the work ;)
and again just to be sure: you're doing all this on the unbase64'd raw bytes message, right?
21:35
I have no idea what I'm doing differently :|
perhaps my hamming is broken and it just happens to work for the test case
the wakka test case? :D
Not sure if it matters, but aren't you including the hamming distances of a block compared to itself in the mean?
So some 0 there.
I was just about to write that again.
yes.
@AndrasDeak you've got 2 loops, where do you filter them out?
21:38
wait
            if c1 is c2:
                continue
And different key lens would give you different amounts of blocks and ...
oh yam, you guys I right, I started with a full loop (with proper bounds) then I screwed up writing it into a list comp
thanks, that's probably what I've been missing at least in the last 10 minutes
(I still believe that the prescribed heuristic is wrong, but this might fix my code)
let's see...
no, hamming distance you can use to recognize the block size in an XOR crypto...
and it is pretty easy to prove it
the plaintext was ASCII
nope, no luck still :D
let me check if there's something stupid still
I'm probably doing a very stupid mistake that I can't see because I've been looking at this for too long
HUH
@Antti that^ is what I get with complete cross-correlations
21:56
@AndrasDeak you need to get per-byte mean distance and for the non-self-correlated
what's a byte?
per byte in one key...
dividng by keysize should be per-byte...shouldn't it?
well I am
as per the instructions...
nblocks = len(msg)//trysize
avgdist = sum(hamming(msg[i0*trysize:(i0+1)*trysize],msg[j0*trysize:(j0+1)*trysize])
              for i0 in range(nblocks) for j0 in range(i0+1,nblocks))/(nblocks*(nblocks-1)/2*trysize)
going from 0->nblocks-1 then i0->nblocks-1 I have nblocks*(nblocks-1)/2 items for averaging
and the rest in the denominator is the key size
21:58
your numbers are still off
I KNOW D: :D
idk why...
maybe you cheated
this looks like an sqrt so maybe I should take the square
but no; that's a monotonic function so the minimum won't budge
this is so annoying
and I'm pretty sure it's something stupid
let me try reproducing your factor of 2
your initial numbers are too large :P
one thing you didn't show: your chunking function
22:02
are you using python 2 :P
@AnttiHaapala hell no :P
ah that could be :P
this is my one chance of trying to learn bytes vs str
def chunks(l, n):
    """Yield successive n-sized chunks from l."""
    for i in range(0, len(l), n):
        yield l[i:i + n]
WHAT
ah, yes
:P
so your last chunk might be a partial one?
22:04
ah my last chunk might be a partial one.
it would be weird if that was to blame
hmmmm
indeed :P
but it can't be
but not inconceivable, because I can't see anything else for now
because it would affect the 2 even less
can you try reducing the max there to len(l)//n*n?
just to check
I don't want to go on a wild bug chase
22:07
one problem is that your // trysize is wrong
because it is going to round down to some other block size.
how so?
that's not the block size, that's the number of blocks to compute
it's even later for you :D
I should probably check that my hamming gives what I think it gives
@Antti what's your hamming(ciphertext[::2],ciphertext[1::2])? I've got 5118
22:13
print(hamming(ciphertext[::2], ciphertext[1::2]))
-> 4676
son of a
you're b64decoding right?
yes
the decode should be fine because with the right keysize I can decode the whole message and get the right key
with open(infile,'r') as f:
    b64msg = f.read().replace('\n','').encode('ascii')
msg = cd.decode(b64msg,'base64')
22:15
so how's your hamming distance defined
(cd is codecs)
wait wat?
from base64 import b64decode
guess I should compare the two
with open(infile, 'rb') as f:
     msg = b64decode(f.read())
this shouldn't affect it naturally:D
but that's how you do it
ah, I guess the newlines are naturally ignored by any reasonable converter
22:18
I need to go to bed now :D
OK, the two decoded versions are the same :P
thanks for the help, good night
I'll try to see if there's anything else. I should probably give it a rest myself
I just feel annoyingly close
so my hamming is borked, that's a good starting point
how to tight bound n^2(n^2-n) using big theta notation?
is big theta the "exactly this scale"?
What do you mean?
nevermind, I'm probably too tired to be reliable anyway :)
22:25
Alright
22:53
@Antti indeed my hamming was borked: I didn't pad my bytes to a given width :|
so I would compare b'0b10' with b'1000110' etc
And now the heuristic works for 5 blocks with cross-correlations; and 10 blocks with only neighbour checks
yam
23:46
cabbage
04:00 - 19:0019:00 - 00:00

« first day (2547 days earlier)      last day (2626 days later) »