profile
viewpoint
GomesAR gomesar Brasil A restless brain that wants to know about everything. - Bachelor of Science in Computer Science (Federal University of Pará)

juliodosreis/MC302EF-18S1 2

laboratórios disciplina MC302 Programação orientada a objetos, Instituto de Computação, UNICAMP

gomesar/CATGON 1

Cant think in a good name

beothorn/android-anuto 0

Another ugly tower defense for Android

gomesar/aesir 0

Æsir — an open-source cross-platform MMORPG client.

gomesar/android-anuto 0

Another ugly tower defense for Android

gomesar/arancino 0

Arancino is a dynamic protection framework that defends Intel Pin against anti-instrumentation attacks.

gomesar/djongo 0

Django and MongoDB database connector

gomesar/EC_algoritmoIntrodutorio 0

Universidade Federal do Para 2014, periodo 04 Computacao Evolucionaria, Alexandre R. Gomes. Trabalho 01: Algoritmo de busca introdutório para algoritmos genéticos

push eventsatwikkansal/wtfpython

Satwik

commit sha 048a620502d7eb6ccd4ece1fe805ba867da910a2

Update notebook

view details

push time in a day

push eventsatwikkansal/wtfpython

Satwik

commit sha 2bc1cd61c11285b19e575dfcbda971b0b90a7477

Update the sticy output example Closes https://github.com/satwikkansal/wtfpython/issues/245

view details

push time in a day

push eventsatwikkansal/wtfpython

Satwik

commit sha 6f9c0b92e36cdb6931cb75333af7e5344c3f1673

Update the sticy output example Closes https://github.com/satwikkansal/wtfpython/issues/245

view details

push time in a day

issue closedsatwikkansal/wtfpython

Schrödinger's variable

▶ Schrödinger's variable *

The asterisk at the end of the title indicates the example was not present in the first release and has been recently added.

def make_func():
    for target in ('a', 2, None):
        if isinstance(target, str):
            def f():
                print(f'inside f(), {target=}')
            print(f'just created f(), {target=} at this point!')
    return f

Output (Python version):

>>> f = make_func()
target='a' at this point!

>>> f()
inside f(), target=None

💡 Explanation:

  • Python doesn't actually bind the value of target in f(). It just creates a function that will look up target in the surrounding context.

  • Since target will continue to be updated until it is set to None in the last iteration of the for loop, target=None when it prints inside of f()

    Output:

>>> f.__code__.co_freevars
('target',)
>>> import inspect
>>> print(inspect.getclosurevars(f).nonlocals['target'])
None

This might be made a bit clearer if we use a global variable rather than a free variable:

for target in ('a', 2, None):
    if isinstance(target, str):
        def f():
            print(f'inside f(), {target=}')
        print(f'just created f(), {target=} at this point!')

Output.

just created f(), target='a' at this point!
>>> print(target)
None
>>> f()
inside f(), target=None
>>> target = "whoa"
inside f(), target='whoa'

closed time in a day

charles-l

issue openedTemtaime/aesir

Missing nuklear_x64.lib

Hi,

I have tried to compile and got an error regarding missing nuklear_x64.lib

Maybe it‘s missing in deps.7z, can you please add the file or link?

BR Roland

created time in 2 days

issue commentsatwikkansal/wtfpython

Schrödinger's variable

▶ Schrödinger's variable *

The asterisk at the end of the title indicates the example was not present in the first release and has been recently added.

funcs = []
results = []
for x in range(7):
    def some_func():
        return x
    funcs.append(some_func)
    results.append(some_func())  # note the function call here

funcs_results = [func() for func in funcs]

Output (Python version):

>>> results
[0, 1, 2, 3, 4, 5, 6]
>>> funcs_results
[6, 6, 6, 6, 6, 6, 6]

The values of x were different in every iteration prior to appending some_func to funcs, but all the functions return 6 when they're evaluated after the loop completes.

>>> powers_of_x = [lambda x: x**i for i in range(10)]
>>> [f(2) for f in powers_of_x]
[512, 512, 512, 512, 512, 512, 512, 512, 512, 512]

💡 Explanation:

  • When defining a function inside a loop that uses the loop variable in its body, the loop function's closure is bound to the variable, not its value. The function looks up x in the surrounding context, rather than using the value of x at the time the function is created. So all of the functions use the latest value assigned to the variable for computation. We can see that it's using the x from the surrounding context (i.e. not a local variable) with:
>>> import inspect
>>> inspect.getclosurevals(funcs[0])
ClosureVars(nonlocals={}, globals={'x': 6}, builtins={}, unbound=set())

Since x is a global value, we can change the value that the funcs will lookup and return by updating x:

