- 1
- 2
- 3
- 4
if ((u[i]!=100500)&&(v[j]==100500))
v[j]=matr[i+1][j+1].cost-u[i];
if ((u[i]==100500)&&(v[j]!=100500))
u[i]=matr[i+1][j+1].cost-v[j];
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+140
if ((u[i]!=100500)&&(v[j]==100500))
v[j]=matr[i+1][j+1].cost-u[i];
if ((u[i]==100500)&&(v[j]!=100500))
u[i]=matr[i+1][j+1].cost-v[j];
пересчет платежей в ТЗЛП
+161
if($age != '') {
$d_m_y = explode('-', $age); // Разделяем на day(0) month(1) year(2)
// ГЕНЕРАЦИЯ ФОРМЫ С ДНЕМ РОЖДЕНИЯ
$vars['bday'] = "<select name=\"b_day\">\n<option>-</option>\n";
$i = 1;
while ($i <= 31) {
if($d_m_y[0] == $i) {
$sel = ' selected';
} else {
$sel = '';
}
$vars['bday'] .= '<option'.$sel.'>'.$i."</option>\n";
$i++;
}
$vars['bday'] .= "</select>\n";
// ГЕНЕРАЦИЯ СПИСКА С МЕСЯЦАМИ
$i = 1;
$vars['bmonth'] = "<select name=\"b_month\">\n<option>-</option>\n";
while ($i <= 12) {
if($d_m_y[1] == $i) {
$sel = ' selected';
} else {
$sel = '';
}
$vars['bmonth'] .= '<option'.$sel.'>'.$i."</option>\n";
$i++;
}
$vars['bmonth'] .= "</select>\n"; // Месяц ДР при ред
// ГЕНЕРАЦИЯ СПИСКА С ГОДАМИ
$i = 1940;
$vars['byear'] = "<select name=\"b_year\"\n<option>-</option>\n"; // Год ДР при ред
while ($i <= 2003) {
if($d_m_y[2] == $i) {
$sel = ' selected';
} else {
$sel = '';
}
$vars['byear'] .= '<option'.$sel.'>'.$i."</option>\n";
$i++;
}
$vars['byear'] .= "</select>\n";
$vars['use_age'] = false; // ОТКЛЮЧАЕМ ПОКАЗ ПУСТОГО СПИСКА
} else {
$vars['use_age'] = true;
$vars['bday'] = false;
$vars['bmonth'] = false;
$vars['byear'] = false;
}
Генерация SELECT'ов для выбора даты рождения
−864
comment on column XXX.status
is '0 -- вопрос включен, 1-- выкл';
+124
private void TextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Space)
{
TextBox box = sender as TextBox;
int start = box.SelectionStart;
int length = box.SelectionLength;
if (length == 0)
{
box.Text = box.Text.Insert(start + length, " ");
box.SelectionStart = start + 1;
}
else
{
string str1 = box.Text.Substring(0, start);
string str2 = box.Text.Substring(start + length);
box.Text = str1 + " " + str2;
box.SelectionStart = start + 1;
}
e.Handled = true;
}
}
Отборный говнокод выращенный на территории Индии.
Видимо им зарплату действительно за строчки кода платят.
−860
-- Из простого...
select kdet, cexnum, cex, last_value(cex) over(partition by kdet) as final_cex
from xxtpa_rout_aztpa_v;
-- Сделаем сложное...
select t.*, max(max_cex) over(partition by kdet, rout_num) max_cex
from (select t.*, case cex_num when max(cex_num) over(partition by t.kdet, t.rout_num) then t.cex else null end max_cex
from xxtpa_rout_aztpa_v t) t;
Пример того, как НЕ применять KISS-принцип.
+158
foreach ($firstQueryRes as $row)
{
$K = $this->ccnm;
$U = $this->getFncByCategory($row->category); // compile material href //
$R = $row->category;
$W = $row->date;
$A = $row->huu_1;
$materialHref[$row->id_all] = site_url("$K/$U/$R/$W/$A");
$materialTitle[$row->id_all] = $row->name;
}
Задание: расшифруйте какое польское плохое слово здесь инкапсулировано.
+72
public class Tm_SP_RP extends Tm_Service implements IObject{
private static final String m_MsgProfileStore =
"UPDATE TM_SP_RP SET strMsgProfile=? WHERE nServiceID=?";
private static final String m_WorkaroundHack =
"SELECT data_type FROM user_tab_columns WHERE table_name='TM_SP_RP' AND column_name='STRMSGPROFILE'";
private String strMsgProfile = null;
/* Здесь ещё разные всякие методы */
private static String getWorkaroundType(Connection conn) throws SQLException
{
PreparedStatement stmt = conn.prepareStatement(m_WorkaroundHack);
try
{
ResultSet rset = stmt.executeQuery();
try
{
if (!rset.next())
return "VARCHAR2";
return rset.getString(1);
}
finally
{
if (rset != null)
rset.close();
}
}
finally
{
if (stmt!=null)
stmt.close();
}
}
public void storeMsgProfile(Connection conn) throws SQLException
{
String w_around = getWorkaroundType(conn);
PreparedStatement stmt = conn.prepareStatement(m_MsgProfileStore);
try
{
if (w_around.equalsIgnoreCase("VARCHAR2") ||
w_around.equalsIgnoreCase("VARCHAR"))
{
if (strMsgProfile == null)
stmt.setNull(1, Types.NULL);
else
stmt.setString(1, strMsgProfile);
}
else
{
byte []data = (strMsgProfile == null) ?
new byte[0] : strMsgProfile.getBytes();
stmt.setBytes(1, data);
}
stmt.setLong(2, this.getId());
stmt.executeUpdate();
}
finally
{
if (stmt!=null)
stmt.close();
}
}
}
Комбинация из багованных JDBC-дров Oracle и работающего с ним Hibernate (чтоб он сдох) иногда заставляет рождать вот такие хитрые workaround-хаки. Несколько баз, в одной тип поля - LONG, в другой - VARCHAR2.
+96
function OnShape(sh: TShape; X, Y: Integer) : TBrushStyle;
var r, cx, cy, d2: Integer;
begin
r := sh.Width div 2;
cx := sh.Left + r;
cy := sh.Top + r;
d2 := (X - cx) * (X - cx) + (Y - cy) * (Y - cy);
OnShape := bsClear;
if d2 < r*r then OnShape := bsSolid;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Shape1.Brush.Color := clRed;
Shape1.Brush.Style := OnShape(Shape1, X, Y);
Shape2.Brush.Color := clLime;
Shape2.Brush.Style := OnShape(Shape2, X, Y);
Shape3.Brush.Color := clYellow;
Shape3.Brush.Style := OnShape(Shape3, X, Y);
end;
Откуда бы вы думали это? Правильно, "Занимательное программирование Delphi". Глава 14. Светофор.
+73
if ((float)TF1.getText()>(float)(TF2.getText()){
}
Вот так вот приводят типы:)
http://www.sql.ru/forum/actualthread.aspx?bid=38&tid=551373&hl=
+132
int cont[15];
bool stop_access = false;
struct cel container[MAX_SIZE];
struct termios savetty;
struct termios tty;
pthread_t thread[100];
pthread_mutexattr_t muattr;
pthread_mutex_t count_mutex;
int icn=0;//Number elements in container
static int x;
static int y;
void* stack;
pthread_mutex_unlock(&count_mutex);
sleep(1);
};
return (void*)1;
};
void* main_thread(void *arg){
while(true){
sleep(1);
char ic=getchar();
if(ic=='\n'){
printf("Thread\tnumber elements\n");
for(int i=0;i<=x;i++)
pthread_cancel(thread[i]);
for(int i=0;i<=x;i++){
printf("%d ",i);
int cn=0;
for(int j=0;j<=icn;j++){
if(container[j].thrnm==i){ cn++; };
};
printf("\t%d\n",cn);
};
printf("container number element %d\n",icn);
exit(0);
};
};
};
int main(int argc, char * argv[])
{
icn=0;
if(argc<2){printf("1 arg n number of threads, 2 argument maximum number element in container");exit(0);};
x=atoi(argv[1]);
y=atoi(argv[2]);
if(x>64){printf("Число потоков должно быть меньше 64\n");exit(0);}
printf("x %d y %d\n",x,y);
//mutex initialization
int ret;
ret = pthread_mutexattr_init(&muattr);
//switch the keyboard to noncanonical mode
pid_t pt=tcgetsid(0);
// char *var=ctermid (NULL);
printf("pid %d\n",pt);
tcgetattr (0, &tty);
savetty = tty;
tty.c_lflag &= ~(ICANON);
tty.c_cc[VMIN] = 1;
tcsetattr (0, TCSAFLUSH, &tty);
pthread_t mthr;
pthread_attr_t mattr;
pthread_attr_init(&mattr);
pthread_attr_setdetachstate(&mattr,PTHREAD_CREATE_DETACHED);
int mres = pthread_create(&mthr, &mattr, main_thread, NULL);
if (mres == 0) {
printf("Creating main thread\n");
sleep(0.7);
} else {
perror("Creating the main first thread");
return EXIT_FAILURE;
}
for(int i=0;i<=x;i++){
int id1, id2, result;
id1 = 1;
pthread_attr_t attr;
pthread_attr_init(&attr);
// отсоединенный поток - не ждем его возврата
pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
result = pthread_create(&thread[i], &attr, thread_func, &i);
if (result == 0) {
printf("Creating thread %d\n",i);
sleep(1);
} else {
perror("Creating the first thread");