Jump to content

0x21

Member
  • Posts

    144
  • Joined

  • Last visited

Reputation Activity

  1. Like
    0x21 got a reaction from duckypath in JAVASCRIPT - Where is the array mutation happening?!?   
    // Add your functions below: const validateCred = arr => { ... doubleDigit = arr[i] *= 2; ... } const findInvalidCards = batchArr => { ... invalidCards.push(invalid1); ... } //console.log(findInvalidCards(batch)); console.log(findInvalidCards(batch)); You are using multiplication assignment, where I think you just want multiplication.
     
    Also, you are always pushing `invalid1` to your `invalidCards` array, as opposed to the specific card you are validating for that iteration.
  2. Agree
    0x21 got a reaction from vorticalbox in Discord bot, 1 hour timer reminder thingy   
    I've never used the library, but do you not want:
    // this: var testChannel = client.channels.cache.get('channel id') // instead of this? var testChannel = client.channels.cache.get(channel => channel.id === ('*channel id here*'))
  3. Like
    0x21 got a reaction from bomberblyat in Discord bot, 1 hour timer reminder thingy   
    I've never used the library, but do you not want:
    // this: var testChannel = client.channels.cache.get('channel id') // instead of this? var testChannel = client.channels.cache.get(channel => channel.id === ('*channel id here*'))
  4. Agree
    0x21 reacted to Sauron in Installing bs4 for python   
    If you had researched it you'd have discovered that the name of the package is beautifulsoup4.
    pip install beautifulsoup4  
  5. Agree
    0x21 reacted to Sauron in Can't install python-3.7.7 on win 7   
    You could install an up to date operating system.
     
    Or run one in a virtual machine.
  6. Agree
    0x21 reacted to Ashley MLP Fangirl in Can't install python-3.7.7 on win 7   
    you are choosing to use an outdated unsupported OS. that's your choice, but don't get angry at us for suggesting you use an up to date supported OS.
  7. Informative
    0x21 got a reaction from mrchow19910319 in what does export default do in VueJS ?   
    export: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
     
    data: https://vuejs.org/v2/api/#data
  8. Informative
    0x21 got a reaction from WillLTT in [HTML & CSS] steal a div from another website.   
    Here you go:
    (function() { var xhr = new XMLHttpRequest(); if (!xhr) { console.error('Cannot create XMLHTTP instance'); return false; } xhr.onreadystatechange = extractNews; xhr.open('GET', 'https://www.startsiden.no'); xhr.responseType = 'document'; xhr.send(); function extractNews() { if (xhr.readyState === XMLHttpRequest.DONE) { if (xhr.status === 200) { // Insert this into DOM // xhr.responseXML.all.namedItem('main_news'); } else { console.error('There was a problem with the request.'); } } } })(); This will get you div#main_news, now you just have to insert it into your document.
  9. Informative
    0x21 got a reaction from vorticalbox in NodeJS Issue   
    https://discordjs.guide/popular-topics/reactions.html#listening-for-reactions-on-old-messages
  10. Like
    0x21 got a reaction from OliverBryant in Transport API Operator Codes   
    https://www.travelinedata.org.uk/traveline-open-data/transport-operations/browse/
  11. Informative
    0x21 got a reaction from Maltego in Semantic UI   
    https://semantic-ui.com/introduction/getting-started.html#install-semantic-ui
    npm install semantic-ui --save cd semantic/ gulp build Though from your screenshot, it appears as if it is building into "out" as opposed to "dist".
  12. Agree
    0x21 got a reaction from ILoveZed in Music downloader?   
    Similar to above:
    youtube-dl --add-metadata -i -x -f bestaudio/best "ytsearch1:ARTIST AND SONG NAME"  
  13. Informative
    0x21 got a reaction from Aspect11 in Maximum numbers python file reading help   
    No, if you want to have multiple scores from the same user then this will work:
    def printScores(n): with open('scores.txt', mode='r') as file: reader = csv.reader(file) # Create a list of tuples from the text file scores = [(row[0], int(row[1])) for row in reader] # Sort into a list of the top n scores. scores = sorted(scores, key=lambda score: score[1], reverse=True)[:n] # Print if len(scores) > 0: print("The top {} scores are:\n".format(n)) pos = 1 for name, score in scores: print("\t{}. {} with {}".format(pos, name, score)) pos += 1 else: print("There are no scores")  
  14. Informative
    0x21 got a reaction from Ashley MLP Fangirl in RaspPi: need some help with autostart [Linux]   
    Default for raspbian is `pi ALL=(ALL) NOPASSWD: ALL` in sudoers file. This is not a bug.
     
    As user pi:
    echo 'sudo ~/openauto/bin/autoapp' >> /home/pi/.bashrc
  15. Informative
    0x21 got a reaction from cluelessgenius in RaspPi: need some help with autostart [Linux]   
    Default for raspbian is `pi ALL=(ALL) NOPASSWD: ALL` in sudoers file. This is not a bug.
     
    As user pi:
    echo 'sudo ~/openauto/bin/autoapp' >> /home/pi/.bashrc
  16. Informative
    0x21 got a reaction from mrchow19910319 in Website hosting platform for front end project.   
    As your project has no backend, GitHub Pages will be most cost effective.
  17. Like
    0x21 reacted to .Ocean in Websites which knows your new password is similar to your old one   
    AHH so it was a misunderstanding after all. They are not checking the similarity of the hashes, they are attempting to generate the old password by applying slight modifications to the current password supplied and then seeing if that produces the SAME digest that they have on record.
  18. Like
    0x21 got a reaction from reniat in Websites which knows your new password is similar to your old one   
    Took some time to find again: https://security.stackexchange.com/questions/53481/does-facebook-store-plain-text-passwords#comment84577_53483
     
    Yes. Taken from the linked answer:
    user sets first password to "first" and fb stores hash("first"). later on, users resets password and is asked to provide new password "First2" Facebook can generate bunch of passwords (similar to the new one): ["First2", "fIrst2", "firSt2", ... "first2", ... "first", ... ] and and then compare hash of each with the stored hash.
  19. Informative
    0x21 reacted to vorticalbox in Websites which knows your new password is similar to your old one   
    That is not how hashing works, without using salt each password will be different but the same password will always give the same hash but if you use salt every password will be different regardless if they are the same.
     
    const bcrypt = require('bcrypt') const hashPassword = (password, saltRounds) =>{ return new Promise((resolve, reject) =>{ bcrypt.hash(password, saltRounds, function(err, hash) { err ? reject(err) : resolve((hash)) }); }) } const plainPassword = 'hello' const saltRounds = 10; (async() =>{ console.log(await hashPassword(plainPassword, saltRounds)) console.log(await hashPassword(plainPassword, saltRounds)) })() event though we are hashing the same passed in this case 'hello' the hashes will always be different
     
    example
    $2b$10$Vn7upkjk5Kq5kYOjS1ThZ.3MTd.bakQ0MJEzFM1RHXlhm.o05jN/S $2b$10$.h1W7BEvZqCTjA.zqXTALepbQ3tA.EPbHlyJh1rv8JdZNWDS3NmPu  
    Live example
     
    https://repl.it/@vorticalbox/FrugalVillainousInterfacestandard
  20. Informative
    0x21 got a reaction from Rakanoth in Websites which knows your new password is similar to your old one   
    Yes, it is true that hashes have collisions, but your claim that they are common isn't. The bitcoin network generates hundreds of quadrillions of these hashes a second, and to date there are no known examples of hash collisions using SHA-256,
     
    The system I describe is what Facebook did/does to determine whether a password is too similar.
  21. Informative
    0x21 got a reaction from Rakanoth in Websites which knows your new password is similar to your old one   
    This is simply untrue.
     
    You create your account and set your password, the system will then store the hash of that password.
    When changing your password, the system can generate similar passwords, and then compare the hash of each with the stored hash. This is how Facebook used to do it.
  22. Agree
    0x21 got a reaction from wONKEyeYEs in Websites which knows your new password is similar to your old one   
    This is simply untrue.
     
    You create your account and set your password, the system will then store the hash of that password.
    When changing your password, the system can generate similar passwords, and then compare the hash of each with the stored hash. This is how Facebook used to do it.
  23. Agree
    0x21 reacted to reniat in Function   
    ....why does this need to be 1 line? That's usually pretty bad codesmanship. Super complex one line statements might seem clever, but you get no performance benefit from it and it usually only makes things harder to maintain.
     
    Good code is finding ways to be elegant and performant, all while also being easy to read, test, and maintain. Trying to find cheeky ways to crunch 4-5 lines into 1 PROBABLY isn't going to be "good" (though as always, there are exceptions)

    Note, I don't write python professionally, so maybe there is some language standard i'm ignoring, but in a general software engineering sense this:
    d = defaultdict(set) pairs = [("Thomas", "pen"), ("Mike", "pencilcase"), ("Thomas", "rubber"), ("Tom", "scissors")] for name, item in pairs: d[name].add(item) print(dict(d)) is far better than:
    print(dict((lambda d: (d, [d[name].add(item) for name, item in [("Thomas", "pen"), ("Mike", "pencilcase"), ("Thomas", "rubber"), ("Tom", "scissors")]])[0])(__import__('collections').defaultdict(set)))) And unless there is some python specific reason, I wouldn't let the 2nd example through code review. Sure it's not that hard to figure out what's going on, but why make the people maintaining this code have to go through even simple puzzles to figure out what your code is doing? What's the advantage of getting this all onto 1 line? The easier you make it for others to understand your code, the less chance a defect gets introduced. This is the same issue I have with list comprehensions that get too crazy, or when `auto` is abused in C++ to use a non-python example.
  24. Agree
    0x21 reacted to fizzlesticks in Function   
    You use things that don't need indenting. For example here's elpiops answer in 1 line:
    print(dict((lambda d: (d, [d[name].add(item) for name, item in [("Thomas", "pen"), ("Mike", "pencilcase"), ("Thomas", "rubber"), ("Tom", "scissors")]])[0])(__import__('collections').defaultdict(set))))  
  25. Like
    0x21 got a reaction from mrchow19910319 in cannot execute shell script on macOS?   
    I assume:
    mas signin account1@example.com mas install foo mas signout mas signin account2@example.com mas install bar
×