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

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

    0

    1. 1
    var result = IsConnected  && dataMax != "" ? true : !IsConnected && dataMin != "" ? true : false;

    Обфускация условия говнокодом!

    MatureGovnocoder, 02 Июля 2020

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

    +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
    function(t) {
        switch (t) {
            case 1:
                return g.emailNotConfirmed;
            case 2:
                return g.showCaptcha;
            case 3:
                return g.authFailed;
            case 4:
                return g.makeRedirect;
            case 5:
                return g.reload;
            case 6:
                return g.mobileActivationRequired;
            case 7:
                return g.showMessage;
            case 8:
                return g.showError;
            case 9:
                return g.votesPayment;
            case 10:
                return g.zeroZone;
            case 11:
            case 12:
                return Object(g.mobileValidationRequired)(t);
            case 13:
                return g.evalCode;
            case 14:
                return g.otpBox;
            case 15:
                return g.passwordValidationRequired;
            default:
                return Object(g.defaultHandler)(t)
        }
    }(t)

    https://vk.com/js/cmodules/bundles/common.2ce877ca4bd415d95d03.js?51fe80b96 a07a7861643

    #байтоклюйство #спичечная-экономика #олимпиадники #ebivk

    Fike, 18 Июня 2020

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

    +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
    ```rust
    impl actix_web::FromRequest for Token {
        type Error = ApiError;
        type Future = Pin<Box<dyn Future<Output = Result<Self, Self::Error>>>>;
        type Config = ();
    
        fn from_request(req: &actix_web::HttpRequest, _: &mut actix_web::dev::Payload) -> Self::Future {
            match req.extensions().get::<Option<Self>>().map(Clone::clone) {
                Some(Some(v)) => Box::pin(async { Ok(v) }),
                None | Some(None) => {
                    let header = req.headers().get("Authorization").map(Clone::clone);
    
                    Box::pin(
                        web::Data::<Pool>::extract(req)
                            .map_err(ApiError::from)
                            .and_then(move |pool| {
                                async move {
                                    let header = header.ok_or(ApiError::authorization_required())?;
    
                                    let auth = header.to_str()?;
    
                                    let uuid = Uuid::parse_str(auth)
                                        .map_err(|_| ApiError::authorization_bad_token())?;
    
                                    let (_, token) = Self::find(&uuid, pool.get_conn().await?).await?;
    
                                    let token = token.ok_or(ApiError::authorization_bad_token())?;
    
                                    Ok(token)
                                }
                            })
                            .boxed_local()
                    )
                }
            }
        }
    }

    Было принято решение создать Authorization middleware, который при каждом запросе авторизировал пользователя, если есть нужный хидер. В связи с тем, что некоторые роуты достают модель через ручной экстрактор, пришлось дописать эту хуйню (Второе условие никогда не будет выполнена вообще судя по всему).

    1rei, 18 Июня 2020

    Комментарии (9)
  5. Куча / Говнокод #26730

    0

    1. 1
    https://sun1-93.userapi.com/SSu8G4XtIyohtocFhPi9jy7aPkBla7N_ZPnNdw/z5IDchObVcA.jpg

    Тушенка из русни

    OlegUP, 02 Июня 2020

    Комментарии (9)
  6. PHP / Говнокод #26668

    +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
    public function isSpecial()
    {
        $special_ids = array(
            2222,
            3028,
            3333,
            5555,
            5702,
            6666,
            6700,
            7654,
            7777,
            8451,
            11225
        );
    
        return in_array((int)$this->getId(), $special_ids);
        //return $this->getId() == 2222 || $this->getId() == 3028 || $this->getId() == 3333 || $this->getId() == 5555 || $this->getId() == 5702;
    }

    https://github.com/wiistriker/govnokod_legacy/blob/master/modules/quoter/models/quote.php
    Рекурсивный говнокод.

    gost, 19 Мая 2020

    Комментарии (9)
  7. Куча / Говнокод #26629

    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
    import sequtils
    
    when not declared(unzip):
      proc unzip*[S, T](s: openArray[(S, T)]): (seq[S], seq[T]) =
        result[0] = newSeq[S](s.len)
        result[1] = newSeq[T](s.len)
        for i in 0..<s.len:
          result[0][i] = s[i][0]
          result[1][i] = s[i][1]
    
    let a = @[('a', 1), ('b', 2), ('c', 3)]
    let b = unzip(a) # version 1.0 will use the proc declared above
                     # version 1.2 will use sequtils' proc
    
    assert b == (@['a', 'b', 'c'], @[1, 2, 3])

    Если в библиотеке нет нужного метода, вы можете написать его сами и кинуть в сторону своих пользователей.

    Desktop, 01 Мая 2020

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

    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
    https://github.com/boundary/wireshark/blob/master/epan/dissectors/packet-rpc.c
    
    /* compare 2 keys */
    static gint
    rpc_proc_equal(gconstpointer k1, gconstpointer k2)
    {
    	const rpc_proc_info_key* key1 = (const rpc_proc_info_key*) k1;
    	const rpc_proc_info_key* key2 = (const rpc_proc_info_key*) k2;
    
    	return ((key1->prog == key2->prog &&
    		key1->vers == key2->vers &&
    		key1->proc == key2->proc) ?
    	TRUE : FALSE);
    }

    OlegUP, 08 Апреля 2020

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

    +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
    > At its core, Swarm implements a distributed content-addressed chunk store. 
    > Chunks are arbitrary data blobs with a fixed maximum size (currently 4KB). 
    > Content addressing means that the address of any chunk is deterministically derived from its content. 
    > The addressing scheme falls back on a hash function which takes a chunk as input and returns a 32-byte long key as output. 
    > A hash function is irreversible, collision free and uniformly distributed (indeed this is what makes bitcoin, and in general proof-of-work, work).
    
    исключая лишнее
    
    > derived from content
    > content = 4KB
    > 32-byte output
    > collision free!

    И еще немного несвежых новостей из мира, где «блокчейн» стал устойчивым синонимом слова «распределенный»

    https://blog.ethereum.org/2016/12/15/swarm-alpha-public-pilot-basics-swarm/

    Fike, 07 Марта 2020

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

    +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
    // I'm interested in using something other than the C preprocessor to preprocess my C and Objective-C source code. Are there good alternatives?
    //
    // ---
    //
    // You can use PHP as a C preprocessor. The advantages are:
    //
    // - very similiar syntax, so syntax highlighting works.
    // - <? and ?> are not used in standard C (with non-standard C, the only thing that gets broken is old GCC extension operator that returns min/max)
    // - it's rich in libraries.
    // - it's turing complete.
    // - usage of macros is very explicit. (compared to sneaky C preprocessor macros)
    // For serious use though, making PHP print the #line directives is needed for debugging preprocessed code.
    
    <?php include_once "stdio.h"; ?>
    
    int main()
    {
        <?php
            for($i = 0; $i < 20; $i++)
                echo 'printf("%d\n", '.$i.');';
        ?>
    }

    https://stackoverflow.com/a/16256052

    абсолютно невыносимо

    Fike, 25 Января 2020

    Комментарии (9)
  11. C# / Говнокод #26375

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public static void ActivateChangeHotKeyButtonModeButtonClick(object sender, EventArgs e)
    {
           TaskBarHidderForm.ChangeHotKeyPanel.Visible = true;
           TaskBarHidderForm.KeyButtons[0].Text = TaskBarHidder.HotKeyCodes[0].ToString();
           TaskBarHidderForm.KeyButtons[1].Text = TaskBarHidder.HotKeyCodes[1].ToString();
    }

    кодить под пивко заебись :)

    pashaluk31, 21 Января 2020

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