- 1
- 2
- 3
- 4
- 5
template<const bool Value>
const bool BoolToFunc(void) const
{
return Value;
};
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+162
template<const bool Value>
const bool BoolToFunc(void) const
{
return Value;
};
+96
procedure tnew.execute;
var
cod:utf8string;
id:byte;
captcha,sim,idc:string;
ss:TStringStream;
s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,
s11,s12,s13,s14,s15,s16,s17,s18,
s19,s20,s21,s22,s23,s24,s25,s26,
s27,s28,s29,s30,s31,s32,s33:utf8string;
FS:TFileStream;
Antigate: TAntigate;
begin
form3.IdHTTP1.Request.Referer :='http://www.aboutlive.ru/phpBB2/profile.php?mode=register';
cod:=form3.IdHTTP1.get('http://www.aboutlive.ru/phpBB2/profile.php?mode=register&agreed=true');
function Pars (T_, ForS, _T: string): string;
var
a, b: integer;
begin
Result := '';
if (T_ = '') or (ForS = '') or (_T = '') then
Exit;
a := Pos (T_, ForS);
if a = 0 then
Exit
else
a := a + Length (T_);
ForS := Copy (ForS, a, Length (ForS) - a + 1);
b := Pos (_T, ForS);
if b > 0 then
Result := Copy (ForS, 1, b - 1);
end;
idc:= pars('confirm_id" value="',cod,'" />');
sim:= pars('sid" value="',cod,'" />');
FS:=TFileStream.Create('captcha.png',FMCreate);
form3.IdHTTP1.Get('http://www.aboutlive.ru/phpBB2/profile.php?mode=confirm&id='+idc, FS);
FS.free;
form3.Image1.Picture.LoadFromFile('captcha.png');
Antigate := TAntigate.Create; // это разгадка капчи
antigate.Calc:=1;
antigate.MaxRetry:=3;
Antigate.Key := '';
Antigate.ImageFile := 'captcha.png';
captcha:=Antigate.Recognize;
Antigate.free;
form3.RichEdit1.Lines.Add('Капча: '+AnsiUpperCase(captcha));
form3.IdHTTP1.Request.Referer :='http://www.aboutlive.ru/phpBB2/profile.php?mode=register&agreed=true';
ss := TStringStream.Create;
s1:='username=sadsaddfsa12342';
s2:='[email protected]';
s3:='new_pasword=1234567';
s4:='pasword_confirm=1234567';
s5:='confirm_code='+captcha;
s6:='icq=';
s7:='aim=';
s8:='msn=';
s9:='yim=';
s10:='website=';
s11:='location=';
s12:='occupation=';
s13:='interests=';
s14:='signature=';
s15:='viewemail=0';
s16:='hideonline=0';
s17:='notifyreply=0';
s18:='notifypm=1';
s19:='popup_pm=1';
s20:='attachsig=1';
s21:='allowbbcode=1';
s22:='allowhtml=1';
s23:='allowsmilies=1';
s24:='language=russian';
s25:='style=1';
s26:='timezone=4';
s27:='dateformat=D M d, Y g:i a';
s28:='mode=register';
s29:='agreed=true';
s30:='coppa=0';
s31:='sid='+sim;
s32:='confirm_id='+idc;
s33:='submit=Отправить';
ss.WriteString (s1+'&'+s2+'&'+s3+'&'+s4+'&'+s5+'&'+s6+'&'+s7+'&'+s8+'&'+s9+'&'+s10+'&'+s11+'&'+s12+'&'+s13+'&'+s14+'&'+s15+'&'+s16+'&'+s17+'&'+s18+'&'+s19+'&'+s20+'&'+s21+'&'+s22+'&'+s23+'&'+s24+'&'+s25+'&'+s26+'&'+s27+'&'+s28+'&'+s29+'&'+s30+'&'+s31+'&'+s32+'&'+s33);
Что уж тут напишешь....
+163
function isInt($val) {
return is_int($val) || (string)(int)$val === (string)$val;
}
Проверка на целое число
+156
# Преоброзование расширения в MIME тип
function replace_type_in_mime($type) {
$type = strtolower($type);
$res = array("323" => "text/h323", "acx" => "application/internet-property-stream", "ai" => "application/postscript", "aif" => "audio/x-aiff", "aifc" => "audio/x-aiff", "aiff" => "audio/x-aiff", "asf" => "video/x-ms-asf", "asr" => "video/x-ms-asf", "asx" => "video/x-ms-asf", "au" => "audio/basic", "avi" => "video/x-msvideo", "axs" => "application/olescript", "bas" => "text/plain", "bcpio" => "application/x-bcpio", "bin" => "application/octet-stream", "bmp" => "image/bmp", "c" => "text/plain", "cat" => "application/vnd.ms-pkiseccat", "cdf" => "application/x-cdf", "cer" => "application/x-x509-ca-cert", "class" => "application/octet-stream", "clp" => "application/x-msclip", "cmx" => "image/x-cmx", "cod" => "image/cis-cod", "cpio" => "application/x-cpio", "crd" => "application/x-mscardfile", "crl" => "application/pkix-crl", "crt" => "application/x-x509-ca-cert", "csh" => "application/x-csh", "css" => "text/css", "dcr" => "application/x-director", "der" => "application/x-x509-ca-cert", "dir" => "application/x-director", "dll" => "application/x-msdownload", "dms" => "application/octet-stream", "doc" => "application/msword", "dot" => "application/msword", "dvi" => "application/x-dvi", "dxr" => "application/x-director", "eps" => "application/postscript", "etx" => "text/x-setext", "evy" => "application/envoy", "exe" => "application/octet-stream", "fif" => "application/fractals", "flr" => "x-world/x-vrml", "gif" => "image/gif", "gtar" => "application/x-gtar", "gz" => "application/x-gzip", "h" => "text/plain", "hdf" => "application/x-hdf", "hlp" => "application/winhlp", "hqx" => "application/mac-binhex40", "hta" => "application/hta", "htc" => "text/x-component", "htm" => "text/html", "html" => "text/html", "htt" => "text/webviewhtml", "ico" => "image/x-icon", "ief" => "image/ief", "iii" => "application/x-iphone", "ins" => "application/x-internet-signup", "isp" => "application/x-internet-signup", "jfif" => "image/pipeg", "jpe" => "image/jpeg", "jpeg" => "image/jpeg", "jpg" => "image/jpeg", "js" => "application/x-javascript", "latex" => "application/x-latex", "lha" => "application/octet-stream", "lsf" => "video/x-la-asf", "lsx" => "video/x-la-asf", "lzh" => "application/octet-stream", "m13" => "application/x-msmediaview", "m14" => "application/x-msmediaview", "m3u" => "audio/x-mpegurl", "man" => "application/x-troff-man", "mdb" => "application/x-msaccess", "me" => "application/x-troff-me", "mht" => "message/rfc822", "mhtml" => "message/rfc822", "mid" => "audio/mid", "mny" => "application/x-msmoney", "mov" => "video/quicktime", "movie" => "video/x-sgi-movie", "mp2" => "video/mpeg", "mp3" => "audio/mpeg", "mpa" => "video/mpeg", "mpe" => "video/mpeg", "mpeg" => "video/mpeg", "mpg" => "video/mpeg", "mpp" => "application/vnd.ms-project", "mpv2" => "video/mpeg", "ms" => "application/x-troff-ms", "mvb" => "application/x-msmediaview", "nws" => "message/rfc822", "oda" => "application/oda", "p10" => "application/pkcs10", "p12" => "application/x-pkcs12", "p7b" => "application/x-pkcs7-certificates", "p7c" => "application/x-pkcs7-mime", "p7m" => "application/x-pkcs7-mime", "p7r" => "application/x-pkcs7-certreqresp", "p7s" => "application/x-pkcs7-signature", "pbm" => "image/x-portable-bitmap", "pdf" => "application/pdf", "pfx" => "application/x-pkcs12", "pgm" => "image/x-portable-graymap", "pko" => "application/ynd.ms-pkipko", "pma" => "application/x-perfmon", "pmc" => "application/x-perfmon", "pml" => "application/x-perfmon", "pmr" => "application/x-perfmon", "pmw" => "application/x-perfmon", "pnm" => "image/x-portable-anymap");
if($ret == null) {
$ret = "application/x-unknown-content-type";
} else {
$ret = $res[$type];
}
return $ret;
}
Не знаю смешно ли это или нет, но разобраться в одной километровой строке будет ооочень интересно))))
Я вас огорчу, пришлось урезать на несколько тысяч символов эту дистанцию))
+80
boolean isTrue = false;
+154
// Parse strings looking for color tuples [255,255,255]
function getRGB(color) {
var result;
if (color && isArray(color) && color.length == 3)
return color;
if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
}
+157
function getAvailablePrivileges(Workset_Model_Object_Interface $resource, $where = null, $order = null, $limit = null, $offset = null, $offsetByPage = false) {
if (true == $offsetByPage) {
$offset = $this->getPageOffset($limit, $offset);
}
$table = $this->_getTable();
$select = $table->prepareSelect($where, $order, $limit, $offset);
$iselect = $this->_getTable()->select();
$iselect->from(
array('m' => $this->_getTable()->info(Zend_Db_Table_Abstract::NAME)),
array('id')
)
->join(
array('i' => $this->_getTable($this->_linkedObjectTableClass)->info(Zend_Db_Table_Abstract::NAME)),
"i.privilege_id = m.id",
array()
)
->where(
'i.resource_id = ?', $resource->getId()
);
$select->where("id not in(?)", new Zend_Db_Expr($iselect->assemble()));
$rowset = $table->fetchAll($select);
return $this->getIterator($rowset, array(
'countRows' => $this->_countAllRecords,
'filter' => $select
));
}
Из проекта на Zend
+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, никого не волнует.