- 1
 
sed -e 's/""/"/g;s/^"//g;s/"$//g;s/";/;/g;s/;"/;/g'
                                    Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 168
−110
sed -e 's/""/"/g;s/^"//g;s/"$//g;s/";/;/g;s/;"/;/g'
                                    Для любителей регулярок. Убирает экранирование строк в CSV.
−122
#!/usr/bin/perl
use strict;
# немного настроек
my $url = "http://govnokod.ru/comments";
my $min_delay = 2*60;
my $max_delay = 30*60;
my $delay_slowdown = 2;
# получение идентификатора последнего коммента
sub get_last_comment_info {
    print STDERR "Checking for the new comments...\n";
    my @content = `curl "$url" 2>/dev/null`;
    my $s = join(' ', @content);
    if ($s =~ /<a href=".*?\/(\d+)#comment(\d+)"/) {
        print STDERR "Last comment id was $2 in the thread $1\n";
        return ("thread" => $1, "comment" => $2);
    }
    print "Can't get new comments\n";
    return ();
}
# отправка сообщения
sub notify {
    my ($id) = @_;
    print STDERR "Sending notify about $id\n";
    `notify-send "Кто-то наложил в $id"`;
}
my $last_id = undef;
my $delay = $min_delay;
while (1) {
    # смотрим есть ли новый коммент
    if (my %r = get_last_comment_info()) {
        if (defined($last_id) && $r{"comment"} > $last_id) {
            $delay = $min_delay;
            notify($r{"thread"});
        }
        $last_id = $r{"comment"};
    }
    # спим
    print STDERR "Sleeping for $delay seconds...\n";
    sleep($delay);
    # пересчитываем задержку
    $delay = $delay * $delay_slowdown;
    $delay = $max_delay if ($delay > $max_delay);
}
                                    Говноскрипт для мониторинга сточных вод.
−17
if(0){}else for (... тут всякий код...) и тут всякий код
                                    Из реализации foreach в Qt. Не ГК. Кто первый скажет почему не ГК получит пирожок с полочки.
−84
data (,) a b = (,) a b
    deriving Generic
data (,,) a b c = (,,) a b c
    deriving Generic
data (,,,) a b c d = (,,,) a b c d
    deriving Generic
.......
data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__ g__ h__ i__ j__
 = (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__ g__ h__ i__ j__
    -- deriving Generic
{- Manuel says: Including one more declaration gives a segmentation fault.
                                    
            Вот такая вот реализация туплов:
http://www.haskell.org/ghc/docs/7.4.1/html/libraries/ghc-prim-0.2.0.0/src/GHC-Tuple.html
        
+25
/*
    Шаг по оси, представляет собой число из следующего ряда:
    ... 0.02 0.05 0.1 0.2 0.5 1 2 5 ...
    next и prev позволяют перемещаться в обе стороны по ряду
    после создания хранится число 1
*/
class Step
{
public:
    Step()
    {
        scale = 1; pr = 1; type=0;
    }
    void next()
    {
        // шаг вперед
        type++;
        if (type==1)
            scale = pr * 2;
        else if (type==2)
            scale = pr * 5;
        else
        {
            type = 0;
            pr *= 10;
            scale = pr;
        }
    }
    void prev()
    {
        // шаг назад
        type--;
        if (type==0)
            scale = pr;
        else if (type==1)
            scale = pr*2;
        else
        {
            type = 2;
            pr /= 10;
            scale = pr*5;
        }
    }
    operator float()
    {
        return scale;
    }
protected:
    float scale;    // текущее значение
    float pr;       // недомноженое значение 1 10 100 ...
    int type;       // 0 - x1 1 - x2 2 - x5
};
                                    http://govnokod.ru/10117 напомнил о том, как я когда-то рисовал график, и для меток на осях потребовались те же самые красивые значения [... 0.1 0.2 0.5 1 2 5 ...]
+138
memset(cb->chars, cb->width * cb->height, ' ');
                                    Мой однострочный эпик фейл.
+99
import Text.Parsec
import Control.Monad
romanToArabic :: String -> Either ParseError Integer
romanToArabic = parse (genParser (Nothing : Nothing : map Just romans)) "" where
    romans = [('M', 1000), ('D', 500), ('C', 100),
              ('L', 50), ('X', 10), ('V', 5), ('I', 1)]
    genParser [_] = eof >> return 0
    genParser (ten : five : one : rest) = state1 where
        state1 = choice [on one state2, on five state3, next]
        state2 = choice [on (sub2 five one) next, on (sub2 ten one) next,
                         on one state5, next]
        state3 = choice [on one state4, next]
        state4 = choice [on one state5, next]
        state5 = choice [on one next, next]
        next = genParser (one : rest)
        on Nothing _ = fail ""
        on (Just (ch, val)) nextNode = char ch >> nextNode >>= return . (+val)
        sub2 = liftM2 $ \(ch1, val1) (ch2, val2) -> (ch1, val1-2*val2)
                                    
            Кучка в ответ на http://govnokod.ru/9995#comment136058
> с другой стороны раз хаскель, то хотелось бы, например:
> *Main> romanToArabic "LC"
> Left (line 1, column 2):
> unexpected 'C'
> expecting "X", "IX", "IV", "V", "I" or end of input
        
+129
function assemble(var w:word;s:string):boolean;
.....
 else if length(cmd)=3 then
  begin
   {ТРЕХБУКВЕННЫЕ КОМАНДЫ}
   case cmd[1] of
    'a':case cmd[2] of
         'c':if cmd[3]='i' then
              begin
               code:=$ce;
               typ:=7;
              end;
         'd':case cmd[3] of
              'd':begin
                   code:=$80;
                   typ:=4;
                  end;
              'c':begin
                   code:=$88;
                   typ:=4;
                  end;
              'i':begin
                   code:=$c6;
                   typ:=7;
                  end;
             end;
..... еще 500 подобных строк ....
end;
                                    Прочитал http://govnokod.ru/10002 и вспомнил, как когда-то писал асм\дизасм\эмуль для 8080 на паскале.