1. Куча / Говнокод #14374

    +126

    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
    cnt_queue_files()->
      Command = "ls "++code:lib_dir(messaging, priv)++" | grep -v ^l | wc -l",
      case catch list_to_integer(string:strip(os:cmd(Command), right, $\n)) of 
        X when is_integer(X) -> X;
        _ -> 0
      end. 
    
    clear_queue_files()->
      Command = "rm "++code:lib_dir(messaging, priv)++"/*",
      os:cmd(Command).
    
    create_empty_queue_file()->
      Command = "touch "++code:lib_dir(messaging, priv)++"/~"++?COLD_HALT_EXCHANGE++".que",
      os:cmd(Command).

    Ну просто похапе какое-то.

    kovyl2404, 16 Января 2014

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

    +127

    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
    % restarter.erl
    
    -module(restarter).
    % Save it to restart the node!
    
    % где-то в коде при запуске приложения
       ....
       ok = sync:go(),
       sync:onsync(fun(Mods) ->
                    case lists:member(restarter, Mods) of
                        true -> 
                            lager:warning("Restarting node!"),
                            init:restart(); 
                        _ -> ok
                    end  
                end),
       ....

    Клуб веселых и находчивых эрлангеров.
    Придумал такую фичу: если мне во время разработки надо перезапустить тестовую ноду, я просто жму сохранить в открытом файле restarter.erl
    Sync подхватывает пересохраненный файл, компилит его и вызывает коллбэк со списком измененных модулей. Собственно, если рестартер среди них, то нода перезапускается :)

    tirinox, 16 Января 2014

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

    +150

    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
    $up = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".$x."_".($y-1)."_'"));
    $down = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".$x."_".($y+1)."_'"));
    $right = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".($x+1)."_".($y)."_'"));
    $left = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".($x-1)."_".($y)."_'"));
    $lup = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".($x-1)."_".($y-1)."_'"));
    $rup = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".($x+1)."_".($y-1)."_'"));
    $rdown = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".($x+1)."_".($y+1)."_'"));
    $ldown = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".($x-1)."_".($y+1)."_'"));
    if (@$up["name"]) $up = 1; else $up=0;
    if (@$down["name"]) $down = 1;  else $down=0;
    if (@$right["name"]) $right = 1;  else $right=0;
    if (@$left["name"]) $left = 1; else $left=0;
    if (@$lup["name"]) $lup = 1; else $lup=0;
    if (@$rup["name"]) $rup = 1; else $rup=0;
    if (@$rdown["name"]) $rdown = 1;  else $rdown=0;
    if (@$ldown["name"]) $ldown = 1;  else $ldown=0;
    if ($_GET["go_nature"]=='up' and $up==1) $y-=1;
    if ($_GET["go_nature"]=='down' and $down==1) $y+=1;
    if ($_GET["go_nature"]=='left' and $left==1) $x-=1;
    if ($_GET["go_nature"]=='right' and $right==1) $x+=1;
    if ($_GET["go_nature"]=='lup' and $lup==1) $x-=1;
    if ($_GET["go_nature"]=='rup' and $rup==1) $x+=1;
    if ($_GET["go_nature"]=='lup' and $lup==1) $y-=1;
    if ($_GET["go_nature"]=='rup' and $rup==1) $y-=1;
    if ($_GET["go_nature"]=='rdown' and $rdown==1) $x+=1;
    if ($_GET["go_nature"]=='ldown' and $ldown==1) $x-=1;
    if ($_GET["go_nature"]=='rdown' and $rdown==1) $y+=1;
    if ($_GET["go_nature"]=='ldown' and $ldown==1) $y+=1;

    вксняшка

    SuperChel, 16 Января 2014

    Комментарии (35)
  4. Java / Говнокод #14371

    +79

    1. 1
    2. 2
    3. 3
    4. 4
    if(VovaJSONparser.ParseText(d, text))
    {
    	return d;
    }

    Вова, фас!

    arbuzz, 16 Января 2014

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

    +119

    1. 1
    "По какой-то причине не удается завершить установку вин 8.1"

    Информативное сообщение при апдейте 8.0 -> 8.1.

    bormand, 16 Января 2014

    Комментарии (269)
  6. Objective C / Говнокод #14369

    −104

    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
    -(BOOL) wasChanged
    {
        BOOL a,b,c,d,e,f;
        if (dueDate == nil) {
            a = (_task.dueDate == nil?YES:NO);
        }
        else
            a = [dueDate isEqualToDate:_task.dueDate];
        if (reminderTime == nil) {
            b = (_task.reminderTime == nil?YES:NO);
        }
        else
            b = [reminderTime isEqualToDate:_task.reminderTime];
        c = (importance == _task.importance?YES:NO);
        d = (reccurentType == _task.reccurentType?YES:NO);
        e = [list isEqualToString:_task.parentID];
        f = [body isEqualToString:_task.body];
        if (a && b && c && d && e && f) {
            return NO ;
        }
        return YES;
    }

    Вот такая радость в проекте..

    Jackos, 15 Января 2014

    Комментарии (25)
  7. Pascal / Говнокод #14368

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if mas[i-1,j-1]=true then begin neib[m]:=true; inc(m); end; //считаем соседей
    if mas[i-1,j]=true then begin neib[m]:=true; inc(m); end;
    if mas[i-1,j+1]=true then begin neib[m]:=true; inc(m); end;
    if mas[i,j-1]=true then begin neib[m]:=true; inc(m); end;
    if mas[i,j+1]=true then begin neib[m]:=true; inc(m); end;
    if mas[i+1,j-1]=true then begin neib[m]:=true; inc(m); end;
    if mas[i+1,j]=true then begin neib[m]:=true; inc(m); end;
    if mas[i+1,j+1]=true then begin neib[m]:=true; inc(m); end;

    Знакомый человек реализовывал «Жизнь» на делфях...

    POPSuL, 15 Января 2014

    Комментарии (75)
  8. PHP / Говнокод #14367

    +149

    1. 1
    2. 2
    3. 3
    array_unshift($available, $noSize);
    if (is_null($noSize))
        unset($available[0]);

    CRRaD, 15 Января 2014

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

    +139

    1. 1
    #include "intel_glamor.h"

    Строка из драйвера видеокарты X11: intel_driver.c.
    Гламур спасёт мир.

    laMer007, 15 Января 2014

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

    +21

    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
    template <int N>
    void Ololo ()
    {
    	var
    		i : integer;
    	begin
    		for i := 0 to N-1 do begin
    			WriteLn(i, ' ');
    		end;
    	end;
    }
    
    int main () 
    {
    	return 0;
    }
    
    Compiling...
    Test.cpp
    Linking...
    
    Build log was saved at "file://c:\Users\TarasB\Documents\Visual Studio Projects\Test\Debug\BuildLog.htm"
    Test - 0 error(s), 0 warning(s)
    
    
    ---------------------- Done ----------------------
    
        Build: 1 succeeded, 0 failed, 0 skipped

    MSVS2003

    TarasB, 15 Января 2014

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