#programming
1 messages Β· Page 3 of 1
Thanks
Gave +1 Rep to @wicked flame
Indeed, after the bash -p... π
Are there any websites to learn Powershell interactively like Codecademy?
Only powershell interactive resouce I know of is UnderTheWire, if that ticks the boxws for you.
Iβll look into it, thanks!
Hey! Anyone experienced with JDBC?
Or just MySQL in general?
Nvm, figured it out π
probably can but won't. Try to narrow it down, put debugging statements, trace what is happening and see where it breaks. Give this details with what goes wrong and what should happen (this might as well already help you find the problem yourself)
Also, this feels like some homework stuff. No help on homeworks here I think.
it is to improve my programming skills
i can't fix his code π
in this case .. debugging is an important part of programming and you should be able at least find out which functions is the problem. If you can give us just a few lines of code an "this line somehow does XY, but I'd expect it do AB", we are likely able and willing to point out why it behaves different.
suggestion: print the board in each function and the result of the function. you should see where it misbehaves.
I have a question about sockets in python3
I have made a port scanner
but I was thinking
Is it maybe better to close the sockets right after it scan that port
the semantics would be
for i in range(1, 1024):
s.connect(ip, i)
s.close()
would closing the connection be faster?
You can time it and see
You will learn more doing it through experiment than by asking us and getting a yes or no answer
learning about the queue module
It's really good
for multithreading
watched some tutorial videos
Hello guys, I'm having some issues with the Introduction to Django room, I followed every step and I'm stuck in Unit-3 section 4, when I run python3 manage.py migrate it doesn't like it and throws so many errors (RecursionError: maximum recursion depth exceeded) , I've tried in both the virtual box and my own vm but it still doesn't work, when I run the app without adding urls it works fine (meaning I get the Django admin interface and all that) but when I add a path to urls.py it doesn't like it ( I did import include from django.urls and also tried from django.conf.urls import include) , any tips ?
recursion error sounds like there isn't an exit condition from the loop.
Hey people, any Rustaceans?
I am porting some code from C++ and got stuck at the very end.
@primal summit Cβmon keep it appropriate
okay, iβm sorryβ¦
Hi everyone! When we have a primitive data type such as a String, and assign it to the variable such as name = "Jayy", when we to edit the value of name, because it's immutable does this mean that when we do name = "Bob" its a completely new variable (e.g. memory location) to the old name = "Jayy"? Or is it the same memory location (variable) but the values been overridden? Surely not because it's immutable
Java?
?
is the question about Java or a different language? In case of Java, the string is not stored in the variable itself. the Variable just has an information where the real string is stored in memory. When you do name = "Bob" this information is updated. The variable name itself stays at the same memory location, but its value points to a different memory area (where you can find "bob")
Ah, for python? Or C#?
If it's immutable you cannot reuse the label
For C# it's also a reference generally
Most modern languages that I know of use references for everything, except possibly certain primitive types. String is not a primitive type, it's a complex type and the rules for primitive types don't apply.
"Canonical String Registration" is a good topic to look up.
Okay thanks you guys! So the variable stays at the same memory location, but the value points to a different memory area? (Reference)
You are misunderstanding the difference between value and reference.
Sorry, the value is held in a specific memory location and the variable is a reference to that value / memory location?
"Location" can mean different things in different programming environments. Reference can be a memory address or offset, it can also be an identifier that doesn't correspond to an address. It depends on the language, whether that language requires an interpreter or VM, and how compiled the executing code is.
Got it, so would have to do research on the specific language to find how it actually works for that languaeg
Very likely
hey, if i can ask, what's the difference between cout and printf in c++?
Have you googled this question?
ye i was looking around to see what printf does itself but I really can't see the difference
i just want to get a simpler explanation than on google if possible
They are very different things.
Not quite correct. Please check the C++ docs on what an ostream object is, and how cout implements it.
printf is C code anyways
Oh alright , Iβll check that out sometime today then .
It doesn't try to scan every port
It hangs at the 7th port scan
I tried looking at the queue documentation but
I don't really see anything that could help me with this problem
where do you take the elements out of the queue?
Does it work when you only use 1 thread?
No, it doesn't work when I use 1 thread either
it just hangs
maybe the problem is more with the port 139 itself and not the coding?
huh
no that's not how it works
actually you might be right
Would it be better for you make the ports in a list then do
[0,PortList]
It works now
but I can try that.
My real problem is with scanning ports 1 to 1024
I put 1024 numbers ranging from 1 to 1024 in linear order in the queue
when I run my scan though
it surpasses 1024
and keeps going
very weird
maybe I should append all the numbers in a list and then loop the list and append all those numbers in the queue
I really don't know what to do at this point
putting the stuff in the queue seems fine. your problem has to be somewhere else I'd guess.
I can show how I did the threading?
FINALLY I GOT IT
LETS GOO
This was the solution
nono wait
what
you got some raceconditions here
whats wrong?
there might be problems when a thread checks the while condition (not empty yet) but then the queue gets empty before you get the item
then it will wait forever
TOCTOU time-of-check time-of-use if you want to google about it
Have two queues.
Pull the ports scanned from one queue, and push the results to the other.
I know how to fix it
I while make for loop that counts to 1024 append it to a list then loop through the list and put it in the queue
I'm doing this cause if you scroll up higher
You can see that the ports in the list seemed to work fine
nvm
this just hangs
for some reason
time to debug
you have a multithreaded program with raceconditions. it's a gamble if it is working or not
can I have some good resources about raceconditions
would thread locking work in my case?
sorry, I don't know a good ressource. Maybe the topics "TOCTOU", "producer consumer pattern" might help (targeting your problem) . It's a huge topic
locking might help, but it's probably not the best in your case. You might take a look at the "block" parameter of the queue.get(). With this you can avoid the problem
I really don't get why it's surpassing 1024
You don't get why multithreaded code isn't running them in order?
I'm doing it right?
I think
I don't know what to do more.
Why does it matter if they run in order?
If they have to run in order, you don't want threading.
That's not the problem
I don't mind if they run in order or not
I don't want it surpassing 1024
Oh, you changed your question
Probably not hitting mode 1 then
You haven't tried everything
You can easily work out what mode it's finding by adding print statements
Alright.
lol
thank you
I got it
It's running
65535
ports
Now I just have to figure out how to fix that.
May want to check how your mode is being set
To be fair, I'm a fan of Concurrent.futures
I like threading better
I don't understand why it won't encrypt it
it was working fine earlier
fixed it nvm
anyone know why im having this problem
im sure I gave it the the correct private key
you inputted your message as a bstring which is not how python works. when you input something it takes it as a literal string and then you turn it into bytes if you want
so how should I do it?
.strip(b'')
and then .encode()
I don't really know
Ask for input as hex
Or base64
There's already well known ways of providing raw bytes over printable strings
any resource you can give me for that?
I'm certain you can google "python decode hex" or "python decode base64"
also why ask for input in hex or base64?
This.
So basically I put this as input
encode it with base64
then decode it?
I have a strange feeling you don't know what data types you're dealing with.
Slow down. Take some time to think about raw bytes.
Just explain it lmao
oh my bad
ill google it
Think about what generally terminates a string and how it can be present in raw input
Or other control characters.
True
basically when you get that output instead of taking it as is you should convert it to base64 which you can then decode to get the bytes object that you need and decrypt that with rsa
exactly what I was trying to say to james earlier
thank you bro
like say you have just encrypted some message and it's saved as a bytes objects let's assign it to a variable and call it encrypted_message then we do it like so:
import base64
base64_string = base64.b64encode(encrypted_message)
print(base64_string)
and then you take the string that is printed and you decode it like this:
message = base64.b64decode(input("please input your base64 string"))
and that message is decryptable you can now decrypt it using your private key and everything
It's a pretty common topic, but base64 is not an encryption cipher, it's a data encoding schema. Getting those confused is going to be real bad.
we know it's not, you should read the question
that base64 string that you're gonna get is going to be encrypted because you used rsa on it not because base64 encrypted it
base64 is not capable of encrypting anything. Because it's not an algorithm designed to secure data.
we know
the question was about rsa, i used base64 as a convenient way to make a string that can later be decrypted easily using rsa
I'm being extra explicit here, because the person you're talking with has a long history of mis understanding these topics, and I want to be extra clear what is going on.
ok then
so to be clear that base64 string you're gonna get is not going to be encrypted but after you decypher it you're gonna get an encrypted byte array
you don't have to point a weakness I had before just cause you misread the question
lmao
I know what base64 is
I did not misread the question. You have a long, long history of asking questions that are resolvable by reading the documentation.
i think this question is valid and also there's no reason to judge new people for being new i mean we were all there at some point right?
reading the docs is not always easy for beginners
good
I'm first allowing the user to specify a path to a encrypted file
and then they can decrypt it with a private key
I'm going to add manual input after and see if your suggestion worked
do you not have manual input in your program?
because it seems like you do from what you sent
i thought you wanted to decrypt a message inputted by the user
one sec ill snip the code rq
send it as text instead it's more convenient
do you get any errors or issues with this specific code?
then what is this all about i don't get it
Is there an actual problem?
what i sent you was the solution to the first problem you sent
do you have a problem with the new code that you sent?
i'm confused why did you come here for help without a problem?
the problem I gave you first what was I needed
that's what im going to add as well
ye except I added one more thing which you could also give a file to decrypt
but if you don't have manual input you should know that using the whole base64 thing is pointless because you can just use the byte array straight from the source
yeah I know that
the base64 solution is for manual input
yeah
send me your code anyways i'll review it or something give you some tips
can I dm you?
so I can send it
alr then
Quick note from what you posted, prefer arguments to asking for inputs
It'll make the program far easier to script afterwards
I still have to fix it and add stuff but this is what its at right now
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
hey i h ave a question so i joined a king of the hill on the website it gave me the machine name and the ip adress but i cannot find the start the machine or attack box button can anyone help?
this is programming help
btw
ohh sorry
right the first fix i'll add is to fix your usage of global variables. you should instead move everything into functions and have the values as arguments and then use it as you wish
Use the IP address, also this is probably the wrong channel π
i am really sorry buit which channel shouldi ask on
Right, Globals are usually a bad idea
#koth seems a good place
tyy
that's why in every python script we put everything in a main function and then run it under if __name__ == "__main__"
Always hated that about python
yeah i think it's pretty ugly but it's best practice
i will now
Why are you defining functions under a main?
alright i'll start with the quickest fixes your functions naming convention is wrong it should be lowercase snake casing like this: function_name and not: functionName (camel casing)
also yeah get rid of that main function it's pointless @lilac holly
I actually need it
your class name should be title cased like this: ClassName and not all caps like this: CLASSNAME
Also there's way too many if elif blocks, the cognitive complexity is way too high
also why are you printing the name of your thing in an infinite loop?
Looks like there's a fair bit of duplicated code, in any case a few refactoring passes are probably a good idea
Probably to loop through the menu again once they're done
right that's ok but it shouldn't be reprinted every time
Script like this should be a one shot though
you print the name and then put the menu thing in an infinite loop the name doesn't need to be reprinted
Yeah the paths should be parameters in the command line, lookup argparse
I have an idea
this outputs this
kind of looks cool to me
Yeah that's a useless sleep
you should value efficiency over coolness in this case
Always
can you look at the thing above avi
π speed π
my private key file has the---begin rsa
Print out the first line and debug
send the whole traceback i wanna see where that's from
I'll admit that debugging is more of an art than a science, but it's learnable, even if python makes it difficult
wdym traceback
The stack trace
you have a line that says traceback somewhere in your error everything after that is your traceback
look for it
That will tell you exactly what went wrong and where
@lilac holly perhaps it would be a good idea to learn how code is actually executed on a computer
whats the end goal here?
no I see the traceback
I know how python interprets the code
I mean how functions are called, about the call stack
I know that too I read automate with python
about half of it
Alright
it shows call stacks
Now you need to learn the hard parts π
Aka how to debug when everything inevitably goes wrong
To be fair I'm not that well versed in python
They help
π¦
Anyways, @lilac holly I just want to ask you to please try to remain respectful when we ask you to look up the easy stuff on your own. I know that learning is hard, but being spoonfed the answers won't help you learn unfortunately. Experience is the true teacher here, as is making all the stupid mistakes and learning from them π programming is as much an art as a science, and we have the advantage that mistakes have virtually no cost, at least for small projects.
As you grow older and wiser, you'll see your old code and wonder who the idiot that wrote that was π
yeah
Also it'll help avoid mods getting angry and muting you
Yeah I have been muted like 5 times
π
I mean, there's probably a reason don't you think?
Yeah
Good, I'd be disappointed if I hear you got muted again for the same reason
Ok I will be more respectful
anybody can help me with http proxy server
Hey there, could you be more specific please?
I need help with http proxy as i have my sever suppose ubuntu with some ip address and apache2 running i want if someone hit this ip it shows the other website which i have configured and logged in so the user will directly go to website dashboard instead of login page and url will also not be hte same as actual website
for example my domain is mydomain.com and i configure it to show all the content of some site otherdomain.com which is login protected so i logged in with my credential and now when every body hit my domain.com it automatically logged in and url remain same as my domain.com and user can do the same task as they can do on actual site. on other hand the other site sees it as traffic coming from single ip as they disable 2 ip and account sharing but I badly need it for my office and my remote workers as i cant afford multiple subscriptions and my users have seldom uses this. If anybody help then please do help me as i am stuck with financial issues and its getting worse and worse that those sites are blocking my accounts by saying that i am sharing it https-proxy
so...reverse proxy?
I'm in agreement with Hydra, it sounds like you're looking for a reverse proxy
might need to set a few headers, https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For for one may help the server
Yes i think so i have no experience in it can you please help me
have you tried the docs?
are these custom-developped servers or off-the-shelf software?
If sites are blocking you for breaking their terms of service, you absolutely need to stop here
Site is not blocking me but when i share credentials with my members they share with alot of people then problem happens
That means you shouldn't be sharing your credentials or account.
Yea but brother i have 100 people working in my setup and every have segregated duties if someone uses one feature of that tool than others uses second i cant afford that tool for all seprately as they dont even use 1% of quota suggest me anthing goodβΉοΈ
Maybe better budget for toolage would do
use a different tool or ask the company for a special license?
If u can't afford your tools, something is wrong
Stop trying to bypass licensing restrictions. It's effectively software piracy.
Ok thanks for your response
Hi guys
- I'm trying to use python to entirely extract each unique
<section id=""></section>from an HTML document
1a) I want extract each unique section ID from each unique section tag in HTML document, preferably added to a (tuple?)
1b) I want to be able to access that information, and choose a section ID from that (tuple?) to interact with and modify - Eventually I want to replace a variable amount of content between the
<section id="sectionID">and</section>tags.
2a) This could mean that I need to delete a variable amount of content from between the start and end tags
2b) This could also mean that I need to add a variable amount of content between the start and end tags, without overwriting any content.
I'm trying to figure things out by reading documentation, articles, and googling using different phrases, but I'm having second thoughts as to if I'm even using the right language.
So far I've figured out how to grab the HTML content and assign it to a variable.
print('please provide the absolute file address for the main webpage')
mainpage = input()
print('please provide the absolute file address for the new section content')
newcontent = input()
file1 = open(mainpage, 'r')
file2 = open(newcontent, 'r')
page = file1.read()
content = file2.read()
And I have created a variable to store what I'm searching the document for.
search = "<section id=\"" + * + "\">" + * + "</section>"
I can probably figure out a function to look through the webpage fairly easily and grab each section, but storing each section in a unique variable is going to be annoying, and what if I run out of variables? I can't write a unique variable for each section I find, that's going to be annoying af.
Maybe there's a way I can assign each section I come across, to a generated hexidecimal variable that increments 0000, 0001, and then only print the hex number and the related section ID so I can use that information later?
Sorry for the wall of text.
I couldn't follow your plan exactly,but I have a few remarks about it:
it seems like a bigger task to do with limited python skill. Maybe a few more exercises on programming/python might be a good idea
You might be interested in dict dictionary that can be used to store an unknown amount of data
Also research about list and using sys.args might be easier to get the filenames into the program
And last at the moment: your search string might work in the moment, but it is often a hassle to using simple searches/regex when analysing html. Take a look at the module beautifulsoup. That parses HTML for you and you can search there quite easily
That's true, more exercises might be a good idea, yeah lol
oh yeahhh! I forgot about beautifulsoup, thanks for reminding me
Gave +1 Rep to @minor zealot
I googled sys.args and google keeps trying to autocorrect it to sys.argv?
Yes sorry. argv is correct
No worries! Thanks again!
Or click
hello
i want to embed a meterpreter stager to one of my java projects. can you please suggest me something where i can learn how to do that?
And why would you wish to do that? 
just curiosity. also i gave a programmer friend and the permission to hack him. he is going to clone my repo and execute it.
Uh huh, you're aware that isn't legally binding, yes?
Yes
legal or illegal is not really a problem because he is actually my best friend and we are just having fun. also its gonna be a private repo so nobody could access it only two of us.
Itβs a problem here, though
!rule 9
Rule 9: No discussion of illegal/unethical topics or actions. If the target device doesn't belong to you and you don't have specific permission to perform an attack from the owner of the target, then you don't do it and we don't talk about it. This also applies to piracy / copyright violations -- illegally obtained materials (including classified or potentially classified materials) should not be posted here.
If in doubt, please ask a moderator before posting your message -- preferably without breaking rule 1. Whether an action is unethical or not is at the sole discretion of the moderation team. Be warned -- a community ban over ethical concerns may also be extended to a ban from the TryHackMe website; we do not teach blackhats.
i see. well i have specific permission to do it.
he is also a hacker student and we had an agreement that he can hack me and i can hack him anytime and anyhow.
Sounds like a recipe for disaster
Whether an action is unethical or not is at the sole discretion of the moderation team Is a part that stands out to me, I see where you're coming from having this arrangement with your friend but it doesn't fly with the rules as Jabba already pointed out. What Muiri was pointing out was that unless you have a contract with your friend, this arrangement is not legally binding so you're at risk of breaking laws of your country potentially.
Not looking to backseat mod here, just trying to help you understand
And even still, contracts do not generally give you permission to break the law. If I had a friend who signed a contract that said I could own a weapon that's classed as illegal in the country I'm in, I could still be prosecuted for that
i tought its a common thing to inject a payload to something else to trick the target. i did not know its illegal to do. also i see your point but the actual goal here is learning and laughing
Don't do it outside of a controlled lab environment.
alright! I will not
thats been said. can you please help me out with the original question also? how can I run this byte array from code?
Didnt jabba just tell you not to
-mute 377164261258035202 I hate being ignored :) mod note: proceeding to ask for help when told it was unethical
π Muted hanzs-solo#7124 for 1 day
This
Hi guys. I'm trying to make the 2 highlighted columns to not have the same value, these 2 are the ids from another table. Do you guys have any idea?
Are you selecting data from multiple tables? If so, the issue is likely your join
I'd help if you post what you've tried so far as well, example queries etc.
No, i want it to reject the value entered to one of those columns if one of which happens to be the same as the other one
SELECT column1, column2, column3
CASE
WHEN column1 = column2 THEN 'whatever you want'
END
FROM table
You could use a case statement for example, this allows you to look for a specific condition and then get SQL to display something else.
I'm of the opinion that if you're seeing the same values in different columns then you've got a problem that you're trying to suppress rather than fix. It also smells a little homeworky to me but hope this helps
Otherwise you'll need to dive into how this dataset is configured to see what got messed up
I am trying to authenticate to a werkzeug application's debug console. Is this anappropriate way to do it? It seems to work fine although i always get a resetting dropped connection
def authenticate(session: requests.Session, url: str, secret: str) -> None
parameters = {
"__debugger__":"yes",
"frm": 0,
"cmd": "pinauth",
"pin": None,
"s": secret
}
while True:
pin = input()
parameters["pin"] = pin
resp = session.get(url, params=parameters).json()
if not response["auth"]:
continue
break
I hope that's a POST
Sounds weird but as i can see werkzeug by design uses GET for the authentication. Also replacing it with POST doesnt really change anything
Posting secrets in a get is bad practice
I tried to follow what werkzeug did on submit of the form
In my understanding fetch() performs a GET right? @brazen eagle
You are correct. And your Python at first glance looks to replicate that request. Your variables at the end are wrong though
What variables are you talking about exactly?
Thanks for your help. But that's not what I'm looking for. Luckily, my friend found a solution: it's the CONSTRAINT with CHECK
Link: https://stackoverflow.com/questions/52094985/sql-create-table-with-condition-that-2-columns-cannot-have-equal-values
Gave +1 Rep to @wraith latch
hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
hello
@tulip sail
You've used resp on one line and response on the next
Oh yeah hahah my bad. I copied it from my pc and didnt notice it at all
Although why am i getting the resetting dropped connection thingy.
^ only happens using that loop
If i just send a request it doesnt show up
Show the logs?
Oh, you did
One sec
Here
Honestly? No clue. Try proxying it through Burp and see what you get when you control each request / response
What would the expected results be? As i said a standalone request doesnt show this.
also is that loop the good way of validating user input
Yes, albeit quite a basic one.
There aren't really expected results given you know you're looking for something anomalous to a regular HTTP request flow
Thats true.
Put it through and just see if there's anything weird for a HTTP flow
Sure. If my crappy ahh pc can handle firefox and burp open at the same time
Baha
Just add a proxy to the GET request
, proxies={"http":"127.0.0.1:8080"} should do it iirc
although 8080 isnt open so i get a conn refused error.
Is the Burp Proxy active..?
Weird using the proxy made the resetting dropped conn vanish
Yeah. Was just curious why
Well, no idea then I'm afraid. I wouldn't worry too much
Yeah. Well i just noticed that my GET translates to POST???
Well, intercept and see what's happening there
what video recommends to watch to learn assembly?
and is a good idea to learn? or is a waste of time
I have a problem in python program
describe the problem
yes describing
I made a port scanner with python3
and I want it's syntax to run like python3 port scanner.py
it runs and asks for hostname
but I want hostname to be between 0.0.0.0 - 25.255.255.255
bcse If I put any IP it shows ports it scans
and if I put random number like 1
it shows scanning and does not move further
I want it to give error on wrong IP
if I could show on vc ?
no, im not gonna vc π but if you need help with some programming issue its better to post your problem, maybe some code. Folks will be more inclined to help you that way
for wrong Ip it says hostname could not be resolved
but for single digit it sucks
Google "python validate IP address"
That is a nightmare regex, though less bad than email
no
It worked now
@quartz kraken helped me
Problem was not of wrong IP it was not working previously without regex and all
problem was of normal numerical strings which didn't stop and were running in a loop of scanning.
So I took a logic of validating an IP address and my scan loop I transferred it in a if else condition as : if my IP is valid scan , else say enter valid IP
You don't need regex π
You can do some basic parsing I suppose
Ask the system if it's valid
Has the same problem they were facing, because those are valid expressions of IPs
Yeah that's probably not an intuitive behaviour though
How does nmap do it?
Probably magic :p
Hi all! quick question, doing the python for pentesting and can't for the life of me understand this line..
for sub in subdoms:
sub_domains = f"http://{sub}.{sys.argv[1]}" What is the "f" used for???
May be a viciously stupid question but im super curious why the "f" is needed
Thanks!
it is used for formatted strings (https://docs.python.org/3/reference/lexical_analysis.html#f-strings). basically {X} ist replaced with the value of expression X.
Greatly appreciated! Ill read through the Doc now.. thanks!
Gave +1 Rep to @minor zealot
Hello
what the ****
??
name = "John"
age = "20"
print(f"Hello your name is {name} and your age is {age}")
Output:
Hello your name is john and your age is 20
Does anyone know of a previewer for Outlook 2016/365 emails?
Hi
things are going well today
that seems low π
while cute, probably not age-appropriate. Keep it pg please
that's more like it
that's...a lot of network calls
sounds like you're having early weekend
or no weekend
eek, good luck!
Should be alright, just need to make a cucumber salad now π
should i finish python programmming, or start c#
depends on what you need
Learn Golang instead of C# π
Different tools for different jobs.
If you want to build windows desktop apps, golang probably isn't the right tool.
Most windows desktop apps these days seem to be Electron, so maybe just go for Javascript.
You understand the point I'm making though, right?
yeah, i'm just.. awkward π
I like Go.
Go is not the right tool for every job. C# is the right tool for many jobs.
I write lots of go.
https://github.com/Mknukn/bof-prepper @rough linden
thanks
cool repo
thanks
Who here is specifically interested in programming, as well as talking about what it is?

In general, who wants to chat, write to me in DM, I would be glad.
I'd like someone to tell me how to get a project to properly use the custom gradle plugin I wrote, and also for that plugin to properly generate it's sourceset
But I'll allow that I'm on the wrong forum
Maybe, but I, for example, am just learning about programming.
well I got it working anyways π
Which lang u should learn first ???
Golang?
What are you aiming to achieve?
As always, pythons a great language to learn for beginners
What's Golang n what it is used for ?
?
google it
Go is a language created by google useful for server things among others, not super familiar with it myself
Please be respectful
ok, sorry
The advantage of golang over python is that golang is faster
hmm
I mean, you can write slow code in either. Golang is about more than speed
π
hey
Hello
A suggestion is to pick literally any language you find interesting, start making a small project, like a Calculator, then maybe take a udemy course or YouTube tutorial.
What language you learn first it not important, coding is kind of universal no matter language, especially the beginner stuff.
But if you have a special goal in mind we might be able to help you with a language that suits the project better if you let us know.
I hear golang has a half-decent threading lib, but James can probably say more
It's not even a library, it's just plain built in. Built around a threadsafe queue, it has really nice concurrency and multiprocessing
That sounds nice
im trying to get the clients ip when they go to my flask app but it keeps telling me its own server ip
yoit, so sorry
You're accessing it from 127.0.0.1
It's running on your machine so the traffic is coming from... your machine when you access it from your machine
yeah
Hi, i have a question for bash script
I think you have to ask your question if you want a answer 
In case of break statement inside a while loop, the done is read ?
so if I used tryhackme openvpn file it would show the tryhackme ip correct?
why not just try it? But the answer is probably 'no'. If you access the page via 127.0.0.1, it is not routet via the THM VPN directly back to your server and you will always get this ip. But with an active VPN, you should be able to access it with your own THM VPN IP as well (10.x.x.x) in which case it will show this IP. The way to get a different IP there is to make another server access your page. E.g. start a THM machine where you have RCE and curl <your thm IP>. you should get the ip of the machine.
No
No, It would be relative to where you are hosting the web application
Think about where the traffic will be coming from, what IPs will be on the source amd destination addresses?
The application is not public right now so it will always show localhost
cause my machine is running it
Sounds like you need a different setup so you cam test it effectively
yeah I do
i'm going to deploy it on a linode server
and then test it
You could try in a docker container
But if you want to make your life more difficult then go for it
just started learning c# and built a random number guessing game. the oop structure is a little weird to me but the language seems simple overall
anybody knows C language lmk!
In a server of 150881.
Surely there will be a great majority who do.
You'll get a quicker answer if you just state your question.
appreciate it!
hey guys. I have a question that I can't seem to find an answer for
My question is how do I replace a specific occurrence of a character, in a string, with the replace method?
So I have a variable of example with the value of "oppose". How would I replace the second "p" with an "o"?
I know if I use example.replace('p', 'o') that it'll just replace the first occurrence of 'p'
I've found answers that deal with replacing all occurrences of a character, but not a specific occurrence. thank you
i think this is too specific functionality to exists in common standard libraries. You'll have to implement this by yourself
(also, always include the language you are talking about.)
oh yea I forgot to specify. It's javascript.
I have an idea of how to implement it in other ways, but I was wondering if there was a way to do it simply with the replace method and a few arguments. thank you
Gave +1 Rep to @minor zealot
I mean, you could dynamically create a regex string that scans for x occurances of the character and then match-replace the x+1-st character. But i would not call this the best approach π
The problem formulation sounds very homework-y as well.
There are some unaccounted for edge cases, as stated.
guys how should i learn course cs 50
there is only video in the week one when i finished it what to do repeat it all the week and practice or what
Is it specifically the second match? In that case this maybe works?
s.replace(/(.*?p.*?)p(.*)/, '$1o$2')
I haven't tested it and just woke up, so it might be all wrong. But maybe you can manage to fix it... π
Edit: Just tested it, seems to work fine.
Hi guys, i need help with JS. I wanna to send all keystroke from login form to another site. Can someone could help me?
can you explain further what you are trying to do/what you want it to do
from what I understand is that, you want to send the keystrokes to a different website than what the user is typing it to?
can't you just send the login form to a different website? why send the keystrokes one by one?
What's the purpose of this?
or am I getting the wrong interpretation here?
Thats the task
just testing on js script if i can do it
But why, whatβs the purpose?
Thereβs going to be more than just testing if you can do it
And by the looks of it, itβs a malicious tool
We were given a script in which a window was made available for testing to display, for example, advertisements. The samesite is set to NONE. In this case, we are to check if we can perform such an action as sending keystrokes to another server. Yesterday we tested this with a session cookie which proved impossible. Just this. The code in the screen shot above is just a scrypt from the internet hence my question if it makes sense or try something else.
im not a bad guy, i just ask for help bcoz im newbie in this
I didnβt think you were a bad guy, just your actions
You say we, so I presume you are in a team
Ask your team, if not, as your team leader
Else, please donβt ask here, it is a malicious practice
oh awesome lol thank you so much. I'll use this a bit later
Gave +1 Rep to @chrome carbon
Just for future info, we do not generally help with homework
it isn't homework. in fact it was completely unrelated from any course work I was doing
Just looked like a homework or interview question
ok
Yeah, I realized a bit too late that it looked like some sort of homework. Was half asleep when I answered and thought it was a good challenge to wake me up π
What about ngrok
Im going to use that instead
There is NO ethical reason for someone to do that. Do not offer help.
Oh ok
Sorry
that's actually surprising
given that jabba brought the hammer down on the topic yesterday
That exercise has been around for a while too iirc
does a input submit button in html have a onclick attribute?
Not to be a dick but you can google that no?
I assume buttons are clickable (hint use the HTML button element for buttons)
By the little info you are giving ( :p ) I'm assuming that maybe you are running into confusion like this
I made a little fiddle to demonstrate
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
note how submit types ( input or buttons ) in a form with an action behave differently from a button with type="button". After the alerts show up and you click them away, you'll see that ONLY the button w type "button" does not display a 404 page ( because its just 'clicking', not submitting ). Because the submit types will attempt to submit a form and the button type="button" does not ( 404 ofc because there's nothing to submit to because this is a fiddle π )
if you are trying something with a form ( since its an input ), this may be a cause for something not working as you expect
okidoki
@pale pollen ```py
def cree_jeu():
jeu = []
couleurs = ("pique", "coeur", "carreau", "trèfle")
valeurs =("As", "2", "3", "4" ,"5", "6" ,"7", "8", "9", "10", "Valet", "Reine", "Roi")
for couleur in couleurs:
for valeur in valeurs:
jeu.append((couleurs + valeurs))
return jeu
cree_jeu()
oh
Here, I modified the code for you - firstly placing it in the function and then returning the actual jeu variable instead of the function
does that make sense? pls ask if your confused about anything)
i see thanks alot man i was stuck on this
i just started phyton thats why i was struggling haha, again thank you for this it helped me
Gave +1 Rep to @surreal bronze
Up to 10 last deleted messages (last hour or 12 hours for premium):
none...
sigh
ho can halp me learn "Π‘"? Maybe you'll recommend some courses or teach yourself?
Check the pinned messaged for a comprehensive list of training/learning resources π
It'll be hard to whitelist allowable servers...
In any case yag would have nuked it
This is CS50, Harvard University's Introduction to the intellectual enterprises of computer science and the art of programming. Enroll for free at https://cs...
Any tools on how to identify which fonts app is using..
Yes, plenty on Google:)
Is anyone familiar with command line arguments in nim? I am trying to use https://github.com/c-blake/cligen but im struggling with the syntax. Anyone have any tips for command line args or familiar with the library above? Also could be I am very new to the language so Im still learning the little things but any insight is appreciated π
Hi! I'm a newbie, and made a php webpage to try and test out sql injections, but I can't get past this error... I'm assuming it's a syntax error, but I don't understand why... shouldn't the code at the end be SELECT * FROM users WHERE username=''-- ? (the ' at the end being single quotes)
I had to change some code today but did it in the attackbox, later closed and restarted the attackbox, and gone are the changes, I forgot to export them to a distro or vm of my own.
Is there a way to retain the changes and on the Abox. I could have uploaded on Github or something.
Google can teach you
Try ' or 1=1 --
@flat oriole if you're talking about web applications, often they will be imported in the style sheet. If not, its a matter of exploring the browser dev tools
This is your query:
SELECT * FROM users WHERE username='$username' and password='$password'
If you enter '-- as the username and leave the password empty your final query will eventually look like this:
SELECT * FROM users WHERE username=''--' and password=''
I'll leave you to debug what is wrong with that code.
Hey, how do I check if a GET request is received using js?
I tried googling but no use
Your question is kind of nonsensical as stated. What do you mean by 'using js'?
hmm, I tried the same code but with # at the end instead of --, and it works. I assumed that the -- would've commented out the rest of the code.. (edit: Oh i see, I assume # is for mysql..)
okay, so if I send a request to a file called alive.js using a piece of code written in JS, how do I check if it has received the request/ping to the file/location to then execute a set of actions
Again question doesn't make sense. What kind of server is running this? Is there a reverse proxy in the way? How is file to URL mapping being done? What's the actual GET request being made? What was the response code?
a debian server is running this, so I have alive.js in the same folder as ping.js, And I'm making a GET request from ping.js to alive.js, and the response code was 200
You are missing the point of my questions, Vain
Debian server is completely meaningless in this context
Is it an IIS server? Apache? Nginx? Something else?
Node? React?
ohh, it's apache
Ok, that's progress.
Is this .js part of the frontend or backend?
backend
What's the WSGI plugin to serve backend JS content?
I'm using flask
You are serving JS backend code with flask
Are you 100% sure you are using a python-based web server with javascript backend code
not 100% but I honestly don't know how the hell it's working
Check your flask routing code
if you see something like
def jsalert('/ping.js'):
return 'Some value'
then someone is doing weird shit to fake you out
got it, gonna read through the code again
Here's your steps: Go play around with flask in an environment you control. Understand how it works first, then you can come back to this
Especially pay attention to how routing works for this framework
second this wtf
What the actual fuck lmao
Does this mean that I shouldn't use something like turbo flask π
oh hai Muiri
@tulip sail should I go for the new ejpt certifcation and then go for oscp and crto etc etc
Im currently studying for ccna atm
I mean, what are you wanting them for and where are you currently with your studies?
I want to become a red teamer/pentester
I currently have about 11 python projects which I made and posted to GitHub
Which is in my profile
I also have good knowledge in networking
I can draw the osi model
Iβm trying to get certs like ceh/oscp/ etc etc
If you're not in India then forget about CEH -- it's, uh, quite literally a meme. Useful as a hiring box to tick in India but useless for learning and not widely respected anywhere else.
A code portfolio is good, especially for red team.
eJPT is good as an on-ramp for other certs, kinda like a confidence boost. It's also got good foundational content, so worth doing if you feel shaky on other aspects of offensive security (you should have networking sorted by the sounds of it π). Definitely recommend OSCP after it, or just straight off if you feel up to it. That's a good foundational one that gives you a solid grounding and is also well respected in industry.
If you want to do red team then CRTO -> CRTL is a really good next step, yes.
I did OSCP -> CRTO -> OSEP personally, which landed me a red team job. CRTL is a recent release but I intend to do it as soon as I have my OSCE3 and probably CHECK.
Believe it or not, CCNA is also a really good one to have, especially for infrastructure pentesting jobs, so you're off to a great start with that one.
Thank you a lot for the info
Gave +1 Rep to @tulip sail
I guess I will not be going for CEH
and more to the certifications that you recommended
Np π
Yeah, CEH is very much one that you get if you have to and if someone else is paying. Don't waste your own money on it unless you need it to get a job in your area
I heard OSCP changed to active directory pentesting
instead of buffer overflow
Yes and no. The 2020 changes to the lab material added a chapter on active directory, yes. The exam now also includes an active directory network which is guaranteed, and yes, the buffer overflow may not appear in the exam now.
But it might still show up, so it's not an either/or
More like the exam now includes both
If someone needs some code practice, I did wrote a few projects.
https://github.com/v01dxx/Network-Scanner
https://github.com/v01dxx/PacketSniffer
https://github.com/v01dxx/MAC-Changer
https://github.com/v01dxx/MAC-Changer/blob/main/macchanger.py wrapper for ifconfig ...
hey can someone help me with bash scripting?? In an if else statement, i need to use two conditionals but i get an error if i use more than one condition
such i need to check if its a regular file if [[ -f $FILE ]] then , and if the file is has content [[ -s $FILE ]] then but i am having trouble doing both in one if else statement
bash has an AND and OR statement, yes?
hard to see what's wrong without seeing some code π
i ended up getting by doing this [[ -f $FILE_NAME && -s $FILE_NAME && ! -d $FILE_NAME ]] and just changing what i was checking for with each elif sorry for not being more elaborate
hey what i guessed is actually in this file you sent @magic falcon haha. I was sure i had to use double ampersands but i was formatting it incorrectly. I happen to guess correct just before you sent this but thank you anyways!!
Gave +1 Rep to @magic falcon
im feeling great, i learned this on my own and it feels nice, im happy i figured this out before i read your guys' response because this feels really nice. Thank you both for the help anyways
# Given an alphanumeric string, return the character whose ascii value is that of the integer represenation of all of the digits in the string concatenated in the order in which they appear.
# For example, given 'hell9oworld7', the returned character should be 'a' which has the ascii value of 97.
strng = 'hell9world7'
def q1(strng):
lst = list(strng)
placeholder = []
for n in lst:
if n == 0 or n == 1 or n == 2 or n == 3 or n == 4 or n == 5 or n == 6 or n == 7 or n == 8 or n == 9:
placeholder.append(n)
else:
pass
# return ord(placeholder)
print(placeholder)
q1(strng)```
Hello, I am struggling to get the right value returned. I tried on a bunch of different variations but my output was always blank.
When I try to print "placeholder", I get a return of '[]' and no numbers are being appended to the variable.
variable n is of type string and you try to check for type integer.
9 =/= "9"
are can phyton here
You want to learn python3?
@lilac hollyyes
Go to automate with python3
Search it up
You can learn there for free
https://automatetheboringstuff.com/ this one?
Hi, is this the right channel for mobile app security?
perhaps #infosec-general depending on the questions
Hey, I was just wondering what would you recommend the best route into red team regarding certs for NZ? Assuming not much prior experience, could you go straight into OSCP, or would it be a good idea to do like CompTia Security + first?
also is network + better or CCNA?
Depends on region and organization.
Look at your local network engineer listings and job reqs
Not a clue w/r to New Zealand -- I'm a Scot. You'll need to check your local jobs to see what they're asking for.
As a general rule, red team tends to become an option after you've got a bit of professional experience as a pentester (although there are exceptions). Some people go straight into pentesting, it's common to go through a SOC first (which, as a side note, is a really good idea anyway if your ultimate goal is red team ops).
W/r to OSCP vs Sec+, it's totally up to you. eJPT is the normal "training wheels" cert for OSCP -- Sec+ is useful in its own right but is quite different in terms of format.
It's quite possible to go straight for OSCP with a few months of cyber experience (that's the route I took, personally), but going for something like eJPT is equally valid. Just up to you and how confident you feel.
And yeah, as Juun said, Net+ vs CCNA is quite org specific.
CCNA has the advantage in terms of being more well-known and thus respected, but I hear Net+ covers similar topics, just not Cisco specific.
Personally I would probably still do CCNA (not least because I have the books for it), but again, worth checking what folk are looking for locally.
I see, thank you for explaining it so in depth!
got it, ty
Gave +1 Rep to @magic falcon
Np π
Best programming langauge(s) to prioritize for soc and digital forensics? Learning python right now, I have a strong interest in html (if that counts).
Anybody know any good bootcamps so I can get better with codeing
Nvm all fixed!
Ummm.. is that pirated books?
Super sorry, I'm so focused on this assignment, completely slipped my mind
I dont know :))
I only want to download all, for example not files from these site
If i have a situation when I suppose to download more files how can do more fast
haha no worries
I'd love to tell you but I cannot trust that my knowledge is going to be used ethically.
What was it in the end?
well i thought i had to use require wss but instead, I had to replace
var socketServer = new WebSocket.Server({port: WEBSOCKET_PORT, perMessageDeflate: false, key: keys, cert: certys});
w/
var httpsServer = https.createServer(credentials);
httpsServer.listen(WEBSOCKET_PORT);
var socketServer = new WebSocket.Server({server: httpsServer, perMessageDeflate: false});
Ha, easy mistake
ok, sorry, I will not ask anymore
index.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="tablet">
<div class="content">
<iframe src="/path/to/main.html" style="width:100%;border:none;height:100%" />
</div>
</div>
</body>
</html>
style.css
body {
background: #f1f1f1;
}
.tablet {
position: relative;
width: 768px;
height: 1024px;
margin: auto;
border: 16px black solid;
border-top-width: 60px;
border-bottom-width: 60px;
border-radius: 36px;
}
.tablet:before {
content: '';
display: block;
width: 60px;
height: 5px;
position: absolute;
top: -30px;
left: 50%;
transform: translate(-50%, -50%);
background: #333;
border-radius: 10px;
}
.tablet:after {
content: '';
display: block;
width: 35px;
height: 35px;
position: absolute;
left: 50%;
bottom: -65px;
transform: translate(-50%, -50%);
background: #333;
border-radius: 50%;
}
/* The screen (or content) of the device */
.tablet .content {
width: 768px;
height: 1024px;
background: white;
margin: -1px;
}
Not my code, just adapted
@surreal bronze
<style="border: 10px solid transparent; padding: 0px; border-image: url(assets/border.png) 100 round"> thats what I have currently, will checkout your code
woahh your code is actully nice!
cheers!!
I love it, tysm @true pumice
Hello
@lilac holly check out Jabbas message here: #programming message . If he said no, then dont offer to do it in here either
I think it would be a good idea to learn Networking first.
And also, computing in general.
hello , any help ?
HTML code
so im doing a website for a restaurant
and this is what annoys me
why is the <h1> + <h3> which is
Ninety Nine
The joy of food
why is it so down ?
i want it under the 99 logo
this is the code
<h1> Ninety <span> Nine </span></h1>
<h3>The Joy <span> of Food </span></h3> <br/>
<p> Ninety Nine was founded in 1952 when Charlie Doe opened a pub at 99 state Street in Bosten.<br/>Unlike others
Ninety Nine was one of the pioneers of the casual dining concept many years before it becomes common place. <br/>
In 1962, The restaurant left Boston and moved it's main location to Woburn whcih still stands today.
</p>
and the color is css
.left-column h1{
font-size: 35px;
}
span{
color: red;
}
I don't know what you're asking tbh
This right side bottom
How do I change that and make it on top under the logo ?
Basically like that
How can I change the paragraph <p> from the bottom of the page to up there
this is 100% controlled by CSS. Would recommend you go play around with figuring how CSS boxing and layouts work (flow, grid, et al)
.left-column h1{
font-size: 35px;
text-align: center;
}
span{
color: red;
}
asked my friend in class he said i should add
text-align: center;
i did but didn't work
ig im gonna have to wait till morning and ask my teacher abou it
You need to go experiment with CSS a lot. Here's some food for thought to mull over and meditate on: What's the default behavior for alignment with images and text?
so i should add align: top; ? or align: top-left ?
left i mean
I'll mess with it might find out
@rapid hound big tip: open your dev tools, hover over elements in the DOM and look at the box to the right in dev tools and the styles that are applied to each element. You can uncheck ( or add ) styles directly and find out what is causing this content to display as it does π
See also: the box model
Will check that out in morning, thanks
Gave +1 Rep to @clear lodge
the box model is evil. though Grid or Flex might be useful
it is good to understand how it works
as it can bite you in the ass if you don't and you waste 500 hours
id say grid/flex are separate things? Its layout, whereas the box model pertains to an element
fair, but I never liked floating things
thats good, because you shouldnt :p
it's too unpredictable
but yeah the issue above is a layout issue I think
and some pretty naive coding
I can see a few reasons from the screenshots π
navbar is oddly placed
probably should be using classes to style elements
I don't think a 2 column layout is appropriate here, but that's my opinion
Hence my questions about default behavior π
and even if they want a 2-col layout, they're probably doing it wrong
eh?
flex ftw?
yeah, I find it much easier in use
I use grid for the main structure in general, then flex everything else
but it's a bit clunky to use
stupid powerful though
but yeah for a single columnar layout, then flex is fine
All the web stuff I've done has had a sort of header area, working area with usually 2 columns, and a footer area for actions, so a simple grid handles that well without having to embed a flex in a flex
Right
course the whole thing is using Angular anyways, so it's still a charlie foxtrot
and don't ask about the shenanigans we've had to pull to integrate that into the vendor's software, because there be dragons
pretty sure even the vendor doesn't want to know
if I dont jump in on a project later on and get to set up my stuff from the start, I work with a system of columns in columns in columns. So if I need 3 columns in a row, I make 1 column full width, with 3 column children ( inline, 33% each ). Thats how I build my entire layout. Below an X breakpoint it all snaps to vertical stacking. So its fully responsive and it doesn't require using Grid or Flex ( I'll use flex inside the columns themselves though for other stuff )
and then you see abominations like this: https://hilla.dev/
css for columns would look like this:
@media only screen and ( min-width: 1440px ) {
.column {
width: 100%;
-webkit-box-sizing: border-box;
box-sizing: border-box;
float: left;
}
.column::after {
content: "";
clear: both;
display: block;
height: 0;
visibility: hidden;
}
.column.phi.a {
width: 38%;
}
.column.phi.b {
width: 62%;
}
.column.two,
.column.four.b {
width: 50%;
}
.column.three,
.column.three.a {
width: 33.33%;
}
.column.three.b {
width: 66.66%;
}
.column.four,
.column.four.a {
width: 25%;
}
.column.four.c {
width: 75%;
}
}
so you can make any kind of arrangement you want with that. Plus the template is really clear π
Yes, we do use float in this base even though I just said don't use float π only permitted in this specific method, whaha
I cant keep up anymore
yeah me neither
.<
I already gave up on React because I can't understand their model
I just go with the flow I guess, pick up w/e client is using. Curse a lot. But just do it, whaha
heh
one of these days I'll figure out how to write JS code in Kotlin
though to be fair, the Shaker room does that already
I have no experience w kotlin but one of my (ex) colleagues raved about it
he's a really good engineer
it's a nice language
so im tempted to take him seriously is what I mean* lol
i might give it a try some time π
well it's nice enough that Java is stealing features π
That's what java does! Remember the lambda integration disaster of 1.8?
still better than nothing
Anyone have personal/portfolio websites related to cybersecurity/programming? Looking for inspiration for my own project (learning JavaScript so might as well make my own site where I put some CTF write ups/my homelab/certs/projects etc
you can look at my repo
Thanks sir!
not bad ig
still needs alot of work
gonna add home pages , some JaveScript effects ,maybe background too
@remote echo i like it!!
does anyone have recommendations on what language to learn first? and a progression from there... i know they say once you learn one you can pick up most others relatively easily.. i started with python and i think that was a mistake
yeaaah very nice, responsive and everything β€οΈ
very clean code
10/10
Starting with Python is fine, just spend the time to learn the concepts that weren't as explicit in Python such as Object Oriented Programming, pointers, etc.
thank you!
Gave +1 Rep to @stoic badger
I forgot to send my follow up message π
What language you choose to learn next is really up to what things you plan on programming for
Web? Checkout JavaScript and/or TypeScript, PHP, SQL
Want to get into memory-level stuff (reverse engineering, binary exploitation, embedded systems)? Check out C/C++, Rust, or Golang
Mobile? Probably look into Java or Swift depending on the platform
And the list could go on for a while
Programming fundamentals stay pretty much the same from language to language, the way in which theyβre implemented and used will differ
i want to do pentesting... i tried python first and never grasped it because I wasn't fully invested (just trying to learn a language).. i always wanted to be a "hacker" so i've been passionate about this thm stuff.. I'm almost done with the complete beginner course and i feel like stuff is starting to click. I completed the blue room with no help, which never happened before - so i am a complete beginner
so which language is most benefial for pentesters?
Anyone here gracious enough to give me a little help with a tiny issue im having with my java program
Youβve gotta be invested if you want to get any good at pentesting π
Learn Python, then if your needs call for another language, learn a new one
Pythonβs biggest asset is just how easy it is to write something quickly that works very well
thank you! i'm hoping it will be fun once i actually figure out what i'm doing π€
Gave +1 Rep to @stoic badger
Hello, someone can recommend materials/website to learn golang?
Yea i was tired as hell sorry about how lazily i asked for help
went to bed woke up and fixed it quite easily haha
That happens
yo
π
I'm interested as to why your grandad wants you to do it in less than 10 lines, you could just do that with ; which allows you to multiple statements on one line but thats just not pythonic and not readable at all, why try to squish it in less lines? You want your code to be pythonic and readable
Yeah, try it! π
probably - again, why? ill have a go, but define "cheating" - ; is a resource given to you, if it works the....:P
uhh idk this is a task iv been stuck on for the past 30 minutes or so
you can use whatever id just like to be taught
like how you would go about it
im not good on the programming side of computers
π
I would write out what your first thoughts are, and then see what you can improve and remove until you get to less than 10 lines
weirdly specific
(i know im saying this a lot, but gonna be honest - giving a task of trying to make a program below X lines isn't a great way to learn imo)
cc @magic falcon have you ever seen something like this when teaching programing?
sounds like a teacher-given problem
when did u graduate high school
there self taught, grandad is teaching
in the UK so just a few months after i was 16
then went to college but that wasnt great so left and got a job
i am working on it, thats why im not typing btw
lol thanks
well there is a way to make it 10 lines or less
heck, you could do it in one line haha
no, not with ;
you can do it in one line or so with list comprehension
would love to see that one line without ; π
list comprehension ?
yep. its possible to do the sorting in one line
Okay I have the answer, but how do you think to do it @swift marsh ?
can I see?
you could just google bubble sort list comprehension
until I see one, I don't believe you could do it in one line without ;' π€·ββοΈ
oh iv not a clue iv goodled it and thats the best iv got lol im very very new to coding
im just able able to make a mini game with if statements and inputs lol
ooo I stand corrected, neat
@swift marsh ^ thats what I mean by not readable at all
yeah idk what im looking at
lmao
yeah rubbish way to learn
But anyways, here:
You know you want to go through each item in the list comparing it with the item next to it right?
yes
@surreal bronze Premature optimization is the death of understanding
i get how it works its just i wouldnt know how to write it out
So to now how many times you want to put in your for loop, you would use what function to check the length of the list?
If you want to optimize for something, you have to understand the problem space you are working in
no idea
True, but if your new to programming and you want to learn - starting of by trying to fit it under X lines without much knowldege isn't very good no?
Google it!
Ok!
And, a restriction on 'number of lines of code' is pretty dumb, to be honest. The point of your code ought to be to understand the problem space, write code that makes sense, not to hit some arbitrary target.
Just getting the length of a list
arr = [4,5,1,2,3]
what would I use to get the length of thist list?
len ?
π
okay, now we can do a for loop
for i in range(m)
The i will be our index
Okay now with a bubble sort, what guaranteed fact do you know after 1 pass?
that at least 1 number will be moved
Hold up a hot minute. Going through this way isn't a clear way to solve a general problem.
Have you spent the time to understand what the problem is, and how to approach it?
quick question is it possible to write a bubble sort program that takes an input of random numbers and outputs the in order but the code is in 10 lines or less ?
thats the original question btw juun
^^
can I see your current code for a bubble sort program?
mine ?
yeah
ok
number = int(input("Write numbers: "))
for i > j:
print("in order ", i)
this was all with the current knowledge i have and thats when i realised i have no idea what im doing
oh oh okay
I made the assumption that you alredy knew how to program a bubble sort
okay scrap getting it under 10 lines, I want you to first code one - no restrictions
Bubble sort is a simple, inefficient sorting algorithm used to sort lists. It is generally one of the first algorithms taught in computer science courses because it is a good algorithm to learn to build intuition about sorting. While sorting is a simple concept, it is a basic principle used in complex computer programs such as file search, data ...
thx
would i have to use def bubble_sort(array): in idle python ? i didnt see it anywhere else
How much expierience do you have with functions?
