1. 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)
  2. Си / Говнокод #27812

    +5

    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
    // http://cmustdie.com/ - баттхерт анскильных лалок, неосиливших сишку
    
    // Возьмём следующий фрагмент кода на языке Си:
    
    int x = 1;
    x = x << sizeof(int) * 8;
    
    // Попробуем предположить, какой результат у нас получится. Допустим, мы скомпилировали этот
    // код для процессоров архитектуры ARM. Инструкция битового сдвига в рамках этой аппаратной
    // платформы определена так, что итоговым значением переменной "x" должен быть "0". С другой
    // стороны, мы можем транслировать нашу программу в машинный код архитектуры x86. И уже там 
    // битовый сдвиг реализован таким образом, что значение "x" не изменится и останется равным
    // "1". Мы могли бы сделать вывод, что результат работы данного фрагмента кода зависит от
    // того, для какой аппаратной платформы мы его скомпилировали. Но на самом деле это не так.
    
    // В действительности данный фрагмент кода может быть обработан компилятором любым возможным 
    // и невозможным образом. Причина в следующем: согласно тексту стандарта языка Си битовый 
    // сдвиг на величину, большую или равную размеру выражения в битах, является неопределённым
    // поведением. Получается, нет никакой гарантии, что этот кусок кода вообще будет работать.

    Охуеть конечно

    j123123, 12 Ноября 2021

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    let checks: boolean[] = [];
    
          languages.value.map((language) => {
            checks.push(name.value.hasOwnProperty(language.locale) && !!name.value[language.locale]);
            checks.push(description.value.hasOwnProperty(language.locale) && !!description.value[language.locale]);
          });
    
          return !checks.includes(false);

    hulkmaster, 12 Ноября 2021

    Комментарии (25)
  4. C++ / Говнокод #27810

    +1

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    // https://github.com/gcc-mirror/gcc/blob/b0c83d59f44bf677c8d74acae228acf32719acb3/libstdc%2B%2B-v3/include/bits/regex_compiler.tcc#L446
      template<typename _TraitsT>
      template<bool __icase, bool __collate>
        bool
        _Compiler<_TraitsT>::
        _M_expression_term(pair<bool, _CharT>& __last_char,
    		       _BracketMatcher<_TraitsT, __icase, __collate>& __matcher)
        {
          if (_M_match_token(_ScannerT::_S_token_bracket_end))
    	return false;
    
          const auto __push_char = [&](_CharT __ch)
          {
    	if (__last_char.first)
    	  __matcher._M_add_char(__last_char.second);
    	else
    	  __last_char.first = true;
    	__last_char.second = __ch;
          };
          const auto __flush = [&]
          {
    	if (__last_char.first)
    	  {
    	    __matcher._M_add_char(__last_char.second);
    	    __last_char.first = false;
    	  }
          };
    
          if (_M_match_token(_ScannerT::_S_token_collsymbol))
    	{
    	  auto __symbol = __matcher._M_add_collate_element(_M_value);
    	  if (__symbol.size() == 1)
    	    __push_char(__symbol[0]);
    	  else
    	    __flush();
    	}
          else if (_M_match_token(_ScannerT::_S_token_equiv_class_name))
    	{
    	  __flush();
    	  __matcher._M_add_equivalence_class(_M_value);
    	}
          else if (_M_match_token(_ScannerT::_S_token_char_class_name))
    	{
    	  __flush();
    	  __matcher._M_add_character_class(_M_value, false);
    	}
          else if (_M_try_char())
    	__push_char(_M_value[0]);
          // POSIX doesn't allow '-' as a start-range char (say [a-z--0]),
          // except when the '-' is the first or last character in the bracket
          // expression ([--0]). ECMAScript treats all '-' after a range as a
          // normal character. Also see above, where _M_expression_term gets called.
          //
          // As a result, POSIX rejects [-----], but ECMAScript doesn't.
          // Boost (1.57.0) always uses POSIX style even in its ECMAScript syntax.
          // Clang (3.5) always uses ECMAScript style even in its POSIX syntax.
          //
          // It turns out that no one reads BNFs ;)
          else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
    	{
    	  if (!__last_char.first)
    	    {
    	      if (!(_M_flags & regex_constants::ECMAScript))
    		{
    		  if (_M_match_token(_ScannerT::_S_token_bracket_end))
    		    {
    		      __push_char('-');
    		      return false;
    		    }
    		  __throw_regex_error(
    		    regex_constants::error_range,
    		    "Unexpected dash in bracket expression. For POSIX syntax, "
    		    "a dash is not treated literally only when it is at "
    		    "beginning or end.");
    		}
    	      __push_char('-');
    	    }
    	  else
    	    {
    	      if (_M_try_char())
    		{
    		  __matcher._M_make_range(__last_char.second, _M_value[0]);
    		  __last_char.first = false;
    		}
    	      else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
    		{
    		  __matcher._M_make_range(__last_char.second, '-');
    		  __last_char.first = false;
    		}
    	      else
    		{
    		  if (_M_scanner._M_get_token()
    		      != _ScannerT::_S_token_bracket_end)
    		    __throw_regex_error(
    		      regex_constants::error_range,
    		      "Character is expected after a dash.");
    		  __push_char('-');
    		}
    	    }
    	}

    Читаю тут реализацию стандартной говнокрестовой библиотеки из GCC
    Какой багор )))

    j123123, 10 Ноября 2021

    Комментарии (54)
  5. JavaScript / Говнокод #27809

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function s(v: any): v is string
    {
    	return typeof v === "string";
    }
    
    function main()
    {
    	print(s("sss"));
    }

    А ты так можешь на С/C++ .. а я могу....

    ASD_77, 10 Ноября 2021

    Комментарии (40)
  6. JavaScript / Говнокод #27808

    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
    function test_nest_capture_of_this() {
        let deck = {
            val: 1,
            funcWithCapture: function () {
                return () => {
                    return this.val;
                };
            },
        };
    
        let funcInst = deck.funcWithCapture();
        print(funcInst());
    }
    
    function main() {
        test_nest_capture_of_this();
        print("done.");
    }

    а вот мой компилятор может так говнокодить .. а ваш? (коментов не будет - сайт все блокирует) на этот раз скину дампик
    https://pastebin.com/MXVLGnGM

    результат работы

    C:\temp\MLIR_to_exe>1.exe
    1
    done.

    ASD_77, 10 Ноября 2021

    Комментарии (14)
  7. Си / Говнокод #27807

    +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
    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
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    // https://github.com/j123123/sexpr_parse/blob/584fc23de71bebe02545214f819e16b720a2c1e2/my_struct_utils.c#L119
    
    blob *
    blob_scan_fromstream
    (
      FILE *stream
    )
    {
      size_t st_len = 0;
      size_t st_alloc;
      uint8_t *st = NULL;
    
      while(true)
      {
        const int fg = getc(stream);
        if(fg == EOF)
        {
          PRV_ERR_MACRO();
        }
        uint8_t c = fg;
        if(!isprint(fg))
        {
          PRV_ERR_MACRO();
        }
        switch(c)
        {
          case '\\':
            {
              int c2 = getc(stream);
              switch(c2)
              {
                case 'x':
                  {
                    int c3[2] =
                    {
                      getc(stream),
                      getc(stream)
                    };
                    uint8_t tmp[2];
    
                    for(size_t i = 0; i < 2; ++i)
                    {
                      switch(c3[i])
                      {
                        case '0' ... '9':
                          tmp[i] = c3[i]-'0';
                          break;
                        case 'a' ... 'f':
                          tmp[i] = c3[i]+10-'a';
                          break;
                        case 'A' ... 'F':
                          tmp[i] = c3[i]+10-'A';
                          break;
                        default:
                          PRV_ERR_MACRO();
                      }
                    }
                    M_PUSH(tmp[1] | tmp[0] << 4);
                  }
                  break;
                case '\\':
                  M_PUSH('\\');
                  break;
                case 't':
                  M_PUSH('\t');
                  break;
                case 'n':
                  M_PUSH('\n');
                  break;
                case '"':
                  M_PUSH('"');
                  break;
                default:
                  PRV_ERR_MACRO();
              }
            }
            break;
    //      case '\t':
    //      case '\n':
    //        PRV_ERR_MACRO();
    //        break;
          case '"':
            goto end;
          default:
            M_PUSH(c);
        }
      }
    
    end:
      ;
      blob *tmp = blob_init(st_len, st);
      PRV_FREE(st);
      return tmp;
    }

    Эта вот хрень вычитывает из "FILE *" одно "слово".

    j123123, 09 Ноября 2021

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

    −2

    1. 1
    Узнал, что доблестный Робин-гуд был активным гомо, чья пассивная банда резала и жгла натурастов за их "натурастность"..

    Мой мир никогда не будtт прежним.

    MaaKut, 08 Ноября 2021

    Комментарии (0)
  9. JavaScript / Говнокод #27805

    0

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    class RayTracer {
        private maxDepth = 5;
    
        private intersections(ray: Ray, scene: Scene) {
            let closest = +Infinity;
            let closestInter: Intersection = undefined;
            for (let i in scene.things) {
                let inter = scene.things[i].intersect(ray);
                if (inter != null && inter.dist < closest) {
                    closestInter = inter;
                    closest = inter.dist;
                }
            }
    
            return closestInter;
        }
    
        private testRay(ray: Ray, scene: Scene) {
            let isect = this.intersections(ray, scene);
            if (isect != null) {
                return isect.dist;
            } else {
                return undefined;
            }
        }
    
        private traceRay(ray: Ray, scene: Scene, depth: number): Color {
            let isect = this.intersections(ray, scene);
            if (isect === undefined) {
                return Color.background;
            } else {
                return this.shade(isect, scene, depth);
            }
        }
    
        private shade(isect: Intersection, scene: Scene, depth: number) {
            let d = isect.ray.dir;
            let pos = Vector.plus(Vector.times(isect.dist, d), isect.ray.start);
            let normal = isect.thing.normal(pos);
            let reflectDir = Vector.minus(d, Vector.times(2, Vector.times(Vector.dot(normal, d), normal)));
            let naturalColor = Color.plus(Color.background,
                this.getNaturalColor(isect.thing, pos, normal, reflectDir, scene));
            let reflectedColor = (depth >= this.maxDepth) ? Color.grey : this.getReflectionColor(isect.thing, pos, normal, reflectDir, scene, depth);
            return Color.plus(naturalColor, reflectedColor);
        }
    
        private getReflectionColor(thing: Thing, pos: Vector, normal: Vector, rd: Vector, scene: Scene, depth: number) {
            return Color.scale(thing.surface.reflect(pos), this.traceRay({ start: pos, dir: rd }, scene, depth + 1));
        }
    
        private getNaturalColor(thing: Thing, pos: Vector, norm: Vector, rd: Vector, scene: Scene) {
            const addLight = (col: Color, light: Light) => {
                let ldis = Vector.minus(light.pos, pos);
                let livec = Vector.norm(ldis);
                let neatIsect = this.testRay({ start: pos, dir: livec }, scene);
                let isInShadow = (neatIsect === undefined) ? false : (neatIsect <= Vector.mag(ldis));
                if (isInShadow) {
                    return col;
                } else {
                    let illum = Vector.dot(livec, norm);
                    let lcolor = (illum > 0) ? Color.scale(illum, light.color)
                        : Color.defaultColor;
                    let specular = Vector.dot(livec, Vector.norm(rd));
                    let scolor = (specular > 0) ? Color.scale(Math.pow(specular, thing.surface.roughness), light.color)
                        : Color.defaultColor;
                    return Color.plus(col, Color.plus(Color.times(thing.surface.diffuse(pos), lcolor),
                        Color.times(thing.surface.specular(pos), scolor)));
                }
            }
            //return scene.lights.reduce(addLight, Color.defaultColor);
            let resColor = Color.defaultColor;
            for (const light of scene.lights) {
                resColor = addLight(resColor, light);
            }
    
            return resColor;
        }
    
        render(scene: Scene, screenWidth: number, screenHeight: number) {
            const getPoint = (x: number, y: number, camera: Camera) => {
                const recenterX = (x: number) => (x - (screenWidth / 2.0)) / 2.0 / screenWidth;
                const recenterY = (y: number) => - (y - (screenHeight / 2.0)) / 2.0 / screenHeight;
                return Vector.norm(Vector.plus(camera.forward, Vector.plus(Vector.times(recenterX(x), camera.right), Vector.times(recenterY(y), camera.up))));
            }
    
            for (let y = 0; y < screenHeight; y++) {
                for (let x = 0; x < screenWidth; x++) {
                    let color = this.traceRay({ start: scene.camera.pos, dir: getPoint(x, y, scene.camera) }, scene, 0);
                    let c = Color.toDrawingColor(color);
                    //ctx.fillStyle = "rgb(" + String(c.r) + ", " + String(c.g) + ", " + String(c.b) + ")";
                    //ctx.fillRect(x, y, x + 1, y + 1);
    		// next line eats stack (or memory?)
    		print(`<rect x="${x}" y="${y}" width="1" height="1" style="fill:rgb(${c.r},${c.g},${c.b});" />`);
                }
            }
        }
    }
    
    
    function defaultScene(): Scene {

    шас я вас залью кодик т.к. все не влазит ловите код на https://pastebin.com/qMZmnCqT так вот это вот компилиться и работает на новом компиляторе

    ASD_77, 08 Ноября 2021

    Комментарии (20)
  10. Куча / Говнокод #27803

    −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
    a     G    a      G C         G C
    Deszcze niespokojne      potargaly sad
    a               G     F      G    a
     А my na tej wojnie ladnych pare lat
          a                       b      a          b
    Do domu wrocimy, w piecu napalimy, nakarmimy psa
           a                     B7 e           B7     e    a E7 a
    Przed noca zdazymy, tylko zwyciezymy, a to wazna gra
    a       G      a  G C               G  C
    Na niebie obloki,     po wsiach pelno bzu,
    a                   G       F     G       a
     Gdziez ten swiat daleki, pelen dobrych snow
          a                           b     a             b
    Powrocimy wierni my czterej pancerni, "Rudy" i nasz pies
            a                  B7    e         B7     e
    My czterej pancerni powrocimy wierni po wiosenny bez.

    HE_OTBE4Au_YE6KY, 07 Ноября 2021

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