- 1
- 2
comment on column XXX.status
is '0 -- вопрос включен, 1-- выкл';
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−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");
−97
hash.to_a.select{|elem| elem[1].map{|st| st.from}.include? state}.map{|elem| elem[1].map{|inner| inner.to}.uniq}.flatten
+147
void
syslog(int pri, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vsyslog(pri, fmt, ap);
va_end(ap);
}
......................................
void
vsyslog(int pri, const char *fmt, va_list ap)
{
vsyslog_r(pri, &sdata, fmt, ap);
}
....................................
void
vsyslog_r(int pri, struct syslog_data *data, const char *fmt, va_list ap)
{
int cnt;
char ch, *p, *t;
time_t now;
int fd, saved_errno, error;
#define TBUF_LEN 2048
#define FMT_LEN 1024
char *stdp = NULL, tbuf[TBUF_LEN], fmt_cpy[FMT_LEN];
int tbuf_left, fmt_left, prlen;
#define INTERNALLOG LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID
/* Check for invalid bits. */
if (pri & ~(LOG_PRIMASK|LOG_FACMASK)) {
if (data == &sdata) {
syslog(INTERNALLOG,
"syslog: unknown facility/priority: %x", pri);
} else {
syslog_r(INTERNALLOG, data,
"syslog_r: unknown facility/priority: %x", pri);
}
pri &= LOG_PRIMASK|LOG_FACMASK;
}
.......................
}
......................
Из исходников Bioninc - Android libc.
В реализации сислога, в случае ошибки, вызывается syslog