+[[>+]>[+>]+] 
By tbz, 2017-12-13 11:13:00
boolean darkModeSelected = (!darkModeSelected ? true : false);
By Anonymous, 2017-12-13 09:40:59
outerloop:
try {
    if (selectedFile == null) {
        break outerloop;
    } else {
        if (selectedFile != null) {
            readTo = new PrintStream(selectedFile);
            readTo.println(userCodeInput.getText());
            readTo = readTheOptionsIntegers(readTo);
    }
} catch(IOException e) {
    System.out.println(e);
}
By Anonymous, 2017-12-13 09:39:37
// Is this valid?
function validateStockInItems() {
    if (stockInItemsToUpdate.length === 0)
        return true;
    return true;
}

Found in a legacy code base for a stock management system. I will be rewriting said system soon.

By Anonymous, 2017-12-13 09:15:42
int number = -1;
                //todo: refactor this horse shit.
                for (String res: results) {
                    if(number == -1){
                        if(res.toLowerCase().contains("ten") || res.contains("10") || res.contains("10") || res.contains("十") || res.contains("십")){
                            number = 10;
                        }
                        else if(res.toLowerCase().contains("nine") || res.contains("9") || res.contains("9") || res.contains("九") || res.contains("구")){
                            number = 9;
                        }
                        else if(res.toLowerCase().contains("eight") || res.contains("8") || res.contains("8") || res.contains("八") || res.contains("팔")){
                            number = 8;
                        }
                        else if(res.toLowerCase().contains("seven") || res.contains("7") || res.contains("7") || res.contains("七") || res.contains("칠")){
                            number = 7;
                        }
                        else if(res.toLowerCase().contains("six") || res.contains("6") || res.contains("6") || res.contains("六") || res.contains("육")){
                            number = 6;
                        }
                        else if(res.toLowerCase().contains("five") || res.contains("5") || res.contains("5") || res.contains("五") || res.contains("오")){
                            number = 5;
                        }
                        else if(res.toLowerCase().contains("four") || res.contains("4") || res.contains("4") || res.contains("四") || res.contains("사")){
                            number = 4;
                        }
                        else if(res.toLowerCase().contains("three") || res.contains("3") || res.contains("3") || res.contains("三") || res.contains("삼")){
                            number = 3;
                        }
                        else if(res.toLowerCase().contains("two") || res.contains("2") || res.contains("2") || res.contains("二") || res.contains("이")){
                            number = 2;
                        }
                        else if(res.toLowerCase().contains("one") || res.contains("1") || res.contains("1") || res.contains("一") || res.contains("일")){
                            number = 1;
                        }
                    }
                }

refactor this horse shit.

By mister MVC, plus grumpy commenter, 2017-12-13 07:28:20
for(var j=0;j<10;j++){
    cell=document.createElement('td');
    switch(j)
    {
        case 0: 
            var date1 = events[i]['start'];
            var date2 = events[i]['end'];
            cell.appendChild(document.createTextNode(date1.getFullYear()+'/'+date1.getMonth()+'/'+date1.getDate()+' '+date1.getHours()+':'+date1.getMinutes()+' To '+date2.getFullYear()+'/'+date2.getMonth()+'/'+date2.getDate()+' '+date2.getHours()+':'+date2.getMinutes())); 
            break;
        case 1: cell.appendChild(document.createTextNode(events[i]['title'])); break;
        case 2: cell.appendChild(document.createTextNode(events[i]['description'])); break;
    }
    row.appendChild(cell);
}

The for loop that counts to 10, but the last seven elements are completely useless.

By Anonymous, 2017-12-13 07:16:36
var list = new List<string>() { // Assume some items in the list };

for (var i = 0; i < list.Count; i++)
{
    var item = list[i];
    list.Remove(item);
    
    i--;
}

Simple alternative to List.Clear()

By Taylor, 2017-12-13 07:07:56
socket.on('newMessage', (messageObj) => {
	if (roomNumber === messageObj.roomNumber) {

		console.log("message received:" + messageObj.message);
		$('#messages').append($('<li>').text(messageObj.userName + ' : ' + messageObj.message));

	}
});

socket.in wasn't behaving as advertised (broadcasting to all rooms). I decided to take matters into my own hands.

By Andrew, 2017-12-13 02:57:58

if let _ = detailInformation {
     loadDetailInformation()
}

when optionals are killing yourself

By gc, 2017-12-13 00:19:02
if(typeof(sortOrder) != "boolean"){        
    return items;
}
filtered.sort(function (a, b) {
    if(sortOrder == true){
        return (CustomOrder(a.status) > CustomOrder(b.status) ? 1 : -1);
    }
    else if(sortOrder == false){
        return (CustomOrder(a.status) < CustomOrder(b.status) ? 1 : -1);
    }
});

The status property is a string ("Started", "Running", "Failed", "Finished", etc.), and CustomOrder is a function with a switch that just returns a predefined integer for each string. I switched CustomOrder to just be a simple lookup table object, and the sort call was changed to filtered.sort((a, b) => CustomOrder[a.status] - CustomOrder[b.status]);

By Anonymous, 2017-12-13 00:06:25
    if (SelectionAndTimeData[1] < 2000 or \
        SelectionAndTimeData[2] < 1 or SelectionAndTimeData[2] > 12 or \
        SelectionAndTimeData[3] < 1 or SelectionAndTimeData[3] > 31 or \
        SelectionAndTimeData[4] < 0 or SelectionAndTimeData[4] > 24 or \
        SelectionAndTimeData[5] < 0 or SelectionAndTimeData[5] > 60 or \
        SelectionAndTimeData[2] < 0 or SelectionAndTimeData[2] >60):   
        
        print('***************************************************************************')
        print(' Entered date is not valid')
        print('****************************************************************************')
By loopyroberts, 2017-12-12 22:55:56
#139 HTML +78
<img src="../../../../../../../../../../../../../../../../../assets/logo.png" /> 
By Anonymous, 2017-12-12 20:59:00
for module in next_possible_modules: 
  import math; math.factorial(40000) # approx. a 1 second operation 
  end_time = start_time + timedelta(minutes=module.duration) 
By Anonymous, 2017-12-12 20:23:37
if (!String.prototype.replaceLast) {
        String.prototype.replaceLast = function(find, replace) {
            String.prototype.replaceLast = function (what, replacement) {
                var pcs = this.split(what);
                var lastPc = pcs.pop();
                return pcs.join(what) + replacement + lastPc;
            };
        };
    }

Prototypes are super buggy anyway, I should rewrite that as a pure function.

By Anonymous, 2017-12-12 18:21:40
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.


   O | O | O 
  -----------
   O | O | O 
  -----------
   O | O | O 
     

 */
package tictactoe;

import java.util.Scanner;

public class TicTacToe {

    /**
     * @param args the command line arguments
     * @throws java.lang.InterruptedException
     */
    public static void main(String[] args) throws InterruptedException {
        Scanner input = new Scanner(System.in);
        String a1 = "1";
        String a2 = "2";
        String a3 = "3";
        String a4 = "4";
        String a5 = "5";
        String a6 = "6";
        String a7 = "7";
        String a8 = "8";
        String a9 = "9";
        int inO;
        int inX = 0;
        boolean winner = false;
        PrintBoard(a1,a2,a3,a4,a5,a6,a7,a8,a9);
        System.out.printf("How to play - wait for your turn and when it comes write the number of the field that you want to draw in (from 1 to 9)\n");
        System.out.printf("Player O's turn: ");
        inO = input.nextInt();
        while (true) {
            switch (inO) {
                case 1:
                    if (a1 == "1") {
                        a1 = "O";
                    }
                    break;
                case 2:
                    if (a2 == "2") {
                    a2 = "O";
                    }
                    break;
                case 3:
                    if (a3 == "3") {
                    a3 = "O";
                    }
                    break;
                case 4:
                    if (a4 == "4") {
                    a4 = "O";
                    }
                    break;
                case 5:
                    if (a5 == "5") {
                    a5 = "O";
                    }
                    break;
                case 6:
                    if (a6 == "6") {
                    a6 = "O";
                    }
                    break;
                case 7:
                    if (a7 == "7") {
                    a7 = "O";
                    }
                    break;
                case 8:
                    if (a8 == "8") {
                    a8 = "O";                        
                    }
                    break;
                case 9:
                    if (a9 == "9") {
                    a9 = "O";
                    }
                    break;
                default:
                    System.out.printf("An error occured. Please accept it politely and restart the game.");
                    break;
            }
            System.out.printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
            if (null != Winners(a1,a2,a3,a4,a5,a6,a7,a8,a9))switch (Winners(a1,a2,a3,a4,a5,a6,a7,a8,a9)) {
                case "NONE":
                    if (a1 != "1" && a2 != "2" && a3 != "3" && a4 != "4" && a5 != "5" && a6 != "6" && a7 != "7" && a8 != "8" && a9 != "9") {
                        winner = true;
                        System.out.println("DRAW!");
                        Thread.sleep(3000);
                        break;
                    } else {
                    PrintBoard(a1,a2,a3,a4,a5,a6,a7,a8,a9);
                    System.out.printf("Player X's turn: ");
                    inX = input.nextInt();
                    break;
                    }
                case "X":
                    winner = true;
                    System.out.println("X HAS WON!!!");
                    Thread.sleep(3000);
                    break;
                case "O":
                    winner = true;
                    System.out.printf("O HAS WON!!!");
                    Thread.sleep(3000);
                    break;
                default:
                    break;
            }
            if (winner) {
                break;
            }
            switch (inX) {
                case 1:
                    if (a1 == "1") {
                    a1 = "X";
                    }
                    break;
                case 2:
                    if (a2 == "2") {
                    a2 = "X";
                    }
                    break;
                case 3:
                    if (a3 == "3") {
                    a3 = "X";
                    }
                    break;
                case 4:
                    if (a4 == "4") {
                    a4 = "X";
                    }
                    break;
                case 5:
                    if (a5 == "5") {
                    a5 = "X";
                    }
                    break;
                case 6:
                    if (a6 == "6") {
                    a6 = "X";
                    }
                    break;
                case 7:
                    if (a7 == "7") {
                    a7 = "X";
                    }
                    break;
                case 8:
                    if (a8 == "8") {
                    a8 = "X";
                    }
                    break;
                case 9:
                    if (a9 == "9") {
                    a9 = "X";
                    }
                    break;
                default:
                    System.out.printf("An error occured. Please accept it politely and restart the game.");
                    break;
            }
            System.out.printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
            if (null != Winners(a1,a2,a3,a4,a5,a6,a7,a8,a9))switch (Winners(a1,a2,a3,a4,a5,a6,a7,a8,a9)) {
                case "NONE":
                    if (a1 != "1" && a2 != "2" && a3 != "3" && a4 != "4" && a5 != "5" && a6 != "6" && a7 != "7" && a8 != "8" && a9 != "9") {
                        winner = true;
                        System.out.println("DRAW!");
                        Thread.sleep(3000);
                        break;
                    } else {
                    PrintBoard(a1,a2,a3,a4,a5,a6,a7,a8,a9);
                    System.out.printf("Player O's turn: ");
                    inO = input.nextInt();
                    break;
                    }
                case "X":
                    winner = true;
                    System.out.println("X HAS WON!!!");
                    Thread.sleep(3000);
                    break;
                case "O":
                    winner = true;
                    System.out.println("O HAS WON!!!");
                    Thread.sleep(3000);
                    break;
                default:
                    break;
            }
            if (winner) {
                break;
            }
        }    
    }
    
    public static void PrintBoard(String f1, String f2, String f3, String f4, String f5, String f6, String f7, String f8, String f9) {  
        System.out.printf("   %s | %s | %s \n",f1,f2,f3);
        System.out.printf("  ----------- \n");
        System.out.printf("   %s | %s | %s \n",f4,f5,f6);
        System.out.printf("  ----------- \n");
        System.out.printf("   %s | %s | %s \n",f7,f8,f9);
        System.out.printf(" \n");
    }
    
    public static String Winners(String f1, String f2, String f3, String f4, String f5, String f6, String f7, String f8, String f9) {
        if (f1 == f2 && f2 == f3 && f3 == "O") {
            return "O";
        } else if (f4 == f5 && f5 == f6 && f6 == "O") {
            return "O";
        } else if (f7 == f8 && f8 == f9 && f9 == "O") {
            return "O";
        } else if (f1 == f4 && f4 == f7 && f7 == "O") {
            return "O";
        } else if (f2 == f5 && f5 == f8 && f8 == "O") {
            return "O";
        } else if (f3 == f6 && f6 == f9 && f9 == "O") {
            return "O";
        } else if (f1 == f5 && f5 == f9 && f9 == "O") {
            return "O";
        } else if (f3 == f5 && f5 == f7 && f7 == "O") {
            return "O";
        } else if (f1 == f2 && f2 == f3 && f3 == "X") {
            return "X";
        } else if (f4 == f5 && f5 == f6 && f6 == "X") {
            return "X";
        } else if (f7 == f8 && f8 == f9 && f9 == "X") {
            return "X";
        } else if (f1 == f4 && f4 == f7 && f7 == "X") {
            return "X";
        } else if (f2 == f5 && f5 == f8 && f8 == "X") {
            return "X";
        } else if (f3 == f6 && f6 == f9 && f9 == "X") {
            return "X";
        } else if (f1 == f5 && f5 == f9 && f9 == "X") {
            return "X";
        } else if (f3 == f5 && f5 == f7 && f7 == "X") {
            return "X";
        } else {
            return "NONE";
        }
    }
}

There are so many problems with this...

By umnikos, 2017-12-12 17:38:50