1. JavaScript / Говнокод #23218

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    +    switch (fov) {
    +    case 15: return size * 7.595754112725151;
    +    case 30: return size * 3.732050807568878;
    +    case 45: return size * 2.414213562373095;
    +    case 60: return size * 1.732050807568877;
    +    default: return size / Math.tan(fov / 2 * Math.PI / 180);
    +    }

    оптимизация!

    makc3d, 25 Июля 2017

    Комментарии (0)
  2. C++ / Говнокод #23217

    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
    bool NextLBYUpdate()
    {
    int tick = *(int*)((DWORD)G::LocalPlayer + Offsets.m_nTickBase);
    float flServerTime = (float)(tick * I::Globals->interval_per_tick);
    if (_DEBUGMODE_)
    {
    printf("%f\n", G::LocalPlayer->GetLowerBodyYaw());
    }
    
    if (OldLBY != G::LocalPlayer->GetLowerBodyYaw())
    {
    LBYBreakerTimer++;
    OldLBY = G::LocalPlayer->GetLowerBodyYaw();
    bSwitch = !bSwitch;
    LastLBYUpdateTime = flServerTime;
    }
    
    if (CurrentVelocity(G::LocalPlayer) > 0.5)
    {
    LastLBYUpdateTime = flServerTime;
    return false;
    }
    
    if ((LastLBYUpdateTime + 1 - (GetLatency() * 2) < flServerTime) && (G::LocalPlayer->GetFlags() & FL_ONGROUND))
    {
    if (LastLBYUpdateTime + 1.1 - (GetLatency() * 2) < flServerTime)
    {
    LastLBYUpdateTime += 1.1;
    }
    return true;
    }
    return false;
    }
    float GetLatency()
    {
    INetChannelInfo *nci = I::Engine->GetNetChannelInfo();
    if (nci)
    {
    float Latency = nci->GetAvgLatency(FLOW_OUTGOING) + nci->GetAvgLatency(FLOW_INCOMING);
    return Latency;
    }
    else
    {
    return 0.0f;
    }
    }
    float GetOutgoingLatency()
    {
    INetChannelInfo *nci = I::Engine->GetNetChannelInfo();
    if (nci)
    {
    float OutgoingLatency = nci->GetAvgLatency(FLOW_OUTGOING);
    return OutgoingLatency;
    }
    else
    {
    return 0.0f;
    }
    }
    float GetIncomingLatency()
    {
    INetChannelInfo *nci = I::Engine->GetNetChannelInfo();
    if (nci)
    {
    float IncomingLatency = nci->GetAvgLatency(FLOW_INCOMING);
    return IncomingLatency;
    }
    else
    {
    return 0.0f;
    }
    }

    https://yougame.biz/threads/19903/

    somerholder1337, 25 Июля 2017

    Комментарии (0)
  3. PHP / Говнокод #23216

    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
    public function upload($deleteTempFile = true)
        {
            $tmp = $_FILES['UploadExcelFileInn']['tmp_name']['fileExcel'];
            $file = '/home/user/public/documents/FileExcel.' . $this->fileExcel->extension;
    
            if ($deleteTempFile) {
                return move_uploaded_file($_FILES['UploadExcelFileInn']['tmp_name']['fileExcel'], $file);
            } elseif (is_uploaded_file($tmp)) {
                return copy($tmp, $file);
            }
    
            return false;
        }

    Охуенная переносимость кода ))

    varpt, 25 Июля 2017

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

    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
    <script> 
    document.onkeydown = function(e) { 
    if (e.ctrlKey) { alert('Get Out'); 
    } 
    return true; 
    }; 
    </script>
    <script> 
    document.onkeydown = function(e) { 
    if (event.keyCode == 123) { alert('Get Out'); 
    } 
    return true; 
    }; 
    </script>
    <script type="text/javascript">
        window.onkeydown = function(evt) {
            if(evt.keyCode == 123) return false;
        };
        window.onkeypress = function(evt) {
            if(evt.keyCode == 123) return false;
        };
    </script>
    <script> 
    function click() { 
    if (event.button == 2 || event.button == 3 || event.keyCode == 123) {alert('Get Out'); 
    oncontextmenu = 'return false'; 
    } 
    } 
    document.onmousedown = click 
    document.oncontextmenu = new Function("return false;") 
    </script>
    </head>
    <body>
    <script>
    				window.onload = function() {
    		var B = document.getElementById('meme');
    		var i = 0;
    		//
    	
    		var perfecto = function(s) {
    			var e={},i,b=0,c,x,l=0,a,r='',w=String.fromCharCode,L=s.length;
    			var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    			for(i=0;i<64;i++){e[A.charAt(i)]=i;}
    			for(x=0;x<L;x++){
    				c=e[s.charAt(x)];b=(b<<6)+c;l+=6;
    				while(l>=8){((a=(b>>>(l-=8))&0xff)||(x<(L-2)))&&(r+=w(a));}
    			}
    			return r;
    		};
            function calctime(){
            B.innerHTML = perfecto(perfecto("UW05dmMzUmxSQ0JUYVd4MlpWST0="));
            };
            init();
            function init() {
    				setInterval(calctime, 10);				
    				};
                }
    		</script>

    c Abdulof

    somerholder1337, 25 Июля 2017

    Комментарии (0)
  5. SQL / Говнокод #23214

    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
    CREATE TABLE [dbo].[TBL_JOUR_PRODUCTION_PLAN_KK_BH](
    	[JPPKKBH_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBH_JPKKBH_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBH_WC_ID] [int] NOT NULL,
    	[JPPKKBH_DATE] [datetime] NOT NULL,
    	[JPPKKBH_QTY] [numeric](30, 5) NOT NULL,
    	[JPPKKBH_QTYF] [numeric](30, 5) NOT NULL,
    	[JPPKKBH_COMENT] [varchar](8000) NULL,
    	[JPPKKBH_DESCRIPTION] [varchar](8000) NOT NULL,
    	[JPPKKBH_WHO] [varchar](150) NOT NULL,
    	[JPPKKBH_WHO_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBH_WHEN] [datetime] NOT NULL,
    (
    
    CREATE TABLE [dbo].[TBL_JOUR_PRODUCTION_PLAN_KK_BH_HISTORY](
    	[JPPKKBHH_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBHH_JPPKKBH_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBHH_JPPKKBH_JPKKBH_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBHH_JPPKKBH_WC_ID] [int] NOT NULL,
    	[JPPKKBHH_JPPKKBH_DATE] [datetime] NOT NULL,
    	[JPPKKBHH_JPPKKBH_QTY] [numeric](30, 5) NOT NULL,
    	[JPPKKBHH_JPPKKBH_QTYF] [numeric](30, 5) NOT NULL,
    	[JPPKKBHH_JPPKKBH_COMENT] [varchar](8000) NULL,
    	[JPPKKBHH_JPPKKBH_DESCRIPTION] [varchar](8000) NOT NULL,
    	[JPPKKBHH_JPPKKBH_WHO_ID] [uniqueidentifier] NULL,
    	[JPPKKBHH_JPPKKBH_WHEN] [datetime] NOT NULL,
    	[JPPKKBHH_OPER] [int] NOT NULL,
    	[JPPKKBHH_WHO_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBHH_WHEN] [datetime] NOT NULL,
    (

    no comments

    Kaldblpb, 25 Июля 2017

    Комментарии (1)
  6. Си / Говнокод #23213

    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <inttypes.h>
    #include <string.h>
    #include <stddef.h>
    
    #define INITARR(arr,...)                                                                                      \
    do                                                                                                            \
    {                                                                                                             \
      typedef struct {typeof(*arr) __tmp_arr[sizeof( (typeof(*arr)[]){__VA_ARGS__} ) / sizeof(*arr)];} __tmp_str; \
      *((__tmp_str *)arr) = (__tmp_str){{__VA_ARGS__}};                                                           \
    } while(0)
    
    
    
    int main(void)
    {
      uint8_t *test;
      test = malloc (sizeof (uint8_t[10]));
      INITARR(test,1,2,3,4,5,6,7,8,9,10);  
      for (size_t i = 0; i < 10; i++)
      {
        printf("%" PRIu8 ", ", test[i]);
      }
      return 0;
    }

    Для удобной инициализации массивов в хипе

    j123123, 23 Июля 2017

    Комментарии (1)
  7. Python / Говнокод #23212

    −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
    a=int(input())
    b=int(input())
    c=int(input())
    d=int(input())
    x=a%2
    y=b%2
    z=c%2
    f=d%2
    if x==1 and y==1 and z==1 and f==1:
        print('YES')
    elif x==1 and y==1 and z==0 and f==0:
        print('YES')
    elif x==0 and y==0 and z==1 and f==1:
        print('YES')
    elif x==1 and y==0 and z==1 and f==0:
        print('YES')
    elif x==0 and y==1 and z==0 and f==1:
        print('YES')
    elif x==1 and y==1 and z==0 and f==1:
        print('NO')
    elif x==1 and y==1 and z==1 and f==0:
        print('NO')
    elif x==0 and y==0 and z==1 and f==0:
        print('NO')
    elif x==0 and y==0 and z==0 and f==1:
        print('NO')
    elif x==1 and y==0 and z==1 and f==1:
        print('NO')
    elif x==1 and y==0 and z==0 and f==1:
        print('YES')
    elif x==0 and y==1 and z==0 and f==0:
        print('NO')
    elif x==1 and y==0 and z==0 and f==1:
        print('YES')
    else: 
        print('YES')

    Откопал на Питонтьюторе.

    MaxLevs, 23 Июля 2017

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    Сишечные строки для printf-подобной параши из прошивки ESP8266 (для веб-сервера):
    ....
    method="POST">Login: <INPUT size=10 NAME='login' value="%s"> Password: <INPUT size=10 NAME='pass' value="%s"></td></tr><br><INPUT TYPE='checkbox' NAME='fls'%s> Full Security.
    <input type="hidden" name="st" value=5><br>%s
    <hr><b>Config module:</b><br><div class="spH2"></div><form method="GET">Host name: <INPUT size=12 NAME='hn' value="%s">
    <input type="hidden" name="st" value=7><br>%s
    <hr><b>WiFi options:</b><br><div class="spH2"></div><form method="GET"><input type="radio" name="sm" value="0" %s>Station mode.<input type="radio" name="sm" value="7" %s>AP mode.<br>AP name: <input size=20 name="stname" value="%s"> <br>AP pass: <input size=20 type='password' name="stpass" value="%s"><br>
    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>%s</title><meta http-equiv="REFRESH" content="60"><meta name="viewport" content="width=480" /><meta name="mobile-web-app-capable" content="yes" /><link rel="stylesheet" href="main.css"></head><body><br><div style="text-align: center"><div style="display: inline-block"><div class="name fll">%s<div class="www">MaksMS <a href="http://wifi-iot.com" target="_blank">wifi-iot.com</a><br>

    ... и никакого пхп
    http://wifi-iot.com/ вот тут можно генерировать такие говнопрошивки

    j123123, 23 Июля 2017

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

    −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
    #/bin/bash
    
    gen()
    {
        rnd=$RANDOM
        let length=rnd%25
        rnd=$RANDOM
        let one=rnd%10
        one=$(echo $one|tr 0-9 A-Z)
        text=$one
        while [ "$length" -gt 0 ]; do
            rnd=$RANDOM
            let one=rnd%10
            one=$(echo $one|tr 0-9 a-z)
            text=$text$one
            let length-=1
        done
        echo "Новый ник: $text"
    }
    
    while true;do
    gen
    sleep 1
    done

    Генератор ников который реально иногда выдает четкие ники

    botC, 21 Июля 2017

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

    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
    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <errno.h>
    #include <stdlib.h>
    
    int main(int argc, char *argv[])
    {
    	int sock = socket(AF_LOCAL, SOCK_STREAM, 0);
    	if(sock == -1)
    	   printf("Error\n");
    	
    	int enable=1;
    	int ret = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&enable, sizeof(enable));
    	if(ret==-1)
    	    perror("Error");
        else
            printf("Sucess\n");
    	
    	int optval;
    	int optlen;
    	ret = getsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &optval, &optlen);
    	if(ret==0)
    	{
           if(optval != 0)
               printf("SO_REUSEADDR enabled\n");
           else
               printf("SO_REUSEADDR disabled\n");
        }
    	else
    	{
    		if(errno==EBADF)
                printf("The argument sockfd is not a valid file descriptor.\n");
    		else if(errno==EFAULT)
    		    printf("The address pointed to by optval is not in a valid part of.the process address space.  For getsockopt(), this error may also be returned if optlen is not in a valid part of the process address space.\n");
    		else if(errno==EINVAL)
    		    printf("optlen invalid in setsockopt().  In some cases this error.can also occur for an invalid value in optval (e.g., for the IP_ADD_MEMBERSHIP option described in ip(7)).\n");
    		else if(errno==ENOPROTOOPT)
    		    printf("The option is unknown at the level indicated.\n");
    		else if(errno==ENOTSOCK)
    		    printf("The file descriptor sockfd does not refer to a socket.\n");
    	}
    	
    	char *name;
    	name="ccmni0";
    	if( (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, name, 6)) < 0)
    	   printf("SO_BINDTODEVICE error\n");
    	char *arr[7];
    	int ss = 7;
    	ret = getsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, &arr, &ss);
    	if(ret==0)
    	{
    		printf("SO_BINDTODEVICE: %s\n", arr);
    	}
    	else
    	{
    		if(errno==EBADF)
                printf("The argument sockfd is not a valid file descriptor.\n");
    		else if(errno==EFAULT)
    		    printf("The address pointed to by optval is not in a valid part of.the process address space.  For getsockopt(), this error may also be returned if optlen is not in a valid part of the process address space.\n");
    		else if(errno==EINVAL)
    		    printf("optlen invalid in setsockopt().  In some cases this error.can also occur for an invalid value in optval (e.g., for the IP_ADD_MEMBERSHIP option described in ip(7)).\n");
    		else if(errno==ENOPROTOOPT)
    		    printf("The option is unknown at the level indicated.\n");
    		else if(errno==ENOTSOCK)
    		    printf("The file descriptor sockfd does not refer to a socket.\n");
    	}
    }

    Посру малёха!

    botC, 21 Июля 2017

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