- 1
- 2
- 3
- 4
- 5
- 6
if ( check < 50000 ) {
primaryAnimation = primaryAnimation;
} else {
int ani = (check - 50000) / 100;
primaryAnimation = _OptionalAnimations["Run"][ani];
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+116
if ( check < 50000 ) {
primaryAnimation = primaryAnimation;
} else {
int ani = (check - 50000) / 100;
primaryAnimation = _OptionalAnimations["Run"][ani];
}
Найдено в недрах загрузчика MD2-моделек для XNA.
+115
public void chkStatus_OnCheckedChanged(object sender, EventArgs e)
{
CheckBox chkStatus = (CheckBox)sender;
GridViewRow row = (GridViewRow)chkStatus.NamingContainer;
string cid = row.Cells[1].Text;
bool status = chkStatus.Checked;
string constr = @"Server=.\SQLEXPRESS;Database=TestDB;uid=waqas;pwd=sql;";
string query = "UPDATE Categories SET Approved = @Approved WHERE CategoryID = @CategoryID";
SqlConnection con = new SqlConnection(constr);
SqlCommand com = new SqlCommand(query, con);
com.Parameters.Add("@Approved", SqlDbType.Bit).Value = status;
com.Parameters.Add("@CategoryID", SqlDbType.Int).Value = cid;
con.Open();
com.ExecuteNonQuery();
con.Close();
LoadData();
}
Полезный говнокод
+157
// редиректим адреса без слеша на такие же со слешем
$uri = $_SERVER['REQUEST_URI'];
$is_file = false;
if ( (substr_count($uri,".php")>0) or (substr_count($uri,".html")>0) ) {
$is_file = true;
}
if ($is_file == false) {
$len_uri = strlen($uri);
// находим последнее вхождение слеша
$reverst_str = strrev($uri);
//die($reverst_str);
$last_slash = strpos($reverst_str,"/");
//die($last_slash);
if ($last_slash!==0) {
$uri .="/";
$status = "301 Found";
//header("Status: ".$status);
header('HTTP/1.1 301 Moved Permanently');
header("Location: http://www.thermostudio.ru"."$uri");
exit();
}
}
встретилось в проекте одном жаль автор не подписался, увековечить бы...
+115
procedure info_();
var
i:integer;
ActivityCategory,stroka,strok,stroka_sopr,http1100,http_sopr,tag,tag_sopr,until_date,date_:string;
f1100,f_sopr,inf:textfile;
begin //главный
clear();
if form1.radioGroup1.ItemIndex=0 then begin
http1100:='\\server1\Отдел 1\Program Files\Prof\profiki\1100\'+m+'.smc';
http_sopr:='\\server1\Отдел 1\Program Files\prof\profiki\сопроводительное\'+m+'.smc';
end;
if form1.radioGroup1.ItemIndex=1 then begin
http1100:='\\server1\Отдел 1\Program Files\Prof\banki\1100\'+m+'.smc';
http_sopr:='\\server1\Отдел 1\Program Files\prof\banki\сопроводительное\'+m+'.smc';
end;
if form1.radioGroup1.ItemIndex=2 then begin
http1100:='\\server1\Отдел 1\Program Files\Prof\YK\1100\'+m+'.smc';
http_sopr:='\\server1\Отдел 1\Program Files\prof\YK\сопроводительное\'+m+'.smc';
end;
if form1.radioGroup1.ItemIndex=3 then begin
http1100:='\\server1\Отдел 1\Program Files\Prof\NPF\1100\'+m+'.smc';
http_sopr:='\\server1\Отдел 1\Program Files\prof\NPF\сопроводительное\'+m+'.smc';
end;
if form1.radioGroup1.ItemIndex=4 then begin
http1100:='\\server1\Отдел 1\Program Files\Prof\REGISTRATOR\1100\'+m+'.smc';
http_sopr:='\\server1\Отдел 1\Program Files\prof\REGISTRATOR\сопроводительное\'+m+'.smc';
end;
Пытался перенести в другую папку программу, после чего она по сути перестала работать, ругаясь ошибкой 63. Нашел ее исходники и увидел ЭТО... это лишь 5-10% всей процедуры, которая мало того, что ищет XML-файлы по определенному пути, так еще и парсит их...
+74
private static java.util.Hashtable<String, Session> sessions =
new java.util.Hashtable<String, Session>();
...
public static SessionOperations[] getSessions() {
int cnt = sessions.size();
SessionOperations[] res = new SessionOperations[cnt];
java.util.Enumeration<String> e = sessions.keys();
for( int i = 0; i < res.length; i++ ) {
String sid = e.nextElement();
res[i] = sessions.get( sid ).getOperations( sid );
}
return res;
}
Удаление из sessions между получением размера и набора ключей приводит к весьма печальным последствиям...
P.S. В результате в течение трех суток в production не удалялись оставленные сессии (без Logout), sessions отожрал 600М и всё свалилось с OOM.
+155
#include <a_samp>
new objects[MAX_OBJECTS];
public OnFilterScriptInit()
{
objects[0] = CreateObject(980, -2491.1276855469, -129.08126831055, 27.397054672241, 0, 0, 90.675659179688);
objects[1] = CreateObject(980,-2459.8862304688,-152.13926696777,27.652730941772,0,356,0);
objects[2] = CreateObject(980,-2446.0773925781,-82.466796875,35.984577178955,0,356,0);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/garage", cmdtext, true, 10) == 0)
{
MoveObject(objects[0], -2491.1276855469, -129.08126831055, 20, 2);
SetTimer("VTimer", 10000, 0);
return 1;
}
return 0;
}
forward VTimer();
public VTimer()
{
MoveObject(objects[0], -2491.1276855469, -129.08126831055, 27.397054672241, 2);
return 1;
}
+154
function getDateFromTime($dataTime){
$strDate = date('d-m-Y', $dataTime);
$arrDate = explode('-', $strDate);
return mktime(0, 0, 0, $arrDate[1], $arrDate[0], $arrDate[2]);
}
руки-жопа-голова%)
+159
void AClass::registerApplication( int pCaller )
{
if ( mRegistry == NULL )
{
// we will be the first application in registry
mRegistry = createRegistryElement( pCaller );
}
else
{
// there are other applications already registered
// first create registry entry
Application *lApplication = NULL;
lApplication = createRegistryElement( pCaller );
// put entry in front
lApplication->mNext = mRegistry;
mRegistry = lApplication;
}
}
добавляем новый элемент в односвязный список. mRegister голова списка. кто не видит говна - идти читать матчасть.
+153
try
{
sw = gcnew StreamWriter(GetIniFileName());
}
catch(UnauthorizedAccessException^ e)
{
MessageBox::Show( "Access is denied.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(ArgumentNullException^ e)
{
MessageBox::Show( e->ParamName + ": File path is null.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(ArgumentException^ e)
{
MessageBox::Show( e->ParamName + ": Wrong file path.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(DirectoryNotFoundException^ e)
{
MessageBox::Show( "The specified path is invalid, such as being on an unmapped drive.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(PathTooLongException^ e)
{
MessageBox::Show( "The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. ", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(IOException^ e)
{
MessageBox::Show( "File path includes an incorrect or invalid syntax for file name, directory name, or volume label syntax. ", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(SecurityException^ e)
{
MessageBox::Show( "The caller does not have the required permission." + e->ToString(), "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(System::Exception^ e)
{
ShowException(e);
return;
}
Обработка исключений.
+169
const void* const relay(const TrigClass& Overloading=*((TrigClass*)(NULpoter))){
if(&Overloading==NULpoter){