- 1
- 2
- 3
$attr_id = json_decode($_GET['attr_id']);
$obj_id = json_decode($_GET['obj_id']);
$a_href = $_GET['file_id'];
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+58
$attr_id = json_decode($_GET['attr_id']);
$obj_id = json_decode($_GET['obj_id']);
$a_href = $_GET['file_id'];
Разгребаю что осталось от недавно уволенного джуниора.
2 json_decoda толкают в уныние. При том что джсон туда вообще не приходит =\
Жаль вот уже, не сохранился код, в к-м он пришедший на _клиент в браузер_ json парсил руками(JSON.parse() - для слабых)
−92
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
self.view.frame=CGRectMake(10,10, 300, 200);
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
cell.selectionStyle=UITableViewCellSelectionStyleNone;
switch (indexPath.row) {
case 0:
//ToDo: Add UserInfo's view into TableView
[cell.contentView addSubview:upperView];
break;
case 1:{
//Remove preous view/tableview
for (id vw in cell.contentView.subviews) {
if ([vw isKindOfClass:[UITableView class]]) {
[vw removeFromSuperview];
}
}
//
//Add View which contain tableview
EditListViewController *editlistvw=[[EditListViewController alloc] initWithNibName:@"EditListViewController" bundle:nil] ;
editlistvw.view.frame=CGRectMake(10, 10, 300, 20);
[cell.contentView addSubview:editlistvw.tableView];
//
break;
}
case 2:
//Remove previous view/tableview
for (id vw in cell.contentView.subviews) {
if ([vw isKindOfClass:[UITableView class]]) {
[vw removeFromSuperview];
}
}
break;
default:
break;
}
return cell;
}
Творение индийского джуниора, совместно с которым приходится делать проект
+184
CD20
первая программа на асм
−16
void setOn(const bool &on) {
// ...
}
А вот чего только не встретишь в коде...
+199
sum proc ; ax=ax+bx
push dx
m1: mov dx, ax
xor ax, bx
and bx, dx
shl bx, 01h
cmp bx, 00h
jnz m1
pop dx
ret
sum endp
Навеяно http://govnokod.ru/11311
+65
$quGroup = mysql_query($x = "
SELECT
a.latitude, a.longitude, a.catid, a.id, a.title, a.arttype, a.userid, b.firstname, b.lastname, b.usertype,
a.latitude2, a.longitude2, a.latitude3, a.longitude3, a.latitude4, a.longitude4, a.latitude5, a.longitude5,
a.latitude6, a.longitude6, a.latitude7, a.longitude7, a.latitude8, a.longitude8, a.latitude9, a.longitude9,
a.latitude10, a.longitude10, a.latitude11, a.longitude11
from materials a, users b
where a.status='1' and a.userid=b.id and add_date > $day)
$sql_cond");
while ($flGroup = mysql_fetch_row($quGroup)) {
$j++;
$a1 = $a2 = array ();
$l1 = $flGroup[0];
$l2 = $flGroup[1];
if ($l1 && $l2) {
$a1[] = $l1;
$a2[] = $l2;
}
$latitude2 = $flGroup[10];
$longitude2 = $flGroup[11];
if ($latitude2 && $longitude2) {
$a1[] = $latitude2;
$a2[] = $longitude2;
}
$latitude3 = $flGroup[12];
$longitude3 = $flGroup[13];
if ($latitude3 && $longitude3) {
$a1[] = $latitude3;
$a2[] = $longitude3;
}
$latitude4 = $flGroup[14];
$longitude4 = $flGroup[15];
if ($latitude4 && $longitude4) {
$a1[] = $latitude4;
$a2[] = $longitude4;
}
$latitude5 = $flGroup[16];
$longitude5 = $flGroup[17];
if ($latitude5 && $longitude5) {
$a1[] = $latitude5;
$a2[] = $longitude5;
}
$latitude6 = $flGroup[18];
$longitude6 = $flGroup[19];
if ($latitude6 && $longitude6) {
$a1[] = $latitude6;
$a2[] = $longitude6;
}
$latitude7 = $flGroup[20];
$longitude7 = $flGroup[21];
if ($latitude7 && $longitude7) {
$a1[] = $latitude7;
$a2[] = $longitude7;
}
$latitude8 = $flGroup[22];
$longitude8 = $flGroup[23];
if ($latitude8 && $longitude8) {
$a1[] = $latitude8;
$a2[] = $longitude8;
}
$latitude9 = $flGroup[24];
$longitude9 = $flGroup[25];
if ($latitude9 && $longitude9) {
$a1[] = $latitude9;
$a2[] = $longitude9;
}
$latitude10 = $flGroup[26];
$longitude10 = $flGroup[27];
if ($latitude10 && $longitude10) {
$a1[] = $latitude10;
$a2[] = $longitude10;
}
$latitude11 = $flGroup[28];
$longitude11 = $flGroup[29];
if ($latitude11 && $longitude11) {
$a1[] = $latitude11;
$a2[] = $longitude11;
}
if (!$l1 && !$l2 && !$latitude2 && !$longitude2 && !$latitude3 && !$longitude3 && !$latitude4 && !$longitude4 && !$latitude5 && !$longitude5 && !$latitude6 && !$longitude6 && !$latitude7 && !$longitude7 && !$latitude8 && !$longitude8 && !$latitude9 && !$longitude9 && !$latitude10 && !$longitude10 && !$latitude11 && !$longitude11)
continue;
...
}
как изящно
−2
//сравниваем два числа, функция не использует операторы < и > в целях переносимости на платформы, где они не поддерживаются
auto intcmp( int a, int b ) -> int {
while( a && b ) {
a--;
b--;
}
if ( a == 0 && b == 0 ) // числа равны
return 0;
if ( a == 0 ) // a - меньше
return -1;
if ( b == 0 ) // a - больше
return 1;
assert( true ); // да нам подсунули какие-то неправильные числа
}
К слову "auto foo( ... ) -> type" добавили в C++11.
+65
if ($_GET['where'] != '') {
if ($_GET['where'] != '') {
die ("<meta http-equiv='refresh' content='0; url=".$page."?where=".$_GET['where']."'>");
} else {
die ("<meta http-equiv='refresh' content='0; url=".$page."?pid=".$_GET['pid']."'>");
}
} else {
die ("<meta http-equiv='refresh' content='0; url=".$page."?pid=".$_GET['pid']."'>");
}
Интересно, в каком случае выполнится второй die()?
+71
# Разбор time()
function GetTime( $time ) {
# Получение массива из элементов даты
$time = getdate( $time );
# Все элементы с ведущими нулями
$d = ( $time['mday'] > 9 ) ? $time['mday'] : '0' . $time['mday'];
$w = ( $time['mon'] > 9 ) ? $time['mon'] : '0' . $time['mon'];
$y = $time['year'];
$h = ( $time['hours'] > 9 ) ? $time['hours'] : '0' . $time['hours'];
$m = ( $time['minutes'] > 9 ) ? $time['minutes'] : '0' . $time['minutes'];
$s = ( $time['seconds'] > 9 ) ? $time['seconds'] : '0' . $time['seconds'];
# Сборка и возврат результата
return $d . '/' . $w . '/' . $y . ' ' . $h . ':' . $m . ':' . $s;
}
Про date() явно не в курсе...
−29
calculateSomething(int n){
float* x = new float[n];
/*do smth*/
if ( /*validation*/ ) {
delete[] x;
return;
}
float* y = new float[n];
/*do smth*/
if ( /*validation*/ ) {
delete[] x;
delete[] y;
return;
}
float* z = new float[n];
/*next step*/
if ( /*smth goes wrong*/ ) {
delete[] x;
delete[] y;
delete[] z;
return;
}
/*more calculations with validation*/
delete[] x;
delete[] y;
...
/*more delete[]*/
return;
}
Принципиальная схема говногода, найденного на просторах сети.