Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Content Count

  • Joined

  • Last visited

Reputation Activity

  1. Like
    Sergio45 got a reaction from stateofpsychosis in PC sometimes takes longer than normal to shutdown   
    When I am on it it happens to me almost every time. Takes longer to shutdown . When my fiance is done playing on the PC she states that it doesn't happen to her. I am assuming that it is happening to her. Never the less I will give your recommendation a shot. Worst case scenario I do a reset and start from there.  Thanks man I keep you guys posted. 
  2. Funny
    Sergio45 reacted to Dalius in CPU error? 8700k, please help?   
    Lol, CPU power was not connected
  3. Funny
    Sergio45 reacted to fizzlesticks in Find the most frequent value in a sorted vector C++   
    Fair, but I will get angry at you for the text color and missing the edge cases.
  4. Like
    Sergio45 reacted to LyyK in Understanding PHP actions   
    In the order of precedence. The block of the first matching case is run and no other case of the switch should be evaluated afterward if there's a break in the block.
    As long as $_REQUEST['action'] has not been set — which is, in your project's case (no pun intended), always — it will have "firstPage" assigned to it. The reason the "firstPage" case didn't run before was simply because of the lowercase 'p'
    Correct. Have you learned about compile vs runtime yet? At runtime, the code in firstPage.php is effectively considered as code within whatever file it was included by. I think what the assignment is trying to show with the header and footer is that instead of having to have the code from the header/footer files in each file that require it, you can simply include it instead. This makes for editing of code that is used by multiple files quicker and much more efficient.
    If you ever have any questions about coding related topics, you're very welcome to message me and I'll link you my discord or Steam etc. I'm by no means the best web developer out there but I'm always happy to help with this sort of stuff
  5. Like
    Sergio45 reacted to vorticalbox in HELP Figuring out if it's a TIE game.   
    that's not a bad way to do it. +1 on arrays seems nee to this so I didn't suggest it.
  6. Like
    Sergio45 reacted to Cruorzy in PHP Form Validation HELP   
    JavaScrupt is like HTML, you can edit it and completely change what you want for yourself. It does not affect other but if you ONLY validate stuff with Javascript then somebody will try to edit that and ignore your rules.
    So what you do is make a PHP validation for this, since it server-side they cant change anything about it. And you use JavaScript to make it User friendly. for example make the box red if it does not follow your rules.
    Things like password hasing etc is the exact same thing, use a Server-Side language for that. Dont do that stuff with Javascript
  7. Informative
    Sergio45 reacted to Cruorzy in PHP Form Validation HELP   
    Welcome to hell, let me introduce you to regex. http://www.phpliveregex.com/
    Regex will make sure everything is typed in correctly to the reasons you have created. @vorticalbox is right, validations should be done server side not client side.
    Try to get a bit familiar with this, took me a while when i started but you obviously need it.
  8. Informative
    Sergio45 reacted to dannytech357 in Need Help Understanding associative Array   
    The thing to understand is that an associative array is just a normal array. Or, more accurately, the reverse, every array is associative. Think about how you access something in a normal array:
    var array = [ "blitzen", "comet" ]; // Creates an array // These statements do the same, they add to the array array[] = "cupid"; array.push("dasher"); console.log(array[0]); // Prints out "blitzen" The thing that you have to understand, is that when you create that array, you are really doing this:
    var array = [ "blitzen", "comet" ]; // Creates an array // Does the same array[] = "cupid"; array.push("dasher"); console.log(array); // Prints out the following: // [ // 0: "blitzen", // You're printing this out below // 1: "comet", // 2: "cupid", // 3: "dasher" //] console.log(array[0]); // Prints out "blitzen" The "associative array" you are talking about is also known as a hash map, and is known in JavaScript as a key-value object. The above could be represented like this with different keys:
    var object = { "foo": "blitzen", "bar": "comet" }; // Creates an array // Does the same object["baz"] = "cupid"; console.log(object); // Prints out the following: // { // foo: "blitzen", // You're printing this out below // bar: "comet", // baz: "cupid" // } console.log(object["foo"]); // Prints out "blitzen" In you code, I'm not quite sure what you're trying to do. Are you trying to just have an array of reindeer, like this:
    [ "blitzen", "comet", "cupid", "dasher" ] Or is it something else?
  9. Informative
    Sergio45 reacted to vorticalbox in Need Help Understanding associative Array   
    reindeer = { "name":['blitzen', 'comet'] }; console.log(reindeer["name"][0]) console.log(reindeer["name"][1]) output
  10. Like
    Sergio45 reacted to Mr_KoKa in Help. Date validation with JavaScript   
    function validateDate(date){ if(date.match(/^\d{4}-\d{2}-\d{2}$/)){ var dateTime; if(!isNaN((dateTime = Date.parse(date + ' 00:00:00')))){ var now = new Date(); now.setHours(0); now.setMinutes(0); now.setSeconds(0); now.setMilliseconds(0); now = now.getTime(); var minDiff = 1000 * 60 * 60 * 24 * 2; var diff = dateTime - now; if(diff >= minDiff){ return true; } else { alert('Entered date has to be 2 days ahead current date.'); } } else { alert('Wrong value.'); } } else { alert('Wrong format.'); } return false; } What I did is parse date from the input to check if it is valid, because 2016-99-99 will match patter but won't be valid date, parse returns NaN in such case.
    Notice that I added time string, I noticed that without it my date end up ahead of value of timezone, so my timezine is GMT +2 and when i entered 2016-10-30 I ended up with timestamp for datetime of 2016-10-30 02:00:00
    So when date is valid, parse returns timestamp with milliseconds, then I create new Date object that defaults to current datetime, I reset hours, minutes, seconds and milliseconds to compare just dates, then I convert Date object to timestamp by calling getTime method and finally I calculate difference between entered and current date and compare it with the minimal difference.
  11. Funny
    Sergio45 reacted to vorticalbox in Ignore   
    Request denied. 
  12. Informative
    Sergio45 reacted to PlutoNZL in Help! JavaScript giving me an extra image when not needed.   
    What I said above is true, but that condition won't even be executed when user == "bat" because you are using and else-if.
    The reason you are getting 1 "unknown" is because "done" is considered an "unknown". Here's your code with comments:
    var user; // Right now user has no value. if (user !== "done") { // User does not equal done n -= 1; user = prompt("bat,witch, or ghost").toLowerCase(); // Suppose "done" is entered. user is now equal to "done" if (user === "bat") { bat += 1; } else if (user === "ghost") { ghost += 1; } else if (user === "witch") { witch += 1; } else if (user !== "bat" || user !== "ghost" || user !== "witch") { // This condition evalutes to true because "done" is unknown. unknown += 1; } }  
  13. Informative
    Sergio45 reacted to Mr_KoKa in Help! JavaScript giving me an extra image when not needed.   
    You don't need that for loop, it just goes once, from n = 0 to n = 1 because of condition n < 1, so you can omit it and it won't change anything. No problem.
  14. Like
    Sergio45 reacted to Mr_KoKa in Help! JavaScript giving me an extra image when not needed.   
    else { unknown+=1; } to
    else if(user !== "done") { unknown+=1; } because withou t checking for done it will be still incrementing unknown when user is done.
    if(user=="done") { //n-=1; displayThemSpooks(witch,bat,ghost,unknown); } just to
    displayThemSpooks(witch,bat,ghost,unknown); because out of that loop user is always equal done so tehre is no need to change check.
  15. Like
    Sergio45 reacted to Mr_KoKa in Help! JavaScript Looping through Numbers   
    for(i=0; i<num; i++) { number[i] = num; //Think about this line } You prompt user for input once, you set num variable once, so when you iterate from 0 to num - 1 and set every index of number array to num there is no surprise that all indexes are equal to num. It is i variable what changes trough iterations, it goes from 0 to num - 1 so to set it form 1 to num you would need to add 1.
  16. Agree
    Sergio45 reacted to vorticalbox in HELP! How to make a unordered List from user Input.   
    change the first for loop for i<1; you can change the 3 to the number of inputs you require.
  17. Like
    Sergio45 reacted to vorticalbox in HELP! How to make a unordered List from user Input.   
    @Sergio45 You really need to start using arrays and loops, You have repeated yourself a number of times which goes against DRY.
    <html> <head> <script> var $ = function(id) {return document.getElementById(id); }//end $ window.onload = function () { //Provide answer for Question 1 here document.getElementById("title").innerHTML = " <h1> JavaScript Control Structures Test Document.</h1>"; ////////////////////// testQuestion2(); testQuestion3(); } function testQuestion2() { //empty array to store our numbers var number =[] //loop 3 times to get 3 numbers for(i=0; i<3; i++) { var num = parseInt(prompt("enter "+(i+1)+"number")) //store each input in the array number[i] = num; } //start of list var ul = document.createElement('ul'); //loop every item in array for (i=0;i<number.length; i++) { var li = document.createElement('li'); //adds current array item to the page li.innerHTML = number[i]; ul.appendChild(li) } //end of list document.body.appendChild(ul); }//end testQuestion2 function testQuestion3() { }//end testQuestion3 </script> </head> <body> <div id='title'> </div> </body> </html> as you can see by using an array to store the user input and a for loop you can reduce your code by a fair amount.  The only problem is that first loop which if a user inputs a letter then will cause the script to put NaN on the list.
    Though this is likely outside the scope of your assignment but it is worth thinking about if you plan to take your coding to more advanced levels.
  18. Like
    Sergio45 reacted to Mr_KoKa in HELP! How to make a unordered List from user Input.   
    You need to createElement (and then appendChild it to ul) for every li. Was not meant it to be a table?
  19. Funny
    Sergio45 reacted to organ_pleasin in Need Help Android Java Over writing a TextView with two methods.   
    Based on first impressions: have you tried to change onClicktwo to just onClick in the punchLine on click listener? If it's not that I'll get back to you later in the day when I'm infront of my computer.
  20. Informative
    Sergio45 reacted to Mr_KoKa in JAVA 12 days of Christmas With 2 switches and 2 for loops   
    Glad to help, you didn't have to reordering first switch tough, it wont change anything in this case, cause here are breaks so case 1 always will fire on i = 1 no matter order
    The second case has no break so it going through what is under first matched case to the bottom.
  21. Like
    Sergio45 reacted to Mr_KoKa in JAVA 12 days of Christmas With 2 switches and 2 for loops   
    Ok, so I made a mistake explaining how you can do that in the post before, so I corrected it and now it is ok. You don't use inner loop, just switch, that has cases in reverse order and without any breaks, look at example above, it does it. I cannot edit last post, so there is example without new lines:
    switch (i){ case 3: System.out.print('c'); case 2: System.out.print('b'); case 1: System.out.print('a'); } for i = 1 it will display:
    for i = 2 it will display:
    for i = 3 it will display:
  22. Like
    Sergio45 reacted to Mr_KoKa in JAVA 12 days of Christmas With 2 switches and 2 for loops   
    but you're now printing all prizes on first day, and then one prize less on second, shouldn't it be other way?
    My example has cases starting from the highest , so if so, you probably want to start case 12 and go down to case 1 so when it is first day, there will be one prize displayed, and when it will be 6th day 6 prizes will be displayed from 6 to 1 and so on.
  23. Like
    Sergio45 reacted to madknight3 in C# Program issue   
    You don't need to check both a == b and b == a so your if statements can be simplified a little.
    if (a == b || a == c || b == c) { // at least two match // ... if (a == b && a == c && b == c) { // all three match } } else { // No matches } Just in case it's not clear, replace a, b and c with fruits[0], fruits[1], and fruits[2] respectively.
  24. Like
    Sergio45 reacted to vorticalbox in C# Program issue   
    right now your code will give you winnings for 2 and 3 matches if you match all 3. I assume this isn't what you're after
    if (fruits[0]==fruits[1]||fruits[0]==fruits[2]||fruits[1]==fruits[2]) { if (fruits[0]==fruits[1]&&fruits[0 ==fruits[2]&&fruits[1]==fruits[2]) { amountWon = userInput * threeWinners; resultLabel.Text = amountWon.ToString("C"); totalWon = totalWon + amountWon; } else { //moving the 2 win code to here means you will only win 2 matches or 3 matches not both. amountWon = userInput * twoWinners; resultLabel.Text = amountWon.ToString("C"); totalWon = totalWon + amountWon; } }else { resultLabel.Text = "You didn't win anything."; }  
  25. Like
    Sergio45 reacted to madknight3 in C# Program issue   
    Damn it, that's what I meant to write. I guess I need to pay better attention. Oh well, good catch.