- 1
while dlg_SmplSpk.ShowModal = mrOk do ;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+102
while dlg_SmplSpk.ShowModal = mrOk do ;
Узрел такое! Срочно к себе в рецепты прогрессивного программирования!
Сделано это для того, чтобы окно не закрывалось при подтверждении всех сделанных действий.
Закрываться должно только при нажатии кнопочки "Закрыть".
Отсюда непонятен ход мыслей автора сия творения.
−364
Если (ДатаГод(ДатаДок) < 2010) ИЛИ (ДатаГод(ДатаДок) < 2010 ) Тогда
Строка кода из типовой конфигурации 1С: Бухгалтерия 7.7, релиз 522
No comments ...
+124
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
;;; Copyright (C) 2011, Dmitry Ignatiev <[email protected]>
;;; Permission is hereby granted, free of charge, to any person
;;; obtaining a copy of this software and associated documentation
;;; files (the "Software"), to deal in the Software without
;;; restriction, including without limitation the rights to use, copy,
;;; modify, merge, publish, distribute, sublicense, and/or sell copies
;;; of the Software, and to permit persons to whom the Software is
;;; furnished to do so, subject to the following conditions:
;;; The above copyright notice and this permission notice shall be
;;; included in all copies or substantial portions of the Software.
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
;;; DEALINGS IN THE SOFTWARE
(in-package #:neural-flow)
;; Stolen from `trivial-garbage'
#+openmcl
(defvar *weak-pointers* (cl:make-hash-table :test 'eq :weak :value))
#+(or allegro openmcl lispworks)
(defstruct (weak-pointer (:constructor %make-weak-pointer))
#-openmcl pointer)
(declaim (inline make-weak-pointer))
(defun make-weak-pointer (object)
#+sbcl (sb-ext:make-weak-pointer object)
#+(or cmu scl) (ext:make-weak-pointer object)
#+clisp (ext:make-weak-pointer object)
#+ecl (ext:make-weak-pointer object)
#+allegro
(let ((wv (excl:weak-vector 1)))
(setf (svref wv 0) object)
(%make-weak-pointer :pointer wv))
#+openmcl
(let ((wp (%make-weak-pointer)))
(setf (gethash wp *weak-pointers*) object)
wp)
#+corman (ccl:make-weak-pointer object)
#+lispworks
(let ((array (make-array 1)))
(hcl:set-array-weak array t)
(setf (svref array 0) object)
(%make-weak-pointer :pointer array)))
(declaim (inline weak-pointer-value))
(defun weak-pointer-value (weak-pointer)
"If WEAK-POINTER is valid, returns its value. Otherwise, returns NIL."
#+sbcl (values (sb-ext:weak-pointer-value weak-pointer))
#+(or cmu scl) (values (ext:weak-pointer-value weak-pointer))
#+clisp (values (ext:weak-pointer-value weak-pointer))
#+ecl (values (ext:weak-pointer-value weak-pointer))
#+allegro (svref (weak-pointer-pointer weak-pointer) 0)
#+openmcl (values (gethash weak-pointer *weak-pointers*))
#+corman (ccl:weak-pointer-obj weak-pointer)
#+lispworks (svref (weak-pointer-pointer weak-pointer) 0))
;;Red-black tree
(declaim (inline %node %nleft %nright %nparent %nred %ndata %ncode
(setf %nleft) (setf %nright) (setf %nparent)
(setf %nred) (setf %ndata) (setf %ncode)))
(defstruct (%node (:constructor %node (data code parent red))
(:conc-name %n))
(left nil :type (or null %node))
(right nil :type (or null %node))
(parent nil :type (or null %node))
(red nil)
data
(code 0 :type (integer 0 #.most-positive-fixnum)))
(declaim (inline %tree %tree-root (setf %tree-root)))
(defstruct (%tree (:constructor %tree ())
(:copier %copy-tree))
(root nil :type (or null %node)))
(declaim (inline rotate-left))
(defun %rotate-left (tree node)
(declare (type %tree tree) (type %node node)
(optimize (speed 3) (safety 0)))
(let ((right (%nright node)))
(when (setf (%nright node) (%nleft right))
(setf (%nparent (%nleft right)) node))
(if (setf (%nparent right) (%nparent node))
(if (eq node (%nleft (%nparent node)))
(setf (%nleft (%nparent node)) right)
(setf (%nright (%nparent node)) right))
(setf (%tree-root tree) right))
Вылезли глаза! Как на этом можно писать?
+177
auto r=disable(reinterpret_cast<void*>(static_cast<Efrag*>(const_cast<Efrig*>(ef))));
Три мудреца в одном тазу
Пустились по морю в грозу.
Будь попрочнее старый таз,
Длиннее был бы мой рассказ.
..............Самуил Маршак
+147
#include <stdio.h>
int main(int t,int _,char*a)
{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a
)&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_,
t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\
,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\
+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){n\
l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
#'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/")
:t<-50?_==*a ?putchar(a[31]):main(-65,_,a+1):main((*a == '/')+t,_,a\
+1 ):0<t?main ( 2, 2 , "%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc \
i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}
Консольный вывод этой программы:
On the first day of Christmas my true love gave to me
a partridge in a pear tree.
On the second day of Christmas my true love gave to me
two turtle doves
and a partridge in a pear tree.
...
[Все не вместилось]
...
On the tenth day of Christmas my true love gave to me
ten lords a-leaping,
nine ladies dancing, eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.
On the eleventh day of Christmas my true love gave to me
eleven pipers piping, ten lords a-leaping,
nine ladies dancing, eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.
On the twelfth day of Christmas my true love gave to me
twelve drummers drumming, eleven pipers piping, ten lords a-leaping,
nine ladies dancing, eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.
+172
/* Теперь задаём сами функции перекодировки translita в кириллицу и обратно. Вот код: */
function ruslat ($string) # Задаём функцию перекодировки кириллицы в транслит.
{
$string = ereg_replace("ж","zh",$string);
$string = ereg_replace("ё","yo",$string);
$string = ereg_replace("й","i",$string);
$string = ereg_replace("ю","yu",$string);
$string = ereg_replace("ь","'",$string);
$string = ereg_replace("ч","ch",$string);
$string = ereg_replace("щ","sh",$string);
$string = ereg_replace("ц","c",$string);
$string = ereg_replace("у","u",$string);
$string = ereg_replace("к","k",$string);
$string = ereg_replace("е","e",$string);
$string = ereg_replace("н","n",$string);
$string = ereg_replace("г","g",$string);
$string = ereg_replace("ш","sh",$string);
$string = ereg_replace("з","z",$string);
$string = ereg_replace("х","h",$string);
$string = ereg_replace("ъ","''",$string);
$string = ereg_replace("ф","f",$string);
$string = ereg_replace("ы","y",$string);
$string = ereg_replace("в","v",$string);
$string = ereg_replace("а","a",$string);
$string = ereg_replace("п","p",$string);
$string = ereg_replace("р","r",$string);
$string = ereg_replace("о","o",$string);
$string = ereg_replace("л","l",$string);
$string = ereg_replace("д","d",$string);
$string = ereg_replace("э","yе",$string);
$string = ereg_replace("я","jа",$string);
$string = ereg_replace("с","s",$string);
$string = ereg_replace("м","m",$string);
$string = ereg_replace("и","i",$string);
$string = ereg_replace("т","t",$string);
$string = ereg_replace("б","b",$string);
$string = ereg_replace("Ё","yo",$string);
$string = ereg_replace("Й","I",$string);
$string = ereg_replace("Ю","YU",$string);
$string = ereg_replace("Ч","CH",$string);
$string = ereg_replace("Ь","'",$string);
$string = ereg_replace("Щ","SH'",$string);
$string = ereg_replace("Ц","C",$string);
$string = ereg_replace("У","U",$string);
$string = ereg_replace("К","K",$string);
$string = ereg_replace("Е","E",$string);
$string = ereg_replace("Н","N",$string);
$string = ereg_replace("Г","G",$string);
$string = ereg_replace("Ш","SH",$string);
$string = ereg_replace("З","Z",$string);
$string = ereg_replace("Х","H",$string);
$string = ereg_replace("Ъ","''",$string);
$string = ereg_replace("Ф","F",$string);
$string = ereg_replace("Ы","Y",$string);
$string = ereg_replace("В","V",$string);
$string = ereg_replace("А","A",$string);
$string = ereg_replace("П","P",$string);
$string = ereg_replace("Р","R",$string);
$string = ereg_replace("О","O",$string);
$string = ereg_replace("Л","L",$string);
$string = ereg_replace("Д","D",$string);
$string = ereg_replace("Ж","Zh",$string);
$string = ereg_replace("Э","Ye",$string);
$string = ereg_replace("Я","Ja",$string);
$string = ereg_replace("С","S",$string);
$string = ereg_replace("М","M",$string);
$string = ereg_replace("И","I",$string);
$string = ereg_replace("Т","T",$string);
$string = ereg_replace("Б","B",$string);
return $string;
}
Нашел сие чудо на: http://protoplex.ru/lib/?showid=89
+175
template<class Exception>
bool GenerateException(const Exception* const e)
{
throw e;
delete e;
return true;
}
Продолжение цикла говнокодов про исключения из того же самого проекта.
Проблем от неё почти нет, тк в основном исключения генерятся так:
ExceptionТакойто e;
GenerateException(&e);
+166
$pif=explode('?',$_SERVER['REQUEST_URI']);
$tym=explode('=',$pif[1]);
Вот такой вот способ получить значение переменной из GET запроса вида:
http://127.0.0.1/component/index.php?name=r37.edoc
+170
$p = array(1,0,0,0,0,0,0,0,0,0); // вероятность 1/10
$a = array();
for($i=0; $i<100; $i++)
$a[] = $p[mt_rand(0, count($p)-1)];
Это — заполнение массива случайными значениями с заданной вероятностью 1 к 10. =)
+164
RewriteRule ^tn_([0-9]*)x([0-9]*)_([a-z]+)_([0-9]*)_([0-9]+)_(.*)_([c]*)_([f]*)_([0-9]*).[a-z]*$ перенос
/index.php?exception=imageModification&width=$1&height=$2&module=$3&id=$4&time=$5&name=$6&crop=$7&force=$8&query=$9&file_name=%{REQUEST_URI} [L]
В .htaccess:
Победа над ресайзом картинок. Чуваки еще не успели ощутить на себе всю мощь ананимуса