1. Лучший говнокод

    В номинации:
    За время:
  2. Java / Говнокод #48

    −11.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    public static Date createDate(Integer iYear, Integer iMonth, Integer iDay) throws Exception
        {
            if ((!(iYear instanceof Integer))
                    || (!(iMonth instanceof Integer))
                    || (!(iDay instanceof Integer))
                    )
            {
                throw new Exception();
            }
    
            Date date = null;
            String year, month, day;
    
            year = iYear.toString();
            month = iMonth.toString();
            day = iDay.toString();
            try
            {
                date = new SimpleDateFormat("yyyy/MM/dd").parse(year + "/" + month + "/" + day);
    
            } catch (ParseException e)
            {
                log.warn("Date transformation failed for year, month, day:  " + iYear + ", " + iMonth + ", " + iDay);
            }
            return date;
        }

    Индусы Рулят!!!

    guest, 02 Декабря 2008

    Комментарии (25)
  3. JavaScript / Говнокод #29121

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    // java types for typescript
    export type int = number;
    export type float= number;
    export type double = number;
    export type long = number;
    export type short = number;
    export type byte = number;
    export type char = string;
    export type boolean = boolean;
    export type void = void;

    veiny, 12 Апреля 2025

    Комментарии (24)
  4. Куча / Говнокод #28092

    +1

    1. 1
    Петух иньо забыл продлить домен

    inho-pidar, 25 Марта 2022

    Комментарии (24)
  5. Python / Говнокод #28090

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    def getMyIPAddress():
        global __ip__
        if __ip__:
            return __ip__
        with suppress(Exception):
            __ip__ = get('https://api.my-ip.io/ip', timeout=.1).text
        with suppress(Exception):
            __ip__ = get('https://ipwhois.app/json/', timeout=.1).json()["ip"]
        with suppress(Exception):
            __ip__ = get('https://ipinfo.io/json', timeout=.1).json()["ip"]
        with suppress(Exception):
            __ip__ = ProxyTools.Patterns.IP.search(get('http://checkip.dyndns.org/', timeout=.1).text)
        with suppress(Exception):
            __ip__ = ProxyTools.Patterns.IP.search(get('https://spaceiran.com/myip/', timeout=.1).text)
        with suppress(Exception):
            __ip__ = get('https://ip.42.pl/raw', timeout=.1).text
        return getMyIPAddress()

    Что имел в виду автор? Кто понял?

    inho-pidar, 24 Марта 2022

    Комментарии (24)
  6. C++ / Говнокод #27946

    −3

    1. 1
    https://t.me/stdvector

    го в вектор

    CkpunmoBbIu_nemyx, 12 Января 2022

    Комментарии (24)
  7. bash / Говнокод #27876

    +2

    1. 1
    2. 2
    3. 3
    export $(grep PROJECT_NAME .env | xargs)
    export $(grep USERID .env | xargs)
    docker exec -it -u ${USERID} ${PROJECT_NAME}_application bash -l

    На минуточку в проекте написанный лично разрабом до меня docker-compose.

    TrueGameover, 15 Декабря 2021

    Комментарии (24)
  8. Куча / Говнокод #27868

    0

    1. 1
    https://250bpm.com/blog:36/

    > At that point every semi-decent programmer curses spaghetti code in general and the author of the function in particular and embarks on the task of breaking it into managable chunks, trying to decompose the problem into orthogonal issues, layer the design properly, move the common functionality into base classes, create convenient and sufficiently generic extension points et c.

    <…>

    It turns out that the 1500-line function was parsing a network protocol. It is a 30-year old, complex and convoluted Behemoth of a protocol, defined by many parties fighting over the specification, full of compromises and special cases, dragged through multiple standardisation bodies and then anyway slightly customised by each vendor.

    <...>

    Unfortunately, it turns out that the tweak intersects the boundary between two well-defined components in the implementation. The right thing to do would be to re-think the architecture of the parser and to re-factor the codebase accordingly. <

    Вот так вот. Не стоит спешить любую портянку из 100+ строк кода называть "спагетти-кодом". Код может быть функцией микроконтроллера в котором вызов функции достаточно дорогой по памяти/времени, сложным алгоритмом и пр. Спагетти - это про организацию кода. Монолитный (но хорошо мапящийся на домен) код понять проще, чем солянку из функций, классов и пр. которые решают непонятно какую задачу (это и есть спагетти-код). Алсо https://en.wikipedia.org/wiki/Wikipedia:Chesterton%27s_fence

    JaneBurt, 12 Декабря 2021

    Комментарии (24)
  9. Си / Говнокод #27859

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    #include <conio.h>
    
    void activateAlarm(int channelID) {
    
        int key = 0;
    
        while(temperatureChannel[channelID].currentTemperature > temperatureChannel[channelID].highLimit
            ||temperatureChannel[channelID].currentTemperature < temperatureChannel[channelID].lowLimit) {
    
            beep(350,100);
    
            if (_kbhit()) {
                key = _getch();
                if(key == 'P');
                    break;
            }    
        }
    }

    3_dar, 06 Декабря 2021

    Комментарии (24)
  10. JavaScript / Говнокод #27843

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    async init() {
                    const engine = this.engine = new BABYLON.WebGPUEngine(this.canvas);
                    await engine.initAsync();
                }
    
                async initCompute() {
                    const supportCS = this.engine.getCaps().supportComputeShaders;
                    if (!supportCS) {
                        return true;
                    }
    
                    const computeShaderSource = document.getElementById("calculate").value.replace('WORK_GROUP_SIZE', this.WORK_GROUP_SIZE);
                    this.computeShader = new BABYLON.ComputeShader("compute", this.engine, { computeSource: computeShaderSource }, {
                        bindingsMapping:
                        {
                            "params": { group: 0, binding: 0 },
                            "ssboIn": { group: 0, binding: 1 },
                            "ssboOut": { group: 0, binding: 2 },
                        }
                    });
    
                    const simParamsBuffer = new BABYLON.UniformBuffer(this.engine);
                    simParamsBuffer.updateFloat2("time", t, this.numInstances);
                    simParamsBuffer.update();
    
                    const ssboInBuffer = new BABYLON.StorageBuffer(this.engine, this.ssboData.byteLength);
                    ssboInBuffer.update(this.ssboData);
    
                    const ssboOutBuffer = new BABYLON.StorageBuffer(this.engine, this.ssboData.byteLength);
    
                    this.computeShader.setUniformBuffer("params", simParamsBuffer);
                    this.computeShader.setStorageBuffer("ssboIn", ssboInBuffer);
                    this.computeShader.setStorageBuffer("ssboOut", ssboOutBuffer);
                                    
                    const handler = () => {
                        ssboOutBuffer.read().then((res) => {
                            const resFloats = new Float32Array(res.buffer);
                            //console.log(resFloats);
                            this.ssboData.set(resFloats);
    
                            ssboInBuffer.update(this.ssboData);
                            this.computeShader.setStorageBuffer("ssboIn", ssboInBuffer);
                            this.computeShader.dispatchWhenReady(this.numGroups).then(handler);                
    
                            this.loadPositions();
                        });
                    };
    
                    this.computeShader.dispatchWhenReady(this.numGroups).then(handler);                
                }

    Наговнокодить кому нибудь Compute Shader для WebGPU? полный код тут https://pastebin.com/EigxhfqV . Тут короче симуляция гравитации расчетным методом... просто было делать нехрен и скушно... что бы запустить это говно надо Chrome Canary с включенным WebGPU поддержкой.

    ASD_77, 28 Ноября 2021

    Комментарии (24)
  11. JavaScript / Говнокод #27818

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    const express = require('express')
    const app = express()
    const port = 3000;
    const bodyparser = require("body-parser")
    const applications = 2341;
    const https = require('https');
    const util = require('util');
    var sha1 = require("sha1");
    const secret = '123афкуф';
    const connection = require("./mysql")
    var log4js = require("log4js");
    var logger = log4js.getLogger();
    function generatePassword(len){
      if(len > 10) len = 10;
        len = len * (-1);
    		return Math.random().toString(36).slice(len);
    	}
    	app.listen(port, () => {
    			logger.info(`VK Auth is started!`)
    	})
    
    let net =  require("net");
     app.get('/', (req, res) => {
      var code = req.query['code'];
      var state = req.query['state'];
      var computer = req.query['computer']; 
      var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress ||  req.socket.remoteAddress || req.connection.socket.remoteAddress;
      res.sendFile(__dirname + "/index.html");
      console.log(`https://oauth.vk.com/access_token?client_id=${applications}client_secret=${secret}&code=${code}&redirect_uri=http://31.25.243.145:3000/?computer=${computer}`)
       https.get(`https://oauth.vk.com/access_token?client_id=${applications}&client_secret=${secret}&code=${code}&redirect_uri=http://31.25.243.145:3000/?computer=${computer}`, (res) => 
    	{
    		res.on("data", (data) => {
    			data = data.toString('utf8');
    			let obj = JSON.parse(data)
    			if(obj.error == undefined)
    			{   connection.query("SELECT idvk FROM whitelist WHERE idvk = ?", [obj.user_id] ,(err,result1) => {
    				if(err)
    				{
    					return logger.main.error(err)
    				}
    				if(result1.length === 0)
    				{
    					//socket.write("Auth|accessdenied")
    				}
    				else {
    					connection.query("SELECT AccessToken FROM users WHERE VK = ?",[obj.user_id],(err, result,row) => {
    				if (err) {
    					logger.main.error(err)
    				}
    				
    				if (result.length === 0) {
                    connection.query("INSERT INTO users(ipaddress,profileid,hwid,AccessToken,RegTime,VK,nickname,token,Auth) VALUES (?,?,?,?,NOW(),?,?,?,?)",[ip.substr(7),0,computer,obj.access_token,obj.user_id,"",sha1(generatePassword(10)),1], (err,res) => {
    					if (err) {
    						return console.log(err);
    					}
    					console.log( ip.substr(7) + " успешно зарегистрирован!")
    					})
    				}
    				else {
    					// Обновляем access токен если аккаунт есть, но токен недействителен
    					connection.query("UPDATE users SET AccessToken = ?, Auth = ? WHERE VK = ?", [obj.access_token,1,obj.user_id], (err,res) => {
    					if(err) {
    						return logger.main.error(err);
    					}
    					    
    					console.log(ip.substr(7) + " : токен обновлен")
    					})
    				}
    				
    				
    			})
    			}
    			})
    			}
    			else {
    				//socket.write("ERRORAUTH")
    			}
    		}) 
    		
    	})
    	})
    	app.use(bodyparser.urlencoded({extended: false}));
    	app.post('/', (req, res) => {
    	})

    Авторизация ВКонтакте для лаунчера, вместо пыхи, решил использовать ноду)

    lovecode, 13 Ноября 2021

    Комментарии (24)