- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
function onKeyDown() {
var key_f5 = 116; // 116 = F5
if (key_f5 == event.keyCode) {
event.keyCode = 27;
return false;
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+170
function onKeyDown() {
var key_f5 = 116; // 116 = F5
if (key_f5 == event.keyCode) {
event.keyCode = 27;
return false;
}
}
Запрещаем обновление страницы по F5.
+23
struct S* gpS;
struct S
{
// this class has no user-defined default ctor
void *operator new (size_t size, void*p, int i)
{
((S*)p)->i = i; // ordinarily, should not initialize
// memory contents inside placement new
return p;
}
int i;
};
Код с сайта майкрософт.
+58
// Released Under Affero General Public License, Version 3 (AGPL3)
// Author: [email protected]
$result = "TRUE";
$testable_string = strtolower($string_to_test);
$testable_string_length = strlen($string_to_test);
for($i_string = 0; $i_string < $testable_string_length; $i_string++)
{
$current_value_to_test = $testable_string[$i_string];
if( ($current_value_to_test != "0") &&
($current_value_to_test != "1") &&
($current_value_to_test != "2") &&
($current_value_to_test != "3") &&
($current_value_to_test != "4") &&
($current_value_to_test != "5") &&
($current_value_to_test != "6") &&
($current_value_to_test != "7") &&
($current_value_to_test != "8") &&
($current_value_to_test != "9") &&
($current_value_to_test != "a") &&
($current_value_to_test != "b") &&
($current_value_to_test != "c") &&
($current_value_to_test != "d") &&
($current_value_to_test != "e") &&
($current_value_to_test != "f") )
{
$result = "FALSE";
$i_string = $testable_string_length;
}
}
Смахивает на баян, но тем не менее.
http://php.net/manual/ru/function.is-numeric.php, из комментов.
+50
function StringForCountryInt($countryInt)
{
switch ($countryInt)
{
case "1" : return 'Afghanistan'; break;
case "2" : return 'Albania'; break;
case "3" : return 'Algeria'; break;
case "4" : return 'American Samoa'; break;
case "5" : return 'Andorra'; break;
case "6" : return 'Angola'; break;
case "7" : return 'Anguilla'; break;
case "8" : return 'Antarctica'; break;
// ....
// ....
// ....
case "239" : return 'Zimbabwe'; break;
}
}
MODx, evolution. Сниппет WebLoginPE.
В базе сохраняет ID страну, в классе вот такой метод для обратного преобразования :)
+51
$needMoreDataWM = ($exchange->getSumTo()->getCurrency()->getSystem()->getModule() == 'WebMoney' || $exchange->getSumFrom()->getCurrency()->getSystem()->getModule() == 'WebMoney') || $this->getRequest()->request->get('user_wmid');
$needMoreDataWM = $needMoreDataWM && !$user->getWmid();
$needMoreDataBank = ($exchange->getSumTo()->getCurrency()->getSystem()->getClass() == 'bank') && !$user->getVat() || $this->getRequest()->request->get('user_vat');
$needMoreData = $needMoreDataBank || $needMoreDataWM || !($user->getFullname() && $user->getPassport()) || $this->getRequest()->request->get('user_fullname') || $this->getRequest()->request->get('user_passport');
А что поделаешь, Doctrine принуждает
+133
#include<stdio.h>
#include<math.h>
int main()
{
long long a1,a2,a3,a4,t,p,l,m1,m,d1,d2,d3,d4,c1,c2,c3,c4,n,r;
double po;
m=1000000006;
scanf("%lld",&t);
while(t--)
{scanf("%lld",&n);
a1=1;a2=1;a3=1;a4=0;
d1=1;d2=0;d3=0;d4=1;
p=n-2;
while(p>0)
{ if(p%2!=0)
{ c1=((d1*a1)%m+(d3*a3)%m);
c2=((d1*a2)%m+(d2*a4)%m);
c3=((d3*a1)%m+(d4*a3)%m);
c4=((d3*a2)%m+(d4*a4)%m);
d1=c1;d2=c2;d3=c3;d4=c4;
}
c1=((a1*a1)%m+(a2*a3)%m);
c2=((a1*a2)%m+(a2*a4)%m);
c3=((a3*a1)%m+(a4*a3)%m);
c4=((a3*a2)%m+(a4*a4)%m);
a1=c1;a2=c2;a3=c3;a4=c4;
p=p/2;
}
l=((d1*1)%m+(d2*1)%m)%m;m1=((d3*1)%m+(d4*1)%m)%m;
po=pow(2,l);
r=llrintl(po)%(m+1);
printf("%lld\n",r);
}
return 0;
}
+124
Сайт ЦИК Украины, нынешние выборы народных депутатов.
http://cvk.gov.ua/vnd2012/wp300pt001f01=900.html
Говно везде - html, css, дизайн, юзабилити.
Для начала цитаты из html-кода страницы. В шапке мы видим
заголовок "XHTML 1.0 Transitional", а в коде - конструкции
в стиле 90-х годов, например:
<IMG src="img2012/bar-blue1.jpg" WIDTH=" 1" HEIGHT=20>
<table class=t1 cellspacing=0><tr>
<td width="50%" class="td2"><font class="f3"> © WWW ІАС "Вибори
народних депутатів України"
<td align="right" class="td2">
</table>
<td class=td10 align=center><font color="maroon">2</font>
<td class=td2><A class=a1 href="wp302pt001f01=900pf7171=52.html">
політична партія Всеукраїнське об’єднання "Батьківщина"</A></td>
В стилях тоже все в порядке, товарищи проявили
отличное знание спецификаций:
... height=14px; ...
... background-color: 666699; ...
... text-decoration: non ...
... background-color : none; ...
... valign: center; ...
Про отсутствие смысла я даже не говорю.
Вот, например, такой перл:
FONT.F1 {color: black; font-family:Arial;font-size: 14pt}
Сайт ЦИК Украины. Не сомневаюсь, что ООО "НПП "Медирент"" и ООО "НПП "Проком" получили за свою работу сотни нефти.
P.S. Плохо, что в самом говнокоде нельзя применять форматирование bb-тегами, для кучи было бы полезно.
+74
public void aMethod() {
try {
int t = 0;
t = t / t;
} catch (Exception e) {
System.out.println("aMethod");
for (StackTraceElement element : e.getStackTrace()) {
System.out.println("aMethod" + element.getClassName() + " " + element.getMethodName() + " " + element.getLineNumber() );
}
}
...//дополнительная "логика"
}
оригинальный способ узнать кто же вызвал aMethod
+141
var x = new { Items = new List<int> { 1, 2, 3 }.GetEnumerator() };
while (x.Items.MoveNext())
{
Console.WriteLine(x.Items.Current);
}
http://ideone.com/Qzdki
+19
Lennart lennart=new Lennart;
Надпись жёлтым цветом на гпавном меню minecraft.