1. C++ / Говнокод #23072

    −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
    for (int i = 0; i < WorkedVerts.count(); i++)
    	{
    		int R0 = (i + Offset0) % WorkedVerts.count();
    		int R1 = (i + Offset1) % WorkedVerts.count();
    		int R2 = (i + Offset2) % WorkedVerts.count();
    
    		XA << WorkedVerts.at(R0).Position;
    		XB << WorkedVerts.at(R1).Position;
    		XC << WorkedVerts.at(R2).Position;
    	}
    	PrepareDataPointers(XA, XB, XC);
    	Inset_Cuda(InputData0, InputData1, InputData2, OutputData, XA.count(), -Amount);
    
    	for (int x = 0; x < XA.count(); x++)
    	{
    		if (fabs(OutputData[x].x) < 0.0001f && fabs(OutputData[x].y) < 0.0001f && fabs(OutputData[x].z < 0.0001f))
    		{
    			int Start = x;
    			int Start1 = (x + (XA.count() - 1)) % XA.count();
    			QVector3D StartVec = QVector3D(OutputData[Start1].x, OutputData[Start1].y, OutputData[Start1].z);
    			QVector3D EndVec = StartVec;
    			int End = 0;
    			while (true)
    			{
    				End = Start++;
    				if (fabs(OutputData[End].x) > 0.0001f && fabs(OutputData[End].y) > 0.0001f && fabs(OutputData[End].z > 0.0001f))
    				{
    					EndVec = QVector3D(OutputData[End].x, OutputData[End].y, OutputData[End].z);
    					break;
    				}
    			}
    			QVector3D OffsetX0 = WorkedVerts.at(Start).Position - StartVec;
    			QVector3D OffsetX1 = WorkedVerts.at(End).Position - EndVec;
    			QVector3D Mid2 = OffsetX0 + (OffsetX1 - OffsetX0) * 0.5f;
    			OutputData[x].x = Mid2.x();
    			OutputData[x].y = Mid2.y();
    			OutputData[x].z = Mid2.z();
    		}
    	}
    	int VertsCounter = SharedVerts.count();
    	for (int i = 0; i < WorkedVerts.count(); i++)
    	{
    		SharedVertex NewVert;
    		int Count3 = WorkedVerts.count();
    		int index = (i + (Count3 - 1)) % Count3;
    		NewVert.Position = QVector3D(OutputData[index].x, OutputData[index].y, OutputData[index].z);
    		NewVert.Index = VertsCounter++;
    		SV2 << NewVert;
    	}

    Код нахождения копии контура вершин с оффсетом.

    IVK, 26 Мая 2017

    Комментарии (3)
  2. 1C / Говнокод #23071

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Попытка
               ЗаблокироватьДанныеФормыДляРедактирования();
    Исключение
               ВызватьИсключение КраткоеОписаниеОшибки(ОписаниеОшибки());
    КонецПопытки

    Процедура ЗаблокироватьДанныеФормыДляРедактировани я() при невозможности заблокировать данные сама вызывает исключение

    acula98, 26 Мая 2017

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function color_search($color) {
         $arColor["COLOR"] = explode(",","aliceblue,antiquewhite,aqua,aquamarine,azure,beige,bisque,black,blanchedalmond,blue,blueviolet,brown,burlywood,cadetblue,chartreuse,chocolate,coral,cornflowerblue,cornsilk,crimson,cyan,darkblue,darkcyan,darkgoldenrod,darkgray,darkgreen,darkkhaki,darkmagenta,darkolivegreen,darkorange,darkorchid,darkred,darksalmon,darkseagreen,darkslateblue,darkslategray,darkturquoise,darkviolet,deeppink,deepskyblue,dimgray,dodgerblue,firebrick,floralwhite,forestgreen,fuchsia,gainsboro,ghostwhite,gold,goldenrod,gray,green,greenyellow,honeydew,hotpink,indianred,indigo,ivory,khaki,lavender,lavenderblush,lawngreen,lemonchiffon,lightblue,lightcoral,lightcyan,lightgreen,lightgrey,lightpink,lightsalmon,lightseagreen,lightskyblue,lightslategray,lightsteelblue,lightyellow,lime,limegreen,linen,magenta,maroon,mediumaquamarine,mediumblue,mediumorchid,mediumpurple,mediumseagreen,mediumslateblue,mediumspringgreen,mediumturquoise,mediumvioletred,midnightblue,mintcream,mistyrose,moccasin,navajowhite,navy,oldlace,olive,olivedrab,orange,orangered,orchid,palegoldenrod,palegreen,paleturquoise,palevioletred,papayawhip,peachpuff,peru,pink,plum,powderblue,purple,red,rosybrown,royalblue,saddlebrown,salmon,sandybrown,seagreen,seashell,sienna,silver,skyblue,slateblue,slategray,snow,springgreen,steelblue,tan,teal,thistle,tomato,turquoise,violet,wheat,white,whitesmoke,yellow,yellowgreen,black,dimgray,gray,darkgray,silver,lightgrey,gainsboro,whitesmoke,white,snow,rosybrown,lightcoral,indianred,brown,firebrick,maroon,darkred,red,salmon,mistyrose,tomato,darksalmon,coral,orangered,lightsalmon,sienna,seashell,saddlebrown,chocolate,peachpuff,sandybrown,linen,peru,bisque,darkorange,antiquewhite,tan,burlywood,blanchedalmond,navajowhite,papayawhip,moccasin,oldlace,wheat,orange,floralwhite,goldenrod,darkgoldenrod,cornsilk,gold,lemonchiffon,khaki,palegoldenrod,darkkhaki,ivory,beige,lightyellow,olive,yellow,olivedrab,yellowgreen,darkolivegreen,greenyellow,lawngreen,chartreuse,honeydew,darkseagreen,lightgreen,palegreen,forestgreen,limegreen,darkgreen,green,lime,seagreen,mediumseagreen,mintcream,springgreen,mediumspringgreen,mediumaquamarine,aquamarine,turquoise,lightseagreen,mediumturquoise,azure,paleturquoise,darkslategray,teal,darkcyan,aqua,cyan,lightcyan,darkturquoise,cadetblue,powderblue,lightblue,deepskyblue,skyblue,lightskyblue,steelblue,aliceblue,slategray,lightslategray,dodgerblue,lightsteelblue,cornflowerblue,royalblue,ghostwhite,lavender,midnightblue,navy,darkblue,mediumblue,blue,darkslateblue,slateblue,mediumslateblue,mediumpurple,blueviolet,indigo,darkorchid,darkviolet,mediumorchid,thistle,plum,violet,purple,darkmagenta,fuchsia,magenta,orchid,mediumvioletred,deeppink,hotpink,lavenderblush,palevioletred,crimson");
         if(in_array($color, $arColor["COLOR"])){
             return $color;
         }
     }

    scph77008, 25 Мая 2017

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

    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
    #include <bits/stdc++.h> 
            
    using namespace std;
              
    int B[105], N, k, u, v, i, z;
    map<int, int> A;
            
    main()
    {
        for(cin >> N; cin >> k; B[i++] = k)
            ++A[k] > v ? v = A[u = k] :
                A[k] ^ v ?: u = min(u, k);
               
        for(; z < N; z++)
            B[z] == u || cout << B[z] << " ";
                                         
        while(v--) cout << u << " ";
    }

    Решение задачи из acmp, первое место по количеству символов, обогнав других участников на 30 и более символов.

    Обычное решение задачи, тех которые не участвовали у конке, количество символов от 600-700 символов, тут же 208 символов

    aat, 24 Мая 2017

    Комментарии (126)
  5. C++ / Говнокод #23064

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    template<typename T> FORCEINLINE typename std::enable_if<Is_CastToFloat<T>::value, UFloatStat*>::
      type Add(T &v ,const FStatInfo &Info=FStatInfo::Empty, bool Visible=true)
      {
        float vf=(float)v;
        auto r=_AddFloat(vf, Info, Visible);
        T vb=static_cast<T>(vf);
        if(vb!=v)
          v=vb;//const_cast<T&>(v)=vb;
        return r;
      }

    // Method for Enum, Integer types and bool

    antondoe, 24 Мая 2017

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

    +1

    1. 1
    http://googlinho.com.br/

    huesto, 24 Мая 2017

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

    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
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    // oldman and pilul
    $( "#draggable" ).draggable();
    $( "#draggable1" ).draggable();
    $( "#droppable" ).droppable({
      drop: function() {
        $("#droppable").attr("src","img/happy1.png");
        $("#droppable1").attr("src","img/happy1.png");
        $('#draggable').hide();
        $('#draggable1').hide();
      }
    });
    
    //buttons
    
    
    $('#weekbtn').click(function(){
    
      if ( $('#weekbtn').attr("src")== "img/week-pushed-button.png" ) {
    $("#weekbtn").attr("src","img/week-button.png");
    $("#weekbtn1").attr("src","img/week-button.png");
    } else {
    $("#weekbtn").attr("src","img/week-pushed-button.png");
    $("#weekbtn1").attr("src","img/week-pushed-button.png");
    }
    
    });
    
    
    $('#daybtn').click(function(){
    
      if ( $('#daybtn').attr("src")== "img/day-pushed-button.png" ) {
    $("#daybtn").attr("src","img/day-button.png");
    $("#daybtn1").attr("src","img/day-button.png");
    } else {
    $("#daybtn").attr("src","img/day-pushed-button.png");
    $("#daybtn1").attr("src","img/day-pushed-button.png");
    }
    
    });
    
    $('#mounthbtn').click(function(){
    
      if ( $('#mounthbtn').attr("src")== "img/mounth-pushed-button.png" ) {
    $("#mounthbtn").attr("src","img/mounth-button.png");
    $("#mounthbtn1").attr("src","img/mounth-button.png");
    } else {
    $("#mounthbtn").attr("src","img/mounth-pushed-button.png");
    $("#mounthbtn1").attr("src","img/mounth-pushed-button.png");
    }
    
    });
    
    //roller
    
    function move(){
      var rng = document.getElementById('scrol-line'),
      rng1 = document.getElementById('scrol-line1'),
      roll = document.getElementById('bgc'),
      roll1 = document.getElementById('bgc1');
      roll.value = rng.value;
      rng1.value = rng.value;
      roll1.value =   rng1.value;
    
    }
    
    //slider
    
    var slideIndex = 1;
    showSlides(slideIndex);
    
    function plusSlides(n) {
    showSlides(slideIndex += n);
    }
    
    function currentSlide(n) {
      showSlides(slideIndex = n);
    }
    
    function showSlides(n) {
      var i;
      var slides = document.getElementsByClassName("sliders");
    if (n > slides.length) {
      slideIndex = 1
    }
    
    if (n < 1) {
      slideIndex = slides.length
    }
    for (i=0; i < slides.length; i++) {
      slides[i].style.display = "none";
    }
    slides[slideIndex-1].style.display = "block";
    }

    mcheguevara2, 24 Мая 2017

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

    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 Stream(object):
        def __init__(self, generator):
            object.__init__(self)
            self.data = ''
            self.generator = generator
            self.closed = False
            
            generator.subscribe(self)
            
        def update(self, data):
            self.data += data
            
        def read(self):
            if self.closed: return None
            data = self.data
            self.data = ''
            return data
            
        def close(self):
            self.generator.unsubscribe(self)
            self.closed = True
            self.data = ''
    
    class Server(dispatcher, dict):
        writable = lambda x: False
        
        def __init__(self, host = None, port = 0xB00B):
            dispatcher.__init__(self)
            
            self.create_socket(AF_INET, SOCK_STREAM)
            dict.__init__(self, {self.fileno(): self})
            
            self.set_reuse_addr()
            self.bind((host, port))
            self.listen(0xA)
            
            self.dataSource = PiGenerator()
            
        def removeClient(self, client):
            del self[client.fileno()]
            
        def handle_accept(self):
            sock, (host, port) = self.accept()
            print 'new client from %s:%d' % (host, port)
            
            stream = Stream(self.dataSource)        
            self[sock.fileno()] = Client(sock, self, stream)
            
        def handle_error(self):
            print 'Server error: %s' % sys.exc_value
            sys.exit(1)
        
    class Client(dispatcher):
        readable = lambda x: False    
        
        def __init__(self, sock, server, stream):
            dispatcher.__init__(self, sock)
            self.server = server
            self.stream = stream
            self.buffer = ''
            
        def handle_error(self):
            print 'Client error: %s' % sys.exc_value
            import traceback
            print traceback.format_exc(1000)
            sys.exit(1)        
            
        def handle_write(self):                
            sent = self.send(self.buffer)
            self.buffer = self.buffer[sent:]
            
        def handle_expt(self):
            print 'client dropped connection'        
            self.close()
            
        def close(self):
            self.server.removeClient(self)
            self.stream.close()
            self.buffer = ''
            dispatcher.close(self)
            
        def writable(self):
            data = self.stream.read()
            if data == None:
                print 'client finished reading'
                self.close()
                return False
            
            self.buffer += data
            return len(self.buffer) > 0
    
    def main():
        try:
            asyncore.loop(0.1, True, Server('127.0.0.1'))
        except KeyboardInterrupt:
            print '\nBye :-*'
            sys.exit(0)
    
    if __name__ == '__main__':
        main()

    start http://govnokod.ru/23059

    Lis, 23 Мая 2017

    Комментарии (2)
  9. Python / Говнокод #23059

    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
    #!/usr/bin/python
    #encoding: utf-8
    
    import sys
    import time
    import socket
    import asyncore
    import exceptions
    
    from socket import AF_INET, SOCK_STREAM
    from asyncore import dispatcher
    from threading import Thread, RLock
    
    class PiCalcThread(Thread):
        def __init__(self, buffer, lock):
            Thread.__init__(self)
            self.buffer = buffer
            self.lock = lock
            
        def run(self):
            """ See http://web.comlab.ox.ac.uk/oucl/work/jeremy.gibbons/publications/spigot.pdf """
            q,r,t,k,n,l = 1,0,1,1,3,3
            
            while True:
                if 4*q+r-t < n*t:
                    self.lock.acquire()
                    self.buffer.newDigits(str(n))
                    self.lock.release()
                    
                    q,r,t,k,n,l = (10*q,10*(r-n*t),t,k,(10*(3*q+r))/t-10*n,l)
                else:
                    q,r,t,k,n,l = (q*k,(2*q+r)*l,t*l,k+1,(q*(7*k+2)+r*l)/(t*l),l+2)
                
                time.sleep(0.001)
    
    class PiGenerator(list):
        def __init__(self):
            list.__init__(self)
            self.calculator = None
            self.lock = RLock()
            self.digits = ''
        
        def subscribe(self, obj):  
            self.lock.acquire()
            try:     
                self.append(obj)
                self._notify(obj=obj)
            finally:
                self.lock.release()            
                
            if not self.calculator:
                self.calculator = PiCalcThread(self, self.lock)
                self.calculator.start()
            else:
                if len(self) > 0:
                    self._resumeCalculator()
                    
        def unsubscribe(self, obj):
            self.lock.acquire()
            self.remove(obj)   
            self.lock.release()
                 
            if len(self) <= 0:
                self._pauseCalulator()
                
        def _pauseCalulator(self):
            self.lock.acquire()
        
        def _resumeCalculator(self):
            try: self.lock.release()
            except exceptions.AssertionError: pass
                
        def _notify(self, digits = None, obj = None):
            objs = [obj] if obj else self
            digits = digits or self.digits
            
            for obj in objs:
                obj.update(digits)
            
        def newDigits(self, digits):
            self.digits += digits
            self._notify(digits)

    Lis, 23 Мая 2017

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

    0

    1. 1
    2. 2
    3. 3
    SELECT CASE WHEN MIN (t.start_date) IS NULL THEN TO_DATE ('31/12/4712', 'DD/MM/YYYY')
           ELSE MIN (t.start_date) END
      FROM my_table t, ...

    NVL/COALESCE придумали лентяи!
    Это маленький кусочек запроса размером порядка 35 КБ. Там весь этот запрос прекрасен чуть менее чем полностью...

    climber, 23 Мая 2017

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