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

    +166

    1. 1
    window.__debugMode = true; // Don't turn it off

    vk.com/js/al/common.js

    UnnamedUser, 15 Марта 2014

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

    +87

    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
    delim:=0;
    result:='';
    resulttemp:='';
    otv1:=trunc(rez);
    ott2:=rez-otv1;
    while otv1>=s1 do
    begin
    	delim:=delim+1;
    	r1:=otv1 div s1;
    	r2:=otv1 mod s1;
    	otv1:=r1;		
    	if (r2>=0) and (r2<=9) then
    		str(r2,resulttemp);			
    	if r2=10 then resulttemp:='a';
    	if r2=11 then resulttemp:='b';
    	if r2=12 then resulttemp:='c';
    	if r2=13 then resulttemp:='d';
    	if r2=14 then resulttemp:='e';
    	if r2=15 then resulttemp:='f';		
    	result:=result+resulttemp;
    end;	
    if (otv1>=0) and (otv1<=9) then
    	str(otv1,resulttemp);	
    if otv1=10 then resulttemp:='a';
    if otv1=11 then resulttemp:='b';
    if otv1=12 then resulttemp:='c';
    if otv1=13 then resulttemp:='d';
    if otv1=14 then resulttemp:='e';
    if otv1=15 then resulttemp:='f';	
    result:=result+resulttemp;
    delim:=length(result);
    resulttemp:=result;
    for otv1:=1 to delim do
    	result[otv1]:=resulttemp[delim+1-otv1];

    Перевод числа из десятичной системы счисления в систему счисления с основанием s1

    n924, 15 Марта 2014

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

    +133

    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
    if (other && other->client && other->s.number < MAX_CLIENTS)
    		{//player touched me
    			/*
    			char *text;
    			qboolean	keyTaken;
    			//give him my key
                            ...
    
    			*/
    			//rwwFIXMEFIXME: support for goodie/security keys?
    			/*
    			if ( keyTaken )
    			{//remove my key
    				NPC_SetSurfaceOnOff( self, "l_arm_key", 0x00000002 );
    				self->message = NULL;
    				//FIXME: temp pickup sound
    				G_Sound( player, G_SoundIndex( "sound/weapons/key_pkup.wav" ) );
    				//FIXME: need some event to pass to cgame for sound/graphic/message?
    			}
    			//FIXME: temp message
    			gi.SendServerCommand( NULL, text );
    			*/
    		}

    FIXMEFIXMEFIXME... Да ну нахуй, лучше все закомментим.

    gost, 15 Марта 2014

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

    +154

    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
    var SE = document.getElementsByTagName("a");
    for (var i = 0; i < SE.length; i++)
    {
        if (SE[i].href.indexOf('http://www.govnokod.ru/ratings/comment/') == 0
    	    && SE[i].href.indexOf('on') != -1)
    	{
    		plusIT(SE[i].href);
    		console.log(SE[i].href);
    	}
    }
    
    function plusIT(ID)
    {
    	$.get(
        ID,
        {},
        function(x) {
        });
    }

    gost, 15 Марта 2014

    Комментарии (30)
  5. Java / Говнокод #15485

    +72

    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
    public boolean fastItemEquals(ItemStack st, ItemStack nd) {
            if(nd == null) return false;
            if(st.hashCode() != nd.hashCode()) return false;
            if(st.getType() != nd.getType()) return false;
            if(!st.getItemMeta().getDisplayName().equals(nd.getItemMeta().getDisplayName())) return false;
            if(st.getEnchantments().size() != nd.getEnchantments().size()) return false;
            if(st.getItemMeta().getLore().size() != nd.getItemMeta().getLore().size()) return false;
            final List<String> 
                    lst = st.getItemMeta().getLore(),
                    lnd = nd.getItemMeta().getLore();
            for(int i = 0 ; i < st.getItemMeta().getLore().size() ; i++)
                if(!lst.get(i).equals(lnd.get(i))) return false;
            
            //return st.isSimilar(nd);
            return true;
        }
        
        public void fastItemRemove(Inventory inv, ItemStack st) {
            for(int i = 0 ; i < inv.getContents().length ; i++)
                if(fastItemEquals(st, inv.getContents()[i])) inv.clear(i); 
        }

    DiaLight, 15 Марта 2014

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

    +72

    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
    public boolean fastItemEquals(ItemStack st, ItemStack nd) {
            if(st.hashCode() == nd.hashCode()) return true;
            if(st.getType() != nd.getType()) return false;
            if(!st.getItemMeta().getDisplayName().equals(nd.getItemMeta().getDisplayName())) return false;
            if(st.getEnchantments().size() != nd.getEnchantments().size()) return false;
            if(st.getItemMeta().getLore().size() != nd.getItemMeta().getLore().size()) return false;
            final List<String> 
                    lst = st.getItemMeta().getLore(),
                    lnd = nd.getItemMeta().getLore();
            for(int i = 0 ; i < st.getItemMeta().getLore().size() ; i++)
                if(!lst.get(i).equals(lnd.get(i))) return false;
            
            //return st.isSimilar(nd);
            return true;
        }
        
        /* оригинал
        @Override
        public boolean isSimilar(ItemStack stack) {
            if (stack == null) {
                return false;
            }
            if (stack == this) {
                return true;
            }
            if (!(stack instanceof CraftItemStack)) {
                return stack.getClass() == ItemStack.class && stack.isSimilar(this);
            }
    
            CraftItemStack that = (CraftItemStack) stack;
            if (handle == that.handle) {
                return true;
            }
            if (handle == null || that.handle == null) {
                return false;
            }
            if (!(that.getTypeId() == getTypeId() && getDurability() == that.getDurability())) {
                return false;
            }
            return hasItemMeta() ? that.hasItemMeta() && handle.tag.equals(that.handle.tag) : !that.hasItemMeta();
        }
        */

    DiaLight, 15 Марта 2014

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

    +68

    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
    public boolean fastItemEquals(ItemStack st, ItemStack nd) {
            if(st.hashCode() == nd.hashCode()) return true;
            if(st.getType() != nd.getType()) return false;
            if(!st.getItemMeta().getDisplayName().equals(nd.getItemMeta().getDisplayName())) return false;
            if(st.getEnchantments().size() != nd.getEnchantments().size()) return false;
            if(st.getItemMeta().getLore().size() != nd.getItemMeta().getLore().size()) return false;
            List<String> 
                    lst = st.getItemMeta().getLore(),
                    lnd = nd.getItemMeta().getLore();
            for(int i = 0 ; i < st.getItemMeta().getLore().size() ; i++)
                if(!lst.get(i).equals(lst.get(i))) return false;
            
            //return st.isSimilar(nd);
            return true;
        }
        
        /* оригинал
        @Override
        public boolean isSimilar(ItemStack stack) {
            if (stack == null) {
                return false;
            }
            if (stack == this) {
                return true;
            }
            if (!(stack instanceof CraftItemStack)) {
                return stack.getClass() == ItemStack.class && stack.isSimilar(this);
            }
    
            CraftItemStack that = (CraftItemStack) stack;
            if (handle == that.handle) {
                return true;
            }
            if (handle == null || that.handle == null) {
                return false;
            }
            if (!(that.getTypeId() == getTypeId() && getDurability() == that.getDurability())) {
                return false;
            }
            return hasItemMeta() ? that.hasItemMeta() && handle.tag.equals(that.handle.tag) : !that.hasItemMeta();
        }
        */

    DiaLight, 15 Марта 2014

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

    +70

    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
    public boolean fastItemEquals(ItemStack st, ItemStack nd) {
            if(st.hashCode() != nd.hashCode()) return false;
            if(st.getType() != nd.getType()) return false;
            if(!st.getItemMeta().getDisplayName().equals(nd.getItemMeta().getDisplayName())) return false;
            if(st.getEnchantments().size() != nd.getEnchantments().size()) return false;
            //return st.isSimilar(nd);
            return true;
        }
        
        /* оригинал
        @Override
        public boolean isSimilar(ItemStack stack) {
            if (stack == null) {
                return false;
            }
            if (stack == this) {
                return true;
            }
            if (!(stack instanceof CraftItemStack)) {
                return stack.getClass() == ItemStack.class && stack.isSimilar(this);
            }
    
            CraftItemStack that = (CraftItemStack) stack;
            if (handle == that.handle) {
                return true;
            }
            if (handle == null || that.handle == null) {
                return false;
            }
            if (!(that.getTypeId() == getTypeId() && getDurability() == that.getDurability())) {
                return false;
            }
            return hasItemMeta() ? that.hasItemMeta() && handle.tag.equals(that.handle.tag) : !that.hasItemMeta();
        }
        */

    DiaLight, 15 Марта 2014

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

    +152

    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
    // Калькулятор умеющий умножать, делить, складывать и вычитать.
    
    
    <?php
    
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    	if (isset($_POST['num1'])) { 
    		if(is_numeric($_POST['num1'])) {
    			$num1 = strip_tags($_POST['num1']*1); 
    			}
    		} 
    		elseif (isset($_POST['num1'])) {
    			echo "Неверное значение Число 1";
    		}
    	if (isset($_POST['num2'])) { 
    		if(is_numeric($_POST['num2'])) {
    			$num2 = strip_tags($_POST['num2']*1); 
    			}
    		} 
    		elseif (isset($_POST['num2'])) {
    			echo "Неверное значение Число 2";
    		}
    	if (isset($_POST['operator'])) { 
    			$operator = $_POST['operator']; 
    		} 
    		elseif (isset($_POST['operator'])) {
    			echo "Неверное значение Оператор";
    		}
    		
    
    		switch ($operator) {
    		case '-':
    		$output .= $num1-$num2;break;
    		case '+':
    		$output .= $num1+$num2;break;
    		case '*':
    		$output .= $num1*$num2;break;
    		case '/':
    			if ($num2 == 0) {echo "На 0 делить нельзя";}else{$output .= $num1/$num2;break;}
    			default:
    				$output = "Неизвестный оператор ".$operator;
    	}
    }
    	
    ?>
    <h1>Калькулятор</h1>
    
    <?php
    
    if (isset($output)){
    	echo "Результат $output";
    }
    	
    ?>
    
    <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
    
    Число 1:<br />
    <input type="text" name="num1" /><br /><br />
    
    Оператор:<br />
    <input type="text" name="operator" /><br /><br />
    
    Число 2:<br />
    <input type="text" name="num2" /><br /><br />
    
    <input type="submit" value="Считать!" />
    
    </form>

    // Калькулятор умеющий умножать, делить, складывать и вычитать.

    Arthur, 14 Марта 2014

    Комментарии (27)
  10. C++ / Говнокод #15478

    +15

    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
    #include <iostream>
    #include <string>
    #include <vector>
    #include <list>
    #include <algorithm>
    #include <iterator>
    #include <sstream>
    #include <assert.h>
    using namespace std;
    template<class Container, class Iterator> 
    size_t position(Container&& c, Iterator pos){
        return size_t(distance(begin(c), pos));
    }
    template<class Container, class Iterator, class Iterator2> 
    string sposition(Container&& c, const pair<Iterator, Iterator2>& pos){
        ostringstream r;
        r << "(" << position(c, pos.first) << ", " << position(c, pos.second) << ")";
        return r.str();
    }
    template<class Container, class Value> 
    pair<typename remove_reference<Container>::type::iterator, typename remove_reference<Container>::type::iterator>
     binary_search(Container&& source, const Value& item){
        assert(is_sorted(begin(source), end(source)));
        const auto empty = make_pair(source.end(), source.end());
        auto l = begin(source), r=end(source), m=l;
        while(true){
            if(l==r)
                return empty;
            const auto lr = distance(l,r);
            m = next(l, lr/2);
            if(*m<item)
                l = m;
            if(*m>item)
                r = m;
            if(*m==item)
                break;
            if(l!=r && next(l)==r)
                return empty;
        }
        cout<<"part1"<<endl;
        auto l1=l, r1=m, l2=m, r2=r;
        while(true){
            const auto lr1 = distance(l1, r1);
            m = next(l1, lr1/2);
            if(*m<item)
                l1 = m;
            if(*m>=item)
                r1 = m;
            if(l1==r1 || (*l1<item && *r1>=item))
                break;
        }
        cout<<"part2"<<endl;
        while(true){
            const auto lr2 = distance(l2, r2);
            m = next(l2, lr2/2);
            if(*m<=item)
                l2 = m;
            if(*m>item)
                r2 = m;
            if(l2==r2 || (*l2>=item && (r==r2 || *r2>item)))
                break;
        }
        cout<<"part3"<<endl;
        return {r1, next(l2)};
    }
    int main(){
        vector<int> s{5,7,7,7,9,19,23};
        list<int> s2(s.begin()+1, s.end());
        cout<<sposition(s, binary_search(s, 7))<<endl;
        cout<<sposition(s2, binary_search(s2, 7))<<endl;
        cout<<sposition(s, binary_search(s, 9))<<endl;
        cout<<sposition(s, binary_search(s, 5))<<endl;
        cout<<sposition(s, binary_search(s, 23))<<endl;
        cout<<sposition(s, binary_search(s, 0))<<endl;
        vector<int> e;
        cout<<sposition(e, binary_search(e, 0))<<endl;
        cout<<sposition(s, binary_search(s, 25))<<endl;
        cout<<sposition(s, binary_search(s, 10))<<endl;
        return 0;
    }

    http://coliru.stacked-crooked.com/a/0f74a4661c06cd68
    Специально для @Пи, раз ему хачкель не нравится.

    LispGovno, 14 Марта 2014

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