- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
class CellEditor {
protected CellEditor(Composite parent, int style) {
this.style = style;
create(parent);
}
public void create(Composite parent) { ... }
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+71
class CellEditor {
protected CellEditor(Composite parent, int style) {
this.style = style;
create(parent);
}
public void create(Composite parent) { ... }
}
А вот это уже JFace...
5 строка подарил много положительных эмоций, при попытке сконструировать кастомный CellEditor
+87
class PartStack {
...
if (children[i] instanceof EditorSashContainer && !(this instanceof EditorStack)) {
...
}
...
}
class EditorStack extends PartStack { ... }
интересно смотрится сторка номер 3
исходники Eclipse
+165
enum TextAlignment
{
ALIGN_LEFT = 0,
ALIGN_RIGHT,
ALIGN_CENTER
};
...
if(m_textAlignment > 0 && maxLineWidth < m_desiredLength)
{
float offsetx = (m_desiredLength - maxLineWidth) / m_textAlignment;
...
}
Выравниваем текст. Универсальненько.
Что будет, если значения в энумке поменяются или добавится, к примеру, justify, никого не волнует.
+157
if($amount > 0) :
if (is_dir($directory)) {
if ($open_dir = opendir($directory)) {
$a = 0; $b = 0;
while (false !== ($file = readdir($open_dir))) {
if ($file != "." && $file != ".." && !is_dir($directory."/".$file)) {
$a++;
if($a > $min) {
$b++;
echo "<tr id=\"am-list-input\" valign=\"center\" height: 20px;><td align=\"left\" width=\"10%\">";
echo " <a href=\"index.php?am=mod[uploader]&delete=$file\"><img src=\"../images/mini_icons/del.png\" /></a> ";
if(in_array(strtolower(getExtension($file)), $gud_types)) echo "<span OnClick=\"CaricaFoto('".$directory."/".$file."')\" OnMouseOver=\"Tip('<img style="max-width: 400px" src="".$directory."/".$file."" >')\"><img style=\"cursor: help\" src=\"../images/mini_icons/display.png\" /></span>";
if(in_array(strtolower(getExtension($file)), explode(',', strtolower("mp3,wma,waw,amr,ape,bin,flac,m4a,mdi,ram")))) echo "<img src=\"modules/mod[uploader]/assets/type/sound.png\" />";
if(in_array(strtolower(getExtension($file)), explode(',', strtolower("3gp,avi,dat,flv,ifo,m4v,mkv,mov,mp4,rm,vob,wmv")))) echo "<img src=\"modules/mod[uploader]/assets/type/video.png\" />";
if(!in_array(strtolower(getExtension($file)), explode(',', strtolower("3gp,avi,dat,flv,ifo,m4v,mkv,mov,mp4,rm,vob,wmv,mp3,wma,waw,amr,ape,bin,flac,m4a,mdi,ram,jpg,jpeg,png,gif")))) echo "<img src=\"modules/mod[uploader]/assets/type/all.png\" />";
echo "</td><td width=\"70%\"><span style=\"display: block; cursor: pointer; color: #446eb8; font-weight: bold; line-height: 16px;\" onClick=\"document.getElementById('onclick').value='".str_replace("..", $conf_global["base_url"], $directory)."/".$file."'\" />".substr($file, 0, 100)."</span></td><td width=\"20%\">".formatsize(filesize($directory.DS.$file))."</td></tr>";
if($b == $max) : break; endif;
}
}
}
closedir($open_dir);
}
}
endif;
Грех не посмеятся над своими старыми проектами =)))
+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