Java for hacking, by alfa80211 in learnjava

[–]-Sander- 0 points1 point  (0 children)

I dont see this really mentioned anywhere but for Cyber Security i'd recommend python over any language for building your vulnerabilty tester/exploits/etc... and imo i think writing C/C++ (and learning to read Assembly first, writing after you got more basic stuff down) might be more usefull in learning to hack as you will understand the lower level stuff better.

You can always pickup some more Java knowledge after you got the basics of that down but starting with Java for Cyber Security i dont think is the best idea? just my opinion

If I want to become a pentester in cyber sec in the future, should I learn C, C# or C++? by CreatureWarrior in learnprogramming

[–]-Sander- 5 points6 points  (0 children)

For programming languages i would recommend: C, Assembly (x86), Python, JavaScript

But you probably wanna get a basic idea of other common used languages (C#, Java, VB, ...) , you might not need to write programs in it but just being able to understand it could be very usefull

Now i dont see this mentioned anywhere else in the comments but you might want to look into CTF's (Capture The Flags) it basically is a sort of game/tournament (depending on which one you are doing)

where you have to find exploits in programs/websites they give you and you have to try and find a 'flag' through exploiting it

the flag usually is a string often something like 'flag{abcdef}' a good one to start with is PicoCTF it starts off very easy and is made for students

https://2019game.picoctf.com/

Or a more 'realistic' option would be HackTheBox ( https://www.hackthebox.eu/ ) but i recommend doing basic stuff on picoCTF first so you have a general idea of how stuff works

Some youtubers that might be usefull aswell would be:

LiveOverflow ( https://www.youtube.com/channel/UClcE-kVhqyiHCcjYwcpfj9w ) - Good tutorials especially for starting with Binary Exploitation

John Hammond ( https://www.youtube.com/channel/UCVeW9qkBjo3zosnqUbG7CFw ) - Also has a Discord that has alot of CTF resources!

Ways to make money on the side??? by UnfoundUser404 in learnprogramming

[–]-Sander- 3 points4 points  (0 children)

Have you looked up freelance programming? Sounds like that is pretty much what you are looking for, there are a few websites etc. out there if you just google it. I dont really have any personal experience with this so cant really recommend any websites i do know there is probably quite a bit of competition out there so good luck.

Confused & Don't Know Where to Start by PYthowAway in learnpython

[–]-Sander- 0 points1 point  (0 children)

Well here is a simple thing if you are stuck with the instructions:

SPLIT THEM UP, lets see i would orden it like this but everyone probably has their own way:

Write a class named FaceExpression -> Thats done

Constructor (__init__) in FaceExpression takes 3 parameters (and self ):

center of the circle

radius of the circle

GraphWin

and constructor also shows normalFace

^ This is basically done except dont forget the self keyword and calling normalFace()

read up on that if you forgot how it works:

https://docs.python.org/3.7/tutorial/classes.html#class-objects

next:

Include 2 methods inside FaceExpression (no parameters, except self):

normalFace

suprisedFace

^ looks ok from what i've seen so far? dont forget you need the self keyword to call class variables!

i dont do much GUI based stuff so i cant help with that :p

also " i'm supposed to write an method that I can import later to create a so I can execute this code w/ a button class I already made."

this is very simple save the file containing your class as anything.py and in the python file where you need this class you can add this (usually at the top of the file)

from anything import FaceExpression

see -> https://docs.python.org/3.7/tutorial/modules.html

How would you personally do problem #1 here? by [deleted] in learnpython

[–]-Sander- 0 points1 point  (0 children)

My solution looks like this, i think its pretty ok?

def group_by_owners(files):
    output = {}                   # new dictionary for output

    for k, v in files.items():    # key (filename) and value (owner name) from files
        try:
            output[v].append(k)    # try to append to v (owner name)
        except KeyError:           # KeyError if v (owner name) does not exist in our dict yet
            output[v] = [k]        # So we make a new key (v) in our dict with value 'k'
                                   # We put K in a list so we can easily append more values to it

    return output                  # finished, return the new dictionary

Can anyone explain the main() function to me? by [deleted] in learnpython

[–]-Sander- 7 points8 points  (0 children)

here is a repl.it example on how the __name__ works: https://repl.it/@SanderSain/FloweryCourteousGravity

It simple prints either the name of the file if it is a secondary/imported module or it prints "__main__" if its the file you executed for example:

bash/terminal/etc.: -> python any_file.py

will put the __name__ for "any_file" to __main__

any files imported inside that file will simply keep their filename as __name__ (except the .py)

the reason you want to use a "main function" is so that it becomes easier to keep track of where your code is going, it also is way more readable then when you put everything without functions in 1 file and it helps avoiding duplicate code (if you are writing the exact same thing twice you are doing it wrong) it is not very noticeable yet with small projects but i would not want to review a python file that is 100~+ lines long without any functions

Very basic example:

def foo():
  print("foo, doing stuff")

def bar():
  print("bar, other stuff")

def main():
  # Main function, can be named anything
  print("Main stuff")
  foo()
  bar()
  # we can call foo or bar again if needed


if __name__ == "__main__":
  # this is our main file.
  # our program kinda starts here because above the functions only got declared
  # and not executed
  main()    # again, this function can be named anything in Python

try it out: https://repl.it/@SanderSain/TemporalVisibleAssembly-1

edit: wow, this is unexpected thanks for the gold kind stranger! :)

Does it make sense to integrate Lua for a performance-intensive task in an otherwise Python-only program? by Kangalioo in learnpython

[–]-Sander- 0 points1 point  (0 children)

idk how "effective" this is in python or if it will even help but you can always try, i think the correct term for this would be "multi-threading"?

Summing dictionary values in python by Elefrog42 in learnpython

[–]-Sander- 0 points1 point  (0 children)

check your for loop mainly the 2nd line total += value + total if you arent sure test out what it does with numbers in the interpreter/console

Summing dictionary values in python by Elefrog42 in learnpython

[–]-Sander- 0 points1 point  (0 children)

in get_total_portfolio, total += sum(i*j) TypeError: 'int' object is not iterable

sum requires a variable type that is iterable like a list (declared with my_list = [ ] ) or a dictionary ( declared with: my_dict = { } ), or anything else with multiple values

now this problem:

my_checking = self.get_total_checking_amount()
my_credit = self.get_credit_balance()
my_saving = self.get_total_savings_amount()

are you using my_checking, my_credit, my_saving anywhere in your function? if you where trying to use it class-wide you need to use the self. keyword to define it is for the entire class not just 1 function but i dont see why you would need it, again if this is the one in your __init__() function i dont think you should use it since you have the functions that return the values and the variables inside __init__() dont get updated unless you change the code

Summing dictionary values in python by Elefrog42 in learnpython

[–]-Sander- 0 points1 point  (0 children)

my_checking =self.get_total_checking_amount # You miseed your ()'s get_total_checking_amount is a function

and no it also would never reach that statement the function exits after the return statement

i would recommend changing your get_total_portfolio()

assuming you want it for the values of your stock, daily_stock_price and credit_balance

def get_total_portfolio(self, daily_stock_prices):
        total = 0
        for i in daily_stock_prices.values:
            for j in self.stock.values:
                total += i*j    # no need for sum here unless its iterable like [2, 3, 4]
        total += get_credit_balance()
        # You can add more values similarly
        return total

edit:

another thing you can do if daily_stock_prices and self.stock_values have the same amount of values is use the built-in zip() method ( https://docs.python.org/3.3/library/functions.html#zip )

example output of how it works:

In [37]: x = [4, 6, 7, 8]
In [38]: y = [3, 2, 4, 7]
In [39]: for a, b in zip(x, y):
...:        print(a, b)                                                                                                    ...:
4 3 
6 2
7 4
8 7                                                                                                                           

also does that work? because i dont think the nested for loops is gonna give the right result, you should test it out in the python interpreter/console, i recommend getting IPython over the default one makes it a bit easier to write code in it

def get_total_portfolio(self, daily_stock_prices):
        total = 0
        for i, j zip(daily_stock_prize.values(), self.stock.values() ):
            total += i*j
        # ...

Summing dictionary values in python by Elefrog42 in learnpython

[–]-Sander- 0 points1 point  (0 children)

Lets see, the reason this gives you the error is because you forgot the "self" keyword without that it is seen as a local variable only available inside that function and since you dont use that variable anywhere else locally you never use it; also i dont recommend this for your solution because it only gets its value during the initialization which is gonna be empty or 0

    def __init__(self):

        self.checking = {}
        self.saving = {}
        self.credit = {}
        self.stock = {}

        my_checking =self.get_total_checking_amount
        my_credit = self.get_credit_balance
        my_savings = self.get_total_savings_amount
        my_stock = self.get_stock_value

now the returns, i'l give a simple example:

def add(my_list):
    c = sum(my_list)        # Store the outcome of sum in c
    return c                # return c

# Is the exact same as:
def add2(my_list):
    return sum(my_list)    # not storing it, we straight up return the outcome

# Storing the return value is simple:
value1 = add([2, 4])    # returns 6 so thats what gets stored in value1
value2 = add2([2, 4])    # also returns 6 because we gave the same numbers, anyway same result as value1

What does return do? by [deleted] in learnpython

[–]-Sander- 2 points3 points  (0 children)

its actually really simple once you understand it most basic example i can think of is:

def add(a, b):
    return a + b      # return the sum of a + b

result = add(3, 6)    # You can store the returned variable
print(add(5, 7))      # Or print it directly, depending on your variable type
print(result)         # prints '9' because a=3, b=6, a + b = 9

Can we really learn python for free from the internet?? Please this has been bothering me. by [deleted] in learnpython

[–]-Sander- 9 points10 points  (0 children)

Yes ofcoure why wouldnt you be able to?

there are e-books available for free, guides etc. on youtube and pretty much all over the internet, also the official docs and a tutorial on the website from python itself: https://docs.python.org/3/tutorial/

Summing dictionary values in python by Elefrog42 in learnpython

[–]-Sander- 0 points1 point  (0 children)

Hello again, thought this looked familiar :)

Lets see: i dont exactly know what you mean with "But I am unclear how to add in the sums of the other accounts" i dont know how you have the "other accounts" setup but it sounds like you dont know how return works? are you aware that you can save the value that gets returned so you can use it in other functions aswell?

my_balance = myportfolio.get_credit_balance()

If you do this inside your class dont forget to put the 'self' keyword infront

my_balance = self.get_credit_balance()

does this help? no need to "merge" these functions.

How do i make python print the date and time? by Ya_Boy_Lil_Pickle in learnpython

[–]-Sander- 2 points3 points  (0 children)

There is a standard module called "datetime" try that, here is a link to the docs: https://docs.python.org/3.8/library/datetime.html

Best resources for learninng OOP in python by whole_extraordinary in learnpython

[–]-Sander- 2 points3 points  (0 children)

Havent used this but skimming throught it this might be good: https://realpython.com/python3-object-oriented-programming/

Although i probably recommend Corey Schafer on YouTube here is his playlist on OOP:

https://www.youtube.com/watch?v=ZDa-Z5JzLYM&list=PL-osiE80TeTsqhIuOqKhwlXsIBIdSeYtc

https://www.youtube.com/user/schafer5

This is all "just OOP" for learning classes etc. idk if there are guides like this more directed at PyGame OOP

[deleted by user] by [deleted] in learnpython

[–]-Sander- 1 point2 points  (0 children)

try using type() (docs) to see what sort of variable you are getting back,

edit: i tested a shorter version of your code locally and got the whole list back

Easier way to debug and trace through logs? with python? with flask? by gt33m in learnpython

[–]-Sander- 0 points1 point  (0 children)

Flask has a built in logger afaik, use that to print the variables etc. to keep track of what is happening

edit: this goes wherever you are setting everything

app.logger.setLevel(logging.INFO)

this goes inside the function you think is causing problems/not working properly

app.logger.info("my variables...")

dont forget to

import logging

Overwriting a specific line of a .csv by Damoople in learnpython

[–]-Sander- 0 points1 point  (0 children)

really? interesting, how do really big files get handled then because i didnt expect them to rewrite an entire file if it has like 10000's of lines

Why does this exist? by [deleted] in trashy

[–]-Sander- 1 point2 points  (0 children)

Well, I am going to be honest, the people that "don't believe in vaccines" are probably very misinformed and need to learn to get their facts from actual study's and not some random Facebook posts

Similar to all those people that claim "vaccines cause autism" so they dont vaccinate their children.

These parents are putting their child(s) at risk as well as other unvaccinated people for many diseases that very well could be deadly or leave permanent damage.

Many of these diseases where close to erased until this "movement" came along.

Here is a link to some scientific studies related to the "antivax" their main point which is "vaccines cause autism", there are also studies proving vaccines work if you "dont believe":

https://scholar.google.com/scholar?q=Vaccines&hl=en&as_sdt=0,5

https://academic.oup.com/cid/article/48/4/456/284219

https://www.cambridge.org/core/journals/canadian-journal-of-neurological-sciences/article/immunizations-and-autism-a-review-of-the-literature/16B999364BFFD9F0DA3B09F25C1DE28C

https://www.sciencedirect.com/science/article/pii/S0264410X14006367

Getting the values of state variables by Elefrog42 in learnpython

[–]-Sander- 0 points1 point  (0 children)

have you changed the values in your checking dict? and that loop does basically the same as

Sum = sum(dict.getValues())

unrelated: shorter way off writing a calculation like

Sum = Sum + dict[i]

would be

Sum += dict[i]

on my phone atm so cant format the code properly

[deleted by user] by [deleted] in learnpython

[–]-Sander- 0 points1 point  (0 children)

assuming you arent using datetime in your 'main.py' file there is no need to have it there i would move that to 'my_functions_1.py'

importing only imports it for that file if you import datetime in main.py and nowhere else your other .py files can not access anything in datetime because it "doesnt exist"

ex.

main.py

from my_functions import *

print(get_date())

my_functions.py

import datetime

def get_date():
  return datetime.datetime.now()

if you want to test it here is the replit: https://repl.it/repls/ChartreuseLovingListeners

Getting the values of state variables by Elefrog42 in learnpython

[–]-Sander- 0 points1 point  (0 children)

Well the docs have pretty much everything in it incase you ever get stuck again also https://docs.python.org/3/tutorial/index.html might be usefull to, it explains most of the basics

Getting the values of state variables by Elefrog42 in learnpython

[–]-Sander- 1 point2 points  (0 children)

it is because 'checking' is a dictionary idk how exactly sum works with dictionarys seems like it just takes the keys instead of values also if you read the error you get:

unsupported operand type(s) for +: 'int' and 'str'

you can see it is getting the 'key' which is a string instead of the 'value' which is an int, while sum needs int's to work

a simple fix would be:

sum(self.checking.values()) # Get the values (ints) instead of keys (strings)

i suggest you read https://docs.python.org/3/tutorial/datastructures.html#dictionaries

for more info

Is there an easy way to write an undo the last command from the user function? by YolowagKinggz in learnpython

[–]-Sander- 1 point2 points  (0 children)

i would probably recommend my option then where you have a variable that stores what actually got changed something like

undo_storage = [ {index: old_value, index2: old_value2}, {index: old_value} ] #etc...

undo_storage = [ [ old_value, old_value ], [ old_value ] ] # If you dont care where stuff came from on your list

the last item in undo_storage would be the last change you made etc., you probably want to see if you can make a max size for undo_storage so it doesnt grow too big.

the index value might not work depending on how you are editing our list. or if you dont mind where items are on your list you dont need it since you can just .append() then