>>> x = 42
>>> [func() for func in funcs]
[42, 42, 42, 42, 42, 42, 42]
  • To get the desired behavior you can pass in the loop variable as a named variable to the function. Why does this work? Because this will define the variable inside the function's scope. It will no longer go to the surrounding (global) scope to look up the variables value but will create a local variable that stores the value of x at that point in time.
funcs = []
for x in range(7):
    def some_func(x=x):
        return x
    funcs.append(some_func)

Output:

>>> funcs_results = [func() for func in funcs]
>>> funcs_results
[0, 1, 2, 3, 4, 5, 6]

It is not longer using the x in the global scope:

>>> inspect.getclosurevars(funcs[0])
ClosureVars(nonlocals={}, globals={}, builtins={}, unbound=set())
charles-l

comment created time in 2 days

issue commentSecWiki/windows-kernel-exploits

请问压缩包MS15-015的解压密码是多少?

The password is "zcgonvh"

ruincrez

comment created time in 2 days

created repositorygabrielbiasi/python3.9-crypto

created time in 4 days

issue commentreloZid/android-anuto

Strategy / balancing discussions

I've been figuring out why the healers become so powerful in the later waves. By looking at the code and doing some ingame testing, I've found out the following:

  • Heal effect doesn't seem to stack (not sure if that is intentional or not)
  • Healers heal every 5 seconds (at base speed)
  • Healing timer seems to be universal, i.e. shared between the healers and the waves
  • Heal effect heals 10% of enemy health

So there is a point where healer becomes basically immune to the towers: it's when the heal amount is larger than the damage a tower can deal in five seconds! This is easily seen with rocket and laser towers, as their single-target DPS is rather low. Meaning that a single healer within a group of enemies can negate all area damage dealt by level 15 rocket and straightLaser towers after a certain point! That point is somewhere before wave 100, depending on how the health scales (early waves...). For level 15 machineGun towers, this breakpoint becomes later. Against healers it is between waves 130 and 140 due to healers being weak to bullets. After that point you'll need at least two machineGun towers shooting at the same target all the time to overcome the heal effect!

In essence, the issue is that the tower DPS is capped, but the heal amount is not, so at some point the healers simply out-heal the damage you do.

reloZid

comment created time in 5 days

startedjuliocesarfort/public-pentesting-reports

started time in 12 days

issue openedreloZid/android-anuto

Screenshots for F-Droid

You can add Screenshots for F-Droid, too, if you want.

https://f-droid.org/en/docs/All_About_Descriptions_Graphics_and_Screenshots/

https://gitlab.com/snippets/1895688

created time in 14 days

startedslaeryan/AQUARMOURY

started time in 16 days

startedjstrosch/malware-samples

started time in 16 days

fork JulianPedro/rancher-in-kind

Scripts to start up Rancher with Kind (kubernetes in docker) cluster

fork in 18 days

startedozbillwang/rancher-in-kind

started time in 18 days

startedD3VI5H4/Antivirus-Artifacts

started time in 18 days

startedjonathanbaraldi/kubernetes-deploy-go

started time in 20 days

startedm4ll0k/BurpSuite-Secret_Finder

started time in 20 days

startedossu/computer-science

started time in 20 days

startedwh0isdxk/InfosecInANutshell

started time in 22 days

startedjonathanbaraldi/devops

started time in 23 days

startedkevoreilly/CAPEv2

started time in 23 days

startedApr4h/CobaltStrikeScan

started time in 23 days

issue commentsatwikkansal/wtfpython

Add translation for [Persian(Farsi)]

Hi @alirahimifachr

Sure, feel free to translate at your own pace.

do you have a advice for me?

Nothing specific as such, make sure to enjoy and learn as you go :)

w.r.t implementation, you can check out the existing translation issues to check how other contributors have done it https://github.com/satwikkansal/wtfpython/labels/translation

alirahimifachr

comment created time in 25 days

issue openedsatwikkansal/wtfpython

Add translation for [Persian(Farsi)]

hi, if is it possible, i will translate this Repo to Persian. do you have a advice for me? thanks arf

created time in 25 days

issue commentsatwikkansal/wtfpython

Schrödinger's variable

Let me know if you want me to take a shot a combining the explanations.

@charles-l Sure, that'd be helpful, thanks

charles-l

comment created time in a month

issue commentsatwikkansal/wtfpython

Schrödinger's variable

@satwikkansal ahh, I missed that one. Merging them sounds good! Let me know if you want me to take a shot a combining the explanations.

charles-l

comment created time in a month

startedunicorn-engine/unicorn

started time in a month

startedkeystone-engine/keystone

started time in a month

more